Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] Setup Webserver and EMF Client with JSONTexoResource
[Texo] Setup Webserver and EMF Client with JSONTexoResource [message #1086480] Wed, 14 August 2013 08:58 Go to next message
Thomas Driessen is currently offline Thomas DriessenFriend
Messages: 13
Registered: August 2013
Junior Member
Hello everybody,

a few days ago I came across Texo (@Martin: thanks for your great work). As explained on the wiki site, I tried to set up a 3 Tier architecture with a MySQL Database, a Tomcat Webserver and an EMF generated client. So far the webserver and its database connection are working without problems. The part I'm struggling with is the EMF generated client.

The steps I've taken until now:
1)Downloaded sample project org.eclipse.emf.texo.web.example from https : //github.com/mtaal/texo and deleted the folder WebContent/mobile (Do i need this one?)
2)Set up webserver, database and generated test data according to this site: http : //wiki.eclipse.org/Texo/JSON_REST_Web_Services (everything works fine)
3)Generated an EMF Client via creating a genmodel from the files identifiable.ecore and library.ecore (The same i use to generate the JPA annotated model code)
4)Created a JSONTexoFactoryImpl
public class JSONTexoResourceFactoryImpl implements Factory {

	@Override
	public Resource createResource(URI uri) {
		JSONTexoResource res = new JSONTexoResource();
		res.setURI(uri);
		return res;
	}
}

5) Registered this Factory via
Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put("http", new JSONTexoResourceFactoryImpl());

6) Tried to open the generated editor with an URIEditorInput
URIEditorInput input = new URIEditorInput(URI.createURI("http : //localhost:8080/org.eclipse.emf.texo.web.example/jsonws"));
try {
page.openEditor(input, "library.presentation.LibraryEditorID");
} catch (PartInitException e) {
	e.printStackTrace();
} 


The editor came up but had no content, so I changed the input into
URIEditorInput input = new URIEditorInput(URI.createURI("http : //localhost:8080/org.eclipse.emf.texo.web.example/jsonws?type=library_Library"));

Now the editor showed up with the libraries I had in my database, but i couldn't expand those elements to show their children (books / writer). I also tried this setup with Book or Writer as root elements, but this didn't work either.

The expected behaviour, in my opinion, would be, that the editor would work as if I invoked it with a local resource. Libraries would be the root elements and with a click on them I can expand them to show their child elements.
Did I miss some steps until now? Did I do something wrong? Is the described behaviour expected? Is there an example project that shows the proper use of the JSONTexoResource?
I hope you can give me a hint in the right direction.
Any help is appreciated and thanks a lot in advance for your effort.

