diff options
author | 2020-04-14 21:49:47 +0200 | |
---|---|---|
committer | 2020-04-16 22:52:21 +0200 | |
commit | 6c4672dbb3cccd6c7d8cdfde2f59a97af7cfac42 (patch) | |
tree | f2415c6e0de9c63a7b7ebe41adc62120dc45a9ea /src/main | |
parent | 208ab81cd84c06387d6ce7ad335b3fbe4d51ac04 (diff) |
Perform repository cleanup
1. Perform whitespace cleanup in source files
Changes are almost exclusively in indentation and line breaks.
Some safe spelling fixes may had gotten staged too.
2. Update license file and license headers on java files
Change "2019" to "2019-2020" (fix 2017-2018 in some cases).
Convert to block comment format.
Make "Orange Intellectual Property" consistent across headers.
3. Prepend javascript files with license headers
4. Rename frontend filenames to lowercase
5. Add missing semicolons after statements in react files
Issue-ID: AAI-2861
Signed-off-by: Vlastimil Starec <vlastimil.starec@orange.com>
Change-Id: Ieee5562ce9e360da3db1f990a6cf4c1b1e56f657
Diffstat (limited to 'src/main')
25 files changed, 1483 insertions, 1462 deletions
diff --git a/src/main/java/org/onap/aai/graphgraph/App.java b/src/main/java/org/onap/aai/graphgraph/App.java index ed1bb9a..1c6bc61 100644 --- a/src/main/java/org/onap/aai/graphgraph/App.java +++ b/src/main/java/org/onap/aai/graphgraph/App.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph; @@ -40,32 +40,35 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; @SpringBootApplication -public class App{ +public class App { + public static EdgeIngestor edgeIngestor; public static Map<String, MoxyLoader> moxyLoaders = new HashMap<>(); // TODO // this should be used properly within Spring as this is a 'static' workaround due // to some initialization issues. By all means feel free to improve and move it to Spring - public static void loadSchemes(ConfigurableApplicationContext context){ + public static void loadSchemes(ConfigurableApplicationContext context) { String version; for (int i = 10; i < 19; i++) { version = "v" + i; - moxyLoaders.put(version, new MoxyLoader(new SchemaVersion(version), (NodeIngestor) context.getBean("nodeIngestor")) ); + moxyLoaders.put(version, new MoxyLoader( + new SchemaVersion(version), (NodeIngestor) context.getBean("nodeIngestor")) + ); } } - public static void main( String[] args ) throws IOException { + public static void main(String[] args) throws IOException { ArgumentParser parser = new ArgumentParser().parseArguments(args); - if (parser.isPrintHelp()){ + if (parser.isPrintHelp()) { parser.printHelp(); return; } - SpringApplication app = new SpringApplication(App.class); + SpringApplication app = new SpringApplication(App.class); - if (parser.isRunLocally()){ + if (parser.isRunLocally()) { copyKeystore(app); } @@ -74,7 +77,7 @@ public class App{ loadSchemes(context); edgeIngestor = (EdgeIngestor) context.getBean("edgeIngestor"); - if (parser.shoudGenerateUml()){ + if (parser.shouldGenerateUrl()) { writeExportedModel(exportModel(parser.getSchemaVersion())); System.exit(0); } @@ -83,9 +86,10 @@ public class App{ private static void copyKeystore(SpringApplication app) throws IOException { Path path = Paths.get("etc/auth/aai_keystore"); if (Files.notExists(path)) { - FileUtils.copyInputStreamToFile(Objects - .requireNonNull(app.getClassLoader().getResourceAsStream("etc/auth/aai_keystore")), - path.toFile()); + FileUtils.copyInputStreamToFile( + Objects.requireNonNull(app.getClassLoader().getResourceAsStream("etc/auth/aai_keystore")), + path.toFile() + ); } } } diff --git a/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java b/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java index 4405723..e156e39 100644 --- a/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java +++ b/src/main/java/org/onap/aai/graphgraph/ArgumentParser.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph; @@ -24,51 +24,50 @@ import org.kohsuke.args4j.CmdLineParser; import org.kohsuke.args4j.Option; public class ArgumentParser { - @Option(name = "-g", usage = "generates schema model for Papyrus and exits where XY is the version", metaVar = "vXY") - private String schemaVersion; - - @Option(name = "-d", usage = "connect to dev version of schema-service (use JAR bundled keystore)") - private boolean runLocally; - @Option(name = "-h", usage = "print help and exit") - private boolean printHelp; + CmdLineParser parser; + @Option(name = "-g", usage = "generates schema model for Papyrus and exits where XY is the version", + metaVar = "vXY") + private String schemaVersion; + @Option(name = "-d", usage = "connect to dev version of schema-service (use JAR bundled keystore)") + private boolean runLocally; + @Option(name = "-h", usage = "print help and exit") + private boolean printHelp; - CmdLineParser parser; + public ArgumentParser parseArguments(String[] args) { + parser = new CmdLineParser(this); - public ArgumentParser parseArguments(String [] args){ - parser = new CmdLineParser(this); + try { + parser.parseArgument(args); + } catch (CmdLineException e) { + System.err.println(e.getMessage()); + parser.printUsage(System.err); + } - try { - parser.parseArgument(args); - } catch( CmdLineException e ) { - System.err.println(e.getMessage()); - parser.printUsage(System.err); + return this; } - return this; - } - - public String getSchemaVersion() { - return schemaVersion; - } + public String getSchemaVersion() { + return schemaVersion; + } - public void setSchemaVersion(String schemaVersion) { - this.schemaVersion = schemaVersion; - } + public void setSchemaVersion(String schemaVersion) { + this.schemaVersion = schemaVersion; + } - public boolean shoudGenerateUml(){ - return schemaVersion != null; - } + public boolean shouldGenerateUrl() { + return schemaVersion != null; + } - public boolean isRunLocally() { - return runLocally; - } + public boolean isRunLocally() { + return runLocally; + } - public boolean isPrintHelp() { - return printHelp; - } + public boolean isPrintHelp() { + return printHelp; + } - public void printHelp(){ - parser.printUsage(System.out); - } + public void printHelp() { + parser.printUsage(System.out); + } } diff --git a/src/main/java/org/onap/aai/graphgraph/Config.java b/src/main/java/org/onap/aai/graphgraph/Config.java index 1d4152b..bbc082f 100644 --- a/src/main/java/org/onap/aai/graphgraph/Config.java +++ b/src/main/java/org/onap/aai/graphgraph/Config.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph; @@ -31,9 +31,9 @@ import org.springframework.context.annotation.Configuration; @Configuration @ComponentScan(basePackages = { - "org.onap.aai.config", - "org.onap.aai.setup", - "org.onap.aai.graphgraph" + "org.onap.aai.config", + "org.onap.aai.setup", + "org.onap.aai.graphgraph" }) public class Config { @@ -41,7 +41,7 @@ public class Config { String schemaVersions; @Bean - SchemaRepository createSchemaRepository(){ + SchemaRepository createSchemaRepository() { List<SchemaReader> readers = new LinkedList<>(); for (String s : schemaVersions.split(",")) { readers.add(new BasicSchemaReader(s)); @@ -50,4 +50,3 @@ public class Config { } } - diff --git a/src/main/java/org/onap/aai/graphgraph/CorsFilter.java b/src/main/java/org/onap/aai/graphgraph/CorsFilter.java index 448a2ea..ab97255 100644 --- a/src/main/java/org/onap/aai/graphgraph/CorsFilter.java +++ b/src/main/java/org/onap/aai/graphgraph/CorsFilter.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph; @@ -30,15 +30,17 @@ import org.springframework.web.filter.OncePerRequestFilter; @Component public class CorsFilter extends OncePerRequestFilter { - @Override - protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, - final FilterChain filterChain) throws ServletException, IOException { - response.addHeader("Access-Control-Allow-Origin", "*"); - response.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, PATCH, HEAD"); - response.addHeader("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"); - response.addHeader("Access-Control-Expose-Headers", "Access-Control-Allow-Origin, Access-Control-Allow-Credentials"); - response.addHeader("Access-Control-Allow-Credentials", "true"); - response.addIntHeader("Access-Control-Max-Age", 10); - filterChain.doFilter(request, response); - } -}
\ No newline at end of file + @Override + protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, + final FilterChain filterChain) throws ServletException, IOException { + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, PATCH, HEAD"); + response.addHeader("Access-Control-Allow-Headers", + "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"); + response.addHeader("Access-Control-Expose-Headers", + "Access-Control-Allow-Origin, Access-Control-Allow-Credentials"); + response.addHeader("Access-Control-Allow-Credentials", "true"); + response.addIntHeader("Access-Control-Max-Age", 10); + filterChain.doFilter(request, response); + } +} diff --git a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java index 36070db..047bd92 100644 --- a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java +++ b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph; @@ -54,214 +54,221 @@ import org.onap.aai.setup.SchemaVersion; public class ModelExporter { - private static final String AAIMODEL_UML_FILENAME = "aaimodel.uml"; - private static final String VELOCITY_TEMPLATE_FILENAME = "model_export.vm"; - private static final boolean OXM_ENABLED = false; - private static final String camelCaseRegex = "(?=[A-Z][a-z])"; - private static Map<String, Introspector> allEntities; - private static Multimap<String, EdgeRule> getEdgeRules(String schemaVersion) { - try { - Multimap<String, EdgeRule> allRules = App.edgeIngestor.getAllRules(new SchemaVersion(schemaVersion)); - allEntities = App.moxyLoaders.get(schemaVersion).getAllObjects(); - if (OXM_ENABLED) { - addOxmRelationships(allRules, allEntities); - } - return allRules; - } catch (EdgeRuleNotFoundException e) { - e.printStackTrace(); - } - - return null; - } + private static final String AAIMODEL_UML_FILENAME = "aaimodel.uml"; + private static final String VELOCITY_TEMPLATE_FILENAME = "model_export.vm"; + private static final boolean OXM_ENABLED = false; + private static final String camelCaseRegex = "(?=[A-Z][a-z])"; + private static Map<String, Introspector> allEntities; - private static void addOxmRelationships(Multimap<String, EdgeRule> allRules, - Map<String, Introspector> allEntities) { - for (Entry<String, Introspector> currentParent : allEntities.entrySet()) { - currentParent.getValue().getProperties().stream() - .filter(v -> allEntities.containsKey(v)) - .filter(v -> !currentParent.getKey().equals(v)) - .forEach(v -> { - String key = currentParent.getKey() + "|" + v; - if (!allRules.containsKey(key)) { - allRules.put(key, createEdgeRule(currentParent.getKey(), v)); + private static Multimap<String, EdgeRule> getEdgeRules(String schemaVersion) { + try { + Multimap<String, EdgeRule> allRules = App.edgeIngestor.getAllRules(new SchemaVersion(schemaVersion)); + allEntities = App.moxyLoaders.get(schemaVersion).getAllObjects(); + if (OXM_ENABLED) { + addOxmRelationships(allRules, allEntities); } - }); + return allRules; + } catch (EdgeRuleNotFoundException e) { + e.printStackTrace(); + } + + return null; } - } - private static EdgeRule createEdgeRule(String parent, String child) { - Map<String, String> edgeRuleProps = new HashMap<>(); - edgeRuleProps.put(EdgeField.FROM.toString(), child); - edgeRuleProps.put(EdgeField.TO.toString(), parent); - edgeRuleProps.put(EdgeField.DIRECTION.toString(), Direction.OUT.toString()); //TODO check direction - edgeRuleProps.put(EdgeField.LABEL.toString(), "OXM Parent-Child"); - edgeRuleProps.put(EdgeField.MULTIPLICITY.toString(), MultiplicityRule.MANY2ONE.toString()); - edgeRuleProps.put(EdgeField.DEFAULT.toString(), Boolean.toString(false)); - edgeRuleProps.put(EdgeField.PRIVATE.toString(), Boolean.toString(false)); - edgeRuleProps.put(EdgeField.DELETE_OTHER_V.toString(), DirectionNotation.DIRECTION.toString()); - edgeRuleProps.put(EdgeField.PREVENT_DELETE.toString(), DirectionNotation.DIRECTION.toString()); - edgeRuleProps.put(EdgeField.CONTAINS.toString(), DirectionNotation.DIRECTION.toString()); - edgeRuleProps.put(EdgeField.DESCRIPTION.toString(), "fake edgerule representing parent-child"); - return new EdgeRule(edgeRuleProps); - } + private static void addOxmRelationships( + Multimap<String, EdgeRule> allRules, + Map<String, Introspector> allEntities) { + for (Entry<String, Introspector> currentParent : allEntities.entrySet()) { + currentParent.getValue().getProperties().stream() + .filter(v -> allEntities.containsKey(v)) + .filter(v -> !currentParent.getKey().equals(v)) + .forEach(v -> { + String key = currentParent.getKey() + "|" + v; + if (!allRules.containsKey(key)) { + allRules.put(key, createEdgeRule(currentParent.getKey(), v)); + } + }); + } + } - static String exportModel(String schemaVersion) { - Map<String, Introspector> allObjects = App.moxyLoaders.get(schemaVersion).getAllObjects(); - Template t = initVelocity(); - VelocityContext context = populateVelocityContext(schemaVersion, allObjects); - StringWriter writer = new StringWriter(); - t.merge( context, writer ); - return writer.toString(); - } + private static EdgeRule createEdgeRule(String parent, String child) { + Map<String, String> edgeRuleProps = new HashMap<>(); + edgeRuleProps.put(EdgeField.FROM.toString(), child); + edgeRuleProps.put(EdgeField.TO.toString(), parent); + edgeRuleProps.put(EdgeField.DIRECTION.toString(), Direction.OUT.toString()); //TODO check direction + edgeRuleProps.put(EdgeField.LABEL.toString(), "OXM Parent-Child"); + edgeRuleProps.put(EdgeField.MULTIPLICITY.toString(), MultiplicityRule.MANY2ONE.toString()); + edgeRuleProps.put(EdgeField.DEFAULT.toString(), Boolean.toString(false)); + edgeRuleProps.put(EdgeField.PRIVATE.toString(), Boolean.toString(false)); + edgeRuleProps.put(EdgeField.DELETE_OTHER_V.toString(), DirectionNotation.DIRECTION.toString()); + edgeRuleProps.put(EdgeField.PREVENT_DELETE.toString(), DirectionNotation.DIRECTION.toString()); + edgeRuleProps.put(EdgeField.CONTAINS.toString(), DirectionNotation.DIRECTION.toString()); + edgeRuleProps.put(EdgeField.DESCRIPTION.toString(), "fake edgerule representing parent-child"); + return new EdgeRule(edgeRuleProps); + } - static void writeExportedModel(String result) { - try { - FileWriter fw = new FileWriter(AAIMODEL_UML_FILENAME); - fw.write(result); - fw.close(); - } catch (IOException e) { - e.printStackTrace(); + static String exportModel(String schemaVersion) { + Map<String, Introspector> allObjects = App.moxyLoaders.get(schemaVersion).getAllObjects(); + Template t = initVelocity(); + VelocityContext context = populateVelocityContext(schemaVersion, allObjects); + StringWriter writer = new StringWriter(); + t.merge(context, writer); + return writer.toString(); } - } - private static VelocityContext populateVelocityContext(String schemaVersion, - Map<String, Introspector> allObjects) { - VelocityContext context = new VelocityContext(); - Multimap<String, EdgeRule> edgeRules = getEdgeRules(schemaVersion); - Set<VelocityEntity> entityList = createEntityList(edgeRules); - Set<VelocityAssociation> associationsList = createVelocityAssociations(entityList, edgeRules); - updateEntities(entityList, associationsList, allObjects); - context.put("entityList", entityList); - context.put("associationList", associationsList); - return context; - } + static void writeExportedModel(String result) { + try { + FileWriter fw = new FileWriter(AAIMODEL_UML_FILENAME); + fw.write(result); + fw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } - private static Template initVelocity() { - VelocityEngine ve = new VelocityEngine(); - ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); - ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); - ve.init(); - return ve.getTemplate(VELOCITY_TEMPLATE_FILENAME); - } + private static VelocityContext populateVelocityContext( + String schemaVersion, + Map<String, Introspector> allObjects) { + VelocityContext context = new VelocityContext(); + Multimap<String, EdgeRule> edgeRules = getEdgeRules(schemaVersion); + Set<VelocityEntity> entityList = createEntityList(edgeRules); + Set<VelocityAssociation> associationsList = createVelocityAssociations(entityList, edgeRules); + updateEntities(entityList, associationsList, allObjects); + context.put("entityList", entityList); + context.put("associationList", associationsList); + return context; + } - private static void updateEntities(Set<VelocityEntity> entityList, - Set<VelocityAssociation> associationsList, - Map<String, Introspector> allObjects) { - entityList.forEach(e -> { - List<VelocityAssociation> associations = associationsList.stream() - .filter(a -> a.getFromEntityId().equals(e.getId())).collect( - Collectors.toList()); - updateNeighbour(entityList, associations); - String description = allEntities.get(e.getName()).getMetadata(ObjectMetadata.DESCRIPTION); - e.setDescription(StringUtil.isBlank(description) ? "no description is available" : description); - }); + private static Template initVelocity() { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); + ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); + ve.init(); + return ve.getTemplate(VELOCITY_TEMPLATE_FILENAME); + } - entityList.forEach(entity -> entity.setProperties(getPropertiesForEntity(allObjects.get(entity.getName()), entityList))); + private static void updateEntities( + Set<VelocityEntity> entityList, + Set<VelocityAssociation> associationsList, + Map<String, Introspector> allObjects) { + entityList.forEach(e -> { + List<VelocityAssociation> associations = associationsList.stream() + .filter(a -> a.getFromEntityId().equals(e.getId())).collect( + Collectors.toList()); + updateNeighbour(entityList, associations); + String description = allEntities.get(e.getName()).getMetadata(ObjectMetadata.DESCRIPTION); + e.setDescription(StringUtil.isBlank(description) ? "no description is available" : description); + }); - } + entityList.forEach( + entity -> entity.setProperties(getPropertiesForEntity(allObjects.get(entity.getName()), entityList))); - private static void updateNeighbour( - Set<VelocityEntity> entityList, List<VelocityAssociation> associations) { - associations.forEach(ass -> { - VelocityEntity velocityEntity = entityList.stream() - .filter(e -> e.getId().equals(ass.getToEntityId())).findFirst().get(); - velocityEntity.addNeighbours(ass); - }); - } + } - private static Set<VelocityEntityProperty> getPropertiesForEntity(Introspector introspector, - Set<VelocityEntity> entityList) { - return introspector.getProperties().stream() - .map(p -> new VelocityEntityProperty( - p, - introspector.getType(p), - findVelocityEntity(introspector.getType(p), entityList))) - .collect( - Collectors.toSet()); - } + private static void updateNeighbour( + Set<VelocityEntity> entityList, List<VelocityAssociation> associations) { + associations.forEach(ass -> { + VelocityEntity velocityEntity = entityList.stream() + .filter(e -> e.getId().equals(ass.getToEntityId())).findFirst().get(); + velocityEntity.addNeighbours(ass); + }); + } - private static Set<VelocityEntity> createEntityList( - Multimap<String, EdgeRule> edgeRules) { - return Objects.requireNonNull(edgeRules).values().stream() - .flatMap(er -> Stream.of(er.getFrom(), er.getTo())) - .map(VelocityEntity::new) - .collect(Collectors.toSet()); - } + private static Set<VelocityEntityProperty> getPropertiesForEntity( + Introspector introspector, + Set<VelocityEntity> entityList) { + return introspector.getProperties().stream() + .map(p -> new VelocityEntityProperty( + p, + introspector.getType(p), + findVelocityEntity(introspector.getType(p), entityList))) + .collect( + Collectors.toSet()); + } - private static Set<VelocityAssociation> createVelocityAssociations(Set<VelocityEntity> entities, - Multimap<String, EdgeRule> edgeRules) { - return edgeRules.values().stream().flatMap(er -> { - VelocityAssociation out = createVelocityAssociation(entities, er.getFrom(), er.getTo(), - er.getLabel(), er.getMultiplicityRule().name(), er.getContains()); - VelocityAssociation in = createVelocityAssociation(entities, er.getTo(), er.getFrom(), - er.getLabel(), er.getMultiplicityRule().name(), er.getContains()); - switch (er.getDirection()) { - case OUT: - return Stream.of(out); - case IN: - return Stream.of(in); - case BOTH: - return Stream.of(out, in); - default: - return null; - } - }).collect(Collectors.toSet()); - } + private static Set<VelocityEntity> createEntityList( + Multimap<String, EdgeRule> edgeRules) { + return Objects.requireNonNull(edgeRules).values().stream() + .flatMap(er -> Stream.of(er.getFrom(), er.getTo())) + .map(VelocityEntity::new) + .collect(Collectors.toSet()); + } - private static VelocityAssociation createVelocityAssociation(Set<VelocityEntity> entities, - String from, String to, String label, String multiplicity, String contains) { - VelocityEntity fromEntity = entities.stream().filter(ent -> ent.getName().equals(from)) - .findFirst().get(); - VelocityEntity toEntity = entities.stream().filter(ent -> ent.getName().equals(to)).findFirst() - .get(); - switch (contains) { - case "IN": - return new VelocityAssociation( - fromEntity, - toEntity, - String.format("%s - %s (%s)", from, to, shortenLabel(label)), - multiplicity, - true); - case "OUT": - return new VelocityAssociation( - toEntity, - fromEntity, - String.format("%s - %s (%s)", to, from, shortenLabel(label)), - multiplicity.equals("ONE2MANY") ? "MANY2ONE" : multiplicity, - true); - default: - return new VelocityAssociation( - fromEntity, - toEntity, - String.format("%s - %s (%s)", from, to, shortenLabel(label)), - multiplicity, - false); + private static Set<VelocityAssociation> createVelocityAssociations( + Set<VelocityEntity> entities, + Multimap<String, EdgeRule> edgeRules) { + return edgeRules.values().stream().flatMap(er -> { + VelocityAssociation out = createVelocityAssociation(entities, er.getFrom(), er.getTo(), + er.getLabel(), er.getMultiplicityRule().name(), er.getContains()); + VelocityAssociation in = createVelocityAssociation(entities, er.getTo(), er.getFrom(), + er.getLabel(), er.getMultiplicityRule().name(), er.getContains()); + switch (er.getDirection()) { + case OUT: + return Stream.of(out); + case IN: + return Stream.of(in); + case BOTH: + return Stream.of(out, in); + default: + return null; + } + }).collect(Collectors.toSet()); } - } - private static String shortenLabel(String label) { - if (label.contains(".")) { - String[] split = label.split("\\."); - return split[split.length - 1]; + private static VelocityAssociation createVelocityAssociation( + Set<VelocityEntity> entities, String from, String to, String label, String multiplicity, String contains) { + VelocityEntity fromEntity = entities.stream() + .filter(ent -> ent.getName().equals(from)).findFirst().get(); + VelocityEntity toEntity = entities.stream() + .filter(ent -> ent.getName().equals(to)).findFirst().get(); + switch (contains) { + case "IN": + return new VelocityAssociation( + fromEntity, + toEntity, + String.format("%s - %s (%s)", from, to, shortenLabel(label)), + multiplicity, + true); + case "OUT": + return new VelocityAssociation( + toEntity, + fromEntity, + String.format("%s - %s (%s)", to, from, shortenLabel(label)), + multiplicity.equals("ONE2MANY") ? "MANY2ONE" : multiplicity, + true); + default: + return new VelocityAssociation( + fromEntity, + toEntity, + String.format("%s - %s (%s)", from, to, shortenLabel(label)), + multiplicity, + false); + } } - return label; - } + private static String shortenLabel(String label) { + if (label.contains(".")) { + String[] split = label.split("\\."); + return split[split.length - 1]; + } - private static VelocityEntity findVelocityEntity(String entityName, Set<VelocityEntity> entities) { - if (entityName.startsWith("java.lang")){ - return null; + return label; } - if ( ! entityName.startsWith("inventory.aai.onap.org")){ - return null; - } + private static VelocityEntity findVelocityEntity(String entityName, Set<VelocityEntity> entities) { + if (entityName.startsWith("java.lang")) { + return null; + } - String[] split = entityName.split("\\."); - String entityNameRoot = split[split.length - 1]; - final Pattern pattern = Pattern.compile(camelCaseRegex); - final Matcher matcher = pattern.matcher(entityNameRoot.substring(1, entityNameRoot.length())); - String finalEntityNameRoot = (entityNameRoot.charAt(0) + matcher.replaceAll("-")).toLowerCase(); - return entities.stream().filter(e -> e.getName().equals(finalEntityNameRoot)).findFirst().orElse(null); - } -}
\ No newline at end of file + if (!entityName.startsWith("inventory.aai.onap.org")) { + return null; + } + + String[] split = entityName.split("\\."); + String entityNameRoot = split[split.length - 1]; + final Pattern pattern = Pattern.compile(camelCaseRegex); + final Matcher matcher = pattern.matcher(entityNameRoot.substring(1)); + String finalEntityNameRoot = (entityNameRoot.charAt(0) + matcher.replaceAll("-")).toLowerCase(); + return entities.stream().filter(e -> e.getName().equals(finalEntityNameRoot)).findFirst().orElse(null); + } +} diff --git a/src/main/java/org/onap/aai/graphgraph/SchemaResource.java b/src/main/java/org/onap/aai/graphgraph/SchemaResource.java index b38ef7b..577e235 100644 --- a/src/main/java/org/onap/aai/graphgraph/SchemaResource.java +++ b/src/main/java/org/onap/aai/graphgraph/SchemaResource.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph; @@ -43,67 +43,66 @@ public class SchemaResource { SchemaRepository repository; @RequestMapping("/schemas") - public List<String> loadSchemaNames() { + public List<String> loadSchemaNames() { return repository.getAllSchemaNames(); } - @RequestMapping("/schemas/{schema}/nodes") - public List<NodeName> loadVertexNames(@PathVariable("schema") String schemaName, - @RequestParam("edgeFilter") String edgeFilter) { + public List<NodeName> loadVertexNames( + @PathVariable("schema") String schemaName, + @RequestParam("edgeFilter") String edgeFilter) { return repository.getSchemaReader(schemaName).getAllVertexNames(edgeFilter); } @RequestMapping("/schemas/{schema}/nodes/{node}") - public List<NodeProperty> loadProperties(@PathVariable("schema") String schemaName, @PathVariable("node") String node) { + public List<NodeProperty> loadProperties( + @PathVariable("schema") String schemaName, + @PathVariable("node") String node) { return repository.getSchemaReader(schemaName).getVertexProperties(node); } - @RequestMapping("/schemas/{schema}/edges") - public List<Property> loadedgeProperties ( + public List<Property> loadEdgeProperties( @PathVariable("schema") String schemaName, @RequestParam("fromNode") String fromNodeName, @RequestParam("toNode") String toNodeName) { return repository.getSchemaReader(schemaName).getEdgeProperties(fromNodeName, toNodeName, "edgerule"); } - @RequestMapping("/schemas/{schema}/graph/basic") - public Graph loadGraph ( + public Graph loadGraph( @PathVariable("schema") String schemaName, @RequestParam("node") String initialNodeName, @RequestParam("parentHops") Integer parentHops, @RequestParam("cousinHops") Integer cousinHops, @RequestParam("childHops") Integer childHops, - @RequestParam("edgeFilter") String edgeFilter) - { - Graph graph = repository.getSchemaReader(schemaName).getGraph(initialNodeName, parentHops, cousinHops, childHops, edgeFilter); - graph.setPaths(Collections.emptyList()); - return graph; + @RequestParam("edgeFilter") String edgeFilter) { + Graph graph = repository.getSchemaReader(schemaName) + .getGraph(initialNodeName, parentHops, cousinHops, childHops, edgeFilter); + graph.setPaths(Collections.emptyList()); + return graph; } - @RequestMapping("/schemas/{schema}/graph/paths") - public Graph loadGraphWithPaths ( + public Graph loadGraphWithPaths( @PathVariable("schema") String schemaName, @RequestParam("fromNode") String fromNode, @RequestParam("toNode") String toNode, - @RequestParam("edgeFilter") String edgeFilter) - { + @RequestParam("edgeFilter") String edgeFilter) { return repository.getSchemaReader(schemaName).getGraph(fromNode, toNode, edgeFilter); } @RequestMapping("/schemas/{schema}/validation") - public ValidationProblems validateSchema ( @PathVariable("schema") String schemaName) { + public ValidationProblems validateSchema( + @PathVariable("schema") String schemaName) { return new SchemaValidator().validate(schemaName); } @RequestMapping(value = "/schemas/{schema}/xmiexport", produces = MediaType.TEXT_XML_VALUE) @ResponseBody - public String exportSchema ( @PathVariable("schema") String schemaName) { + public String exportSchema( + @PathVariable("schema") String schemaName) { return ModelExporter.exportModel(schemaName); } } - diff --git a/src/main/java/org/onap/aai/graphgraph/SchemaValidator.java b/src/main/java/org/onap/aai/graphgraph/SchemaValidator.java index aa260aa..076c31e 100644 --- a/src/main/java/org/onap/aai/graphgraph/SchemaValidator.java +++ b/src/main/java/org/onap/aai/graphgraph/SchemaValidator.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph; @@ -32,70 +32,74 @@ import org.onap.aai.graphgraph.dto.ValidationProblems; import org.onap.aai.graphgraph.reader.BasicSchemaReader; public class SchemaValidator { - private Graph edgerules; - private Graph oxm; - public ValidationProblems validate(String schemaVersion) { - ValidationProblems validationProblems = new ValidationProblems(); - BasicSchemaReader schema = new BasicSchemaReader(schemaVersion); - oxm = schema.getGraph("all", 0, 0, 0, "Parents"); - edgerules = schema.getGraph("all", 0, 0, 0, "Edgerules"); - checkIfDanglingEdgerules(validationProblems); - checkIfObsoleteOxm(validationProblems); - schema.getSchemaErrors().forEach(validationProblems::addProblem); - return validationProblems; - } + private Graph edgerules; + private Graph oxm; + + public ValidationProblems validate(String schemaVersion) { + ValidationProblems validationProblems = new ValidationProblems(); + BasicSchemaReader schema = new BasicSchemaReader(schemaVersion); + oxm = schema.getGraph("all", 0, 0, 0, "Parents"); + edgerules = schema.getGraph("all", 0, 0, 0, "Edgerules"); + + checkIfDanglingEdgerules(validationProblems); + checkIfObsoleteOxm(validationProblems); + schema.getSchemaErrors().forEach(validationProblems::addProblem); + return validationProblems; + } - /** - * computes nodes connected to relationship-list but not used in edgerules - * @param validationProblems - */ - private void checkIfObsoleteOxm(ValidationProblems validationProblems) { - Set<String> relationshipListConnected = getAllNodesConnectedToRelationshipList(); - Set<String> nodesInEdgerules = getEdgerulePairs().stream().flatMap(p -> Stream.of(p._1, p._2)) - .collect(Collectors.toSet()); - relationshipListConnected.removeAll(nodesInEdgerules); - relationshipListConnected.forEach(n -> - validationProblems.addProblem(String.format("%s is associated with relationship-list in OXM but not present in edgerules", n))); - } + /** + * computes nodes connected to relationship-list but not used in edgerules + * @param validationProblems + */ + private void checkIfObsoleteOxm(ValidationProblems validationProblems) { + Set<String> relationshipListConnected = getAllNodesConnectedToRelationshipList(); + Set<String> nodesInEdgerules = getEdgerulePairs().stream() + .flatMap(p -> Stream.of(p._1, p._2)) + .collect(Collectors.toSet()); + relationshipListConnected.removeAll(nodesInEdgerules); + relationshipListConnected.forEach(n -> validationProblems.addProblem( + String.format("%s is associated with relationship-list in OXM but not present in edgerules", + n))); + } - private Set<Tuple2<String, String>> getEdgerulePairs() { - return edgerules.getEdges().stream() - .map(e -> Tuple.of(e.getSource(), e.getTarget())).collect( - Collectors.toSet()); - } + private Set<Tuple2<String, String>> getEdgerulePairs() { + return edgerules.getEdges().stream() + .map(e -> Tuple.of(e.getSource(), e.getTarget())) + .collect(Collectors.toSet()); + } - /** - * computes edgerules which don't have the necessary connection to relationship-list in OXM - * @param validationProblems - */ - private void checkIfDanglingEdgerules( - ValidationProblems validationProblems) { - Set<Tuple2<String, String>> edgerulePairs = getEdgerulePairs(); - edgerulePairs.removeAll(getOxmPairs()); - edgerulePairs.forEach( erp -> - validationProblems.addProblem(String.format("%s and %s are associated in edgerules but not in OXM (via relationship-list)", erp._1, erp._2))); - } + /** + * computes edgerules which don't have the necessary connection to relationship-list in OXM + * @param validationProblems + */ + private void checkIfDanglingEdgerules(ValidationProblems validationProblems) { + Set<Tuple2<String, String>> edgerulePairs = getEdgerulePairs(); + edgerulePairs.removeAll(getOxmPairs()); + edgerulePairs.forEach(erp -> validationProblems.addProblem( + String.format("%s and %s are associated in edgerules but not in OXM (via relationship-list)", + erp._1, erp._2))); + } - private Set<Tuple2<String, String>> getOxmPairs() { - Set<Tuple2<String, String>> pairs = new HashSet<>(); - Set<String> inRelationshipList = getAllNodesConnectedToRelationshipList(); + private Set<Tuple2<String, String>> getOxmPairs() { + Set<Tuple2<String, String>> pairs = new HashSet<>(); + Set<String> inRelationshipList = getAllNodesConnectedToRelationshipList(); - inRelationshipList.forEach(edge1 -> - inRelationshipList.forEach(edge2 -> { - pairs.add(Tuple.of(edge1, edge2)); - })); - return pairs; - } + inRelationshipList.forEach(edge1 -> inRelationshipList + .forEach(edge2 -> pairs.add(Tuple.of(edge1, edge2)))); + return pairs; + } - private Set<String> getAllNodesConnectedToRelationshipList() { - List<Edge> edges = oxm.getEdges(); - Set<String> inRelationshipList = edges.stream().filter(e -> e.getSource().equals("relationship-list")).map( - Edge::getTarget).collect( - Collectors.toSet()); - inRelationshipList.addAll(edges.stream().filter(e -> e.getTarget().equals("relationship-list")) - .map(Edge::getSource).collect( - Collectors.toSet())); - return inRelationshipList; - } + private Set<String> getAllNodesConnectedToRelationshipList() { + List<Edge> edges = oxm.getEdges(); + Set<String> inRelationshipList = edges.stream() + .filter(e -> e.getSource().equals("relationship-list")) + .map(Edge::getTarget) + .collect(Collectors.toSet()); + inRelationshipList.addAll(edges.stream() + .filter(e -> e.getTarget().equals("relationship-list")) + .map(Edge::getSource) + .collect(Collectors.toSet())); + return inRelationshipList; + } } diff --git a/src/main/java/org/onap/aai/graphgraph/dto/Edge.java b/src/main/java/org/onap/aai/graphgraph/dto/Edge.java index 5154e5b..c3ba8df 100644 --- a/src/main/java/org/onap/aai/graphgraph/dto/Edge.java +++ b/src/main/java/org/onap/aai/graphgraph/dto/Edge.java @@ -1,26 +1,25 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.dto; import java.util.Arrays; -import java.util.Collections; import java.util.List; public class Edge { @@ -49,14 +48,14 @@ public class Edge { return source; } - public List<NodeName> getNodeNames() { - return Arrays.asList(new NodeName(source), new NodeName(target)); - } - public void setSource(String source) { this.source = source; } + public List<NodeName> getNodeNames() { + return Arrays.asList(new NodeName(source), new NodeName(target)); + } + public String getTarget() { return target; } diff --git a/src/main/java/org/onap/aai/graphgraph/dto/Graph.java b/src/main/java/org/onap/aai/graphgraph/dto/Graph.java index 83e5977..7d5f957 100644 --- a/src/main/java/org/onap/aai/graphgraph/dto/Graph.java +++ b/src/main/java/org/onap/aai/graphgraph/dto/Graph.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.dto; @@ -23,12 +23,15 @@ import java.util.Collections; import java.util.List; public class Graph { + private List<NodeName> nodeNames; private List<Edge> edges; private List<List<NodeName>> paths; private List<NodeProperty> startNodeProperties; - public Graph(List<NodeName> nodeNames, List<Edge> edges, List<List<NodeName>> pathsList, List<NodeProperty> startNodeProperties) { + public Graph( + List<NodeName> nodeNames, List<Edge> edges, + List<List<NodeName>> pathsList, List<NodeProperty> startNodeProperties) { this.nodeNames = nodeNames; this.edges = edges; this.paths = pathsList; @@ -36,8 +39,8 @@ public class Graph { } public static Graph emptyGraph() { - return new Graph(Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), - Collections.emptyList()); + return new Graph( + Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList()); } public List<NodeProperty> getStartNodeProperties() { diff --git a/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java b/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java index 992609c..013f1aa 100644 --- a/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java +++ b/src/main/java/org/onap/aai/graphgraph/dto/NodeName.java @@ -1,25 +1,26 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.dto; public class NodeName { + private String id; public NodeName(String name) { @@ -56,8 +57,6 @@ public class NodeName { @Override public String toString() { - return "NodeName{" + - "id='" + id + '\'' + - '}'; + return "NodeName{" + "id='" + id + '\'' + '}'; } } diff --git a/src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java b/src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java index 93b04cf..0daa9f4 100644 --- a/src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java +++ b/src/main/java/org/onap/aai/graphgraph/dto/NodeProperty.java @@ -1,33 +1,35 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.dto; public class NodeProperty extends Property { + private String description; private String type; private boolean key; private boolean index; private boolean required; - public NodeProperty(String propertyName, - String description, String type, boolean key, boolean index, boolean required) { + public NodeProperty( + String propertyName, String description, String type, + boolean key, boolean index, boolean required) { super(propertyName, ""); this.description = description; this.type = type; @@ -92,7 +94,7 @@ public class NodeProperty extends Property { @Override public int hashCode() { - return getPropertyName().hashCode(); + return getPropertyName().hashCode(); } @Override diff --git a/src/main/java/org/onap/aai/graphgraph/dto/Property.java b/src/main/java/org/onap/aai/graphgraph/dto/Property.java index add7dc1..a08b0ec 100644 --- a/src/main/java/org/onap/aai/graphgraph/dto/Property.java +++ b/src/main/java/org/onap/aai/graphgraph/dto/Property.java @@ -1,25 +1,26 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.dto; -public class Property implements Comparable<Property>{ +public class Property implements Comparable<Property> { + private String propertyName; private String propertyValue; @@ -59,7 +60,6 @@ public class Property implements Comparable<Property>{ return false; } return propertyValue.equals(property.propertyValue); - } @Override @@ -71,8 +71,8 @@ public class Property implements Comparable<Property>{ @Override public int compareTo(Property o) { - if (o.getPropertyName().equals(getPropertyName()) && o.getPropertyValue() != null - && getPropertyValue() != null) { + if (o.getPropertyName().equals(getPropertyName()) + && o.getPropertyValue() != null && getPropertyValue() != null) { return getPropertyValue().compareTo(o.getPropertyValue()); } diff --git a/src/main/java/org/onap/aai/graphgraph/dto/ValidationProblems.java b/src/main/java/org/onap/aai/graphgraph/dto/ValidationProblems.java index 9b031d0..976058d 100644 --- a/src/main/java/org/onap/aai/graphgraph/dto/ValidationProblems.java +++ b/src/main/java/org/onap/aai/graphgraph/dto/ValidationProblems.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.dto; @@ -23,17 +23,18 @@ import java.util.LinkedList; import java.util.List; public class ValidationProblems { + private List<String> problems = new LinkedList<>(); - public List<String> getProblems() { - return problems; - } + public List<String> getProblems() { + return problems; + } - public void setProblems(List<String> problems) { - this.problems = problems; - } + public void setProblems(List<String> problems) { + this.problems = problems; + } - public void addProblem(String problem) { - problems.add(problem); - } + public void addProblem(String problem) { + problems.add(problem); + } } diff --git a/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java b/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java index b2d766b..7f903f7 100644 --- a/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java +++ b/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.reader; @@ -50,357 +50,356 @@ import org.onap.aai.setup.SchemaVersion; public class BasicSchemaReader implements SchemaReader { - private Map<String, Introspector> allEntities; - private Graph<String, MetadataEdge> graph = new DefaultDirectedGraph<>(MetadataEdge.class); - private EdgeIngestor edgeIngestor; - private String version; - private List<String> schemaErrors = new LinkedList<>(); + private Map<String, Introspector> allEntities; + private Graph<String, MetadataEdge> graph = new DefaultDirectedGraph<>(MetadataEdge.class); + private EdgeIngestor edgeIngestor; + private String version; + private List<String> schemaErrors = new LinkedList<>(); - public List<String> getSchemaErrors() { - return schemaErrors; - } + public BasicSchemaReader(String version) { + this.version = version; + } - public BasicSchemaReader(String version) { - this.version = version; - } + public List<String> getSchemaErrors() { + return schemaErrors; + } - private void init() { - if (allEntities != null) { - return; + private void init() { + if (allEntities != null) { + return; + } + allEntities = App.moxyLoaders.get(getSchemaName()).getAllObjects(); + edgeIngestor = App.edgeIngestor; + graph = createGraph(true, true); } - allEntities = App.moxyLoaders.get(getSchemaName()).getAllObjects(); - edgeIngestor = App.edgeIngestor; - graph = createGraph(true, true); - } - - private Graph<String, MetadataEdge> createGraph(boolean withParentChild, boolean withEdgeRules) { - Graph<String, MetadataEdge> graph = new DefaultDirectedGraph<>(MetadataEdge.class); - for (Entry<String, Introspector> currentParent : allEntities.entrySet()) { - graph.addVertex(currentParent.getKey()); - currentParent.getValue().getProperties().stream() - .filter(v -> allEntities.containsKey(v)) - .filter(v -> !currentParent.getKey().equals(v)) - .forEach(v -> { - graph.addVertex(v); - if (withParentChild) { - addParentChildEdge(currentParent.getKey(), v, graph); - } - }); + + private Graph<String, MetadataEdge> createGraph(boolean withParentChild, boolean withEdgeRules) { + Graph<String, MetadataEdge> graph = new DefaultDirectedGraph<>(MetadataEdge.class); + for (Entry<String, Introspector> currentParent : allEntities.entrySet()) { + graph.addVertex(currentParent.getKey()); + currentParent.getValue().getProperties().stream() + .filter(v -> allEntities.containsKey(v)) + .filter(v -> !currentParent.getKey().equals(v)) + .forEach(v -> { + graph.addVertex(v); + if (withParentChild) { + addParentChildEdge(currentParent.getKey(), v, graph); + } + }); + } + + if (!withEdgeRules) { + return graph; + } + + Multimap<String, EdgeRule> allRules = null; + try { + allRules = edgeIngestor.getAllRules(new SchemaVersion(getSchemaName())); + } catch (EdgeRuleNotFoundException e) { + //TODO fix + } + + allRules.asMap().values().stream() + .flatMap(e -> e.stream()) + .forEach(e -> { + switch (e.getDirection()) { + case OUT: + addEdgerule(e.getFrom(), e.getTo(), e.getLabel(), graph); + break; + case IN: + addEdgerule(e.getTo(), e.getFrom(), e.getLabel(), graph); + break; + case BOTH: + addEdgerule(e.getFrom(), e.getTo(), e.getLabel(), graph); + addEdgerule(e.getTo(), e.getFrom(), e.getLabel(), graph); + break; + } + }); + + return graph; + } + + private void addEdgerule(String parent, String child, String label, Graph<String, MetadataEdge> graph) { + //shortening labels, long edge names are unreadable in the UI + if (label.contains(".")) { + String[] split = label.split("\\."); + label = split[split.length - 1]; + } + checkVertexExist(graph, parent); + checkVertexExist(graph, child); + + graph.addEdge(child, parent, + new MetadataEdge(EdgeType.EDGE_RULE.getTypeName(), child, parent, label)); + } + + private void checkVertexExist(Graph<String, MetadataEdge> graph, String vertex) { + if (!graph.vertexSet().contains(vertex)) { + graph.addVertex(vertex); + schemaErrors.add(String.format("Schema is inconsistent, missing node %s", vertex)); + } + } + + private void addParentChildEdge(String parent, String child, Graph<String, MetadataEdge> graph) { + graph.addEdge(parent, child, + new MetadataEdge(EdgeType.PARENT.getTypeName(), parent, child, EdgeType.PARENT.getTypeName())); + graph.addEdge(child, parent, + new MetadataEdge(EdgeType.CHILD.getTypeName(), child, parent, EdgeType.CHILD.getTypeName())); + } + + @Override + public String getSchemaName() { + return version; + } + + @Override + public List<NodeName> getAllVertexNames(String edgeFilter) { + init(); + + return createGraph( + isParentChildFilter(edgeFilter), + isEdgeRulesFilter(edgeFilter)).edgeSet().stream() + .flatMap(e -> Arrays.asList(e.getSource(), e.getTarget()).stream()) + .sorted().distinct() + .map(NodeName::new) + .collect(Collectors.toList()); } - if (!withEdgeRules) { - return graph; + @Override + public List<NodeProperty> getVertexProperties(String nodeName) { + init(); + + if (!allEntities.containsKey(nodeName)) { + return Collections.emptyList(); + } + Introspector introspector = allEntities.get(nodeName); + List<String> properties = introspector.getProperties().stream().sorted().collect(Collectors.toList()); + + return properties.stream() + .map(p -> new NodeProperty( + p, + introspector.getPropertyMetadata(p).getOrDefault( + PropertyMetadata.DESCRIPTION, "no description available"), + introspector.getType(p), + introspector.getAllKeys().contains(p), + introspector.getIndexedProperties().contains(p), + introspector.getRequiredProperties().contains(p))) + .collect(Collectors.toList()); + } + + @Override + public List<Property> getEdgeProperties(String fromNode, String toNode, String type) { + init(); + if (type.equals(EdgeType.EDGE_RULE.getTypeName())) { + try { + List<EdgeRule> rules = edgeIngestor.getAllRules(new SchemaVersion(getSchemaName())) + .asMap().values().stream() + .flatMap(Collection::stream) + .filter(identifyEdgeRule(fromNode, toNode)) + .collect(Collectors.toList()); + + Optional<List<Property>> properties = rules.stream().map(this::edgeRuleProperties).findFirst(); + return properties.orElse(Collections.emptyList()); + + } catch (EdgeRuleNotFoundException e) { + //TODO fix + } + } + return Collections.emptyList(); } - Multimap<String, EdgeRule> allRules = null; - try { - allRules = edgeIngestor.getAllRules(new SchemaVersion(getSchemaName())); - } catch (EdgeRuleNotFoundException e) { - //TODO fix + private Predicate<EdgeRule> identifyEdgeRule(String fromNode, String toNode) { + return e -> { + switch (e.getDirection()) { + case OUT: + return e.getFrom().equals(fromNode) && e.getTo().equals(toNode); + case IN: + return e.getFrom().equals(toNode) && e.getTo().equals(fromNode); + case BOTH: + return e.getFrom().equals(toNode) && e.getTo().equals(fromNode) + || e.getFrom().equals(fromNode) && e.getTo().equals(toNode); + default: + return false; + } + }; } - allRules.asMap().values().stream().flatMap(e -> e.stream()).forEach(e -> { - switch (e.getDirection()) { - case OUT: - addEdgerule(e.getFrom(), e.getTo(), e.getLabel(), graph); - break; - case IN: - addEdgerule(e.getTo(), e.getFrom(), e.getLabel(), graph); - break; - case BOTH: - addEdgerule(e.getFrom(), e.getTo(), e.getLabel(), graph); - addEdgerule(e.getTo(), e.getFrom(), e.getLabel(), graph); - break; - } - }); - - return graph; - } - - private void addEdgerule(String parent, String child, String label, - Graph<String, MetadataEdge> graph) { - //shortening labels, long edge names are unreadable in the UI - if (label.contains(".")) { - String[] split = label.split("\\."); - label = split[split.length - 1]; + private List<Property> edgeRuleProperties(EdgeRule r) { + List<Property> ps = new LinkedList<>(); + ps.add(new Property("Multiplicity", r.getMultiplicityRule().name())); + ps.add(new Property("Is default edge", String.valueOf(r.isDefault()))); + ps.add(new Property("Description", r.getDescription())); + ps.add(new Property("Is private edge", String.valueOf(r.isPrivateEdge()))); + ps.add(new Property("Contains", r.getContains())); + ps.add(new Property("Prevent delete", r.getPreventDelete())); + ps.add(new Property("Label", r.getLabel())); + ps.add(new Property("Delete other v", r.getDeleteOtherV())); + return ps; } - checkVertexExist(graph, parent); - checkVertexExist(graph, child); - graph.addEdge(child, parent, - new MetadataEdge(EdgeType.EDGE_RULE.getTypeName(), child, parent, label)); - } + @Override + public org.onap.aai.graphgraph.dto.Graph getGraph( + String initialNode, int parentHops, int cousinHops, int childHops, String edgeFilter) { + init(); + + Optional<String> anyVertex = graph.vertexSet().stream().findFirst(); + if (!anyVertex.isPresent()) { + return org.onap.aai.graphgraph.dto.Graph.emptyGraph(); + } + Set<Edge> edges = computeAllEdges( + anyVertex.get(), isParentChildFilter(edgeFilter), isEdgeRulesFilter(edgeFilter)); + + if (!"all".equals(initialNode)) { + Set<String> subGraphVertices = computeNodes(initialNode, parentHops, EdgeType.CHILD.getTypeName()); + subGraphVertices.addAll(computeNodes(initialNode, childHops, EdgeType.PARENT.getTypeName())); + subGraphVertices.addAll(computeNodes(initialNode, cousinHops, EdgeType.EDGE_RULE.getTypeName())); + edges = filterEdges(edges, subGraphVertices); + } - private void checkVertexExist(Graph<String, MetadataEdge> graph, String vertex) { - if (! graph.vertexSet().contains(vertex)) { - graph.addVertex(vertex); - schemaErrors.add(String.format("Schema is inconsistent, missing node %s", vertex)); + return new org.onap.aai.graphgraph.dto.Graph(new LinkedList<>(computeNodeNames(edges)), + new LinkedList<>(edges), Collections.emptyList(), getVertexProperties(initialNode)); } - } - - private void addParentChildEdge(String parent, String child, Graph<String, MetadataEdge> graph) { - graph.addEdge(parent, child, - new MetadataEdge(EdgeType.PARENT.getTypeName(), parent, child, EdgeType.PARENT.getTypeName())); - graph.addEdge(child, parent, - new MetadataEdge(EdgeType.CHILD.getTypeName(), child, parent, EdgeType.CHILD.getTypeName())); - } - - @Override - public String getSchemaName() { - return version; - } - - @Override - public List<NodeName> getAllVertexNames(String edgeFilter) { - init(); - - return createGraph(isParentChildFilter(edgeFilter), isEdgeRulesFilter(edgeFilter)) - .edgeSet().stream().flatMap(e -> Arrays.asList(e.getSource(), e.getTarget()).stream()) - .sorted() - .distinct() - .map(NodeName::new).collect( - Collectors.toList()); - } - - @Override - public List<NodeProperty> getVertexProperties(String nodeName) { - init(); - - if (!allEntities.containsKey(nodeName)) { - return Collections.emptyList(); + + private boolean isParentChildFilter(String edgeFilter) { + return "Parents".equals(edgeFilter); } - Introspector introspector = allEntities.get(nodeName); - List<String> properties = introspector.getProperties().stream() - .sorted() - .collect(Collectors.toList()); - - List<NodeProperty> result = properties.stream().map( p -> - new NodeProperty( - p, - introspector.getPropertyMetadata(p) - .getOrDefault(PropertyMetadata.DESCRIPTION,"no description available"), - introspector.getType(p), - introspector.getAllKeys().contains(p), - introspector.getIndexedProperties().contains(p), - introspector.getRequiredProperties().contains(p)) - ).collect(Collectors.toList()); - - return result; - } - - @Override - public List<Property> getEdgeProperties(String fromNode, String toNode, String type) { - init(); - if (type.equals(EdgeType.EDGE_RULE.getTypeName())) { - try { - List<EdgeRule> rules = edgeIngestor.getAllRules(new SchemaVersion(getSchemaName())) - .asMap() - .values() - .stream() - .flatMap(Collection::stream) - .filter(identifyEdgeRule(fromNode, toNode)) - .collect(Collectors.toList()); - - Optional<List<Property>> properties = rules.stream().map(this::edgeRuleProperties) - .findFirst(); - return properties.orElse(Collections.emptyList()); - - } catch (EdgeRuleNotFoundException e) { - //TODO fix - } + private boolean isEdgeRulesFilter(String edgeFilter) { + return "Edgerules".equals(edgeFilter); } - return Collections.emptyList(); - } - - private Predicate<EdgeRule> identifyEdgeRule(String fromNode, String toNode) { - return e -> { - switch (e.getDirection()) { - case OUT: - return e.getFrom().equals(fromNode) && e.getTo().equals(toNode); - case IN: - return e.getFrom().equals(toNode) && e.getTo().equals(fromNode); - case BOTH: - return e.getFrom().equals(toNode) && e.getTo().equals(fromNode) - || e.getFrom().equals(fromNode) && e.getTo().equals(toNode); - default: - return false; - } - }; - } - - private List<Property> edgeRuleProperties(EdgeRule r) { - List<Property> ps = new LinkedList<>(); - ps.add(new Property("Multiplicity", r.getMultiplicityRule().name())); - ps.add(new Property("Is default edge", String.valueOf(r.isDefault()))); - ps.add(new Property("Description", r.getDescription())); - ps.add(new Property("Is private edge", String.valueOf(r.isPrivateEdge()))); - ps.add(new Property("Contains", r.getContains())); - ps.add(new Property("Prevent delete", r.getPreventDelete())); - ps.add(new Property("Label", r.getLabel())); - ps.add(new Property("Delete other v", r.getDeleteOtherV())); - return ps; - } - - @Override - public org.onap.aai.graphgraph.dto.Graph getGraph(String initialNode, int parentHops, - int cousinHops, int childHops, String edgeFilter) { - init(); - - Optional<String> anyVertex = graph.vertexSet().stream().findFirst(); - if (!anyVertex.isPresent()) { - return org.onap.aai.graphgraph.dto.Graph.emptyGraph(); + + private Set<Edge> filterEdgesStrict(Set<Edge> edges, Set<String> subGraphVertices) { + return edges.stream() + .filter(e -> subGraphVertices.contains(e.getSource()) && subGraphVertices.contains(e.getTarget())) + .collect(Collectors.toSet()); } - Set<Edge> edges = computeAllEdges(anyVertex.get(), isParentChildFilter(edgeFilter), - isEdgeRulesFilter(edgeFilter)); - - if (!"all".equals(initialNode)) { - Set<String> subGraphVertices = computeNodes(initialNode, parentHops, EdgeType.CHILD.getTypeName()); - subGraphVertices.addAll(computeNodes(initialNode, childHops, EdgeType.PARENT.getTypeName())); - subGraphVertices.addAll(computeNodes(initialNode, cousinHops, EdgeType.EDGE_RULE.getTypeName())); - edges = filterEdges(edges, subGraphVertices); + + private Set<Edge> filterEdges(Set<Edge> edges, Set<String> subGraphVertices) { + return edges.stream() + .filter(e -> subGraphVertices.contains(e.getSource()) || subGraphVertices.contains(e.getTarget())) + .filter(e -> !e.getType().equals(EdgeType.EDGE_RULE.getTypeName())) + .collect(Collectors.toSet()); } - return new org.onap.aai.graphgraph.dto.Graph(new LinkedList<>(computeNodeNames(edges)), - new LinkedList<>(edges), Collections.emptyList(), getVertexProperties(initialNode)); - } - - private boolean isParentChildFilter(String edgeFilter) { - return "Parents".equals(edgeFilter); - } - - private boolean isEdgeRulesFilter(String edgeFilter) { - return "Edgerules".equals(edgeFilter); - } - - private Set<Edge> filterEdgesStrict(Set<Edge> edges, Set<String> subGraphVertices) { - return edges.stream().filter( - e -> subGraphVertices.contains(e.getSource()) && subGraphVertices.contains(e.getTarget())) - .collect( - Collectors.toSet()); - } - - private Set<Edge> filterEdges(Set<Edge> edges, Set<String> subGraphVertices) { - return edges.stream().filter(e -> - subGraphVertices.contains(e.getSource()) || subGraphVertices.contains(e.getTarget())) - .filter(e -> !e.getType().equals(EdgeType.EDGE_RULE.getTypeName())) - .collect(Collectors.toSet()); - } - - private Set<NodeName> computeNodeNames(Set<Edge> edges) { - return edges.stream().flatMap(e -> e.getNodeNames().stream()).collect( - Collectors.toSet()); - } - - private Set<Edge> computeAllEdges(String initial, boolean parentChild, boolean edgeRules) { - Set<Edge> result = new HashSet<>(); - List<String> toQuery = new LinkedList<>(); - toQuery.add(initial); - final List<String> toVisit = new LinkedList<>(); - Set<String> visited = new HashSet<>(); - - while (!toQuery.isEmpty()) { - for (String v : toQuery) { - visited.add(v); - - graph.edgesOf(v).forEach(edge -> { - String neighbour = edge.getTarget(); - toVisit.add(neighbour); - - if (EdgeType.CHILD.isType(edge.getType()) && parentChild) { - result.add(new Edge(neighbour, edge.getSource(), EdgeType.PARENT.getTypeName(), - createTooltip(neighbour, edge.getSource(), EdgeType.PARENT.getTypeName(), edge.getLabel()))); - } - - if (EdgeType.EDGE_RULE.isType(edge.getType()) && edgeRules) { - result.add(new Edge(edge.getSource(), neighbour, edge.getLabel(), - createTooltip(neighbour, edge.getSource(), EdgeType.EDGE_RULE.getTypeName(), - edge.getLabel()))); - } - }); - } - toQuery.clear(); - toQuery.addAll( - toVisit.stream().filter(s -> !visited.contains(s)).collect(Collectors.toList())); + private Set<NodeName> computeNodeNames(Set<Edge> edges) { + return edges.stream() + .flatMap(e -> e.getNodeNames().stream()) + .collect(Collectors.toSet()); } - return result; + private Set<Edge> computeAllEdges(String initial, boolean parentChild, boolean edgeRules) { + Set<Edge> result = new HashSet<>(); + List<String> toQuery = new LinkedList<>(); + toQuery.add(initial); + final List<String> toVisit = new LinkedList<>(); + Set<String> visited = new HashSet<>(); + + while (!toQuery.isEmpty()) { + for (String v : toQuery) { + visited.add(v); + + graph.edgesOf(v).forEach(edge -> { + String neighbour = edge.getTarget(); + toVisit.add(neighbour); + + if (EdgeType.CHILD.isType(edge.getType()) && parentChild) { + result.add(new Edge( + neighbour, edge.getSource(), EdgeType.PARENT.getTypeName(), createTooltip( + neighbour, edge.getSource(), EdgeType.PARENT.getTypeName(), edge.getLabel()))); + } + + if (EdgeType.EDGE_RULE.isType(edge.getType()) && edgeRules) { + result.add(new Edge( + edge.getSource(), neighbour, edge.getLabel(), createTooltip( + neighbour, edge.getSource(), EdgeType.EDGE_RULE.getTypeName(), edge.getLabel()))); + } + }); + } + toQuery.clear(); + toQuery.addAll(toVisit.stream().filter(s -> !visited.contains(s)).collect(Collectors.toList())); + } + + return result; + + } - } + private Set<String> computeNodes(String vertex, int hops, String relationshipName) { + List<String> toQuery = new LinkedList<>(); + toQuery.add(vertex); - private Set<String> computeNodes(String vertex, int hops, String relationshipName) { - List<String> toQuery = new LinkedList<>(); - toQuery.add(vertex); + Set<String> visited = new HashSet<>(); + int i = 0; - Set<String> visited = new HashSet<>(); - int i = 0; + final List<String> toVisit = new LinkedList<>(); + while (!toQuery.isEmpty() && hops > i) { + i++; + toVisit.clear(); - final List<String> toVisit = new LinkedList<>(); - while (!toQuery.isEmpty() && hops > i) { - i++; - toVisit.clear(); + for (String v : toQuery) { + visited.add(v); + graph.edgesOf(v).stream() + .filter(e -> e.getType().equals(relationshipName)) + .map(MetadataEdge::getTarget) + .forEach(toVisit::add); + } - for (String v : toQuery) { - visited.add(v); - graph.edgesOf(v).stream().filter(e -> e.getType().equals(relationshipName)).map( - MetadataEdge::getTarget).forEach(toVisit::add); - } + toQuery.clear(); + toQuery.addAll(toVisit.stream().filter(v -> !visited.contains(v)).collect(Collectors.toList())); + } - toQuery.clear(); - toQuery - .addAll(toVisit.stream().filter(v -> !visited.contains(v)).collect(Collectors.toList())); + return visited; } - return visited; - } - - - @Override - public org.onap.aai.graphgraph.dto.Graph getGraph(String fromNode, String toNode, - String edgeFilter) { - init(); - Graph<String, MetadataEdge> tempGraph = createGraph(isParentChildFilter(edgeFilter), isEdgeRulesFilter(edgeFilter)); - List<List<NodeName>> paths = new LinkedList<>(); - FloydWarshallShortestPaths<String, MetadataEdge> shortestPaths; - - while (true) { - shortestPaths = new FloydWarshallShortestPaths<>(tempGraph); - GraphPath<String, MetadataEdge> p = shortestPaths.getPath(fromNode, toNode); - if (p == null || p.getEdgeList() == null || p.getEdgeList().isEmpty()) { - break; - } - String previous = fromNode; - List<NodeName> path = new LinkedList<>(); - for (MetadataEdge e : p.getEdgeList()) { - if (e.getTarget().equals(previous)) { - previous = e.getSource(); - path.add(new NodeName(e.getTarget())); - } else { - previous = e.getTarget(); - path.add(new NodeName(e.getSource())); + @Override + public org.onap.aai.graphgraph.dto.Graph getGraph(String fromNode, String toNode, String edgeFilter) { + init(); + Graph<String, MetadataEdge> tempGraph = createGraph( + isParentChildFilter(edgeFilter), isEdgeRulesFilter(edgeFilter)); + List<List<NodeName>> paths = new LinkedList<>(); + FloydWarshallShortestPaths<String, MetadataEdge> shortestPaths; + + while (true) { + shortestPaths = new FloydWarshallShortestPaths<>(tempGraph); + GraphPath<String, MetadataEdge> p = shortestPaths.getPath(fromNode, toNode); + if (p == null || p.getEdgeList() == null || p.getEdgeList().isEmpty()) { + break; + } + String previous = fromNode; + List<NodeName> path = new LinkedList<>(); + for (MetadataEdge e : p.getEdgeList()) { + if (e.getTarget().equals(previous)) { + previous = e.getSource(); + path.add(new NodeName(e.getTarget())); + } else { + previous = e.getTarget(); + path.add(new NodeName(e.getSource())); + } + } + path.add(new NodeName(previous)); + paths.add(path); + tempGraph.removeEdge(p.getEdgeList().get(p.getLength() - 1)); //remove last edge from path } - } - path.add(new NodeName(previous)); - paths.add(path); - tempGraph.removeEdge(p.getEdgeList().get(p.getLength() - 1)); //remove last edge from path + + Set<Edge> edges = computeAllEdges(fromNode, isParentChildFilter(edgeFilter), isEdgeRulesFilter(edgeFilter)); + edges = filterEdgesStrict( + edges, + paths.stream() + .flatMap(Collection::stream) + .map(NodeName::getId) + .collect(Collectors.toSet())); + return new org.onap.aai.graphgraph.dto.Graph( + new LinkedList<>(computeNodeNames(edges)), new LinkedList<>(edges), + paths, getVertexProperties(fromNode)); } - Set<Edge> edges = computeAllEdges(fromNode, isParentChildFilter(edgeFilter), - isEdgeRulesFilter(edgeFilter)); - edges = filterEdgesStrict(edges, - paths.stream().flatMap(Collection::stream).map(NodeName::getId).collect( - Collectors.toSet())); - return new org.onap.aai.graphgraph.dto.Graph(new LinkedList<>(computeNodeNames(edges)), - new LinkedList<>(edges), paths, getVertexProperties(fromNode)); - } - - private List<Property> createTooltip(String target, String v, String type, String label) { - List<Property> properties = new LinkedList<>(); - properties.add(new Property("From", target)); - properties.add(new Property("To", v)); - properties.add(new Property("Type", type)); - properties.add(new Property("Relationship", label)); - properties.addAll(getEdgeProperties(v, target, EdgeType.EDGE_RULE.isType(type) ? EdgeType.EDGE_RULE.getTypeName() : EdgeType.PARENT.getTypeName())); - return properties; - } + private List<Property> createTooltip(String target, String v, String type, String label) { + List<Property> properties = new LinkedList<>(); + properties.add(new Property("From", target)); + properties.add(new Property("To", v)); + properties.add(new Property("Type", type)); + properties.add(new Property("Relationship", label)); + properties.addAll(getEdgeProperties( + v, target, + EdgeType.EDGE_RULE.isType(type) ? EdgeType.EDGE_RULE.getTypeName() : EdgeType.PARENT.getTypeName())); + return properties; + } } diff --git a/src/main/java/org/onap/aai/graphgraph/reader/EdgeType.java b/src/main/java/org/onap/aai/graphgraph/reader/EdgeType.java index 1250474..fd2614c 100644 --- a/src/main/java/org/onap/aai/graphgraph/reader/EdgeType.java +++ b/src/main/java/org/onap/aai/graphgraph/reader/EdgeType.java @@ -1,38 +1,40 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.reader; public enum EdgeType { - EDGE_RULE("edgerule"), PARENT("parent"), CHILD("child"); + EDGE_RULE("edgerule"), + PARENT("parent"), + CHILD("child"); - private final String name; + private final String name; - EdgeType(String s) { - name = s; - } + EdgeType(String s) { + name = s; + } - public String getTypeName() { - return this.name; - } + public String getTypeName() { + return this.name; + } - public boolean isType(String o){ - return name.equals(o); - } + public boolean isType(String o) { + return name.equals(o); + } } diff --git a/src/main/java/org/onap/aai/graphgraph/reader/MetadataEdge.java b/src/main/java/org/onap/aai/graphgraph/reader/MetadataEdge.java index fb8e53f..2dea403 100644 --- a/src/main/java/org/onap/aai/graphgraph/reader/MetadataEdge.java +++ b/src/main/java/org/onap/aai/graphgraph/reader/MetadataEdge.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.reader; @@ -23,49 +23,49 @@ import org.jgrapht.graph.DefaultEdge; public class MetadataEdge extends DefaultEdge { - private final String type; - private final String target; - private final String source; - private final String label; + private final String type; + private final String target; + private final String source; + private final String label; - MetadataEdge(String type, String source, String target) { - this.source = source; - this.target = target; - this.type = type; - this.label = ""; - } + MetadataEdge(String type, String source, String target) { + this.source = source; + this.target = target; + this.type = type; + this.label = ""; + } - MetadataEdge(String type, String target, String source, String label) { - this.type = type; - this.target = target; - this.source = source; - this.label = label; - } + MetadataEdge(String type, String target, String source, String label) { + this.type = type; + this.target = target; + this.source = source; + this.label = label; + } - public String getLabel() { - return label; - } + public String getLabel() { + return label; + } - @Override - public String getTarget() { - return target; - } + @Override + public String getTarget() { + return target; + } - @Override - public String getSource() { - return source; - } + @Override + public String getSource() { + return source; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - @Override - public String toString() { - return "MetadataEdge{" + - "type='" + type + '\'' + - ", target='" + target + '\'' + - ", source='" + source + '\'' + - '}'; - } + @Override + public String toString() { + return "MetadataEdge{" + + "type='" + type + '\'' + + ", target='" + target + '\'' + + ", source='" + source + '\'' + + '}'; + } } diff --git a/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java b/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java index a924e63..38e1bf6 100644 --- a/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java +++ b/src/main/java/org/onap/aai/graphgraph/reader/SchemaReader.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.reader; @@ -27,11 +27,16 @@ import org.onap.aai.graphgraph.dto.Property; import java.util.List; public interface SchemaReader { + String getSchemaName(); + List<NodeName> getAllVertexNames(String edgeFilter); + List<NodeProperty> getVertexProperties(String nodeName); + List<Property> getEdgeProperties(String fromNode, String toNode, String type); - Graph getGraph(String initialNode, int parentHops, int cousinHops, int childHops, - String edgeFilter); + + Graph getGraph(String initialNode, int parentHops, int cousinHops, int childHops, String edgeFilter); + Graph getGraph(String fromNode, String toNode, String edgeFilter); } diff --git a/src/main/java/org/onap/aai/graphgraph/reader/SchemaRepository.java b/src/main/java/org/onap/aai/graphgraph/reader/SchemaRepository.java index f49a669..5764c50 100644 --- a/src/main/java/org/onap/aai/graphgraph/reader/SchemaRepository.java +++ b/src/main/java/org/onap/aai/graphgraph/reader/SchemaRepository.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.reader; @@ -24,20 +24,22 @@ import java.util.Optional; import java.util.stream.Collectors; public class SchemaRepository { + private List<SchemaReader> readers; public SchemaRepository(List<SchemaReader> readers) { this.readers = readers; } - public List<String> getAllSchemaNames(){ + public List<String> getAllSchemaNames() { return readers.stream().map(SchemaReader::getSchemaName).collect(Collectors.toList()); } - public SchemaReader getSchemaReader(String schemaName){ + public SchemaReader getSchemaReader(String schemaName) { Optional<SchemaReader> reader = readers.stream().filter(r -> schemaName.equals(r.getSchemaName())).findFirst(); - if(!reader.isPresent()) + if (!reader.isPresent()) { throw new IllegalArgumentException("Schema " + schemaName + " not found"); + } return reader.get(); } diff --git a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityAssociation.java b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityAssociation.java index 697fad1..dda37b5 100644 --- a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityAssociation.java +++ b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityAssociation.java @@ -1,115 +1,113 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.velocity; public class VelocityAssociation extends VelocityId { - private final String name; - private final VelocityEntity fromEntity; - private final VelocityEntity toEntity; - private final String fromId = getRandomId(); - private final String toId = getRandomId(); - private final String multiplicity; - private final boolean isComposition; - - public VelocityAssociation(VelocityEntity fromEntity, - VelocityEntity toEntity, String name, String multiplicity, boolean isComposition) { - this.fromEntity = fromEntity; - this.toEntity = toEntity; - this.name = name; - this.multiplicity = multiplicity; - this.isComposition = isComposition; - } - - public String getFromEntityName(){ - return fromEntity.getName(); - } - - public String getToEntityName(){ - return toEntity.getName(); - } - - public String getFromEntityId(){ - return fromEntity.getId(); - } - - public String getToEntityId(){ - return toEntity.getId(); - } - - public String getFromId() { - return fromId; - } - - public String getToId() { - return toId; - } - - public String getName() { - return name; - } - - public String getMultiplicity() { - return multiplicity.toUpperCase(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + private final String name; + private final VelocityEntity fromEntity; + private final VelocityEntity toEntity; + private final String fromId = getRandomId(); + private final String toId = getRandomId(); + private final String multiplicity; + private final boolean isComposition; + + public VelocityAssociation(VelocityEntity fromEntity, + VelocityEntity toEntity, String name, String multiplicity, boolean isComposition) { + this.fromEntity = fromEntity; + this.toEntity = toEntity; + this.name = name; + this.multiplicity = multiplicity; + this.isComposition = isComposition; } - if (o == null || getClass() != o.getClass()) { - return false; + + public String getFromEntityName() { + return fromEntity.getName(); + } + + public String getToEntityName() { + return toEntity.getName(); + } + + public String getFromEntityId() { + return fromEntity.getId(); } - VelocityAssociation that = (VelocityAssociation) o; + public String getToEntityId() { + return toEntity.getId(); + } + + public String getFromId() { + return fromId; + } + + public String getToId() { + return toId; + } - if (!name.equals(that.name)) { - return false; + public String getName() { + return name; } - if (!fromEntity.equals(that.fromEntity)) { - return false; + + public String getMultiplicity() { + return multiplicity.toUpperCase(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + VelocityAssociation that = (VelocityAssociation) o; + + if (!name.equals(that.name)) { + return false; + } + if (!fromEntity.equals(that.fromEntity)) { + return false; + } + return toEntity.equals(that.toEntity); + } + + public boolean getIsComposition() { + return isComposition; + } + + @Override + public String toString() { + return "VelocityAssociation{" + + "name='" + name + '\'' + + ", fromEntity=" + fromEntity + + ", toEntity=" + toEntity + + '}'; + } + + @Override + public int hashCode() { + int result = name.hashCode(); + result = 31 * result + fromEntity.hashCode(); + result = 31 * result + toEntity.hashCode(); + return result; } - return toEntity.equals(that.toEntity); - } - - public boolean getIsComposition() { - return isComposition; - } - - @Override - public String toString() { - return "VelocityAssociation{" + - "name='" + name + '\'' + - ", fromEntity=" + fromEntity + - ", toEntity=" + toEntity + - '}'; - } - - @Override - public int hashCode() { - int result = name.hashCode(); - result = 31 * result + fromEntity.hashCode(); - result = 31 * result + toEntity.hashCode(); - return result; - - - } } diff --git a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntity.java b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntity.java index 99f94f3..424c0e6 100644 --- a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntity.java +++ b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntity.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.velocity; @@ -24,75 +24,73 @@ import java.util.List; import java.util.Set; public class VelocityEntity extends VelocityId { - private String name; - private String description; - private List<VelocityAssociation> neighbours = new LinkedList<>(); - private Set<VelocityEntityProperty> properties; - public Set<VelocityEntityProperty> getProperties() { - return properties; - } + private String name; + private String description; + private List<VelocityAssociation> neighbours = new LinkedList<>(); + private Set<VelocityEntityProperty> properties; - public void setProperties(Set<VelocityEntityProperty> properties) { - this.properties = properties; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } + public VelocityEntity(String name) { + this.name = name; + } - public VelocityEntity(String name) { - this.name = name; - } + public Set<VelocityEntityProperty> getProperties() { + return properties; + } - public String getName() { - return name; - } + public void setProperties(Set<VelocityEntityProperty> properties) { + this.properties = properties; + } - public void setName(String name) { - this.name = name; - } + public String getDescription() { + return description; + } - public List<VelocityAssociation> getNeighbours() { - return neighbours; - } + public void setDescription(String description) { + this.description = description; + } - public void setNeighbours(List<VelocityAssociation> neighbours) { - this.neighbours = neighbours; - } + public String getName() { + return name; + } - public void addNeighbours(VelocityAssociation neighbour) { - neighbours.add(neighbour); - } + public void setName(String name) { + this.name = name; + } + public List<VelocityAssociation> getNeighbours() { + return neighbours; + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public void setNeighbours(List<VelocityAssociation> neighbours) { + this.neighbours = neighbours; } - if (o == null || getClass() != o.getClass()) { - return false; + + public void addNeighbours(VelocityAssociation neighbour) { + neighbours.add(neighbour); } - VelocityEntity that = (VelocityEntity) o; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } - return name.equals(that.name); - } + VelocityEntity that = (VelocityEntity) o; - @Override - public int hashCode() { - return name.hashCode(); - } + return name.equals(that.name); + } - @Override - public String toString() { - return "VelocityEntity{" + - "name='" + name + '\'' + - '}'; - } + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public String toString() { + return "VelocityEntity{" + "name='" + name + '\'' + '}'; + } } diff --git a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntityProperty.java b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntityProperty.java index e8dec9f..2c65ae3 100644 --- a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntityProperty.java +++ b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntityProperty.java @@ -1,21 +1,21 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.velocity; @@ -24,35 +24,33 @@ import org.onap.aai.graphgraph.dto.Property; public class VelocityEntityProperty extends Property { - private final VelocityEntity entity; - private final String propertyId; - public VelocityEntityProperty(String propertyName, String propertyValue, VelocityEntity entity) { - super(propertyName, propertyValue); - this.entity = entity; - propertyId = entity != null ? entity.getRandomId() : UUID.randomUUID().toString(); - } - - public String getEntityId() { - return entity.getId(); - } - - public String getEntityName() { - return entity.getName(); - } - - public boolean hasEntity(){ - return entity != null; - } - - public String getPropertyId() { - return propertyId; - } - - @Override - public String toString() { - return "VelocityEntityProperty{" + - " name=" + getPropertyName() + - " type=" + getPropertyValue() + - '}'; - } + private final VelocityEntity entity; + private final String propertyId; + + public VelocityEntityProperty(String propertyName, String propertyValue, VelocityEntity entity) { + super(propertyName, propertyValue); + this.entity = entity; + propertyId = entity != null ? entity.getRandomId() : UUID.randomUUID().toString(); + } + + public String getEntityId() { + return entity.getId(); + } + + public String getEntityName() { + return entity.getName(); + } + + public boolean hasEntity() { + return entity != null; + } + + public String getPropertyId() { + return propertyId; + } + + @Override + public String toString() { + return "VelocityEntityProperty{" + " name=" + getPropertyName() + " type=" + getPropertyValue() + '}'; + } } diff --git a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityId.java b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityId.java index fc44a5e..9b59c82 100644 --- a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityId.java +++ b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityId.java @@ -1,34 +1,35 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2019 Orange Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/* + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 2019-2020 Orange Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= */ package org.onap.aai.graphgraph.velocity; import java.util.UUID; public abstract class VelocityId { - private String id = getRandomId(); - public String getId() { - return id; - } + private String id = getRandomId(); + + public String getId() { + return id; + } - public String getRandomId() { - return UUID.randomUUID().toString(); - } + public String getRandomId() { + return UUID.randomUUID().toString(); + } } diff --git a/src/main/resources/docker-assembly.xml b/src/main/resources/docker-assembly.xml index afd1970..54a87af 100644 --- a/src/main/resources/docker-assembly.xml +++ b/src/main/resources/docker-assembly.xml @@ -1,6 +1,6 @@ <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> <id>distribution</id> <formats> <format>jar</format> @@ -13,11 +13,11 @@ </fileSet> </fileSets> -<files> - <file> + <files> + <file> <source>target/${project.artifactId}-${project.version}.${project.packaging}</source> <outputDirectory>/</outputDirectory> <filtered>false</filtered> </file> -</files> -</assembly>
\ No newline at end of file + </files> +</assembly> diff --git a/src/main/resources/etc/auth/realm.properties b/src/main/resources/etc/auth/realm.properties index f0e0172..3ba96bc 100644 --- a/src/main/resources/etc/auth/realm.properties +++ b/src/main/resources/etc/auth/realm.properties @@ -1,13 +1,13 @@ # format : username: password[,rolename ...] # default username/password: AAI/AAI, MSO/MSO, ModelLoader/ModelLoader... -AAI:OBF:1gfr1ev31gg7,admin -MSO:OBF:1jzx1lz31k01,admin -SDNC:OBF:1itr1i0l1i151isv,admin -DCAE:OBF:1g8u1f9d1f991g8w,admin -POLICY:OBF:1mk61i171ima1im41i0j1mko,admin -ASDC:OBF:1f991j0u1j001f9d,admin -VID:OBF:1jm91i0v1jl9,admin -APPC:OBF:1f991ksf1ksf1f9d,admin -ModelLoader:OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw,admin -AaiUI:OBF:1gfr1p571unz1p4j1gg7,admin -OOF:OBF:1img1ke71ily,admin +AAI=OBF:1gfr1ev31gg7,admin +MSO=OBF:1jzx1lz31k01,admin +SDNC=OBF:1itr1i0l1i151isv,admin +DCAE=OBF:1g8u1f9d1f991g8w,admin +POLICY=OBF:1mk61i171ima1im41i0j1mko,admin +ASDC=OBF:1f991j0u1j001f9d,admin +VID=OBF:1jm91i0v1jl9,admin +APPC=OBF:1f991ksf1ksf1f9d,admin +ModelLoader=OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw,admin +AaiUI=OBF:1gfr1p571unz1p4j1gg7,admin +OOF=OBF:1img1ke71ily,admin diff --git a/src/main/resources/model_export.vm b/src/main/resources/model_export.vm index c461d59..ae92fab 100644 --- a/src/main/resources/model_export.vm +++ b/src/main/resources/model_export.vm @@ -5,148 +5,148 @@ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/> </packageImport> - <packagedElement xmi:type="uml:Package" xmi:id="_dl4P8LIpEemXwfLFUQ7Icw" name="Associations"> + <packagedElement xmi:type="uml:Package" xmi:id="_dl4P8LIpEemXwfLFUQ7Icw" name="Associations"> #foreach($association in $associationList) - <packagedElement xmi:type="uml:Association" xmi:id="$association.id" - name="$association.name" memberEnd="$association.fromId $association.toId"> - <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="$association.randomId" - source="org.eclipse.papyrus"> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="$association.randomId" - key="nature" value="UML_Nature"/> - </eAnnotations> - <ownedEnd xmi:type="uml:Property" xmi:id="$association.fromId" - name="$association.toEntityName" type="$association.toEntityId" - association="$association.id"> - #if($association.multiplicity == "ONE2MANY" || $association.multiplicity == - "MANY2MANY") - <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId"/> - <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="$association.randomId" - value="*"/> - #else - <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" value="1"/> - <upperValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" value="1"/> - #end - </ownedEnd> - #if( ! $association.isComposition) - <ownedEnd xmi:type="uml:Property" xmi:id="$association.toId" - name="$association.fromEntityName" type="$association.fromEntityId" - association="$association.id"> - #if($association.multiplicity == "MANY2ONE" || $association.multiplicity == - "MANY2MANY") - <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId"/> - <upperValue xmi:type="uml:LiteralUnlimitedNatural" - xmi:id="$association.randomId" value="*"/> - #else - <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" - value="1"/> - <upperValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" - value="1"/> - #end - </ownedEnd> - #end - </packagedElement> + <packagedElement xmi:type="uml:Association" xmi:id="$association.id" + name="$association.name" memberEnd="$association.fromId $association.toId"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="$association.randomId" + source="org.eclipse.papyrus"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="$association.randomId" + key="nature" value="UML_Nature"/> + </eAnnotations> + <ownedEnd xmi:type="uml:Property" xmi:id="$association.fromId" + name="$association.toEntityName" type="$association.toEntityId" + association="$association.id"> + #if($association.multiplicity == "ONE2MANY" || $association.multiplicity == + "MANY2MANY") + <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId"/> + <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="$association.randomId" + value="*"/> + #else + <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" value="1"/> + <upperValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" value="1"/> + #end + </ownedEnd> + #if( ! $association.isComposition) + <ownedEnd xmi:type="uml:Property" xmi:id="$association.toId" + name="$association.fromEntityName" type="$association.fromEntityId" + association="$association.id"> + #if($association.multiplicity == "MANY2ONE" || $association.multiplicity == + "MANY2MANY") + <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId"/> + <upperValue xmi:type="uml:LiteralUnlimitedNatural" + xmi:id="$association.randomId" value="*"/> + #else + <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" + value="1"/> + <upperValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" + value="1"/> + #end + </ownedEnd> + #end + </packagedElement> #end - </packagedElement> - <packagedElement xmi:type="uml:Package" xmi:id="_rBN-QLIqEemXwfLFUQ7Icw" name="ObjectClasses"> + </packagedElement> + <packagedElement xmi:type="uml:Package" xmi:id="_rBN-QLIqEemXwfLFUQ7Icw" name="ObjectClasses"> #foreach($entity in $entityList) - <packagedElement xmi:type="uml:Class" xmi:id="$entity.id" name="$entity.name"> - <ownedComment xmi:type="uml:Comment" xmi:id="$entity.randomId" annotatedElement="$entity.id"> - <body>$entity.description</body> - </ownedComment> - #foreach($association in $entity.neighbours) - #if( $association.isComposition) - <ownedAttribute xmi:type="uml:Property" xmi:id="$association.toId" - name="$association.fromEntityName" - type="$association.fromEntityId" aggregation="composite" - association="$association.id"> - #if($association.multiplicity == "MANY2ONE" || $association.multiplicity == - "MANY2MANY") - <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId"/> - <upperValue xmi:type="uml:LiteralUnlimitedNatural" - xmi:id="$association.randomId" value="*"/> - #else - <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" - value="1"/> - <upperValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" - value="1"/> - #end - </ownedAttribute> - #end - #end - #foreach($prop in $entity.properties) - #if($prop.propertyValue.contains("java.lang")) - <ownedAttribute xmi:type="uml:Property" xmi:id="$prop.propertyId" - name="$prop.propertyName"> - #if($prop.propertyValue == "java.lang.String") - <type xmi:type="uml:PrimitiveType" - href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/> - #end# - #if($prop.propertyValue == "java.lang.Long") - <type xmi:type="uml:PrimitiveType" - href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/> - #end - #if($prop.propertyValue == "java.lang.Boolean") - <type xmi:type="uml:PrimitiveType" - href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Boolean"/> - #end - #if($prop.propertyValue == "java.lang.Integer") - <type xmi:type="uml:PrimitiveType" - href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/> - #end - </ownedAttribute> - #elseif(! $prop.hasEntity) - #* <ownedAttribute xmi:type="uml:Property" xmi:id="$entity.randomId" name="$prop.propertyName"/>*# - #else - <ownedAttribute xmi:type="uml:Property" xmi:id="$prop.propertyId" - name="$prop.getEntityName()" type="$prop.getEntityId()"/> - #end - #end - </packagedElement> - #end - </packagedElement> - <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_o4e8sN4HEemqKsY3En9wuw"> - <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_o5H14N4HEemqKsY3En9wuw" source="PapyrusVersion"> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic8N4HEemqKsY3En9wuw" key="Version" value="0.0.4"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic8d4HEemqKsY3En9wuw" key="Comment" value="Metaclasses Property and Stereotype added via <Element Import>."/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic8t4HEemqKsY3En9wuw" key="Copyright" value=""/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic894HEemqKsY3En9wuw" key="Date" value="2017-08-08"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic9N4HEemqKsY3En9wuw" key="Author" value=""/> - </eAnnotations> - <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_o4lDUN4HEemqKsY3En9wuw" source="http://www.eclipse.org/uml2/2.0.0/UML"> - <references xmi:type="ecore:EPackage" href="../ProfileLifecycleProfile/ProfileLifecycle_Profile.profile.uml#_AL3HsHweEee8oZaf2rRQlg"/> - </eAnnotations> - <appliedProfile xmi:type="uml:Profile" href="../ProfileLifecycleProfile/ProfileLifecycle_Profile.profile.uml#_CBpGoEdZEearpawF38eisA"/> - </profileApplication> - <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_o5JEAN4HEemqKsY3En9wuw"> - <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_pCSY8d4HEemqKsY3En9wuw" source="PapyrusVersion"> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCSY8t4HEemqKsY3En9wuw" key="Version" value="0.2.17"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAAN4HEemqKsY3En9wuw" key="Comment" value="Editorial corrections in the description of OpenModelAttribute::partOfObjectKey and Reference."/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAAd4HEemqKsY3En9wuw" key="Copyright" value=""/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAAt4HEemqKsY3En9wuw" key="Date" value="2018-12-12"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAA94HEemqKsY3En9wuw" key="Author" value=""/> - </eAnnotations> - <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_o5JrEN4HEemqKsY3En9wuw" source="http://www.eclipse.org/uml2/2.0.0/UML"> - <references xmi:type="ecore:EPackage" href="../OpenModelProfile/OpenModel_Profile.profile.uml#_FV_e4P4LEeiJYfiYi3RAYQ"/> - </eAnnotations> - <appliedProfile xmi:type="uml:Profile" href="../OpenModelProfile/OpenModel_Profile.profile.uml#_m1xqsHBgEd6FKu9XX1078A"/> - </profileApplication> -</uml:Model> -<OpenModel_Profile:OpenModelStatement xmi:id="_o-KG4N4HEemqKsY3En9wuw" base_Model="_Z9InoLIpEemXwfLFUQ7Icw"/> -#foreach($association in $associationList) -<OpenModel_Profile:OpenModelAttribute xmi:id="$association.randomId" base_StructuralFeature="$association.fromId"/> -#if( ! $association.isComposition) -<OpenModel_Profile:OpenModelAttribute xmi:id="$association.randomId" base_StructuralFeature="$association.toId"/> -#end -#end -#foreach($entity in $entityList) - <OpenModel_Profile:OpenModelClass xmi:id="$entity.randomId" base_Class="$entity.id"/> - #foreach($association in $entity.neighbours) + <packagedElement xmi:type="uml:Class" xmi:id="$entity.id" name="$entity.name"> + <ownedComment xmi:type="uml:Comment" xmi:id="$entity.randomId" annotatedElement="$entity.id"> + <body>$entity.description</body> + </ownedComment> + #foreach($association in $entity.neighbours) #if( $association.isComposition) - <OpenModel_Profile:OpenModelAttribute xmi:id="$association.randomId" base_StructuralFeature="$association.toId"/> + <ownedAttribute xmi:type="uml:Property" xmi:id="$association.toId" + name="$association.fromEntityName" + type="$association.fromEntityId" aggregation="composite" + association="$association.id"> + #if($association.multiplicity == "MANY2ONE" || $association.multiplicity == + "MANY2MANY") + <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId"/> + <upperValue xmi:type="uml:LiteralUnlimitedNatural" + xmi:id="$association.randomId" value="*"/> + #else + <lowerValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" + value="1"/> + <upperValue xmi:type="uml:LiteralInteger" xmi:id="$association.randomId" + value="1"/> + #end + </ownedAttribute> #end - #end - #foreach($prop in $entity.properties) - <OpenModel_Profile:OpenModelAttribute xmi:id="$entity.randomId" base_StructuralFeature="$prop.propertyId"/> - #end -#end -</xmi:XMI>
\ No newline at end of file + #end + #foreach($prop in $entity.properties) + #if($prop.propertyValue.contains("java.lang")) + <ownedAttribute xmi:type="uml:Property" xmi:id="$prop.propertyId" + name="$prop.propertyName"> + #if($prop.propertyValue == "java.lang.String") + <type xmi:type="uml:PrimitiveType" + href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/> + #end# + #if($prop.propertyValue == "java.lang.Long") + <type xmi:type="uml:PrimitiveType" + href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/> + #end + #if($prop.propertyValue == "java.lang.Boolean") + <type xmi:type="uml:PrimitiveType" + href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Boolean"/> + #end + #if($prop.propertyValue == "java.lang.Integer") + <type xmi:type="uml:PrimitiveType" + href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/> + #end + </ownedAttribute> + #elseif(! $prop.hasEntity) + #* <ownedAttribute xmi:type="uml:Property" xmi:id="$entity.randomId" name="$prop.propertyName"/>*# + #else + <ownedAttribute xmi:type="uml:Property" xmi:id="$prop.propertyId" + name="$prop.getEntityName()" type="$prop.getEntityId()"/> + #end + #end + </packagedElement> + #end + </packagedElement> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_o4e8sN4HEemqKsY3En9wuw"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_o5H14N4HEemqKsY3En9wuw" source="PapyrusVersion"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic8N4HEemqKsY3En9wuw" key="Version" value="0.0.4"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic8d4HEemqKsY3En9wuw" key="Comment" value="Metaclasses Property and Stereotype added via <Element Import>."/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic8t4HEemqKsY3En9wuw" key="Copyright" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic894HEemqKsY3En9wuw" key="Date" value="2017-08-08"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_o5Ic9N4HEemqKsY3En9wuw" key="Author" value=""/> + </eAnnotations> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_o4lDUN4HEemqKsY3En9wuw" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="../ProfileLifecycleProfile/ProfileLifecycle_Profile.profile.uml#_AL3HsHweEee8oZaf2rRQlg"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="../ProfileLifecycleProfile/ProfileLifecycle_Profile.profile.uml#_CBpGoEdZEearpawF38eisA"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_o5JEAN4HEemqKsY3En9wuw"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_pCSY8d4HEemqKsY3En9wuw" source="PapyrusVersion"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCSY8t4HEemqKsY3En9wuw" key="Version" value="0.2.17"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAAN4HEemqKsY3En9wuw" key="Comment" value="Editorial corrections in the description of OpenModelAttribute::partOfObjectKey and Reference."/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAAd4HEemqKsY3En9wuw" key="Copyright" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAAt4HEemqKsY3En9wuw" key="Date" value="2018-12-12"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_pCTAA94HEemqKsY3En9wuw" key="Author" value=""/> + </eAnnotations> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_o5JrEN4HEemqKsY3En9wuw" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="../OpenModelProfile/OpenModel_Profile.profile.uml#_FV_e4P4LEeiJYfiYi3RAYQ"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="../OpenModelProfile/OpenModel_Profile.profile.uml#_m1xqsHBgEd6FKu9XX1078A"/> + </profileApplication> + </uml:Model> + <OpenModel_Profile:OpenModelStatement xmi:id="_o-KG4N4HEemqKsY3En9wuw" base_Model="_Z9InoLIpEemXwfLFUQ7Icw"/> + #foreach($association in $associationList) + <OpenModel_Profile:OpenModelAttribute xmi:id="$association.randomId" base_StructuralFeature="$association.fromId"/> + #if( ! $association.isComposition) + <OpenModel_Profile:OpenModelAttribute xmi:id="$association.randomId" base_StructuralFeature="$association.toId"/> + #end + #end + #foreach($entity in $entityList) + <OpenModel_Profile:OpenModelClass xmi:id="$entity.randomId" base_Class="$entity.id"/> + #foreach($association in $entity.neighbours) + #if( $association.isComposition) + <OpenModel_Profile:OpenModelAttribute xmi:id="$association.randomId" base_StructuralFeature="$association.toId"/> + #end + #end + #foreach($prop in $entity.properties) + <OpenModel_Profile:OpenModelAttribute xmi:id="$entity.randomId" base_StructuralFeature="$prop.propertyId"/> + #end + #end +</xmi:XMI> |