Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] EMF databinding
[TEXO] EMF databinding [message #635799] Thu, 28 October 2010 07:59 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello,

is there a API for the Texo databinding with a eclipse RCP.
EMF has EMFObservables with undo/redo support.
EMFObservables.observeValue(myEObject,
MyPackage.Literals.MYNAME__NAME)


Is there a possibilty to use the undo/redo support and the databinding with EMFT?

Thanks
Re: [TEXO] EMF databinding [message #635822 is a reply to message #635799] Thu, 28 October 2010 09:21 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Wayne,
I asked around and this is the answer I got from Tom Schindl:
>>>>
BeanBinding currently does not support undo/redo and EMFObservables does
neither. The only one providing this feature currently is EMFEditObservables
(deprecated) and EMFEditProperties.

There's an open bug for BeanBinding to add such a support. Since 3.6 IIRC
the fundamental low level API is
available but nobody stepped up to implement something similar to
EMF-Commands on top of it (who is responsible to for the undo/redo support).
<<<<
Texo is currently targeted mainly for the server side and the above means that databinding support for pojos does not
support undo/redo.

So assuming that you do an rcp I would go for this scenario:
- Texo on the server with EclipseLink
- EMF on the client with EMFEditProperties

gr. Martin

On 10/28/2010 09:59 AM, SirWayne wrote:
> Hello,
>
> is there a API for the Texo databinding with a eclipse RCP.
> EMF has EMFObservables with undo/redo support.
>
> EMFObservables.observeValue(myEObject,
> MyPackage.Literals.MYNAME__NAME)
>
>
> Is there a possibilty to use the undo/redo support and the databinding
> with EMFT?
>
> Thanks


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #635826 is a reply to message #635822] Thu, 28 October 2010 09:38 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello Martin,

thanks again for your answer =).

Yes that was my idea too.
- Texo on the server with EclipseLink
- EMF on the client with EMFEditProperties

So I just need a Wrapper which convert the client EMF Object to Texo pojos.

Do you know a Util class for convert the objects?
Or how can I save the client emf objects on the server side which are generated by texo?



Martin taal wrote on Thu, 28 October 2010 05:21
Hi Wayne,
I asked around and this is the answer I got from Tom Schindl:
>>>>
BeanBinding currently does not support undo/redo and EMFObservables does
neither. The only one providing this feature currently is EMFEditObservables
(deprecated) and EMFEditProperties.

There's an open bug for BeanBinding to add such a support. Since 3.6 IIRC
the fundamental low level API is
available but nobody stepped up to implement something similar to
EMF-Commands on top of it (who is responsible to for the undo/redo support).
<<<<
Texo is currently targeted mainly for the server side and the above means that databinding support for pojos does not
support undo/redo.

So assuming that you do an rcp I would go for this scenario:
- Texo on the server with EclipseLink
- EMF on the client with EMFEditProperties

gr. Martin

On 10/28/2010 09:59 AM, SirWayne wrote:
> Hello,
>
> is there a API for the Texo databinding with a eclipse RCP.
> EMF has EMFObservables with undo/redo support.
>
> EMFObservables.observeValue(myEObject,
> MyPackage.Literals.MYNAME__NAME)
>
>
> Is there a possibilty to use the undo/redo support and the databinding
> with EMFT?
>
> Thanks


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org

[Updated on: Thu, 28 October 2010 09:45]

Report message to a moderator

Re: [TEXO] EMF databinding [message #635830 is a reply to message #635826] Thu, 28 October 2010 09:54 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Wayne,
See here:
http://wiki.eclipse.org/Texo/Convert_to_EMF

For Model to EMF:
This conversion will convert the whole object graph (traversing all references). I can imagine that you don't want to
traverse the whole object graph (loading all the data from the database). I would like to improve the converter to
handle this better, so let me know what type of changes/extendability you need to make this work (if needed).

For EMF to Model:
Here you probably need to read referenced objects from the db while converting, also let me know what type of
extendability you need to make this work.

Let me know if there are possibilities to have standard eclipselink/jpa object resolvers and uri generation which can be
used as part of the conversion and which can be added to Texo (I am always interested in contributions here).

gr. Martin

On 10/28/2010 11:38 AM, SirWayne wrote:
> Hello Martin,
>
> thanks again for your answer =).
>
> Yes that was my idea too. - Texo on the server with EclipseLink
> - EMF on the client with EMFEditProperties
>
> So I just need a Wrapper which convert the client EMF Object to Texo pojos.
> Do you know a Util class for convert the objects?
>
>
>
> Martin taal wrote on Thu, 28 October 2010 05:21
>> Hi Wayne,
>> I asked around and this is the answer I got from Tom Schindl:
>> >>>>
>> BeanBinding currently does not support undo/redo and EMFObservables does
>> neither. The only one providing this feature currently is
>> EMFEditObservables
>> (deprecated) and EMFEditProperties.
>>
>> There's an open bug for BeanBinding to add such a support. Since 3.6 IIRC
>> the fundamental low level API is
>> available but nobody stepped up to implement something similar to
>> EMF-Commands on top of it (who is responsible to for the undo/redo
>> support).
>> <<<<
>> Texo is currently targeted mainly for the server side and the above
>> means that databinding support for pojos does not support undo/redo.
>>
>> So assuming that you do an rcp I would go for this scenario:
>> - Texo on the server with EclipseLink
>> - EMF on the client with EMFEditProperties
>>
>> gr. Martin
>>
>> On 10/28/2010 09:59 AM, SirWayne wrote:
>> > Hello,
>> >
>> > is there a API for the Texo databinding with a eclipse RCP.
>> > EMF has EMFObservables with undo/redo support.
>> >
>> > EMFObservables.observeValue(myEObject,
>> > MyPackage.Literals.MYNAME__NAME)
>> >
>> >
>> > Is there a possibilty to use the undo/redo support and the databinding
>> > with EMFT?
>> >
>> > Thanks
>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Cell: +31 (0)6 288 48 943
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #635838 is a reply to message #635830] Thu, 28 October 2010 10:35 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Thanks,

i will try it tomorrow. Where do I implement the convert stuff? On Client side in the controller or on server side?

I think on client side because the pojos are serializable and the emf classes not.
Re: [TEXO] EMF databinding [message #635846 is a reply to message #635838] Thu, 28 October 2010 10:47 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hmmm, I am not sure, I would still think/guess that you would need to control the serialization somewhat to not load the
whole database and pass it from the server to the client.

Note that we are working on json serialization for Texo, but it is not yet ready.

gr. Martin

On 10/28/2010 12:35 PM, SirWayne wrote:

> Thanks,
>
> i will try it tomorrow. Where do I implement the convert stuff? On
> Client side in the controller or on server side?
>
> I think on client side because the pojos are serializable and the emf
> classes not.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #635864 is a reply to message #635846] Thu, 28 October 2010 12:04 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Okay i create a small example and copy it into the forum

Ok if i do the convertion on server site my emf(client) models have to be serilizable.
Re: [TEXO] EMF databinding [message #636463 is a reply to message #635864] Mon, 01 November 2010 13:23 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Okay i try it first on the client side
If i convert the Object

public class View extends ViewPart {
	public static final String ID = "view";

	@Autowired
	private BaseService baseService;
	
	@Override
	public void createPartControl(Composite parent) {
		model.test.Person person = TestFactory.eINSTANCE.createPerson();
		person.setFirstname("hey");
		Object convertedModelObject = new MyEMFModelConverter().convert(person);
		baseService.insert((Person) convertedModelObject);
		
		List<Person> list = baseService.findAll();
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub
		
	}
	
	public class MyEMFModelConverter extends EMFModelConverter{
		public Object convert(EObject eObject) {
			Object o = createTarget(eObject);
			convertContent(eObject);
			return o;
		}
	}
}


i get a NPE:
java.lang.NullPointerException
	at org.eclipse.emf.texo.xml.EMFModelConverter.createModelManagedObject(EMFModelConverter.java:164)
	at org.eclipse.emf.texo.xml.EMFModelConverter.createTarget(EMFModelConverter.java:103)
	at test_rcp.View$MyEMFModelConverter.convert(View.java:41)




The ModelPackage ist null, what ist the mistake? What did i do wrong?

    protected Object createModelManagedObject(final EObject eObject) {
        if (eObject.eClass() == EcorePackage.eINSTANCE.getEObject()) {
            // TODO: check this should maybe be moved to a factory
            // or to a new DynamicModelPackage
            final DynamicModelObject modelObject = new DynamicModelObject();
            modelObject.setEClass(eObject.eClass());
            return modelObject;
        }
        final ModelPackage modelPackage = ModelResolver.getInstance().getModelPackage(
                eObject.eClass().getEPackage().getNsURI());
        return modelPackage.getModelFactory().create(eObject.eClass());
    }

[Updated on: Mon, 01 November 2010 13:23]

Report message to a moderator

Re: [TEXO] EMF databinding [message #636484 is a reply to message #636463] Mon, 01 November 2010 14:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Wayne,
The generated ModelPackage needs to be touched somehow so that it registers itself in the ModelPackageRegistry. The
initialization takes place in a static initialization step of the generated ModelPackage. Did you do this somewhere in
the client side code?

gr. Martin

On 11/01/2010 02:23 PM, SirWayne wrote:
> Okay i try it first on the client side If i convert the Object
>
> public class View extends ViewPart {
> public static final String ID = "view";
>
> @Autowired
> private BaseService baseService;
>
> @Override
> public void createPartControl(Composite parent) {
> model.test.Person person = TestFactory.eINSTANCE.createPerson();
> person.setFirstname("hey");
> Object convertedModelObject = new MyEMFModelConverter().convert(person);
> baseService.insert((Person) convertedModelObject);
>
> List<Person> list = baseService.findAll();
> }
>
> @Override
> public void setFocus() {
> // TODO Auto-generated method stub
>
> }
>
> public class MyEMFModelConverter extends EMFModelConverter{
> public Object convert(EObject eObject) {
> Object o = createTarget(eObject);
> convertContent(eObject);
> return o;
> }
> }
> }
>
>
> But i get a NPE:
>
> java.lang.NullPointerException
> at
> org.eclipse.emf.texo.xml.EMFModelConverter.createModelManage dObject(EMFModelConverter.java:164)
>
> at
> org.eclipse.emf.texo.xml.EMFModelConverter.createTarget(EMFM odelConverter.java:103)
>
> at test_rcp.View$MyEMFModelConverter.convert(View.java:41)
>
>
>
>
> The ModelPackage ist null, what ist the mistake? What did i do wrong?
>
>
> protected Object createModelManagedObject(final EObject eObject) {
> if (eObject.eClass() == EcorePackage.eINSTANCE.getEObject()) {
> // TODO: check this should maybe be moved to a factory
> // or to a new DynamicModelPackage
> final DynamicModelObject modelObject = new DynamicModelObject();
> modelObject.setEClass(eObject.eClass());
> return modelObject;
> }
> final ModelPackage modelPackage =
> ModelResolver.getInstance().getModelPackage(
> eObject.eClass().getEPackage().getNsURI());
> return modelPackage.getModelFactory().create(eObject.eClass());
> }
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #636511 is a reply to message #636484] Mon, 01 November 2010 16:12 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
If i initializethe ModePackage. I can't use the TestFactory.eINSTANCE.createPerson();

TestModelPackage.initialize();


I use 1 ecore Model to generate the EMF Model and the Texo Pojos. And so they use the same NS_URI.
Should i change one NS_URI manuell?
Re: [TEXO] EMF databinding [message #636518 is a reply to message #636511] Mon, 01 November 2010 16:21 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Comments inline.

On 11/01/2010 05:12 PM, SirWayne wrote:
> If i initializethe ModePackage. I can't use the
> TestFactory.eINSTANCE.createPerson();
MT>> Hmm, why not?

>
> TestModelPackage.initialize();
>
>
> I use 1 ecore Model to generate the EMF Model and the Texo Pojos. And so
> they use the same NS_URI.
> Should i change one NS_URI manuell?
MT>> no, their uri should be the same


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #636525 is a reply to message #636518] Mon, 01 November 2010 17:14 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Mhm but then i get a class cast exception...
1 ecore model:
client bundle:
package model.test;

public interface TestFactory extends EFactory {
	/**
	 * The singleton instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	TestFactory eINSTANCE = model.test.impl.TestFactoryImpl.init();

package model.test.impl;

public class TestFactoryImpl extends EFactoryImpl implements TestFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static TestFactory init() {
		try {
			TestFactory theTestFactory = (TestFactory)EPackage.Registry.INSTANCE.getEFactory("http://test"); 
			if (theTestFactory != null) {
				return theTestFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new TestFactoryImpl();
	}


server bundle:
package test;

public class TestModelPackage extends ModelPackage {

	/**
	 * Is set when the package has been initialized.
	 * @generated
	 */
	private static boolean isInitialized = false;

	/**
	 * The package namespace URI.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static final String NS_URI = "http://test/";



public class View extends ViewPart {
	public static final String ID = "view";

	@Autowired
	private BaseService baseService;
	
	@Override
	public void createPartControl(Composite parent) {
		TestModelPackage.initialize();
		model.test.Person person = TestFactory.eINSTANCE.createPerson();
		person.setFirstname("hey");
		Object convertedModelObject = new MyEMFModelConverter().convert(person);
		baseService.insert((Person) convertedModelObject);
		List<Person> list = baseService.findAll();
		System.out.println(list.size());
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub
		
	}
	
	public class MyEMFModelConverter extends EMFModelConverter{
		public Object convert(EObject eObject) {
			Object o = createTarget(eObject);
			convertContent(eObject);
			
			return o;
		}
	}

	
}



!MESSAGE org.eclipse.emf.texo.model.ModelEFactory cannot be cast to model.test.TestFactory
!STACK 0
java.lang.ClassCastException: org.eclipse.emf.texo.model.ModelEFactory cannot be cast to model.test.TestFactory
	at model.test.impl.TestFactoryImpl.init(TestFactoryImpl.java:34)
	at model.test.TestFactory.<clinit>(TestFactory.java:26)
	at test_rcp.View.createPartControl(View.java:28)


Should i send you the bundles?
Or is there a better code example?

[Updated on: Mon, 01 November 2010 17:51]

Report message to a moderator

Re: [TEXO] EMF databinding [message #636542 is a reply to message #636525] Mon, 01 November 2010 19:46 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ha yes, sorry, my mistake, you can cast it to an EFactory and then call something like this:
Person person = (Person)factory.create(TestPackage.eINSTANCE.getPersonEClass ());
(I am not sure about the name of the getPersonEClass method but it is something like that).

The original factory is inside the ModelFactory but I have not yet added an api to get to it, I will add it right away.

gr. Martin


On 11/01/2010 06:14 PM, SirWayne wrote:
> Mhm but then i get a class cast exception...
> 1 ecore model:
> client bundle:
>
> package model.test;
>
> public interface TestFactory extends EFactory {
> /**
> * The singleton instance of the factory.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> TestFactory eINSTANCE = model.test.impl.TestFactoryImpl.init();
>
>
> package model.test.impl;
>
> public class TestFactoryImpl extends EFactoryImpl implements TestFactory {
> /**
> * Creates the default factory implementation.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> public static TestFactory init() {
> try {
> TestFactory theTestFactory =
> (TestFactory)EPackage.Registry.INSTANCE.getEFactory("http://test"); if
> (theTestFactory != null) {
> return theTestFactory;
> }
> }
> catch (Exception exception) {
> EcorePlugin.INSTANCE.log(exception);
> }
> return new TestFactoryImpl();
> }
>
>
> server bundle:
>
> package test;
>
> public class TestModelPackage extends ModelPackage {
>
> /**
> * Is set when the package has been initialized.
> * @generated
> */
> private static boolean isInitialized = false;
>
> /**
> * The package namespace URI.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> public static final String NS_URI = "http://test/";
>
>
>
> !MESSAGE org.eclipse.emf.texo.model.ModelEFactory cannot be cast to
> model.test.TestFactory
> !STACK 0
> java.lang.ClassCastException: org.eclipse.emf.texo.model.ModelEFactory
> cannot be cast to model.test.TestFactory
> at model.test.impl.TestFactoryImpl.init(TestFactoryImpl.java:34 )
> at model.test.TestFactory.<clinit>(TestFactory.java:26)
> at test_rcp.View.createPartControl(View.java:28)
>
>
> Should i send you the bundles?


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #636560 is a reply to message #636542] Mon, 01 November 2010 21:35 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Okay i will try it.
it's very confusing to have 2 Classes with the same name. And it's very difficult to explain which you have to use

Sorry i don't understand you. i try to convert a EObject to a pojo
I added the package name, so its easier to explain the problem.
texo.model is the server side code.
emf.model is the client side code.
		texo.model.TestModelPackage.initialize();
		EFactory factory = emf.model.TestFactory.eINSTANCE;
		emf.model.Person person = (emf.model.Person) factory.create(emf.model.TestPackage.eINSTANCE.getPerson())

Same ClassCastException

[Updated on: Mon, 01 November 2010 22:34]

Report message to a moderator

Re: [TEXO] EMF databinding [message #636594 is a reply to message #636560] Tue, 02 November 2010 06:51 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I now read the stack trace of the class cast exception a bit better... It happens in the static initializer of the
TestFactory. What I don't understand is why this static initializer has not been called already earlier before Texo
replaces the EFactory of the EPackage. Can you put a breakpoint in the constructor of the TestEPackage, there should be
a line there like this:
super(eNS_URI, TestFactory.eINSTANCE);
which should already initialize the TestEFactory.eINSTANCE before Texo places its own EFactory in the TestEPackage. The
replacement of the EFactory happens in the ModelEFactory.getEPackage method, maybe you can put a breakpoint there to to
see when that gets called.

Btw, I am starting to doubt that Texo should replace the EFactory of the generated EPackage... But never the less, what
you try to do should work fine, afaics.

gr. Martin

On 11/01/2010 10:35 PM, SirWayne wrote:
> Okay i will try it.
> it's very confusing to have 2 Classes with the same name. And it's very
> difficult to explain which you have to use
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #637744 is a reply to message #636594] Mon, 08 November 2010 16:26 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Mhm i try it again in a new workspace and it works...
I don't know why. I have to check it.

But now i have a new Exception Evil or Very Mad ...
		texo.model.TestModelPackage.initialize();
		EFactory factory = emf.model.TestFactory.eINSTANCE;
		emf.model.Person person = (emf.model.Person) factory.create(emf.model.TestPackage.eINSTANCE.getPerson())
person .setName("max");
texo.model.Person person2 = (texo.model.Person) new EMFConverter().convert(person );


java.lang.IllegalArgumentException: The feature 'id' is not a valid feature
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenIsSet(BasicEObjectImpl.java:1298)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1251)
	at org.eclipse.emf.texo.xml.EMFModelConverter.convertSingleEAttribute(EMFModelConverter.java:269)
	at org.eclipse.emf.texo.xml.EMFModelConverter.convertContent(EMFModelConverter.java:138)
	at verwaltung.EMFConverter.convert(EMFConverter.java:10)
Re: [TEXO] EMF databinding [message #637776 is a reply to message #637744] Mon, 08 November 2010 19:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Indeed strange, can you debug to check what causes the error? Seems to be related to featuremap handling...
If you have a small test model then I can also try it myself.

gr. Martin

On 11/08/2010 05:26 PM, SirWayne wrote:
> Mhm i try it again in a new workspace and it works... I don't know why.
> I have to check it.
>
> But now i have a new Exception :evil: ...
>
> texo.model.TestModelPackage.initialize();
> EFactory factory = emf.model.TestFactory.eINSTANCE;
> emf.model.Person person = (emf.model.Person)
> factory.create(emf.model.TestPackage.eINSTANCE.getPerson())
> person .setName("max");
> texo.model.Person person2 = (texo.model.Person) new
> EMFConverter().convert(person );
>
>
>
> java.lang.IllegalArgumentException: The feature 'id' is not a valid feature
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenIsSet(Basic EObjectImpl.java:1298)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObj ectImpl.java:1251)
>
> at
> org.eclipse.emf.texo.xml.EMFModelConverter.convertSingleEAtt ribute(EMFModelConverter.java:269)
>
> at
> org.eclipse.emf.texo.xml.EMFModelConverter.convertContent(EM FModelConverter.java:138)
>
> at verwaltung.EMFConverter.convert(EMFConverter.java:10)
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #637947 is a reply to message #637776] Tue, 09 November 2010 12:52 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello Martin,

i send you a mail at your springsite addy with a little example.

Additional i try to debug the problem.
Re: [TEXO] EMF databinding [message #637962 is a reply to message #637947] Tue, 09 November 2010 13:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Wayne,
Okay, I have not yet received your email did you use: mtaal at springsite.com? You can also try mtaal at elver.org.

gr. Martin

On 11/09/2010 01:52 PM, SirWayne wrote:
> Hello Martin,
>
> i send you a mail at your springsite addy with a little example.
>
> Additional i try to debug the problem.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #638377 is a reply to message #637962] Thu, 11 November 2010 05:24 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Michael,
The issue with the classcastexception and the missing id efeature seems to be solved by forcing initialization of the
EMF client ModelPackage before the EMF Texo ModelModelPackage:
public void createPartControl(Composite parent) {
// just call any method on the ModelPackage to force its initialization
ModelPackage.eINSTANCE.getNsURI();
ModelModelPackage.initialize();
...
}

Another place to do this forced initialization is in a plugin Activator for example.

Note that in my idea the client should not have Texo code but just generated EMF code. The serialization between the
client and the server can use XML or in the future json (working on that).

gr. Martin

On 11/09/2010 02:35 PM, Martin Taal wrote:
> Hi Wayne,
> Okay, I have not yet received your email did you use: mtaal at
> springsite.com? You can also try mtaal at elver.org.
>
> gr. Martin
>
> On 11/09/2010 01:52 PM, SirWayne wrote:
>> Hello Martin,
>>
>> i send you a mail at your springsite addy with a little example.
>>
>> Additional i try to debug the problem.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #638630 is a reply to message #638377] Thu, 11 November 2010 20:10 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Martin taal wrote on Thu, 11 November 2010 00:24
Hi Michael,
Note that in my idea the client should not have Texo code but just generated EMF code. The serialization between the
client and the server can use XML or in the future json (working on that).


Thanks Martin for your quick answer =)...

Yes but i don't want to serialize the EMF Objects, cause they have more dependency and they are greater.

Serialize the objects with xml is a good idea.
At time I use the Spring HttpInvoker so i have a interface for remote calls. Do you know a possibilty or tutorial how i can do the serialization with xml?

[Updated on: Thu, 11 November 2010 20:15]

Report message to a moderator

Re: [TEXO] EMF databinding [message #638972 is a reply to message #638630] Sun, 14 November 2010 05:12 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Michael,
See this wiki doc:
http://wiki.eclipse.org/Texo/XML_and_XMI_Serialization

gr. Martin

On 11/11/2010 09:10 PM, SirWayne wrote:
> Martin taal wrote on Thu, 11 November 2010 00:24
>> Hi Michael,
>> Note that in my idea the client should not have Texo code but just
>> generated EMF code. The serialization between the client and the
>> server can use XML or in the future json (working on that).
>
>
> Yes but i don't want to serialize the EMF Objects, cause they have more
> dependency and they are greater.
>
> Serialize the objects with xml is a good idea.
> At time I use the Spring HttpInvoker so i have a interface for remote
> calls. Do you know a possibilty or tutorial how i can do the
> serialization with xml?


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #639154 is a reply to message #638972] Mon, 15 November 2010 12:36 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hi Martin,

could you show your idea?

I should don't use texo code on the client, correct?
Where do i have to do the conversion?
And how works the serialization ?I can only serialization the pojos or?

My Code idea:

Client Side:
	private String writeXMI(final List<Object> objects) {
	    final ModelXMLSaver xmlSaver = new ModelXMLSaver();
	    xmlSaver.setSaveAsXMI(true);
	    xmlSaver.setObjects(objects);
	    final StringWriter sw = new StringWriter();
	    xmlSaver.setWriter(sw);
	    xmlSaver.write();
	    return sw.toString();
	}
	
	public void createPartControl(Composite parent) {

		emf.client.Object object =...
		object.setName("test huhu");
		List<Object> objects = new ArrayList<Object>();
		objects.add(verwaltung);
		String xmi = writeXMI(objects);
                baseService.saveOrUpdate(xmi);


Problem: I can only serialization pojos not the emf objects or?
 java.lang.IllegalStateException: The class class emf.client.Object is not managed by this ModelResolver


Server Side: (Do here the conversion???)
	@Override
	public <T extends DBObject> T saveOrUpdate(String xmi) {
		List<Object> objects = readXML(xmi);
		System.out.println(objects);
		return null;
	}
	
	private List<Object> readXML(final String xml) {
	    final ModelXMLLoader xmlLoader = new ModelXMLLoader();
	    xmlLoader.setLoadAsXMI(true);
	    xmlLoader.setReader(new StringReader(xml));
	    return xmlLoader.read();
	}


Thanks

gr. Michael
Martin taal wrote on Sun, 14 November 2010 00:12
Hi Michael,
See this wiki doc:
http://wiki.eclipse.org/Texo/XML_and_XMI_Serialization

gr. Martin

On 11/11/2010 09:10 PM, SirWayne wrote:
> Martin taal wrote on Thu, 11 November 2010 00:24
>> Hi Michael,
>> Note that in my idea the client should not have Texo code but just
>> generated EMF code. The serialization between the client and the
>> server can use XML or in the future json (working on that).
>
>
> Yes but i don't want to serialize the EMF Objects, cause they have more
> dependency and they are greater.
>
> Serialize the objects with xml is a good idea.
> At time I use the Spring HttpInvoker so i have a interface for remote
> calls. Do you know a possibilty or tutorial how i can do the
> serialization with xml?


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org

Re: [TEXO] EMF databinding [message #639327 is a reply to message #639154] Tue, 16 November 2010 05:48 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Michael,
Can you try the following:
1- On the server: serialize Texo objects to xmi or xml
2- On the client: de-serialize the xmi/xml using a standard EMF XML/XMI resource

and to persist work the other way: serialize EMF objects using a standard XML/XMI resource and de-serialize on the
server using the Texo approach.

So on the client the xml/xmi is de-serialized directly to EMF objects without using Texo there.

Note, that there is one missing feature with the serialization on the Texo side: currently it will traverse all object
associations and serialize them all (effectively reading the complete database...). The plan for the coming 1-2 weeks is
to let this be done differently (use EMF proxies to serialize to xml, and read from the database when de-serializing to
Texo).

I have been busy with both Teneo and CDO the past few days, but that work is finished. So I hope to spend some days on
json serialization and the above logic (to not read the complete database). But it will be another week or so before
this is part of the Texo build....

gr. Martin

On 11/15/2010 01:36 PM, SirWayne wrote:
> Hi Martin,
>
> could you show your idea?
>
> I should don't use texo code on the client, correct?
> Where do i have to do the conversion?
> And how works the serialization ?I can only serialization the pojos or?
>
> My Code idea:
>
> Client Side:
>
> private String writeXMI(final List<Object> objects) {
> final ModelXMLSaver xmlSaver = new ModelXMLSaver();
> xmlSaver.setSaveAsXMI(true);
> xmlSaver.setObjects(objects);
> final StringWriter sw = new StringWriter();
> xmlSaver.setWriter(sw);
> xmlSaver.write();
> return sw.toString();
> }
>
> public void createPartControl(Composite parent) {
>
> emf.client.Object object =...
> object.setName("test huhu");
> List<Object> objects = new ArrayList<Object>();
> objects.add(verwaltung);
> String xmi = writeXMI(objects);
> baseService.saveOrUpdate(xmi);
>
>
> Problem: I can only serialization pojos not the emf objects or?
> java.lang.IllegalStateException: The class class emf.client.Object is
> not managed by this ModelResolver
>
> Server Side: (Do here the conversion???)
>
> @Override
> public <T extends DBObject> T saveOrUpdate(String xmi) {
> List<Object> objects = readXML(xmi);
> System.out.println(objects);
> return null;
> }
>
> private List<Object> readXML(final String xml) {
> final ModelXMLLoader xmlLoader = new ModelXMLLoader();
> xmlLoader.setLoadAsXMI(true);
> xmlLoader.setReader(new StringReader(xml));
> return xmlLoader.read();
> }
>
>
> Thanks
>
> gr. Michael Martin taal wrote on Sun, 14 November 2010 00:12
>> Hi Michael,
>> See this wiki doc:
>> http://wiki.eclipse.org/Texo/XML_and_XMI_Serialization
>>
>> gr. Martin
>>
>> On 11/11/2010 09:10 PM, SirWayne wrote:
>> > Martin taal wrote on Thu, 11 November 2010 00:24
>> >> Hi Michael,
>> >> Note that in my idea the client should not have Texo code but just
>> >> generated EMF code. The serialization between the client and the
>> >> server can use XML or in the future json (working on that).
>> >
>> >
>> > Yes but i don't want to serialize the EMF Objects, cause they have more
>> > dependency and they are greater.
>> >
>> > Serialize the objects with xml is a good idea.
>> > At time I use the Spring HttpInvoker so i have a interface for remote
>> > calls. Do you know a possibilty or tutorial how i can do the
>> > serialization with xml?
>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Cell: +31 (0)6 288 48 943
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #639337 is a reply to message #639327] Tue, 16 November 2010 07:53 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Martin taal wrote on Tue, 16 November 2010 00:48
Hi Michael,
Can you try the following:
1- On the server: serialize Texo objects to xmi or xml
2- On the client: de-serialize the xmi/xml using a standard EMF XML/XMI resource

and to persist work the other way: serialize EMF objects using a standard XML/XMI resource and de-serialize on the
server using the Texo approach.

So on the client the xml/xmi is de-serialized directly to EMF objects without using Texo there.



Okay i will try it, if it works i can send you the example workspace

Martin taal wrote on Tue, 16 November 2010 00:48

Note, that there is one missing feature with the serialization on the Texo side: currently it will traverse all object
associations and serialize them all (effectively reading the complete database...). The plan for the coming 1-2 weeks is
to let this be done differently (use EMF proxies to serialize to xml, and read from the database when de-serializing to
Texo).



Okay it's good to know...

I have 1 more question.
On Client side i write a XMI File for the EMF Objects. What should I send to the server, the "xmi" String oder the xmi File?

	private String writeXMI(final List<EObject> objects) {
		
	     Resource xmiResource = new XMIResourceImpl();
	     xmiResource.getContents().addAll(objects);
	     try {
			xmiResource.save(null);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	    return "";
	}



public interface BaseService {
	Object saveOrUpdate(String xmi);
         //or
Object saveOrUpdate(File xmi);
}


Or do i send the XMIResource to the server?

gr. Michael

[Updated on: Wed, 17 November 2010 09:13]

Report message to a moderator

Re: [TEXO] EMF databinding [message #639636 is a reply to message #639337] Wed, 17 November 2010 10:07 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Okay i send a file to the server
Here is a example, if you want the whole workspace i could send you a mail:
client side:
	private File writeXMI(final List<EObject> objects) {
		
	     XMLResource xmiResource = new XMIResourceImpl(URI.createFileURI("test.xmi"));
	     
	     xmiResource.getContents().addAll(objects);    
	     try {
			xmiResource.save(null);
		} catch (IOException e) {
		}
	    return new File(xmiResource.getURI().toFileString());
	}
	
	private List<EObject> loadXMI(File file) {
		
	     XMLResource xmiResource = new XMIResourceImpl();
	     
	     try {
			xmiResource.load(new FileInputStream(file), null);
		} catch (FileNotFoundException e1) {
		} catch (IOException e1) {
		}
	    return xmiResource.getContents();
	}
	

	

	public void createPartControl(Composite parent) {
		ClientModelPackage.initialize();
		client.DBObject dbObject= ClientFactory.eINSTANCE.createDBObject();
		dbObjectsetName("test huhu");
		List<EObject> objects = new ArrayList<EObject>();
		objects.add(verwaltung);
		File xmi = writeXMI(objects);
		xmi = service.saveOrUpdate(xmi);
		List<EObject> dbObjects = loadXMI(xmi);
		System.out.println(dbObjects.get(0));
}

server side:

import texo.model.DBObject;

public class BaseServiceImpl implements BaseService{

	private Logger logger = LoggerFactory.getLogger(BaseServiceImpl.class);

	@Autowired
	private BaseDao baseDao;
	
	public BaseServiceImpl (){
                //do in activator only for example
		VerwaltungModelPackage.initialize();
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public File saveOrUpdate(File xmi) {
		final List<DBObject> objects = readXML(xmi);
		final List<DBObject> dbObjects = new ArrayList<DBObject>();
		for(DBObject object : objects){
			dbObjects.add(baseDao.saveOrUpdate(object));
		}
		return writeXML(dbObjects);
	}
	
	private List<DBObject> readXML(final File xml) {
	    final ModelXMLLoader xmlLoader = new ModelXMLLoader();
	    xmlLoader.setLoadAsXMI(true);
	    try {
			xmlLoader.setReader(new FileReader(xml));
		} catch (FileNotFoundException e) {
			logger.error("file not found",e);
		}
		List<DBObject> list = new ArrayList<DBObject>();
		for(Object object : xmlLoader.read()){
			list.add((DBObject) object);
		}
	    return list;
	}
	
	private File writeXML(List<DBObject> list) {
	    final ModelXMLSaver modelXMLSaver = new ModelXMLSaver();
	    modelXMLSaver.setSaveAsXMI(true);
	    final File file = new File("saveResult.xmi");
	    try {
	    	modelXMLSaver.setWriter(new FileWriter(file));
		} catch (IOException e) {
			logger.error("save error", e);
		}
		List<Object> objects = new ArrayList<Object>(list);
		modelXMLSaver.setObjects(objects);
		modelXMLSaver.write();
	    return file;
	}


}



Thanks a lot it works =). I have to implement Util class to write/load the xmi files. So i can do the conversion on client side in the controller.
Re: [TEXO] EMF databinding [message #639646 is a reply to message #639636] Wed, 17 November 2010 10:20 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Michael,
Great!
As I mentioned in the previous email the thing I am working on is:
- prevent loading of non-containment associations on the server, so send these as proxies/references to the client
- when updating resolve proxies on the server by reading from the database
- support individual proxy resolving in the resource used on the client

On the client you would be using a specific EMF resource delivered by Texo (is the only Texo specific code needed on the
client). This Texo/EMF resource implements the same api as the XMI/XML resource so theoritically (and hopefully
practically) you can develop your client against this resource api and then later switch to the EMFTexoResource.

And then next to supporting XMI/XML also support json as the data transfer format.

It is all clear in my mind what to develop, just need some time...

Can I contact you next week for a zip file of your then current workspace? Then I can test the above functionality with
your most up-to-date version.

gr. Martin

On 11/17/2010 11:08 AM, SirWayne wrote:
> Okay i send a file to the server
> Here is a example, if you want the whole workspace i could send you a mail:
> client side:
>
> private File writeXMI(final List<EObject> objects) {
>
> XMLResource xmiResource = new
> XMIResourceImpl(URI.createFileURI("test.xmi"));
> xmiResource.getContents().addAll(objects); try {
> xmiResource.save(null);
> } catch (IOException e) {
> }
> return new File(xmiResource.getURI().toFileString());
> }
>
> private List<EObject> loadXMI(File file) {
>
> XMLResource xmiResource = new XMIResourceImpl();
> try {
> xmiResource.load(new FileInputStream(file), null);
> } catch (FileNotFoundException e1) {
> } catch (IOException e1) {
> }
> return xmiResource.getContents();
> }
>
>
>
>
> public void createPartControl(Composite parent) {
> ClientModelPackage.initialize();
> client.DBObject dbObject= ClientFactory.eINSTANCE.createDBObject();
> dbObjectsetName("test huhu");
> List<EObject> objects = new ArrayList<EObject>();
> objects.add(verwaltung);
> File xmi = writeXMI(objects);
> xmi = service.saveOrUpdate(xmi);
> List<EObject> dbObjects = loadXMI(xmi);
> System.out.println(dbObjects.get(0));
> }
>
> server side:
>
>
> import texo.model.DBObject;
>
> public class BaseServiceImpl implements BaseService{
>
> private Logger logger = LoggerFactory.getLogger(BaseServiceImpl.class);
>
> @Autowired
> private BaseDao baseDao;
>
> public BaseServiceImpl (){
> //do in activator only for example
> VerwaltungModelPackage.initialize();
> }
>
> @Override
> @Transactional(propagation = Propagation.REQUIRED)
> public File saveOrUpdate(File xmi) {
> final List<DBObject> objects = readXML(xmi);
> final List<DBObject> dbObjects = new ArrayList<DBObject>();
> for(DBObject object : objects){
> dbObjects.add(baseDao.saveOrUpdate(object));
> }
> return writeXML(dbObjects);
> }
>
> private List<DBObject> readXML(final File xml) {
> final ModelXMLLoader xmlLoader = new ModelXMLLoader();
> xmlLoader.setLoadAsXMI(true);
> try {
> xmlLoader.setReader(new FileReader(xml));
> } catch (FileNotFoundException e) {
> logger.error("file not found",e);
> }
> List<DBObject> list = new ArrayList<DBObject>();
> for(Object object : xmlLoader.read()){
> list.add((DBObject) object);
> }
> return list;
> }
>
> private File writeXML(List<DBObject> list) {
> final ModelXMLSaver modelXMLSaver = new ModelXMLSaver();
> modelXMLSaver.setSaveAsXMI(true);
> final File file = new File("saveResult.xmi");
> try {
> modelXMLSaver.setWriter(new FileWriter(file));
> } catch (IOException e) {
> logger.error("save error", e);
> }
> List<Object> objects = new ArrayList<Object>(list);
> modelXMLSaver.setObjects(objects);
> modelXMLSaver.write();
> return file;
> }
>
>
> }
>
>
>
> Thanks a lot it works =). I have to implement Util class to write/load
> the xmi files. So i can do the conversion on client side in the controller.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] EMF databinding [message #639805 is a reply to message #639646] Wed, 17 November 2010 21:18 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Yes i will create a whole workspace for you.
It's a good practice for me.
I create sever/client workspace
Components:
Database h2
Server Jetty with SpringDM and Spring
DAO Bundle with EclipseLink
Service with Spring HTTP
RCP Client 1 View for save,delete and find with Undo/Redo support
Texo Server model
EMF Client Model

[Updated on: Wed, 17 November 2010 21:22]

Report message to a moderator

Re: [TEXO] EMF databinding [message #639912 is a reply to message #635799] Thu, 18 November 2010 11:50 Go to previous message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hi Martin,

i send you a mail with a example workspace.

I have a question. Is it a good idea to send the file to the server?
Or should i send the OutputStream from the client to the server?
Previous Topic:EMF Compare into plug-in eclipse
Next Topic:EMF and JUnit 4?
Goto Forum:
  


Current Time: Sat Apr 20 03:24:05 GMT 2024

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

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

Back to the top