Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Spatiotemporal Epidemiological Modeler (STEM) » Web interface?
Web interface? [message #521978] Fri, 19 March 2010 14:16 Go to next message
Doug  is currently offline Doug Friend
Messages: 30
Registered: March 2010
Member
I downloaded and have been getting familiar with creating diseases/infectors/inoculators/models/scenarios/triggers/... I am interested in integrating STEM into a web project - are existing projects/plugins working in that area?

At first I would like to just allow users to be able to run scenarios on a remote server through a web interface, and eventually would like to expose portions of the UI to allow them to modify runs by adding modifiers/triggers/inoculators...

I don't want to repeat effort so if there are existing projects, or anyone could point to where would be the best place to hook into STEM, I'd appreciate it. I am grabbing the source at the moment. Even a command-line execution format to pick the scenario to run would be a useful start, but I couldn't find any info about a command line execution.

Thanks,
Doug
Re: Web interface? [message #522018 is a reply to message #521978] Fri, 19 March 2010 16:17 Go to previous messageGo to next message
Matthew DavisFriend
Messages: 269
Registered: July 2009
Senior Member
Hi Doug,

We have some internal work on a Web-based STEM interface, but it's not really in a condition for public release at this time. It's really more of a proof-of-concept/what we can do. Right now, it's just a collection of JSON-generating servlets with a Dojo interface and visualizer built with Google Maps. Simulation controls are mainly related to state (start, stop, etc). The underlying container is running Jetty as an Eclipse plug-in. See: http://www.eclipse.org/equinox/server/

As for the hooks to control STEM through an API, my recommendation is that you start by looking at the SimulationManager and Simulation classes in in the org.eclipse.stem.jobs plug-in.

To initialize and run a headless simulation, pulling from our Web code, here's a very simple set of steps. Obviously any real system will be more advanced, but this is a basic startup. Note that the project name and scenario name correspond to projects and scenarios you created using the STEM UI.

import org.eclipse.emf.common.util.URI;
import org.eclipse.stem.core.Utility;
import org.eclipse.stem.core.scenario.Scenario;
import org.eclipse.stem.jobs.simulation.SimulationManager;
import org.eclipse.stem.jobs.simulation.ISimulation;
import org.eclipse.stem.jobs.simulation.Simulation;
...
String projectName = "somestemproject";
String scenarioName = "somescenarioname.scenario";

// Get the internal URI to the Scenario resource file in the workspace
URI scenarioUri = URI.createURI("platform:/resource/"+ projectName +"/scenarios/"+ scenarioName);
// Load the scenario from file
Scenario scenario = (Scenario)Utility.getIdentifiable(scenarioUri);
// Get the simulation manager
SimulationManager mgr = SimulationManager.getManager();
// Create a runnable simulation from the given scenario
ISimulation sim = mgr.createSimulation(scenario);
// Run the simulation
mgr.runSimulation(sim);

Re: Web interface? [message #522330 is a reply to message #522018] Mon, 22 March 2010 11:45 Go to previous messageGo to next message
Doug  is currently offline Doug Friend
Messages: 30
Registered: March 2010
Member
Thanks for the pointers!
Re: Web interface? [message #524059 is a reply to message #522330] Tue, 30 March 2010 13:51 Go to previous messageGo to next message
Doug  is currently offline Doug Friend
Messages: 30
Registered: March 2010
Member
By the way, is there any planned timeframe for when pieces of the web interface will be available?
Re: Web interface? [message #525562 is a reply to message #522018] Tue, 06 April 2010 21:41 Go to previous messageGo to next message
Doug  is currently offline Doug Friend
Messages: 30
Registered: March 2010
Member
I am still having trouble with this... I have what are probably lots of very basic questions. I have very limited time available to try to learn Eclipse and STEM, so perhaps this just isn't going to work out right now.

To simplify, I dropped the web app part for now and just want to create a standalone, command line version of STEM where parameters can be passed to specify the scenario, for example. I started with the code from Matt above, but swapped the last 4 lines for:
			// Create a runnable simulation from the given scenario and run it
			mgr.createAndRunSimulation(scenario);

(the version above was causing errors, but I don't recall what off the top of my head)

I assume I want to develop my command line driver as a plug-in, then set up a product configuration to export it as a standalone Eclipse application (I still can't seem to get that working for STEM itself, per this thread).

I have scenarios created from the version of STEM I downloaded, but can't seem to load them. Where would I need to copy/import/??? my "US-Flu" project in order to load its "test.scenario"?

If I run as a Java application, my working directory = C:\Documents and Settings\drafalsk\workspace\headlessSTEM, and
scenarioUri.toString() = platform:/resource/US-Flu/scenarios/test.scenario
scenarioUri.toFileString() = null

The code
Scenario scenario = (Scenario)Utility.getIdentifiable(scenarioUri);


Then fails with
Quote:

The serialized instance of an Identifiable at "platform:/resource/USFlu/scenarios/test.scenario" was not found or was of the wrong format
Re: Web interface? [message #526140 is a reply to message #525562] Thu, 08 April 2010 20:40 Go to previous messageGo to next message
Matthew DavisFriend
Messages: 269
Registered: July 2009
Senior Member
Hi Doug,

I suspect the problem here is launching as Java application. STEM has strong dependencies on the Eclipse environment that you only get when launching as an Eclipse application. If you launch, even in Eclipse, as "Java Application", it stills runs in the barebones JVM. To launch with STEM, it has to run in a JVM with the Eclipse/OSGi environment loaded and the Eclipse Workbench launched.

You can still do this headless-ly, it just requires writing the correct boilerplate to run as an Eclipse application - notable a launcher class that implements IApplication and the correct entry in plugin.xml.

First, take a look at the org.eclipse.equinox.app.IApplication interface:

http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/reference/api/org/eclipse/equinox/app/IApp lication.html

At the very least, the class implementing this interface contains a method that can act like a standard main(String[] args) to the Eclipse platform. There's generally much more to this, but you can get started here and run code directly from start(...).

After creating that class, you have to register it in the underlying Platform so Eclipse/OSGi knows about it. Easiest way to do this is add an entry into your plugin's plugin.xml file with the application registration:

Again, a very simple example:

<extension
point="org.eclipse.core.runtime.applications"
id="MyApplicationLoader">
<application>
<run
class="org.example.path.to.MyApplicationLoader">
</run>
</application>
</extension>

Now you should be able to right click on your project and "Run as Eclipse Application", which will cause the loader to get invoked. You'll probably have to fix the run configurations and maybe the OSGi plug-in relationships, but it should allow you to get full access to STEM's API.
Re: Web interface? [message #526792 is a reply to message #524059] Mon, 12 April 2010 22:27 Go to previous messageGo to next message
James Kaufman is currently offline James KaufmanFriend
Messages: 240
Registered: July 2009
Senior Member
Doug,
We are definitely planning to pursue a web interface but have a number of short term items to take care of first. Is this something you might be interested in participating in? Please let us know. Perhaps you might like to join our weekly call (please see the STEM wiki for instructions on how to get the number....)
Re: Web interface? [message #527193 is a reply to message #525562] Wed, 14 April 2010 12:23 Go to previous messageGo to next message
Werner Keil is currently offline Werner KeilFriend
Messages: 1087
Registered: July 2009
Senior Member
I know STEM is very specific in some areas, but generally looking at ways to
get RCP solutions behind a Web interface, the RAP project is a good place to
look.

Eclipse Babel offers rich web clients to define and manipulate messages of
Eclipse projects, but so far most of it doesn't use Eclipse building blocks.
It is mainly written in PHP like other parts of the Eclipse web site, not in
Java.

Werner
Re: Web interface? [message #528167 is a reply to message #526140] Mon, 19 April 2010 15:02 Go to previous messageGo to next message
Doug  is currently offline Doug Friend
Messages: 30
Registered: March 2010
Member
I've been out on travel and didn't get to it right away, but this was very helpful, and I have been able to create my headless version.

I am still working out the details, but I can export my own executable. I still haven't figured out how to access my pre-existing STEM projects/scenarios yet. I'll outline my method, let me know if I am heading the wrong way.

1) Export my project as Eclipse Product. It creates eclipse and repository folders, and the executable in the eclipse folder is named per my project, headlessSTEM.exe.
2) I copied the workspace folder from my official STEM release to the eclipse folder of my headless version. (This is probably wrong, as there is probably more to importing pre-existing projects, but is what I tried so far.)
3) The code for my application is based off of the example noted above. For now I have a loop reading strings from the command line arguments expected to be scenario names. I just have the project name fixed, then I construct the URI with the scenario name.

The code does not seem to be able to locate the project/scenario. The scenario name passed was "DougScenario.scenario". This is in the "scenarios" folder in the "US-Flu" folder in workspace. The error is:
Quote:
!ENTRY org.eclipse.stem.core 4 0 2010-04-19 09:28:10.347
!MESSAGE The serialized instance of an Identifiable at "platform:/resource/US-Flu/scenarios/DougScenario.scenario" was not found or was of the wrong format
!STACK 0
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.core.internal.resources.ResourceException: Resource '/US-Flu/scenarios/DougScenario.scenario' does not exist.


Relevant code trying to run the scenario:
		String projectName = "US-Flu";
		//String scenarioName = "DougScenario.scenario";
		for (String scenarioName: args) {
			// Get the internal URI to the Scenario resource file in the workspace
			URI scenarioUri = URI.createURI("platform:/resource/"+ projectName +"/scenarios/"+ scenarioName);
			System.out.println("Working Directory = " + System.getProperty("user.dir"));
			System.out.println("Scenario URI = "+scenarioUri.toString()+" ==> "+scenarioUri.path()+" ==> "+scenarioUri.toFileString());
			// Load the scenario from file
			Scenario scenario = (Scenario)Utility.getIdentifiable(scenarioUri);
			// Get the simulation manager
			SimulationManager mgr = SimulationManager.getManager();
			// Create/run  simulation from the given scenario
			mgr.createAndRunSimulation(scenario);
		}


I'll play with it more this week, but welcome any comments (especially if there is something obviously wrong Wink
Re: Web interface? [message #528795 is a reply to message #528167] Wed, 21 April 2010 19:01 Go to previous message
Matthew DavisFriend
Messages: 269
Registered: July 2009
Senior Member
Hi Doug,

First question is whether the US-Flu project and DougScenario scenario are visible in your official STEM instance's Project Explorer. You're right that you cannot just copy a folder into an Eclipse workspace and it show up, it must be done in a way that the workbench metadata is updated (either using the "Import" mechanism or by refreshing the workspace). If so, then you should be able to copy and paste the workspace as-is.

Second is to make sure your headless STEM instance is loading the correct workspace path. Normally it's ./workspace relative to the executable, but not always. You can override this by passing the -data parameter to headlessSTEM.exe with a path to your workspace. You might try specifying an absolute path just to make sure it's loading the correct workspace.

[Updated on: Wed, 21 April 2010 20:36]

Report message to a moderator

Re: Web interface? [message #563244 is a reply to message #525562] Thu, 08 April 2010 20:40 Go to previous message
Matthew DavisFriend
Messages: 269
Registered: July 2009
Senior Member
Hi Doug,

I suspect the problem here is launching as Java application. STEM has strong dependencies on the Eclipse environment that you only get when launching as an Eclipse application. If you launch, even in Eclipse, as "Java Application", it stills runs in the barebones JVM. To launch with STEM, it has to run in a JVM with the Eclipse/OSGi environment loaded and the Eclipse Workbench launched.

You can still do this headless-ly, it just requires writing the correct boilerplate to run as an Eclipse application - notable a launcher class that implements IApplication and the correct entry in plugin.xml.

First, take a look at the org.eclipse.equinox.app.IApplication interface:

http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/reference/api/org/eclipse/equinox/app/IApp lication.html

At the very least, the class implementing this interface contains a method that can act like a standard main(String[] args) to the Eclipse platform. There's generally much more to this, but you can get started here and run code directly from start(...).

After creating that class, you have to register it in the underlying Platform so Eclipse/OSGi knows about it. Easiest way to do this is add an entry into your plugin's plugin.xml file with the application registration:

Again, a very simple example:

<extension
point="org.eclipse.core.runtime.applications"
id="MyApplicationLoader">
<application>
<run
class="org.example.path.to.MyApplicationLoader">
</run>
</application>
</extension>

Now you should be able to right click on your project and "Run as Eclipse Application", which will cause the loader to get invoked. You'll probably have to fix the run configurations and maybe the OSGi plug-in relationships, but it should allow you to get full access to STEM's API.
Re: Web interface? [message #563269 is a reply to message #524059] Mon, 12 April 2010 22:27 Go to previous message
James Kaufman is currently offline James KaufmanFriend
Messages: 240
Registered: July 2009
Senior Member
Doug,
We are definitely planning to pursue a web interface but have a number of short term items to take care of first. Is this something you might be interested in participating in? Please let us know. Perhaps you might like to join our weekly call (please see the STEM wiki for instructions on how to get the number....)
Re: Web interface? [message #563291 is a reply to message #525562] Wed, 14 April 2010 12:23 Go to previous message
Werner Keil is currently offline Werner KeilFriend
Messages: 1087
Registered: July 2009
Senior Member
I know STEM is very specific in some areas, but generally looking at ways to
get RCP solutions behind a Web interface, the RAP project is a good place to
look.

Eclipse Babel offers rich web clients to define and manipulate messages of
Eclipse projects, but so far most of it doesn't use Eclipse building blocks.
It is mainly written in PHP like other parts of the Eclipse web site, not in
Java.

Werner
Re: Web interface? [message #563304 is a reply to message #526140] Mon, 19 April 2010 15:02 Go to previous message
Doug  is currently offline Doug Friend
Messages: 30
Registered: March 2010
Member
I've been out on travel and didn't get to it right away, but this was very helpful, and I have been able to create my headless version.

I am still working out the details, but I can export my own executable. I still haven't figured out how to access my pre-existing STEM projects/scenarios yet. I'll outline my method, let me know if I am heading the wrong way.

1) Export my project as Eclipse Product. It creates eclipse and repository folders, and the executable in the eclipse folder is named per my project, headlessSTEM.exe.
2) I copied the workspace folder from my official STEM release to the eclipse folder of my headless version. (This is probably wrong, as there is probably more to importing pre-existing projects, but is what I tried so far.)
3) The code for my application is based off of the example noted above. For now I have a loop reading strings from the command line arguments expected to be scenario names. I just have the project name fixed, then I construct the URI with the scenario name.

The code does not seem to be able to locate the project/scenario. The scenario name passed was "DougScenario.scenario". This is in the "scenarios" folder in the "US-Flu" folder in workspace. The error is:
Quote:
> !ENTRY org.eclipse.stem.core 4 0 2010-04-19 09:28:10.347
> !MESSAGE The serialized instance of an Identifiable at "platform:/resource/US-Flu/scenarios/DougScenario.scenario" was not found or was of the wrong format
> !STACK 0
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.core.internal.resources.ResourceException: Resource '/US-Flu/scenarios/DougScenario.scenario' does not exist.


Relevant code trying to run the scenario:

String projectName = "US-Flu";
//String scenarioName = "DougScenario.scenario";
for (String scenarioName: args) {
// Get the internal URI to the Scenario resource file in the workspace
URI scenarioUri = URI.createURI("platform:/resource/"+ projectName +"/scenarios/"+ scenarioName);
System.out.println("Working Directory = " + System.getProperty("user.dir"));
System.out.println("Scenario URI = "+scenarioUri.toString()+" ==> "+scenarioUri.path()+" ==> "+scenarioUri.toFileString());
// Load the scenario from file
Scenario scenario = (Scenario)Utility.getIdentifiable(scenarioUri);
// Get the simulation manager
SimulationManager mgr = SimulationManager.getManager();
// Create/run simulation from the given scenario
mgr.createAndRunSimulation(scenario);
}


I'll play with it more this week, but welcome any comments (especially if there is something obviously wrong ;)
Re: Web interface? [message #563360 is a reply to message #528167] Wed, 21 April 2010 19:01 Go to previous message
Matthew DavisFriend
Messages: 269
Registered: July 2009
Senior Member
Hi Doug,

First question is whether the US-Flu project and DougScenario scenario are visible in your official STEM instance's Project Explorer. You're right that you cannot just copy a folder into an Eclipse workspace and it show up, it must be done in a way that the workbench metadata is updated (either using the "Import" mechanism or by refreshing the workspace). If so, then you should be able to copy and paste the workspace as-is.

If so, make sure your headless STEM instance is loading the correct workspace path. Normally it's ./workspace relative to the executable, but not always. You can override this by passing the -data parameter to headlessSTEM.exe with a path to your workspace. You might try specifying an absolute path just to make sure it's loading the correct workspace.
Previous Topic:Build from Source Qs
Next Topic:Malaria
Goto Forum:
  


Current Time: Thu Mar 28 20:37:06 GMT 2024

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

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

Back to the top