Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] another problems: my datas are modified by Teneo
[Teneo] another problems: my datas are modified by Teneo [message #608723] Thu, 12 July 2007 15:11
Eclipse UserFriend
Originally posted by: doux.guil.gmail.com

This is a multi-part message in MIME format.
--------------050800070506060004000300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi again,

I'm sorry to have another question but I have a second problem with Teneo.

I use Teneo to store EPackage contained in .ecore files.
My problem is that when I want to get an EPackage from Teneo, this
package has been modified.
When I export it into another .ecore file I see that the "eType" and the
"instanceClassName" attributes of the "eClassifiers" elements have been
deleted...

Can you explain me why and how to avoid it ?

Thanks for your help,

Guillaume


PS : I joined my in ecore file (deb.ecore), my out ecore file
(resulting_deb.ecore) and the class which make them (addget.java).

--------------050800070506060004000300
Content-Type: text/xml;
name="deb.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="deb.ecore"

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI 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">
<ecore:EPackage name="PrimitiveTypes" nsURI="atl.primitive.type" nsPrefix="ptyp">
<eClassifiers xsi:type="ecore:EDataType" name="Boolean" instanceClassName="boolean"/>
<eClassifiers xsi:type="ecore:EDataType" name="Integer" instanceClassName="int"/>
<eClassifiers xsi:type="ecore:EDataType" name="String" instanceClassName="java.lang.String"/>
</ecore:EPackage>
<ecore:EPackage name="deb" nsURI="my.model.of.debian.package" nsPrefix="deb">
<eClassifiers xsi:type="ecore:EClass" name="Deb">
<eStructuralFeatures xsi:type="ecore:EReference" name="metadata" ordered="false"
lowerBound="1" eType="#/1/Databin" containment="true" eOpposite="#/1/Databin/debpm"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="control" ordered="false"
lowerBound="1" eType="#/1/Archcontrol" containment="true" eOpposite="#/1/Archcontrol/debc"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" eType="#/1/Archdata" containment="true" eOpposite="#/1/Archdata/debd"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Databin">
<eStructuralFeatures xsi:type="ecore:EReference" name="debpm" ordered="false"
lowerBound="1" eType="#/1/Deb" eOpposite="#/1/Deb/metadata"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
upperBound="-1" eType="#/1/Bloc" containment="true" eOpposite="#/1/Bloc/meta"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Bloc">
<eStructuralFeatures xsi:type="ecore:EReference" name="meta" ordered="false"
lowerBound="1" eType="#/1/Databin" eOpposite="#/1/Databin/blocs"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="field" ordered="false"
upperBound="-1" eType="#/1/Field" containment="true" eOpposite="#/1/Field/blocs"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Field" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="val" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
lowerBound="1" eType="#/1/Bloc" eOpposite="#/1/Bloc/field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Version" eSuperTypes="#/1/Field"/>
<eClassifiers xsi:type="ecore:EClass" name="package_name" eSuperTypes="#/1/Field"/>
<eClassifiers xsi:type="ecore:EClass" name="Dependancy" eSuperTypes="#/1/Field"/>
<eClassifiers xsi:type="ecore:EClass" name="package_descriptions" eSuperTypes="#/1/Field"/>
<eClassifiers xsi:type="ecore:EClass" name="Script_descriptions" eSuperTypes="#/1/Field"/>
<eClassifiers xsi:type="ecore:EClass" name="Archcontrol">
<eStructuralFeatures xsi:type="ecore:EReference" name="debc" ordered="false"
lowerBound="1" eType="#/1/Deb" eOpposite="#/1/Deb/control"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="scripts" ordered="false"
upperBound="-1" eType="#/1/Script" containment="true" eOpposite="#/1/Script/archscript"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Script">
<eStructuralFeatures xsi:type="ecore:EReference" name="archscript" ordered="false"
lowerBound="1" eType="#/1/Archcontrol" eOpposite="#/1/Archcontrol/scripts"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="script_name" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="code" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Archdata">
<eStructuralFeatures xsi:type="ecore:EReference" name="debd" ordered="false"
lowerBound="1" eType="#/1/Deb" eOpposite="#/1/Deb/data"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="fil" ordered="false"
upperBound="-1" eType="#/1/File" containment="true" eOpposite="#/1/File/data"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="File">
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" eType="#/1/Archdata" eOpposite="#/1/Archdata/fil"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filename" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="location" ordered="false"
unique="false" lowerBound="1" eType="#/0/String"/>
</eClassifiers>
</ecore:EPackage>
</xmi:XMI>

--------------050800070506060004000300
Content-Type: text/xml;
name="resulting_deb.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="resulting_deb.ecore"

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI 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">
<ecore:EPackage name="PrimitiveTypes" nsURI="atl.primitive.type" nsPrefix="ptyp">
<eClassifiers xsi:type="ecore:EDataType" name="Boolean"/>
<eClassifiers xsi:type="ecore:EDataType" name="Integer"/>
<eClassifiers xsi:type="ecore:EDataType" name="String"/>
</ecore:EPackage>
<ecore:EPackage name="deb" nsURI="my.model.of.debian.package" nsPrefix="deb">
<eClassifiers xsi:type="ecore:EClass" name="Deb">
<eStructuralFeatures xsi:type="ecore:EReference" name="metadata" ordered="false"
lowerBound="1" containment="true" eOpposite="#/1/Databin/debpm"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="control" ordered="false"
lowerBound="1" containment="true" eOpposite="#/1/Archcontrol/debc"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" containment="true" eOpposite="#/1/Archdata/debd"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Databin">
<eStructuralFeatures xsi:type="ecore:EReference" name="debpm" ordered="false"
lowerBound="1" eOpposite="#/1/Deb/metadata"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
upperBound="-1" containment="true" eOpposite="#/1/Bloc/meta"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Bloc">
<eStructuralFeatures xsi:type="ecore:EReference" name="meta" ordered="false"
lowerBound="1" eOpposite="#/1/Databin/blocs"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="field" ordered="false"
upperBound="-1" containment="true" eOpposite="#/1/Field/blocs"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Field" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="val" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
lowerBound="1" eOpposite="#/1/Bloc/field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Version">
<eGenericSuperTypes eClassifier="#/1/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="package_name">
<eGenericSuperTypes eClassifier="#/1/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Dependancy">
<eGenericSuperTypes eClassifier="#/1/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="package_descriptions">
<eGenericSuperTypes eClassifier="#/1/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Script_descriptions">
<eGenericSuperTypes eClassifier="#/1/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Archcontrol">
<eStructuralFeatures xsi:type="ecore:EReference" name="debc" ordered="false"
lowerBound="1" eOpposite="#/1/Deb/control"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="scripts" ordered="false"
upperBound="-1" containment="true" eOpposite="#/1/Script/archscript"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Script">
<eStructuralFeatures xsi:type="ecore:EReference" name="archscript" ordered="false"
lowerBound="1" eOpposite="#/1/Archcontrol/scripts"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="script_name" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="code" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Archdata">
<eStructuralFeatures xsi:type="ecore:EReference" name="debd" ordered="false"
lowerBound="1" eOpposite="#/1/Deb/data"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="fil" ordered="false"
upperBound="-1" containment="true" eOpposite="#/1/File/data"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="File">
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" eOpposite="#/1/Archdata/fil"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filename" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="location" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
</ecore:EPackage>
<ecore:EPackage name="PrimitiveTypes" nsURI="atl.primitive.type" nsPrefix="ptyp">
<eClassifiers xsi:type="ecore:EDataType" name="Boolean"/>
<eClassifiers xsi:type="ecore:EDataType" name="Integer"/>
<eClassifiers xsi:type="ecore:EDataType" name="String"/>
</ecore:EPackage>
<ecore:EPackage name="deb" nsURI="my.model.of.debian.package" nsPrefix="deb">
<eClassifiers xsi:type="ecore:EClass" name="Deb">
<eStructuralFeatures xsi:type="ecore:EReference" name="metadata" ordered="false"
lowerBound="1" containment="true" eOpposite="#/3/Databin/debpm"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="control" ordered="false"
lowerBound="1" containment="true" eOpposite="#/3/Archcontrol/debc"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" containment="true" eOpposite="#/3/Archdata/debd"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Databin">
<eStructuralFeatures xsi:type="ecore:EReference" name="debpm" ordered="false"
lowerBound="1" eOpposite="#/3/Deb/metadata"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
upperBound="-1" containment="true" eOpposite="#/3/Bloc/meta"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Bloc">
<eStructuralFeatures xsi:type="ecore:EReference" name="meta" ordered="false"
lowerBound="1" eOpposite="#/3/Databin/blocs"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="field" ordered="false"
upperBound="-1" containment="true" eOpposite="#/3/Field/blocs"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Field" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="val" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
lowerBound="1" eOpposite="#/3/Bloc/field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Version">
<eGenericSuperTypes eClassifier="#/3/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="package_name">
<eGenericSuperTypes eClassifier="#/3/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Dependancy">
<eGenericSuperTypes eClassifier="#/3/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="package_descriptions">
<eGenericSuperTypes eClassifier="#/3/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Script_descriptions">
<eGenericSuperTypes eClassifier="#/3/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Archcontrol">
<eStructuralFeatures xsi:type="ecore:EReference" name="debc" ordered="false"
lowerBound="1" eOpposite="#/3/Deb/control"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="scripts" ordered="false"
upperBound="-1" containment="true" eOpposite="#/3/Script/archscript"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Script">
<eStructuralFeatures xsi:type="ecore:EReference" name="archscript" ordered="false"
lowerBound="1" eOpposite="#/3/Archcontrol/scripts"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="script_name" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="code" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Archdata">
<eStructuralFeatures xsi:type="ecore:EReference" name="debd" ordered="false"
lowerBound="1" eOpposite="#/3/Deb/data"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="fil" ordered="false"
upperBound="-1" containment="true" eOpposite="#/3/File/data"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="File">
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" eOpposite="#/3/Archdata/fil"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filename" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="location" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
</ecore:EPackage>
<ecore:EPackage name="PrimitiveTypes" nsURI="atl.primitive.type" nsPrefix="ptyp">
<eClassifiers xsi:type="ecore:EDataType" name="Boolean"/>
<eClassifiers xsi:type="ecore:EDataType" name="Integer"/>
<eClassifiers xsi:type="ecore:EDataType" name="String"/>
</ecore:EPackage>
<ecore:EPackage name="deb" nsURI="my.model.of.debian.package" nsPrefix="deb">
<eClassifiers xsi:type="ecore:EClass" name="Deb">
<eStructuralFeatures xsi:type="ecore:EReference" name="metadata" ordered="false"
lowerBound="1" containment="true" eOpposite="#/5/Databin/debpm"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="control" ordered="false"
lowerBound="1" containment="true" eOpposite="#/5/Archcontrol/debc"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" containment="true" eOpposite="#/5/Archdata/debd"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Databin">
<eStructuralFeatures xsi:type="ecore:EReference" name="debpm" ordered="false"
lowerBound="1" eOpposite="#/5/Deb/metadata"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
upperBound="-1" containment="true" eOpposite="#/5/Bloc/meta"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Bloc">
<eStructuralFeatures xsi:type="ecore:EReference" name="meta" ordered="false"
lowerBound="1" eOpposite="#/5/Databin/blocs"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="field" ordered="false"
upperBound="-1" containment="true" eOpposite="#/5/Field/blocs"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Field" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="val" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="blocs" ordered="false"
lowerBound="1" eOpposite="#/5/Bloc/field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Version">
<eGenericSuperTypes eClassifier="#/5/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="package_name">
<eGenericSuperTypes eClassifier="#/5/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Dependancy">
<eGenericSuperTypes eClassifier="#/5/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="package_descriptions">
<eGenericSuperTypes eClassifier="#/5/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Script_descriptions">
<eGenericSuperTypes eClassifier="#/5/Field"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Archcontrol">
<eStructuralFeatures xsi:type="ecore:EReference" name="debc" ordered="false"
lowerBound="1" eOpposite="#/5/Deb/control"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="scripts" ordered="false"
upperBound="-1" containment="true" eOpposite="#/5/Script/archscript"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Script">
<eStructuralFeatures xsi:type="ecore:EReference" name="archscript" ordered="false"
lowerBound="1" eOpposite="#/5/Archcontrol/scripts"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="script_name" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="code" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Archdata">
<eStructuralFeatures xsi:type="ecore:EReference" name="debd" ordered="false"
lowerBound="1" eOpposite="#/5/Deb/data"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="fil" ordered="false"
upperBound="-1" containment="true" eOpposite="#/5/File/data"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="File">
<eStructuralFeatures xsi:type="ecore:EReference" name="data" ordered="false"
lowerBound="1" eOpposite="#/5/Archdata/fil"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filename" ordered="false"
unique="false" lowerBound="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="location" ordered="false"
unique="false" lowerBound="1"/>
</eClassifiers>
</ecore:EPackage>
</xmi:XMI>

--------------050800070506060004000300
Content-Type: text/x-java;
name="addget.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="addget.java"

package test;

import java.io.IOException;
import java.util.Collections;
import java.util.Properties;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.emf.teneo.PersistenceOptions;
import org.eclipse.emf.teneo.annotations.pannotation.InheritanceTyp e;
import org.eclipse.emf.teneo.hibernate.HbDataStore;
import org.eclipse.emf.teneo.hibernate.HbHelper;
import org.eclipse.emf.teneo.hibernate.HbSessionDataStore;
import org.eclipse.emf.teneo.hibernate.resource.HibernateResource;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Environment;
import org.hibernate.event.InitializeCollectionEventListener;

public class addget {


// work folder
public static String loc = "/home/doux/temp/";

// work resourceSet
private static ResourceSet resTeneo;
private static ResourceSet resourceSet;

// name of the database
private static String dbname = "test";

// the datastore
private static HbDataStore hbds;

// the name of the datastore
private static String hbName = "MySF";

public static void main(String[] args){
resTeneo = new ResourceSetImpl();
resTeneo.getResourceFactoryRegistry().getExtensionToFactoryM ap().put( "ecore",
new EcoreResourceFactoryImpl());
resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "ecore",
new EcoreResourceFactoryImpl());
final Properties props = new Properties();
props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "doux");
props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" + dbname);
props.setProperty(Environment.PASS, "provisoiredoux");
props.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, InheritanceType.SINGLE_TABLE_LITERAL.getName());
// create the HbDataStore
hbds = HbHelper.INSTANCE.createRegisterDataStore(hbName);
// set the relational database to use and other properties
hbds.setHibernateProperties(props);
EPackage[] tpack = new EPackage[]{EcorePackage.eINSTANCE};
// configure EPackage used in this datastore
hbds.setEPackages(tpack);