Best regards,
Thomas Driessen
Re: [Texo] Setup Webserver and EMF Client with JSONTexoResource [message #1086891 is a reply to message #1086480] Wed, 14 August 2013 22:09 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Thomas,
It should work as you expect, I can't really see why it does not happen, the books/writers containment elist should be
resolved. So not sure why it does not happen. Can you debug into to the code to see if indeed resolving takes place and
that the library indeed has book/writer proxies in the lists?
You can put breakpoints in the getEObject methods in the TexoResource.

gr. Martin

On 08/14/2013 05:34 PM, Thomas Driessen wrote:
> Hello everybody,
>
> a few days ago I came across Texo (@Martin: thanks for your great work). As explained on the wiki site, I tried to set
> up a 3 Tier architecture with a MySQL Database, a Tomcat Webserver and an EMF generated client. So far the webserver and
> its database connection are working without problems. The part I'm struggling with is the EMF generated client.
> The steps I've taken until now:
> 1)Downloaded sample project org.eclipse.emf.texo.web.example from https : //github.com/mtaal/texo and deleted the folder
> WebContent/mobile (Do i need this one?)
> 2)Set up webserver, database and generated test data according to this site: http :
> //wiki.eclipse.org/Texo/JSON_REST_Web_Services (everything works fine)
> 3)Generated an EMF Client via creating a genmodel from the files identifiable.ecore and library.ecore (The same i use to
> generate the JPA annotated model code)
> 4)Created a JSONTexoFactoryImpl
> public class JSONTexoResourceFactoryImpl implements Factory {
>
> @Override
> public Resource createResource(URI uri) {
> JSONTexoResource res = new JSONTexoResource();
> res.setURI(uri);
> return res;
> }
> }
>
> 5) Registered this Factory via
>
> Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put("http", new JSONTexoResourceFactoryImpl());
>
> 6) Tried to open the generated editor with an URIEditorInput
>
> URIEditorInput input = new URIEditorInput(URI.createURI("http :
> //localhost:8080/org.eclipse.emf.texo.web.example/jsonws"));
> try {
> page.openEditor(input, "library.presentation.LibraryEditorID");
> } catch (PartInitException e) {
> e.printStackTrace();
> }
>
> The editor came up but had no content, so I changed the input into
>
> URIEditorInput input = new URIEditorInput(URI.createURI("http :
> //localhost:8080/org.eclipse.emf.texo.web.example/jsonws?type=library_Library"));
>
> Now the editor showed up with the libraries I had in my database, but i couldn't expand those elements to show their
> children (books / writer). I also tried this setup with Book or Writer as root elements, but this didn't work either.
>
> The expected behaviour, in my opinion, would be, that the editor would work as if I invoked it with a local resource.
> Libraries would be the root elements and with a click on them I can expand them to show their child elements.
> Did I miss some steps until now? Did I do something wrong? Is the described behaviour expected? Is there an example
> project that shows the proper use of the JSONTexoResource?
> I hope you can give me a hint in the right direction.
> Any help is appreciated and thanks a lot in advance for your effort.
>
> Best regards, Thomas Driessen


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Setup Webserver and EMF Client with JSONTexoResource [message #1086900 is a reply to message #1086891] Wed, 14 August 2013 22:27 Go to previous messageGo to next message
Thomas Driessen is currently offline Thomas DriessenFriend
Messages: 13
Registered: August 2013
Junior Member
Hey Martin,

thanks for your quick response. I'm on vacation until sunday, but on monday I'll give your advice a try Smile
I'll write back if i got some news on this topic.

Best regards,
Thomas
Re: [Texo] Setup Webserver and EMF Client with JSONTexoResource [message #1089991 is a reply to message #1086900] Mon, 19 August 2013 14:58 Go to previous messageGo to next message
Thomas Driessen is currently offline Thomas DriessenFriend
Messages: 13
Registered: August 2013
Junior Member
Hi Martin,

after some debugging I found out, that the method getEClassFromQualifiedName in the class ModelUtils returns the wrong Library EClass (org.eclipse.m2m.internal.qvt.oml.expressions.Library). The Javadoc of this method already points out that this can happen, if the given name is not qualified via its epackage ns prefix.
As I'm using qualified names (in my case library|Library), might it be, that the second for-loop of the method getEClassFromQualifiedName is missing a check for equality of namespaces?
    for (Object key : new HashSet<Object>(ModelResolver.getInstance().getEPackageRegistry().keySet())) {
      final EPackage ePackage = ModelResolver.getInstance().getEPackageRegistry().getEPackage((String) key);
      
      //Here i would expect something like the following
      //if (nameSpacePrefix != null && !ePackage.getNsPrefix().equals(nameSpacePrefix)) {
      //  continue;
      //}

      for (EClassifier eClassifier : ePackage.getEClassifiers()) {
        if (eClassifier.getName().equals(eClassName)) {
          return (EClass) eClassifier;
        }
      }
    }


Best regards,
Thomas
Re: [Texo] Setup Webserver and EMF Client with JSONTexoResource [message #1090248 is a reply to message #1089991] Mon, 19 August 2013 22:54 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Thomas,
I published a new build which should solve (I made the change you proposed), can you try again?

gr. Martin

On 08/19/2013 04:58 PM, Thomas Driessen wrote:
> Hi Martin,
>
> after some debugging I found out, that the method getEClassFromQualifiedName in the class ModelUtils returns the wrong
> Library EClass (org.eclipse.m2m.internal.qvt.oml.expressions.Library). The Javadoc of this method already points out
> that this can happen, if the given name is not qualified via its epackage ns prefix.
> As I'm using qualified names (in my case library|Library), might it be, that the second for-loop of the method
> getEClassFromQualifiedName is missing a check for equality of namespaces?
>
> for (Object key : new HashSet<Object>(ModelResolver.getInstance().getEPackageRegistry().keySet())) {
> final EPackage ePackage = ModelResolver.getInstance().getEPackageRegistry().getEPackage((String) key);
> //Here i would expect something like the following
> //if (nameSpacePrefix != null && !ePackage.getNsPrefix().equals(nameSpacePrefix)) {
> // continue;
> //}
>
> for (EClassifier eClassifier : ePackage.getEClassifiers()) {
> if (eClassifier.getName().equals(eClassName)) {
> return (EClass) eClassifier;
> }
> }
> }
>
>
> Best regards,
> Thomas


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Setup Webserver and EMF Client with JSONTexoResource [message #1090497 is a reply to message #1090248] Tue, 20 August 2013 08:10 Go to previous message
Thomas Driessen is currently offline Thomas DriessenFriend
Messages: 13
Registered: August 2013
Junior Member
Hi Martin,

thanks a lot for this quick Fix. Now everything works as expected.
Thanks for this great Framework Smile

Best regards,
Thomas
Previous Topic:[Texo] How to reference another object when inserting with post
Next Topic:why i am getting this error
Goto Forum:
  


Current Time: Thu Mar 28 12:48:26 GMT 2024

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

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

Back to the top