-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bugfixes NullPointerException on missing association descriptions * Updates the serialization of derivation relations * Updates baseIri option on gUFO transformation
- Loading branch information
1 parent
01b962c
commit 85a6efb
Showing
14 changed files
with
183 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/it/unibz/inf/ontouml/vp/model/ontouml2vp/IAssociationClassLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/it/unibz/inf/ontouml/vp/model/ontouml2vp/IAssociationClassUIModelLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters