Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Incomplete EPackage from ecore file
Incomplete EPackage from ecore file [message #1861705] Mon, 30 October 2023 08:50 Go to next message
Máté Földiák is currently offline Máté FöldiákFriend
Messages: 3
Registered: October 2023
Junior Member
Hi,

I'm working on checking in runtime if a VQL file is syntactically correct given a metamodel.

The problem is that when I parse an ECore metamodel from file, the references and containments are missing.

val ResourceSet resourceSet = new ResourceSetImpl();
EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE)

resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
	"ecore", new EcoreResourceFactoryImpl());

val resource = resourceSet.getResource(
	URI.createFileURI("res/meta.ecore"), true);
		
val pkg = resource.contents.get(0) as EPackage


If I run the code above, classifiers and super types are loaded in, but none of the structural features. (eAllReferences, eAllStructuralFeatures and eAllContainments are null.)

Do you have any idea on what is the problem and how to fix it?

Thanks,
Máté
Re: Incomplete EPackage from ecore file [message #1861713 is a reply to message #1861705] Mon, 30 October 2023 13:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
Always load a resource using an absolute URI, e.g., URI.createFileURI(new File("res/meta.ecore").getAbsolutePath()), otherwise relative URIs within the serialized resources cannot be properly resolved.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Incomplete EPackage from ecore file [message #1861725 is a reply to message #1861713] Tue, 31 October 2023 08:18 Go to previous messageGo to next message
Máté Földiák is currently offline Máté FöldiákFriend
Messages: 3
Registered: October 2023
Junior Member
Thank you for the response.

There are no relative URIs in the ecore file.

metamodel:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="satellite1" nsURI="http://www.example.org/satellite1" nsPrefix="satellite1">
  <eClassifiers xsi:type="ecore:EClass" name="ConstellationMission">
    <eStructuralFeatures xsi:type="ecore:EReference" name="groundStationNetwork" lowerBound="1"
        eType="#//GroundStationNetwork" containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="spacecraft" lowerBound="2"
        upperBound="-1" eType="#//Spacecraft" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="CommunicatingElement">
    <eStructuralFeatures xsi:type="ecore:EReference" name="commSubsystem" lowerBound="1"
        upperBound="2" eType="#//CommSubsystem" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="GroundStationNetwork" eSuperTypes="#//CommunicatingElement"/>
  <eClassifiers xsi:type="ecore:EClass" name="InterferometryMission" eSuperTypes="#//ConstellationMission"/>
  <eClassifiers xsi:type="ecore:EClass" name="Spacecraft" abstract="true" eSuperTypes="#//CommunicatingElement">
    <eStructuralFeatures xsi:type="ecore:EReference" name="payload" eType="#//Payload"
        containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="CommSubsystem" abstract="true">
    <eStructuralFeatures xsi:type="ecore:EReference" name="target" eType="#//CommSubsystem"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="fallback" eType="#//CommSubsystem"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Payload" abstract="true"/>
  <eClassifiers xsi:type="ecore:EClass" name="InterferometryPayload" eSuperTypes="#//Payload"/>
  <eClassifiers xsi:type="ecore:EClass" name="CubeSat3U" eSuperTypes="#//CubeSat"/>
  <eClassifiers xsi:type="ecore:EClass" name="CubeSat6U" eSuperTypes="#//CubeSat"/>
  <eClassifiers xsi:type="ecore:EClass" name="SmallSat" eSuperTypes="#//Spacecraft"/>
  <eClassifiers xsi:type="ecore:EClass" name="CubeSat" abstract="true" eSuperTypes="#//Spacecraft"/>
  <eClassifiers xsi:type="ecore:EClass" name="UHFCommSubsystem" eSuperTypes="#//CommSubsystem"/>
  <eClassifiers xsi:type="ecore:EClass" name="XCommSubsystem" eSuperTypes="#//CommSubsystem"/>
  <eClassifiers xsi:type="ecore:EClass" name="KaCommSubsystem" eSuperTypes="#//CommSubsystem"/>
</ecore:EPackage>
Re: Incomplete EPackage from ecore file [message #1861727 is a reply to message #1861725] Tue, 31 October 2023 09:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
This is relative reference:
eType="#//GroundStationNetwork"
Always, always use absolute URIs, if only for for your safety and comfort.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Incomplete EPackage from ecore file [message #1861729 is a reply to message #1861727] Tue, 31 October 2023 09:48 Go to previous messageGo to next message
Máté Földiák is currently offline Máté FöldiákFriend
Messages: 3
Registered: October 2023
Junior Member
Ok, I changed it to what you suggested, but the issue persist.

#//CommSubsystem is resolved properly in
<eClassifiers xsi:type="ecore:EClass" name="KaCommSubsystem" eSuperTypes="#//CommSubsystem"/>


But, in case of
<eClassifiers xsi:type="ecore:EClass" name="CommSubsystem" abstract="true">
    <eStructuralFeatures xsi:type="ecore:EReference" name="target" eType="#//CommSubsystem"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="fallback" eType="#//CommSubsystem"/>
</eClassifiers>

there are no entries for the structural features.

index.php/fa/43659/0/
  • Attachment: feature.PNG
    (Size: 31.69KB, Downloaded 80 times)
Re: Incomplete EPackage from ecore file [message #1861731 is a reply to message #1861729] Tue, 31 October 2023 11:05 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
I see a containment list for eStructuralFeatures, but I don't know how you know it's empty. That's not evident from your picture. It's pretty much impossible for containment features not to be populated for a resource that loads without exceptions/errors. I can see eOperations is null (because the getter has never been called) but eStructuralFeatures is not null and I expect it contains your two features.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Models partially loaded with jUnit
Next Topic:Changed behavior of Undo/Redo menu's entries?
Goto Forum:
  


Current Time: Thu May 02 11:38:04 GMT 2024

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

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

Back to the top