aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/aai/graphgraph/ModelExporter.java11
-rw-r--r--src/main/java/org/onap/aai/graphgraph/velocity/VelocityAssociation.java14
-rw-r--r--src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntity.java6
-rw-r--r--src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntityProperty.java20
-rw-r--r--src/main/resources/model_export.vm24
5 files changed, 66 insertions, 9 deletions
diff --git a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
index 6064665..d0db27e 100644
--- a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
+++ b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
@@ -52,6 +52,7 @@ import org.onap.aai.graphgraph.velocity.VelocityEntity;
import org.onap.aai.graphgraph.velocity.VelocityEntityProperty;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.schema.enums.ObjectMetadata;
+import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.setup.SchemaVersion;
public class ModelExporter {
@@ -188,6 +189,7 @@ public class ModelExporter {
.map(p -> new VelocityEntityProperty(
p,
introspector.getType(p),
+ introspector.getPropertyMetadata(p).get(PropertyMetadata.DESCRIPTION),
findVelocityEntity(introspector.getType(p), entityList)))
.collect(
Collectors.toSet());
@@ -206,9 +208,9 @@ public class ModelExporter {
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());
+ er.getLabel(), er.getDescription(), er.getMultiplicityRule().name(), er.getContains());
VelocityAssociation in = createVelocityAssociation(entities, er.getTo(), er.getFrom(),
- er.getLabel(), er.getMultiplicityRule().name(), er.getContains());
+ er.getLabel(), er.getDescription(), er.getMultiplicityRule().name(), er.getContains());
switch (er.getDirection()) {
case OUT:
return Stream.of(out);
@@ -223,7 +225,7 @@ public class ModelExporter {
}
private static VelocityAssociation createVelocityAssociation(
- Set<VelocityEntity> entities, String from, String to, String label, String multiplicity, String contains) {
+ Set<VelocityEntity> entities, String from, String to, String label, String description, String multiplicity, String contains) {
Optional<VelocityEntity> fromEntity = entities.stream()
.filter(ent -> ent.getName().equals(from)).findFirst();
Optional<VelocityEntity> toEntity = entities.stream()
@@ -235,6 +237,7 @@ public class ModelExporter {
fromEntity.get(),
toEntity.get(),
String.format("%s - %s (%s)", from, to, shortenLabel(label)),
+ description,
multiplicity,
true);
case "OUT":
@@ -242,6 +245,7 @@ public class ModelExporter {
toEntity.get(),
fromEntity.get(),
String.format("%s - %s (%s)", to, from, shortenLabel(label)),
+ description,
multiplicity.equals("ONE2MANY") ? "MANY2ONE" : multiplicity,
true);
default:
@@ -249,6 +253,7 @@ public class ModelExporter {
fromEntity.get(),
toEntity.get(),
String.format("%s - %s (%s)", from, to, shortenLabel(label)),
+ description,
multiplicity,
false);
}
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 b7b1503..3966b68 100644
--- a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityAssociation.java
+++ b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityAssociation.java
@@ -19,9 +19,12 @@
*/
package org.onap.aai.graphgraph.velocity;
+import org.eclipse.jetty.util.StringUtil;
+
public class VelocityAssociation extends VelocityId {
private final String name;
+ private final String description;
private final VelocityEntity fromEntity;
private final VelocityEntity toEntity;
private final String fromId = getRandomId();
@@ -31,11 +34,12 @@ public class VelocityAssociation extends VelocityId {
public VelocityAssociation(
VelocityEntity fromEntity, VelocityEntity toEntity,
- String name, String multiplicity, boolean isComposition
+ String name, String description, String multiplicity, boolean isComposition
) {
this.fromEntity = fromEntity;
this.toEntity = toEntity;
this.name = name;
+ this.description = description;
this.multiplicity = multiplicity;
this.isComposition = isComposition;
}
@@ -72,6 +76,14 @@ public class VelocityAssociation extends VelocityId {
return multiplicity.toUpperCase();
}
+ public String getDescription() {
+ return description;
+ }
+
+ public boolean hasDescription() {
+ return !StringUtil.isBlank(description);
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
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 424c0e6..83bb78d 100644
--- a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntity.java
+++ b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntity.java
@@ -19,6 +19,8 @@
*/
package org.onap.aai.graphgraph.velocity;
+import org.eclipse.jetty.util.StringUtil;
+
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -50,6 +52,10 @@ public class VelocityEntity extends VelocityId {
this.description = description;
}
+ public boolean hasDescription() {
+ return !StringUtil.isBlank(description);
+ }
+
public String getName() {
return 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 2c65ae3..a6c404e 100644
--- a/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntityProperty.java
+++ b/src/main/java/org/onap/aai/graphgraph/velocity/VelocityEntityProperty.java
@@ -20,15 +20,19 @@
package org.onap.aai.graphgraph.velocity;
import java.util.UUID;
+
+import org.eclipse.jetty.util.StringUtil;
import org.onap.aai.graphgraph.dto.Property;
public class VelocityEntityProperty extends Property {
private final VelocityEntity entity;
private final String propertyId;
+ private final String description;
- public VelocityEntityProperty(String propertyName, String propertyValue, VelocityEntity entity) {
+ public VelocityEntityProperty(String propertyName, String propertyValue, String propertyDescription, VelocityEntity entity) {
super(propertyName, propertyValue);
+ this.description = propertyDescription;
this.entity = entity;
propertyId = entity != null ? entity.getRandomId() : UUID.randomUUID().toString();
}
@@ -41,6 +45,10 @@ public class VelocityEntityProperty extends Property {
return entity.getName();
}
+ public boolean hasDescription() {
+ return !StringUtil.isBlank(description);
+ }
+
public boolean hasEntity() {
return entity != null;
}
@@ -49,8 +57,16 @@ public class VelocityEntityProperty extends Property {
return propertyId;
}
+ public String getDescription() {
+ return description;
+ }
+
+ public static String getRandomId() {
+ return UUID.randomUUID().toString();
+ }
+
@Override
public String toString() {
- return "VelocityEntityProperty{" + " name=" + getPropertyName() + " type=" + getPropertyValue() + '}';
+ return "VelocityEntityProperty{" + " name=" + getPropertyName() + " description=" + getDescription() + " type=" + getPropertyValue() + '}';
}
}
diff --git a/src/main/resources/model_export.vm b/src/main/resources/model_export.vm
index a8992c2..ec19a44 100644
--- a/src/main/resources/model_export.vm
+++ b/src/main/resources/model_export.vm
@@ -9,6 +9,11 @@
#foreach($association in $associationList)
<packagedElement xmi:type="uml:Association" xmi:id="$association.id"
name="$association.name" memberEnd="$association.fromId $association.toId">
+ #if($association.hasDescription())
+ <ownedComment xmi:type="uml:Comment" xmi:id="$association.randomId" annotatedElement="$association.id">
+ <body>$esc.xml($association.description)</body>
+ </ownedComment>
+ #end
<eAnnotations xmi:type="ecore:EAnnotation" xmi:id="$association.randomId"
source="org.eclipse.papyrus">
<details xmi:type="ecore:EStringToStringMapEntry" xmi:id="$association.randomId"
@@ -50,9 +55,11 @@
<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">
+ #if($entity.hasDescription())
<ownedComment xmi:type="uml:Comment" xmi:id="$entity.randomId" annotatedElement="$entity.id">
<body>$esc.xml($entity.description)</body>
</ownedComment>
+ #end
#foreach($association in $entity.neighbours)
#if( $association.isComposition)
<ownedAttribute xmi:type="uml:Property" xmi:id="$association.toId"
@@ -77,10 +84,15 @@
#if($prop.propertyValue.contains("java.lang"))
<ownedAttribute xmi:type="uml:Property" xmi:id="$prop.propertyId"
name="$prop.propertyName">
+ #if($prop.hasDescription())
+ <ownedComment xmi:type="uml:Comment" xmi:id="$prop.randomId">
+ <body>$esc.xml($prop.description)</body>
+ </ownedComment>
+ #end
#if($prop.propertyValue == "java.lang.String")
<type xmi:type="uml:PrimitiveType"
href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/>
- #end#
+ #end
#if($prop.propertyValue == "java.lang.Long")
<type xmi:type="uml:PrimitiveType"
href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/>
@@ -94,11 +106,17 @@
href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/>
#end
</ownedAttribute>
- #elseif(! $prop.hasEntity)
+ #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()"/>
+ name="$prop.getEntityName()" type="$prop.getEntityId()">
+ #if($prop.hasDescription())
+ <ownedComment xmi:type="uml:Comment" xmi:id="$prop.randomId">
+ <body>$esc.xml($prop.description)</body>
+ </ownedComment>
+ #end
+ </ownedAttribute>
#end
#end
</packagedElement>