Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Create a dynamic instance based on root object(App)

First off, you should create a dynamic instance from the root object in your view/service ecore model, in our case App. To do this, open the ecore model(app.ecore in our case):

Image Added

and right click on the class(App) you want to create a dynamic instance of and click on Create Dynamic Instance... and click Finish:

Image Added

After you have created this instance, you need to rename it for it to be appropriately handled(aliased) in the Editor resource providers view:

Image Added

Now, you should copy-paste this instance over to your runtime configuration of eclipse. Here you can open the file using the Sample Reflective Ecore Model Editor:

Image Added

Since the App class(in our case) is defined to contain references to the underlying model, you have to create a instance of this. We called our model My.gr1600.

You can now load the instace of your underlying model into the Sample Reflective Ecore Model Editor of the App instance by either just drag-and-drop it inside the editor or right-click inside the editor and click on Load Resource..., then the editor should look like this:

Image Added

 

After you have loaded the underlying model into the editor, you can now add this instance to the App instance, this can be done in the Properties View(just right-click on the App insance and click on Show Properties View):

Image Added

Now your instance is ready to start running, but first you have to make sure that the alias of the instance is correct for the REST calls. To do this, open the Editor resource providers view by clicking on Window –> Show view –> Other... --> Editor resource providers view (it's inside the Pgo folder):

Image Added

When you have opened this view, you should see one element in it, namely your instance. You have to make sure that the Name(alias) field is corresponding to what you have specified inside the AppEndPoint.java class in your web project. If you have just copy-pasted the web project from gr1600 and renamed all the appropriate places inside the AppEndPoint.java class, then the alias should be gr16xx/data. You can change the alias to what ever you prefer, corresponding to the naming in the AppEndPoint.java class, by clicking on it inside the editor:

Image Added

When you now tick of the alias checkbox, the resource should be available for your browser on the URI: http://localhost:8082/gr16xx/App.html:

Image Added

You can also check that the methods inside your view model works by writing: http://localhost:8082/gr16xx/data/*method*:

Image Added

Now you can add your own methods inside your view/service model to access the underlying model in an encapsualted way.