hbds.initialize();

final EMFInitializeCollectionEventListener eventListener = new EMFInitializeCollectionEventListener();
((HbSessionDataStore)hbds).getConfiguration().getEventListen ers().setInitializeCollectionEventListeners
(new InitializeCollectionEventListener[] { eventListener });

try {
//loading a meta-model from an ecore file
String uri = loc+"deb.ecore";
Resource res = resourceSet.createResource(URI.createFileURI(uri));
res.load(null);

//making it persistent with Teneo
String uristr = "hibernate://?" + HibernateResource.DS_NAME_PARAM + "=" + hbName;
Resource resourceT = resTeneo.createResource(URI.createURI(uristr));
resourceT.getContents().addAll(res.getContents());
resourceT.save(null);

//retrieve this package from Teneo
String uristr2 = "hibernate://?" + HibernateResource.DS_NAME_PARAM + "=" + hbName+"&query1 =FROM EPackage";
Resource resout = resTeneo.createResource(URI.createURI(uristr));
resout.load(null);

//Serialization of this resource into an ecore file
String uri_res = loc+"resulting_deb.ecore";
Resource result = resourceSet.createResource(URI.createFileURI(uri_res));
result.getContents().addAll(resout.getContents());
result.save(null);


} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

--------------050800070506060004000300--
Previous Topic:[Teneo]Problems when deleting object
Next Topic:[ Teneo ] Comments as annotations?
Goto Forum:
  


Current Time: Tue Aug 09 13:09:53 GMT 2022

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

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

Back to the top