Skip to content

Commit

Permalink
Merge pull request #347 from openworm/development
Browse files Browse the repository at this point in the history
Release 0.2.6
  • Loading branch information
tarelli committed Oct 10, 2015
2 parents ea3aecf + 91daef3 commit 71af403
Show file tree
Hide file tree
Showing 48 changed files with 3,902 additions and 1,564 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ src/main/webapp/css/main.css
.idea/
*.iml
*~
.imdone/
/.externalToolBuilders/
/.settings/
.classpath
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.geppetto</groupId>
<artifactId>frontend</artifactId>
<version>0.2.5</version>
<version>0.2.6</version>
<name>Geppetto Frontend</name>
<packaging>war</packaging>
<properties>
Expand Down
41 changes: 38 additions & 3 deletions src/main/java/org/geppetto/frontend/controllers/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,47 @@ else if(geppettoManager.getUser() == null)
return "redirect:http://geppetto.org";
}

@RequestMapping(value = "/GeppettoTests.html", method = RequestMethod.GET)
public String test()
@RequestMapping(value = "/GeppettoNeuronalTests.html", method = RequestMethod.GET)
public String testNeuronal()
{
return "dist/geppettotests";
return "dist/GeppettoNeuronalTests";
}

@RequestMapping(value = "/GeppettoNeuronalSimulationTests.html", method = RequestMethod.GET)
public String testNeuronalSimulation()
{
return "dist/GeppettoNeuronalSimulationTests";
}

@RequestMapping(value = "/GeppettoCoreTests.html", method = RequestMethod.GET)
public String testCore()
{
return "dist/GeppettoCoreTests";
}

@RequestMapping(value = "/GeppettoPersistenceTests.html", method = RequestMethod.GET)
public String testPersistence()
{
return "dist/GeppettoPersistenceTests";
}

@RequestMapping(value = "/GeppettoFluidDynamicsTests.html", method = RequestMethod.GET)
public String testFluidDynamics()
{
return "dist/GeppettoFluidDynamicsTests";
}

@RequestMapping(value = "/GeppettoAllTests.html", method = RequestMethod.GET)
public String runTests()
{
return "dist/GeppettoAllTests";
}

@RequestMapping(value = "/tests.html", method = RequestMethod.GET)
public String tests()
{
return "dist/Tests";
}

@RequestMapping(value = "/", method = RequestMethod.GET)
public String dashboard()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ public void loadProjectFromId(String requestID, long projectId, long experimentI
try
{
IGeppettoProject geppettoProject = dataManager.getGeppettoProjectById(projectId);
loadGeppettoProject(requestID, geppettoProject, experimentId);
if(geppettoProject == null){
websocketConnection.sendMessage(requestID, OutboundMessages.ERROR_LOADING_PROJECT, "Project not found");
}else{
loadGeppettoProject(requestID, geppettoProject, experimentId);
}
}
catch(NumberFormatException e)
{
Expand Down Expand Up @@ -203,7 +207,7 @@ public void newExperiment(String requestID, long projectId)
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
}
else
{
Expand Down Expand Up @@ -269,13 +273,13 @@ public void runExperiment(String requestID, long experimentID, long projectId)
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
}
IGeppettoProject geppettoProject = retrieveGeppettoProject(projectId);
IExperiment experiment = retrieveExperiment(experimentID, geppettoProject);
if(geppettoProject.isVolatile())
{
info(Resources.VOLATILE_PROJECT.toString());
info(requestID,Resources.VOLATILE_PROJECT.toString());
return;
}
else
Expand Down Expand Up @@ -312,7 +316,7 @@ public void setWatchedVariables(String requestID, List<String> variables, long e
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
}
else
{
Expand Down Expand Up @@ -520,6 +524,7 @@ public void downloadModel(String requestID, String aspectInstancePath, String fo

// Send zip file to the client
websocketConnection.sendBinaryMessage(requestID, path);
websocketConnection.sendMessage(requestID, OutboundMessages.DOWNLOAD_MODEL, "");
}
}
catch(GeppettoExecutionException | IOException e)
Expand Down Expand Up @@ -601,14 +606,14 @@ public void setParameters(String requestID, String modelPath, Map<String, String
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
return;
}
IGeppettoProject geppettoProject = retrieveGeppettoProject(projectId);
IExperiment experiment = retrieveExperiment(experimentID, geppettoProject);
if(geppettoProject.isVolatile())
{
info(Resources.VOLATILE_PROJECT.toString());
info(requestID,Resources.VOLATILE_PROJECT.toString());
return;
}
else
Expand Down Expand Up @@ -737,13 +742,14 @@ private void error(Exception exception, String errorMessage)
}

