[Teneo] (rewritten question): Resource is empty on read, despite DB populated correctly [message #1132947] |
Fri, 11 October 2013 13:56 |
Nikt Zupelnie Messages: 7 Registered: October 2013 |
Junior Member |
|
|
Hello.
I have a problem with Teneo for more advanced .ecore files.
1. Simple .ecore works
(note: some EPackage schema parts were removed and nsURI="http__ introduced due to the forum antispam error filter... grrrr.)
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage [b]NOTE: SCHEMA CONTENT REMOVED because of the "You can only use links to eclipse.org sites while you have fewer than 5 messages" forum error message (c'mon...).[/b]
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="example" nsURI="http___example/1.0" nsPrefix="example">
<eClassifiers xsi:type="ecore:EClass" name="Entity">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="email" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
I can persist this entity to/from database without problem using Teneo's Resource.
2. What doesn't work
But for this ecore:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage [b]NOTE: CONTENT REMOVED because of the "You can only use links to eclipse.org sites while you have fewer than 5 messages" forum error message (c'mon...).[/b]
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="process" nsURI="http__process/1.0" nsPrefix="process">
<eClassifiers xsi:type="ecore:EClass" name="ProcessModel">
<eStructuralFeatures xsi:type="ecore:EReference" name="ownedActivity" upperBound="-1"
eType="#//Activity" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="ownedParticipant" upperBound="-1"
eType="#//Participant" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="ownedTechnique" upperBound="-1"
eType="#//Technique" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Activity">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="startTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="endTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="subActivity" upperBound="-1"
eType="#//Activity" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="precedingActivity" eType="#//Activity"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="executingParticipant" upperBound="-1"
eType="#//Participant"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="technique" upperBound="-1"
eType="#//Technique"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="ownedRel" upperBound="-1"
eType="#//ActivityRel" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Participant"/>
<eClassifiers xsi:type="ecore:EEnum" name="ActivityRelKind">
<eLiterals name="Decomposition"/>
<eLiterals name="Precedence" value="1" literal="Precedence"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Technique"/>
<eClassifiers xsi:type="ecore:EClass" name="Person" eSuperTypes="#//Participant">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="email" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="organization" upperBound="-1"
eType="#//Organization"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Tool" eSuperTypes="#//Participant">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="version" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Organization" eSuperTypes="#//Participant">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="address" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="subOrganization" upperBound="-1"
eType="#//Organization" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ActivityRel">
<eStructuralFeatures xsi:type="ecore:EReference" name="target" lowerBound="1"
eType="#//Activity"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="source" lowerBound="1"
eType="#//Activity"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ActivityRelKind"/>
</eClassifiers>
</ecore:EPackage>
I succesfully initialized Teneo (the same code as in "1. What works"):
private void init(IInitializationStrategy initializationStrategy)
{
final Properties props = new Properties();
initializationStrategy.initializeProperties(props);
String hbName = "test";
hibernateDataStore = HbHelper.INSTANCE.createRegisterDataStore(hbName);
hibernateDataStore.setDataStoreProperties(props);
hibernateDataStore.setAuditing(true);
hibernateDataStore.setEPackages(getPackagesToInitialize());
hibernateDataStore.initialize();
String uriStr = "hibernate://?"+ HibernateResource.DS_NAME_PARAM +"="+hbName;
final URI uri = URI.createURI(uriStr);
ResourceSet resourceSet = new ResourceSetImpl();
resource = resourceSet.getResource(uri, true);
}
and persist an entity to it (the same code as in "1. What works"):
Organization organization = ProcessFactory.eINSTANCE
.createOrganization();
organization.setAddress("resource-created organization");
resource.getContents().add(organization);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
Now I can see that database has this entity persisted. When I'm using Teneo's hibernate session to read this data I can do it without problems, but when I try to read it using Resource (after initializing it in the init() method above), the initialized resource object holds no data, so iteration on it brings nothing:
for (EObject eObject : resource.getContents()) {
System.out.println(eObject.toString());
};
Why it is empty? How can I read this data using the Resource API? What are the Teneo limitations that I apparently hit for this .ecore? I think that this is Teneo-related problem because I can write/read this exactly model with replacing Teneo with XMIResourceFactoryImpl in my code and write/read to XMI without any problems.
This is just a small part of my whole domain. It contains several .ecore files and references between them (some classes extends classes from other .ecores).
[Updated on: Sat, 12 October 2013 13:59] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03268 seconds