Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [TEXO] EMF databinding
| |
Re: [TEXO] EMF databinding [message #635826 is a reply to message #635822] |
Thu, 28 October 2010 09:38 |
Dennis Melzer 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 |
Martin Taal 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 #636463 is a reply to message #635864] |
Mon, 01 November 2010 13:23 |
Dennis Melzer 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 #636525 is a reply to message #636518] |
Mon, 01 November 2010 17:14 |
Dennis Melzer 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 #636560 is a reply to message #636542] |
Mon, 01 November 2010 21:35 |
Dennis Melzer 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 |
Martin Taal 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 #638377 is a reply to message #637962] |
Thu, 11 November 2010 05:24 |
Martin Taal 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 |
Dennis Melzer 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 #639154 is a reply to message #638972] |
Mon, 15 November 2010 12:36 |
Dennis Melzer 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 |
Martin Taal 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 |
Dennis Melzer 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 #639646 is a reply to message #639636] |
Wed, 17 November 2010 10:20 |
Martin Taal 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 |
Dennis Melzer 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
|
|
| |
Goto Forum:
Current Time: Thu Sep 26 05:51:57 GMT 2024
Powered by FUDForum. Page generated in 0.06583 seconds
|