Skip to content

Commit

Permalink
Release 0.5.2 (#108)
Browse files Browse the repository at this point in the history
* Bugfixes NullPointerException on missing association descriptions

* Updates the serialization of derivation relations

* Updates baseIri option on gUFO transformation
  • Loading branch information
claudenirmf authored Sep 20, 2021
1 parent 01b962c commit 85a6efb
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 48 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>it.unibz.inf.ontouml</groupId>
<artifactId>ontouml-vp-plugin</artifactId>
<version>0.5.1</version>
<version>0.5.2</version>

<name>OntoUML 2 Plugin for Visual Paradigm</name>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/it/unibz/inf/ontouml/vp/OntoUMLPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class OntoUMLPlugin implements VPPlugin {

public static final String PLUGIN_VERSION_RELEASE = "0.5.1";
public static final String PLUGIN_VERSION_RELEASE = "0.5.2";
public static final String PLUGIN_ID = "it.unibz.inf.ontouml.vp";
public static final String PLUGIN_NAME = "OntoUML Plugin";
public static final String PLUGIN_REPO = "https://github.com/OntoUML/ontouml-vp-plugin/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
public class SmartModellingController {

public static void setAggregationKind(IModelElement element) {
IAssociation association = (IAssociation) element;
IAssociationEnd compositionFromEnd = (IAssociationEnd) association.getFromEnd();
IAssociationEnd compositionToEnd = (IAssociationEnd) association.getToEnd();
final IAssociation association = (IAssociation) element;
final IAssociationEnd toEnd = (IAssociationEnd) association.getToEnd();
final IAssociationEnd fromEnd = (IAssociationEnd) association.getFromEnd();
final String toAgg = toEnd.getAggregationKind().toLowerCase();

if (compositionToEnd.getAggregationKind().equals(IAssociationEnd.AGGREGATION_KIND_NONE)) {
compositionToEnd.setAggregationKind(IAssociationEnd.AGGREGATION_KIND_COMPOSITED);
if (IAssociationEnd.AGGREGATION_KIND_NONE.toLowerCase().equals(toAgg)) {
toEnd.setAggregationKind(IAssociationEnd.AGGREGATION_KIND_COMPOSITED);
}

compositionFromEnd.setAggregationKind(IAssociationEnd.AGGREGATION_KIND_NONE);
fromEnd.setAggregationKind(IAssociationEnd.AGGREGATION_KIND_NONE);
}

public static void removeAggregationKind(IModelElement element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class GufoExportOptions {

private String baseIRI;
private String baseIri;
private String format;
private String uriFormatBy;
private boolean createInverses;
Expand All @@ -20,7 +20,7 @@ public class GufoExportOptions {
public GufoExportOptions() {}

public GufoExportOptions(ProjectConfigurations projectConfigurations) {
baseIRI = projectConfigurations.getExportGUFOIRI();
baseIri = projectConfigurations.getExportGUFOIRI();
format = projectConfigurations.getExportGUFOFormat();
uriFormatBy = projectConfigurations.getExportGUFOURIFormat();
createInverses = projectConfigurations.getExportGUFOInverseBox();
Expand All @@ -38,12 +38,12 @@ public GufoExportOptions(ProjectConfigurations projectConfigurations) {
}
}

public String getBaseIRI() {
return baseIRI;
public String getBaseIri() {
return baseIri;
}

public void setBaseIRI(String baseIRI) {
this.baseIRI = baseIRI;
public void setBaseIri(String baseIri) {
this.baseIri = baseIri;
}

public String getFormat() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package it.unibz.inf.ontouml.vp.model.ontouml2vp;

import static it.unibz.inf.ontouml.vp.model.ontouml2vp.LoaderUtils.loadName;
import static it.unibz.inf.ontouml.vp.model.ontouml2vp.LoaderUtils.logElementCreation;

import com.vp.plugin.ApplicationManager;
import com.vp.plugin.model.IAssociationClass;
import com.vp.plugin.model.IModelElement;
import com.vp.plugin.model.IProject;
import com.vp.plugin.model.factory.IModelElementFactory;
import it.unibz.inf.ontouml.vp.model.ontouml.model.Classifier;
import it.unibz.inf.ontouml.vp.model.ontouml.model.Relation;
import it.unibz.inf.ontouml.vp.utils.StereotypesManager;

public class IAssociationClassLoader {

static IProject vpProject = ApplicationManager.instance().getProjectManager().getProject();

public static IAssociationClass importElement(Relation fromRelation) {
logElementCreation(fromRelation);

IAssociationClass toRelation = getOrCreateAssociation(fromRelation);
fromRelation.setId(toRelation.getId());

loadName(fromRelation, toRelation);

loadSource(fromRelation, toRelation);
loadTarget(fromRelation, toRelation);

// Unable to process "isDerived" for IAssociationClass
// Unable to process "isAbstract" for IAssociationClass
// Unable to process "property ends" fully for IAssociationClass

fromRelation
.getStereotype()
.ifPresent(
stereotype -> {
if (!"derivation".equals(stereotype)) {
StereotypesManager.applyStereotype(toRelation, stereotype);
}
});

ITaggedValueLoader.loadTaggedValues(fromRelation, toRelation);

return toRelation;
}

private static void loadSource(Relation fromRelation, IAssociationClass toRelation) {
Classifier<?, ?> fromSource = fromRelation.getSource();
IModelElement toSource = vpProject.getModelElementById(fromSource.getId());

if (toSource != null) {
toRelation.setFrom(toSource);
}
}

private static void loadTarget(Relation fromRelation, IAssociationClass toRelation) {
Classifier<?, ?> fromTarget = fromRelation.getTarget();
IModelElement toTarget = vpProject.getModelElementById(fromTarget.getId());

if (toTarget != null) {
toRelation.setTo(toTarget);
}
}

private static IAssociationClass getOrCreateAssociation(Relation fromRelation) {
IModelElement toRelation = vpProject.getModelElementById(fromRelation.getId());

if (toRelation instanceof IAssociationClass) {
System.out.println("Relation " + fromRelation.getId() + " exists! Let's update it!");
} else {
System.out.println("Relation " + fromRelation.getId() + " not found! Let's create it");
toRelation = IModelElementFactory.instance().createAssociationClass();
}

return (IAssociationClass) toRelation;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package it.unibz.inf.ontouml.vp.model.ontouml2vp;

import static it.unibz.inf.ontouml.vp.model.ontouml2vp.LoaderUtils.getIDiagramElement;
import static it.unibz.inf.ontouml.vp.model.ontouml2vp.LoaderUtils.getIModelElement;

import com.vp.plugin.ApplicationManager;
import com.vp.plugin.DiagramManager;
import com.vp.plugin.diagram.IClassDiagramUIModel;
import com.vp.plugin.diagram.IDiagramElement;
import com.vp.plugin.model.IAssociationClass;
import com.vp.plugin.model.IModelElement;
import it.unibz.inf.ontouml.vp.model.ontouml.view.RelationView;
import java.awt.Point;

public class IAssociationClassUIModelLoader {

static DiagramManager diagramManager = ApplicationManager.instance().getDiagramManager();

public static void load(IClassDiagramUIModel toDiagram, RelationView fromView) {
IModelElement toModelElement = getIModelElement(fromView);

if (!(toModelElement instanceof IAssociationClass)) {
System.out.println(
LoaderUtils.getIncompatibleMessage(fromView, toModelElement, IAssociationClass.class));
return;
}

IDiagramElement toSource = getIDiagramElement(toDiagram, fromView.getSource());
IDiagramElement toTarget = getIDiagramElement(toDiagram, fromView.getTarget());

Point[] toPoints = IConnectorUIModelLoader.loadPoints(fromView);

IDiagramElement toView =
diagramManager.createConnector(toDiagram, toModelElement, toSource, toTarget, toPoints);

fromView.setId(toView.getId());
toView.resetCaption();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import com.vp.plugin.DiagramManager;
import com.vp.plugin.diagram.IClassDiagramUIModel;
import com.vp.plugin.diagram.IDiagramElement;
import com.vp.plugin.diagram.connector.IAssociationUIModel;
import com.vp.plugin.model.IAssociation;
import com.vp.plugin.model.IAssociationClass;
import com.vp.plugin.model.IModelElement;
import it.unibz.inf.ontouml.vp.model.ontouml.view.RelationView;
import java.awt.*;
Expand All @@ -21,8 +19,8 @@ public class IAssociationUIModelLoader {
public static void load(IClassDiagramUIModel toDiagram, RelationView fromView) {
IModelElement toModelElement = getIModelElement(fromView);

if (!(toModelElement instanceof IAssociation)
&& !(toModelElement instanceof IAssociationClass)) {
if (!(toModelElement instanceof IAssociation)) {
// && !(toModelElement instanceof IAssociationClass)) {
System.out.println(
LoaderUtils.getIncompatibleMessage(fromView, toModelElement, IAssociation.class));
return;
Expand All @@ -33,9 +31,8 @@ public static void load(IClassDiagramUIModel toDiagram, RelationView fromView) {

Point[] toPoints = IConnectorUIModelLoader.loadPoints(fromView);

IAssociationUIModel toView =
(IAssociationUIModel)
diagramManager.createConnector(toDiagram, toModelElement, toSource, toTarget, toPoints);
IDiagramElement toView =
diagramManager.createConnector(toDiagram, toModelElement, toSource, toTarget, toPoints);

fromView.setId(toView.getId());
toView.resetCaption();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ public static void load(Diagram fromDiagram, boolean shouldOverride, boolean sho
.filter(view -> !view.getModelElement().holdsBetweenClasses())
.forEach(fromRelationView -> IAssociationUIModelLoader.load(toDiagram, fromRelationView));

fromDiagram.getAllRelationViews().stream()
.filter(view -> view.getModelElement() != null)
.filter(view -> view.getModelElement().holdsBetweenClassAndRelation())
.forEach(
fromRelationView -> IAssociationClassUIModelLoader.load(toDiagram, fromRelationView));

fromDiagram.getAllRelationViews().stream()
.filter(view -> view.getModelElement() != null)
.filter(view -> !view.getModelElement().holdsBetweenClassAndRelation())
.forEach(
fromRelationView -> IAssociationClassUIModelLoader.load(toDiagram, fromRelationView));

fromDiagram
.getAllGeneralizationViews()
.forEach(fromGenView -> IGeneralizationUIModelLoader.load(toDiagram, fromGenView));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public static void importModel(Project fromProject) {
.forEach(rel -> IAssociationLoader.importElement(rel));

// transform relations between classes and relations
fromProject.getAllRelations().stream()
.filter(rel -> rel.holdsBetweenClassAndRelation())
.forEach(rel -> IAssociationClassLoader.importElement(rel));

// transform generalization
fromProject.getAllGeneralizations().forEach(gen -> IGeneralizationLoader.importElement(gen));
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/it/unibz/inf/ontouml/vp/model/uml/Association.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,11 @@ public static void setNavigability(IAssociation association) {

final IAssociationEnd sourceEnd = getSourceEnd(association);
final IAssociationEnd targetEnd = getTargetEnd(association);
final String targetAgg = targetEnd.getAggregationKind().toLowerCase();

sourceEnd.setNavigable(IAssociationEnd.NAVIGABLE_NAV_UNSPECIFIED);

if (IAssociationEnd.AGGREGATION_KIND_NONE.equals(targetEnd.getAggregationKind())) {
if (IAssociationEnd.AGGREGATION_KIND_NONE.toLowerCase().equals(targetAgg)) {
targetEnd.setNavigable(IAssociationEnd.NAVIGABLE_NAV_NAVIGABLE);
} else {
targetEnd.setNavigable(IAssociationEnd.NAVIGABLE_NAV_UNSPECIFIED);
Expand Down Expand Up @@ -336,22 +337,19 @@ public static void setDefaultAggregationKind(IAssociation association, boolean f
targetEnd.setAggregationKind(aggregationKind);
} else {
// By not forcing override we keep user-defined aggregation (e.g., "shared")
final String currentAggregationKind = targetEnd.getAggregationKind();

if (IAssociationEnd.AGGREGATION_KIND_NONE.equals(currentAggregationKind)) {
// The 16.3 release changes the aggregation kind's string and we must keep backwards
// compatibility
final String targetCurrentAggregation =
targetEnd.getAggregationKind() != null
? targetEnd.getAggregationKind().toLowerCase()
: "none";

if (IAssociationEnd.AGGREGATION_KIND_NONE.toLowerCase().equals(targetCurrentAggregation)) {
targetEnd.setAggregationKind(aggregationKind);
}
}
}

public static void setAggregationKind(IAssociation association, String aggregationKind) {
final IAssociationEnd sourceEnd = getSourceEnd(association);
final IAssociationEnd targetEnd = getTargetEnd(association);

sourceEnd.setAggregationKind(IAssociationEnd.AGGREGATION_KIND_NONE);
targetEnd.setAggregationKind(aggregationKind);
}

public static void setDefaultMultiplicity(IAssociation association, boolean forceOverride) {
final IClass source = getSource(association);
final IClass target = getTarget(association);
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/it/unibz/inf/ontouml/vp/model/uml/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.vp.plugin.model.*;
import com.vp.plugin.model.IAssociationClass;
import com.vp.plugin.model.IAssociationEnd;
import com.vp.plugin.model.IAttribute;
import com.vp.plugin.model.IClass;
import com.vp.plugin.model.IModelElement;
import com.vp.plugin.model.IMultiplicity;
import com.vp.plugin.model.factory.IModelElementFactory;
import java.util.ArrayList;
import java.util.Iterator;
Expand Down Expand Up @@ -382,13 +387,13 @@ public String getAggregationKind() {
public void setAggregationKind(int aggregation) {
switch (aggregation) {
case 0:
this.aggregationKind = "NONE";
this.aggregationKind = IAssociationEnd.AGGREGATION_KIND_NONE;
break;
case 1:
this.aggregationKind = "SHARED";
this.aggregationKind = IAssociationEnd.AGGREGATION_KIND_SHARED;
break;
case 2:
this.aggregationKind = "COMPOSITE";
this.aggregationKind = IAssociationEnd.AGGREGATION_KIND_COMPOSITED;
break;
default:
}
Expand All @@ -401,14 +406,14 @@ public void setAggregationKind(String aggregationKind) {
}

switch (aggregationKind.toUpperCase()) {
case "NONE":
this.aggregationKind = "NONE";
case IAssociationEnd.AGGREGATION_KIND_NONE:
this.aggregationKind = IAssociationEnd.AGGREGATION_KIND_NONE;
return;
case "COMPOSITED":
this.aggregationKind = "COMPOSITE";
case IAssociationEnd.AGGREGATION_KIND_SHARED:
this.aggregationKind = IAssociationEnd.AGGREGATION_KIND_SHARED;
return;
case "SHARED":
this.aggregationKind = "SHARED";
case IAssociationEnd.AGGREGATION_KIND_COMPOSITED:
this.aggregationKind = IAssociationEnd.AGGREGATION_KIND_COMPOSITED;
return;
default:
this.aggregationKind = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public static void transform(IModelElement source, Element target) {
target.addName(name);

String description = source.getDescription();
target.addDescription(description.isEmpty() ? null : description);
target.addDescription(description != null && description.isEmpty() ? null : description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.vp.plugin.model.IAttribute;
import com.vp.plugin.model.IModelElement;
import com.vp.plugin.model.IMultiplicity;
import it.unibz.inf.ontouml.vp.model.ontouml.model.AggregationKind;
import java.util.Iterator;

public class IPropertyAdapter implements IAdapter {
Expand Down Expand Up @@ -75,11 +76,11 @@ public String getAggregationKind() {
int value = attribute.getAggregation();
switch (value) {
case 0:
return "NONE";
return AggregationKind.NONE.getName();
case 1:
return "SHARED";
return AggregationKind.SHARED.getName();
case 2:
return "COMPOSITE";
return AggregationKind.COMPOSITE.getName();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ public static void transform(IModelElement source, Decoratable<?> target) {
String stereotype = null;

if (source instanceof IClass
|| source instanceof IAssociationClass
|| source instanceof IAssociation
|| source instanceof IAttribute
|| source instanceof IAssociationEnd) stereotype = getFirstStereotype(source);

if (source instanceof IDataType) stereotype = "datatype";

if (source instanceof IAssociationClass) stereotype = "derivation";

// if (source instanceof IClass) {
// stereotype = getFirstStereotype((IClass) source);
// } else if (source instanceof IAssociationClass) {
Expand Down

0 comments on commit 85a6efb

Please sign in to comment.