Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Missing references
Missing references [message #1759999] Fri, 21 April 2017 05:37 Go to next message
Pavan Muthoju is currently offline Pavan MuthojuFriend
Messages: 3
Registered: April 2017
Junior Member
Hi Experts ,

One of my models element in Model_A is referring an element present in Fragment_x of Model_B . So for Model_A I have imported the respective Element (Using Add UML -> Releationship -> Element Import ) which corresponds to the Fragment_x .

During my validation , I am retrieving the Packaged Elements of Model_A and as well its imported elements and checking the applied profiles . I am able to retrieve the imported element corresponding to Fragment_x but its eContainer is null along with its parent package and also the applied profiles .

I understood in this case , I could not traverse from Fragment_x to its base model Model_B and loosing the information from Model_B . When I absorbed the Fragment_x into Model_B and re imported the required Elements , then everything worked well .

The same validations passed well when I triggered them through eclipse IDE . So I hope this is a valid use case .

Problem is seen even after I made sure that ResourceSet is properly updated and resolved the model .

So problem is something wrong with the initialization of the model Model_A ? How should the connection between the Fragment_x and Model_B retained ?

Thanks,
Pavan
Re: Missing references [message #1760048 is a reply to message #1759999] Fri, 21 April 2017 13:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This sounds like a question better directed to the UML2 forum.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Missing references [message #1760054 is a reply to message #1760048] Fri, 21 April 2017 14:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

And without a repro, I doubt an expert can understand what your problem is.

Regards

Ed Willink

Re: Missing references [message #1760821 is a reply to message #1759999] Wed, 03 May 2017 10:16 Go to previous messageGo to next message
Pavan Muthoju is currently offline Pavan MuthojuFriend
Messages: 3
Registered: April 2017
Junior Member
Hi all ,

I have trimmed with the required and the error is reproduced with the below . I have attached the RSA RTE models (TestProject1 and TestProject2) .

In short , for model in TestProject1 a package from TestProject2 is imported , the package comes from an fragment (.efx) of TestProject 2 as below.

<elementImport xmi:id="_zQY58CtDEeeCxpJ1Lm0y_w">
<importedElement xmi:type="uml:Package" href="platform:/resource/TestProject2/subfolder1/subfolder2/Package1.efx#_HFdcYCtDEeeSw-dHyXRF1g?ReproToImport/Package1?"/>
</elementImport>

I have created the resourceSet and loaded the model in TestProject1 as below .
It is very clear that imported package is an indirect reference of the model , so I could not further get the econtainer/model/expected parent package from model2 of the respective package .

But I need opinion on how to establish the connection between the fragment and its base model (TestProject2) when I am dealing with package imports of the fragment .
How could this be done or am I missing something ?


private static void loadModelAndReproduceIssue() {

String inModelFile = "/home/TestProject1/Repro.emx";


ResourceSet rs = new ResourceSetImpl();

URI modelUri = URI.createFileURI(inModelFile);


Registry packageRegistry = rs.getPackageRegistry();

packageRegistry.put("http://schema.omg.org/spec/XMI/2.0", UMLPackage.eINSTANCE);
packageRegistry.put("http://schema.omg.org/spec/UML/3.0", UMLPackage.eINSTANCE);
packageRegistry.put("http://www.eclipse.org/uml2/3.0.0/UML", UMLPackage.eINSTANCE);


final Map<String, Object> extensionToFactoryMap = rs.getResourceFactoryRegistry().getExtensionToFactoryMap();

extensionToFactoryMap.put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
extensionToFactoryMap.put("emx", UMLResource.Factory.INSTANCE);
extensionToFactoryMap.put("efx", UMLResource.Factory.INSTANCE);
extensionToFactoryMap.put("uml2", UML22UMLResource.Factory.INSTANCE);


HashMap<String, String> uriStringMappingMap = new HashMap<>();


uriStringMappingMap.put("platform:/resource/TestProject1/", "file://home/TestProject1/");
uriStringMappingMap.put("platform:/resource/TestProject2/", "file://home/TestProject2/");
uriStringMappingMap.put("platform:/resource/TestProject2/subfolder1/subfolder2/",
"file:/home/TestProject2/subfolder1/subfolder2/");


final Map<URI, URI> uri_map = rs.getURIConverter().getURIMap();
for (Map.Entry<String, String> entry : uriStringMappingMap.entrySet()) {
uri_map.put(URI.createURI(entry.getKey()), URI.createURI(entry.getValue()));
}



// EVen added the dependant model in resorceSet
String inModelFile2 = "/home/TestProject2/IFM.emx";
URI modelUri2 = URI.createFileURI(inModelFile2);

Resource dependantModelResource = rs.createResource(modelUri2);
rs.getResources().add(dependantModelResource);


// Now work on the emx URI

UMLResource umlModelResource = (UMLResource) rs.getResource(modelUri, true);

Package modelPackage = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(umlModelResource.getContents(),
UMLPackage.Literals.PACKAGE);



reproduceFault(modelPackage);

}


private static void reproduceFault(Package model) {
for (Element child : model.getOwnedElements()) {
if (child instanceof Package) {
reproduceFault((Package) child);
}
if (child instanceof ElementImport) {
Element importedElement = ((ElementImport) child).getImportedElement();
if (importedElement instanceof Package) {

// Problem is here !!!
if (importedElement.getModel() == null) {
System.out.println("Unable to fetch the UML model of the imported element :"
+ importedElement.getNearestPackage().getName());
}
if (importedElement.eContainer() == null) {
System.out.println("Unable to fetch the eContainer of the imported element :"
+ importedElement.getNearestPackage().getName());
}

}
}

}
}
  • Attachment: ToUpload.7z
    (Size: 35.61KB, Downloaded 81 times)
Re: Missing references [message #1760832 is a reply to message #1760821] Wed, 03 May 2017 12:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Your question is probably best directed to the UML2 forum because I can't comment about UML2-specific details. I see no immediate reason for you to expect getModel() to return non-null or eContainer() to be non-null. The target appears to be a package contained directly in the root of a resource and contained nowhere else, so I don't know why you're expecting it to be contained somewhere.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Missing references [message #1760908 is a reply to message #1759999] Thu, 04 May 2017 09:18 Go to previous message
Pavan Muthoju is currently offline Pavan MuthojuFriend
Messages: 3
Registered: April 2017
Junior Member
Thanks for your reply .
I will redirect this to UML forum .

The null values are expected in this case , but as said in the above message , to perform some validations on model elements I am finding the ways to traverse from imported element to the parent package and further of its own model (TestProject2) to get information like applied profiles etc.,

For example if I absorb the fragment , and re import like below referring the element through emx file , I could get all the information of the parent packages and other model information when I am dealing with the imported element .

<elementImport xmi:id="_kjXMwDCREee9a7um1aNiYg">
<importedElement xmi:type="uml:Package" href="platform:/resource/TestProject2/IFM.emx#_HFdcYCtDEeeSw-dHyXRF1g?ReproToImport/Package1?"/>
</elementImport>

In my problematic case it look something like this

<elementImport xmi:id="_zQY58CtDEeeCxpJ1Lm0y_w">
<importedElement xmi:type="uml:Package" href="platform:/resource/TestProject2/subfolder1/subfolder2/Package1.efx#_HFdcYCtDEeeSw-dHyXRF1g?ReproToImport/Package1?"/>
</elementImport>

I wish to have the similar possibility to get the information from the base model when element is imported from the fragment . In short wanted to know if some
mapping could be created between the fragment and its base model , in cases like
one of the fragments element is imported in loaded through other model .

Previous Topic:EMF: thread safety for read only access to an EMF resource
Next Topic:Separate Projects for .genmodel and .ecore
Goto Forum:
  


Current Time: Fri Apr 26 17:25:59 GMT 2024

Powered by FUDForum. Page generated in 0.03286 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top