/**
* @param requestID
* @param exception
* @param errorMessage
*/
private void info(String message)
private void info(String requestID, String message)
{
logger.info(message);
websocketConnection.sendMessage(null, OutboundMessages.INFO_MESSAGE, getGson().toJson(message));
websocketConnection.sendMessage(requestID, OutboundMessages.INFO_MESSAGE, getGson().toJson(message));

}

Expand Down Expand Up @@ -806,7 +812,7 @@ public void deleteExperiment(String requestID, long experimentId, long projectId
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
}
else
{
Expand Down Expand Up @@ -841,7 +847,7 @@ public void persistProject(String requestID, long projectId)
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
}
else
{
Expand Down Expand Up @@ -930,7 +936,7 @@ public void uploadModel(String aspectPath, long projectId, long experimentId, St
try
{
geppettoManager.uploadModelToDropBox(aspectPath, experiment, geppettoProject, modelFormat);
websocketConnection.sendMessage(null, OutboundMessages.RESULTS_UPLOADED, null);
websocketConnection.sendMessage(null, OutboundMessages.MODEL_UPLOADED, null);
}
catch(Exception e)
{
Expand Down Expand Up @@ -976,7 +982,7 @@ public void downloadResults(String requestID, String aspectPath, long projectId,
{
if(resultsFormat == null)
{
websocketConnection.sendMessage(requestID, OutboundMessages.ERROR_DOWNLOADING_MODEL, "");
websocketConnection.sendMessage(requestID, OutboundMessages.ERROR_DOWNLOADING_RESULTS, "");
}
else
{
Expand All @@ -991,6 +997,7 @@ public void downloadResults(String requestID, String aspectPath, long projectId,

// Send zip file to the client
websocketConnection.sendBinaryMessage(requestID, path);
websocketConnection.sendMessage(requestID, OutboundMessages.DOWNLOAD_RESULTS, "");
}
else
{
Expand All @@ -1013,29 +1020,32 @@ public void saveProjectProperties(String requestID, long projectId, Map<String,
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
}
IGeppettoProject geppettoProject = retrieveGeppettoProject(projectId);
if(geppettoProject.isVolatile())
{
info(Resources.VOLATILE_PROJECT.toString());
info(requestID,Resources.VOLATILE_PROJECT.toString());
return;
}
else
{
IGeppettoDataManager dataManager = DataManagerHelper.getDataManager();
for(String p : properties.keySet())
{
switch(p)
if(properties!=null){
for(String p : properties.keySet())
{
switch(p)
{
case "name":
{
geppettoProject.setName(properties.get(p));
break;
}
}
}
}
dataManager.saveEntity(geppettoProject);
websocketConnection.sendMessage(requestID, OutboundMessages.PROJECT_PROPS_SAVED, "");
}
}

Expand All @@ -1049,13 +1059,13 @@ public void saveExperimentProperties(String requestID, long projectId, long expe
{
if(DataManagerHelper.getDataManager().isDefault())
{
info(Resources.UNSUPPORTED_OPERATION.toString());
info(requestID,Resources.UNSUPPORTED_OPERATION.toString());
}
IGeppettoProject geppettoProject = retrieveGeppettoProject(projectId);
IExperiment experiment = retrieveExperiment(experimentId, geppettoProject);
if(geppettoProject.isVolatile())
{
info(Resources.VOLATILE_PROJECT.toString());
info(requestID,Resources.VOLATILE_PROJECT.toString());
return;
}
else
Expand Down Expand Up @@ -1204,7 +1214,7 @@ public void setConnectionProject(IGeppettoProject geppettoProject) throws Geppet
{
if(this.geppettoProject != null)
{
geppettoManager.closeProject(null, geppettoProject);
geppettoManager.closeProject(null, this.geppettoProject);
}
this.geppettoProject = geppettoProject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.geppetto.core.data.model.ExperimentStatus;
import org.geppetto.core.data.model.IExperiment;
import org.geppetto.core.data.model.IGeppettoProject;
import org.geppetto.core.data.model.IPersistedData;
import org.geppetto.core.data.model.ISimulationResult;
import org.geppetto.core.data.model.IUser;
import org.geppetto.core.data.model.ResultsFormat;
Expand Down Expand Up @@ -518,7 +519,9 @@ public URL downloadResults(String aspectPath, ResultsFormat resultsFormat, IExpe
{
try
{
return URLReader.getURL(result.getResult().getUrl());
IPersistedData resultObject = result.getResult();
String url = resultObject.getUrl();
return URLReader.getURL(url);
}
catch(Exception e)
{
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/geppetto/frontend/controllers/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

package org.geppetto.frontend.controllers;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.SecurityUtils;
Expand All @@ -48,6 +52,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class Login
Expand All @@ -63,7 +68,8 @@ public Login()
}

@RequestMapping(value = "/login", method = {RequestMethod.GET, RequestMethod.POST})
public String login(@RequestParam String username, @RequestParam String password, @RequestParam(defaultValue="",required=false) String url)
public @ResponseBody
IUser login(@RequestParam String username, @RequestParam String password, @RequestParam(defaultValue="",required=false) String url, @RequestParam(defaultValue="web",required=false) String outputFormat, HttpServletResponse response) throws IOException
{
IGeppettoDataManager dataManager = DataManagerHelper.getDataManager();
if(!dataManager.isDefault())
Expand All @@ -84,7 +90,9 @@ public String login(@RequestParam String username, @RequestParam String password
logger.error(e);
}
}
return "redirect:/" + url;
if (outputFormat.equals("web"))
response.sendRedirect("/" + url);
return geppettoManager.getUser();
}

@RequestMapping(value = "/logout", method = RequestMethod.GET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
import org.geppetto.core.data.model.IGeppettoProject;
import org.geppetto.core.manager.Scope;
import org.geppetto.core.model.IModelInterpreter;
import org.geppetto.core.model.simulation.Model;
import org.geppetto.core.model.simulation.visitor.BaseVisitor;
import org.geppetto.core.model.simulation.visitor.TraversingVisitor;
import org.geppetto.core.model.geppettomodel.Model;
import org.geppetto.core.model.geppettomodel.visitor.BaseVisitor;
import org.geppetto.core.model.geppettomodel.visitor.TraversingVisitor;
import org.geppetto.core.model.state.visitors.DepthFirstTraverserEntitiesFirst;
import org.geppetto.core.s3.S3Manager;
import org.geppetto.core.utilities.URLReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.geppetto.core.data.IGeppettoDataManager;
import org.geppetto.core.data.model.IGeppettoProject;
import org.geppetto.core.manager.IGeppettoManager;
import org.geppetto.core.model.simulation.GeppettoModel;
import org.geppetto.core.model.geppettomodel.GeppettoModel;
import org.geppetto.core.utilities.URLReader;
import org.geppetto.simulation.GeppettoModelReader;
import org.geppetto.simulation.visitor.PopulateModelReferencesVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ IUser addNewUser(@RequestParam String username, @RequestParam String password)
return user;
}

@RequestMapping(value = "/setPassword", method = RequestMethod.GET)
public @ResponseBody
IUser setPassword(@RequestParam String username, @RequestParam String oldPassword, @RequestParam String newPassword)
{
IGeppettoDataManager manager = DataManagerHelper.getDataManager();
IUser user = manager.getUserByLogin(username);
if (user != null && user.getPassword().equals(oldPassword)){
return manager.updateUser(user, newPassword);
}
else{
return null;
}
}

private IUser getGuestUser()
{
synchronized(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public enum InboundMessages {
UNLINK_DROPBOX("unlink_drobpox"),
UPLOAD_MODEL("upload_model"),
UPLOAD_RESULTS("upload_results"),
DOWNLOAD_RESULTS("download_results");
DOWNLOAD_RESULTS("download_results"), GEPPETTO_PERSISTENCE("geppetto_persistence");


private InboundMessages(final String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public enum OutboundMessages {
DELETE_EXPERIMENT("experiment_deleted"),
PLAY_EXPERIMENT("play_experiment"),
PROJECT_PERSISTED("project_persisted"),
PROJECT_PROPS_SAVED("project_props_saved"),
DROPBOX_LINKED("dropbox_linked"),
DROPBOX_UNLINKED("dropbox_unlinked"),
RESULTS_UPLOADED("results_uploaded"),
Expand Down
Loading

0 comments on commit 71af403

Please sign in to comment.