Quick and Useful Way to Edit Data from an EOModel
I created something useful. It did not take very long, but it is useful and I do not remember anyone mentioning this kind of thing in the past.I have a Direct to Web app built that, when I give it an EOModel as a parameter, launches a fresh, new web interface that allows me to edit data in the entities of the model. Imagine if you could do a "Browse Data" in EOModeler and then edit the data. One cannot do that, but one can take just an EOModel and put data into the entities without creating a fresh project. I used to create a D2W app to administrate every EOModel I have in any app, so I find this useful. I no longer need those duplicate projects around.
Here is how you do this:
- Using Xcode, create a "Direct to Web Application" project named "d2Model". When it asks you to specify an EOModel, just specify some model. It does not matter which model.
- You may want to build the project at this point. There is no reason for this, but I usually do. I just always build a project first thing, after I create it.
- Delete the model from your project. Make sure that you delete the references and the files and do a build in the project for "Clean All Targets".
- Edit the project's Application class's constructor as so:
public Application() {
super();
System.out.println("Welcome to " + this.name() + "!");
String modelPath = System.getProperty("eomodel.full.path");
if (modelPath == null)
throw new java.lang.IllegalArgumentException("Please give me a \"eomodel.full.path\" to use as a model.");
try {
EOModel model = new EOModel(new java.net.URL("file://"+modelPath));
EOModelGroup.defaultGroup().addModel(model);
} catch (java.net.MalformedURLException mue) {
throw new java.lang.IllegalArgumentException("Could not find EOModel: "+modelPath);
}
}
- build the project
- launch Terminal
- If you have Xcode set up in the default manner, you can cd to the
build
directory, inside the project, then the Development
directory inside that. If you have Xcode set up differently, you will know where the woa is already.- I moved the woa to a useful location. For example, you can do:
mv d2Model.woa ~/d2Model.woa
To use the application, I then do the following:
- open Terminal
- type the following:
~/d2Model.woa/d2Model -Deomodel.full.path=/Users/ray/Projects/MyToDo/ToDo.eomodeld
This lets me edit the data in the "to do" app I have been playing with. When I am done editing, I log out, close the browser window, and do a ^C in the Terminal window.
There are lots of better things to do here.
For example, a while back I had a droplet for this. One would drop a model on it and, like magic, there it was.
But this is version 0.1.
On the "to do" list for this is:
1) put the project somewhere, where I decide to put things.
2) create a double-clickable java app that I can drop an EOModel on, as I used to do with the droplet.
3) shorten the session time-out and put a "System.exit(0)" somewhere convenient in the Session subclass, so that I do not have to ^C the application instance
4) turn the woa into a standalone-app, so that one can use it on a machine that does not a WO installation.
5) whatever else I think of later....
1 Comments:
Really useful idea.
Now I don't need to have a D2W project for every model.
Saludos,
Daniel Mejia.
Post a Comment
Subscribe to Post Comments [Atom]
<< Home