From c1c7b1701c566d3e668a28c95a88f6253722e03d Mon Sep 17 00:00:00 2001 From: Igor Dysko Date: Fri, 12 Feb 2021 11:07:42 +0100 Subject: Descriptions of attributes and associations were added into generated xmi files. Descriptions of attributes and associations were added into generated xmi files for papyrus. Issue-ID: AAI-3203 Signed-off-by: Igor Dysko Change-Id: Ifbf38673b2c3956ebc36cb1a27419da75f23cff4 --- .../org/onap/aai/graphgraph/ModelExporter.java | 11 +++++++--- .../graphgraph/velocity/VelocityAssociation.java | 14 ++++++++++++- .../aai/graphgraph/velocity/VelocityEntity.java | 6 ++++++ .../velocity/VelocityEntityProperty.java | 20 ++++++++++++++++-- src/main/resources/model_export.vm | 24 +++++++++++++++++++--- 5 files changed, 66 insertions(+), 9 deletions(-) (limited to 'src/main') 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 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 entities, String from, String to, String label, String multiplicity, String contains) { + Set entities, String from, String to, String label, String description, String multiplicity, String contains) { Optional fromEntity = entities.stream() .filter(ent -> ent.getName().equals(from)).findFirst(); Optional 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) + #if($association.hasDescription()) + + $esc.xml($association.description) + + #end
#foreach($entity in $entityList) + #if($entity.hasDescription()) $esc.xml($entity.description) + #end #foreach($association in $entity.neighbours) #if( $association.isComposition) + #if($prop.hasDescription()) + + $esc.xml($prop.description) + + #end #if($prop.propertyValue == "java.lang.String") - #end# + #end #if($prop.propertyValue == "java.lang.Long") @@ -94,11 +106,17 @@ href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/> #end - #elseif(! $prop.hasEntity) + #elseif(! $prop.hasEntity()) #* *# #else + name="$prop.getEntityName()" type="$prop.getEntityId()"> + #if($prop.hasDescription()) + + $esc.xml($prop.description) + + #end + #end #end -- cgit 1.2.3-korg