diff --git a/src/main/java/org/aero/mtip/ModelElements/Profile/OpaqueExpression.java b/src/main/java/org/aero/mtip/ModelElements/Profile/OpaqueExpression.java index 1679daf..0aea1f7 100644 --- a/src/main/java/org/aero/mtip/ModelElements/Profile/OpaqueExpression.java +++ b/src/main/java/org/aero/mtip/ModelElements/Profile/OpaqueExpression.java @@ -61,9 +61,6 @@ public Element createElement(Project project, Element owner, XMLItem xmlElement) */ public Element createElement(Project project, Element owner, String body, String language) { ElementsFactory f = project.getElementsFactory(); - if (!SessionManager.getInstance().isSessionCreated(project)) { - SessionManager.getInstance().createSession(project, "Create Opaque Expression Element"); - } com.nomagic.uml2.ext.magicdraw.classes.mdkernel.OpaqueExpression oe = f.createOpaqueExpressionInstance(); ((NamedElement)oe).setName(name); @@ -73,7 +70,6 @@ public Element createElement(Project project, Element owner, String body, String oe.getLanguage().clear(); oe.getLanguage().add(language); - SessionManager.getInstance().closeSession(project); return oe; } diff --git a/src/main/java/org/aero/mtip/XML/Import/ImportXmlSysml.java b/src/main/java/org/aero/mtip/XML/Import/ImportXmlSysml.java index 348f02f..0415519 100644 --- a/src/main/java/org/aero/mtip/XML/Import/ImportXmlSysml.java +++ b/src/main/java/org/aero/mtip/XML/Import/ImportXmlSysml.java @@ -229,7 +229,7 @@ public static Element buildDiagram(Project project, HashMap par public static Element buildRelationship(Project project, HashMap parsedXML, XMLItem modelElement, String id) { if(!IsRelationshipSupported(modelElement)) { - ImportLog.log(modelElement.getType() + " type not supported. "+ modelElement.getEAID()); + ImportLog.log(String.format("%s type not supported. Import id %s", modelElement.getType(), modelElement.getEAID())); return null; } @@ -240,44 +240,50 @@ public static Element buildRelationship(Project project, HashMap parsedXML, XMLItem modelElement, String id) { if(!IsElementSupported(modelElement)) { - ImportLog.log(modelElement.getType() + " type not supported. "+ modelElement.getEAID()); + ImportLog.log(String.format("%s type not supported. Import id %s", modelElement.getType(), modelElement.getEAID())); return null; } @@ -297,6 +303,7 @@ public static Element buildElement(Project project, HashMap par if (!SessionManager.getInstance().isSessionCreated(project)) { SessionManager.getInstance().createSession(project, "Create " + modelElement.getType() + " with dependent Elements"); } + Element newElement = element.createElement(project, owner, modelElement); // addStereotypeTaggedValues and addDependentElements will call and end their own sessions. End session here. SessionManager.getInstance().closeSession(project); @@ -306,6 +313,7 @@ public static Element buildElement(Project project, HashMap par addStereotypes(newElement, modelElement); element.addStereotypeTaggedValues(modelElement); element.addDependentElements(parsedXML, modelElement); + if(newElement.getOwner() == null) { newElement.dispose(); ImportLog.log("Owner failed to be set including any default owners. Element with id " + modelElement.getEAID() + " not created."); @@ -313,7 +321,6 @@ public static Element buildElement(Project project, HashMap par } ImportLog.log("Created element " + modelElement.getAttribute("name") + " of type: " + modelElement.getType() + " with no initial owner."); - return newElement; }