Skip to content

Commit

Permalink
Merge pull request #131 from openworm/development
Browse files Browse the repository at this point in the history
Release 0.3.6
  • Loading branch information
tarelli authored Jun 6, 2017
2 parents 9711320 + fc49db6 commit e96bdff
Show file tree
Hide file tree
Showing 36 changed files with 938 additions and 320 deletions.
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
The MIT License (MIT)

Copyright (c) 2011, 2013 OpenWorm.
http://openworm.org
Copyright © 2011, 2017 Geppetto authors
http://geppetto.org

All rights reserved. This program and the accompanying materials
are made available under the terms of the MIT License
which accompanies this distribution, and is available at
http://opensource.org/licenses/MIT

Contributors:
OpenWorm - http://openworm.org/people.html
Geppetto - http://contributors.geppetto.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.geppetto</groupId>
<artifactId>core</artifactId>
<name>Geppetto Core Bundle</name>
<version>0.3.5</version>
<version>0.3.6</version>
<packaging>bundle</packaging>
<properties>
<github.global.server>github</github.global.server>
Expand Down Expand Up @@ -163,6 +163,11 @@
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
</dependency>
<dependency>
<groupId>uk.com.robust-it</groupId>
<artifactId>cloning</artifactId>
<version>1.9.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/geppetto/core/beans/PathConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ public static File createFolderInProjectTmpFolder(Scope scope, long projectId, S
return folder;
}

/**
* @param scope
* @param projectId
* @param folderName
* @return
*/
public static File createFolderInExperimentTmpFolder(Scope scope, long projectId, long experimentId, String instancePath, String folderName)
{
File folder = new File(createExperimentTmpPath(scope, projectId, experimentId, instancePath, folderName) + File.separator);
// createProjectTmpFolder creates only up to the project level, the following mkdir will create also folderName
folder.mkdir();
return folder;
}

public static URL getModelSchemaURL()
{
return PathConfiguration.class.getResource("/schema/geppettoModel/geppettoModelSchema.xsd");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/geppetto/core/common/HDF5Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static H5File readHDF5File(URL url, long projectId) throws GeppettoExecut
// https://github.com/jrmartin/hdf5-java-bindings/blob/master/src/main/java/ncsa/hdf/hdf5lib/H5.java#L2566

// The scope is CONNECTION since if we are reading a recording the simulation has already happened
url = URLReader.createLocalCopy(Scope.CONNECTION, projectId, url);
url = URLReader.createLocalCopy(Scope.CONNECTION, projectId, url, true);
}
H5File testFile = (H5File) fileFormat.createInstance(url.getPath(), FileFormat.READ);

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/geppetto/core/conversion/AConversion.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
package org.geppetto.core.conversion;

import org.geppetto.core.beans.PathConfiguration;
import org.geppetto.core.data.model.IExperiment;
import org.geppetto.core.services.AService;
import org.geppetto.model.ModelFormat;

Expand All @@ -45,6 +46,7 @@ public abstract class AConversion extends AService implements IConversion
{

protected boolean convertModel = true;
private IExperiment experiment;

public void checkSupportedFormat(ModelFormat input) throws ConversionException
{
Expand All @@ -64,4 +66,14 @@ public void setConvertModel(boolean convert)
this.convertModel = convert;
}

public void setExperiment(IExperiment experiment)
{
this.experiment=experiment;
}

public IExperiment getExperiment()
{
return this.experiment;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.geppetto.core.data.model.ISimulatorConfiguration;
import org.geppetto.core.data.model.IUser;
import org.geppetto.core.data.model.IUserGroup;
import org.geppetto.core.data.model.IView;
import org.geppetto.core.data.model.PersistedDataType;
import org.geppetto.core.data.model.ResultsFormat;
import org.geppetto.core.data.model.UserPrivileges;
Expand All @@ -71,9 +72,12 @@
import org.geppetto.core.data.model.local.LocalSimulatorConfiguration;
import org.geppetto.core.data.model.local.LocalUser;
import org.geppetto.core.data.model.local.LocalUserGroup;
import org.geppetto.core.data.model.local.LocalView;
import org.geppetto.core.utilities.LocalViewSerializer;
import org.springframework.http.HttpStatus;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class DefaultGeppettoDataManager implements IGeppettoDataManager
{
Expand Down Expand Up @@ -139,15 +143,16 @@ public IUser getUserByLogin(String login)

return user;
}

/*
* (non-Javadoc)
*
* @see org.geppetto.core.data.IGeppettoDataManager#getUserGroupById(long)
*/
@Override
public IUserGroup getUserGroupById(long id){
return getUserGroup();
public IUserGroup getUserGroupById(long id)
{
return getUserGroup();
}

/*
Expand Down Expand Up @@ -226,8 +231,6 @@ public List<? extends IExperiment> getExperimentsForProject(long projectId)
return project.getExperiments();
}



/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -256,8 +259,7 @@ public IExperiment newExperiment(String name, String description, IGeppettoProje
/*
* (non-Javadoc)
*
* @see org.geppetto.core.data.IGeppettoDataManager#cloneExperiment(java.lang.String, java.lang.String,
* org.geppetto.core.data.model.IGeppettoProject,org.geppetto.core.data.model.IExperiment)
* @see org.geppetto.core.data.IGeppettoDataManager#cloneExperiment(java.lang.String, java.lang.String, org.geppetto.core.data.model.IGeppettoProject,org.geppetto.core.data.model.IExperiment)
*/
@Override
public IExperiment cloneExperiment(String name, String description, IGeppettoProject project, IExperiment e)
Expand All @@ -268,7 +270,7 @@ public IExperiment cloneExperiment(String name, String description, IGeppettoPro
((LocalGeppettoProject) project).getExperiments().add(experiment);
return experiment;
}

/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -349,10 +351,15 @@ private void loadGeppettoProjects() throws IOException, URISyntaxException
@Override
public IGeppettoProject getProjectFromJson(Gson gson, String json)
{
LocalGeppettoProject project = gson.fromJson(json, LocalGeppettoProject.class);
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LocalGeppettoProject.class, new LocalViewSerializer());

LocalGeppettoProject project = gsonBuilder.create().fromJson(json, LocalGeppettoProject.class);
project.setId(getRandomId());
project.setVolatile(true);

if(project.getView()==null){
DataManagerHelper.getDataManager().newView(null, project);
}
// set project as parent for experiments
for(IExperiment e : project.getExperiments())
{
Expand All @@ -375,12 +382,18 @@ private long getRandomId()
* @see org.geppetto.core.data.IGeppettoDataManager#getProjectFromJson(com.google.gson.Gson, java.io.Reader)
*/
@Override
public IGeppettoProject getProjectFromJson(Gson gson, Reader json)
public IGeppettoProject getProjectFromJson(Gson gson, Reader json, String baseURL)
{
LocalGeppettoProject project = gson.fromJson(json, LocalGeppettoProject.class);
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LocalGeppettoProject.class, new LocalViewSerializer());

LocalGeppettoProject project = gsonBuilder.create().fromJson(json, LocalGeppettoProject.class);
project.setId(getRandomId());
project.setVolatile(true);

project.setBaseURL(baseURL);
if(project.getView()==null){
DataManagerHelper.getDataManager().newView(null, project);
}
// set project as parent for experiments
for(IExperiment e : project.getExperiments())
{
Expand All @@ -399,8 +412,7 @@ public IGeppettoProject getProjectFromJson(Gson gson, Reader json)
@Override
public void clearWatchedVariables(IAspectConfiguration aspectConfig)
{
// TODO Auto-generated method stub

// Cannot do watch without db, cannot clear watched
}

@Override
Expand Down Expand Up @@ -436,16 +448,15 @@ public void saveEntity(IGeppettoProject entity)
@Override
public IAspectConfiguration newAspectConfiguration(IExperiment experiment, String instancePath, ISimulatorConfiguration simulatorConfiguration)
{
LocalAspectConfiguration ac = new LocalAspectConfiguration(0l, instancePath, new ArrayList<String>(), new ArrayList<LocalParameter>(),
(LocalSimulatorConfiguration) simulatorConfiguration);
LocalAspectConfiguration ac = new LocalAspectConfiguration(0l, instancePath, new ArrayList<String>(), new ArrayList<LocalParameter>(), (LocalSimulatorConfiguration) simulatorConfiguration);
((LocalExperiment) experiment).getAspectConfigurations().add(ac);
return ac;
}

@Override
public ISimulatorConfiguration newSimulatorConfiguration(String simulator, String conversionService, float timestep, float length,Map<String, String> parameters)
public ISimulatorConfiguration newSimulatorConfiguration(String simulator, String conversionService, float timestep, float length, Map<String, String> parameters)
{
return new LocalSimulatorConfiguration(0l, simulator, conversionService, timestep, length,parameters);
return new LocalSimulatorConfiguration(0l, simulator, conversionService, timestep, length, parameters);
}

@Override
Expand Down Expand Up @@ -489,9 +500,25 @@ private static IUserGroup getUserGroup()
}

@Override
public void makeGeppettoProjectPublic(long projectId, boolean isPublic)
throws GeppettoExecutionException {
public void makeGeppettoProjectPublic(long projectId, boolean isPublic) throws GeppettoExecutionException
{
// TODO Auto-generated method stub


}

@Override
public IView newView(String view, IExperiment experiment)
{
IView v = new LocalView(1, view);
experiment.setView(v);
return v;
}

@Override
public IView newView(String view, IGeppettoProject project)
{
IView v = new LocalView(1, view);
project.setView(v);
return v;
}
}
14 changes: 11 additions & 3 deletions src/main/java/org/geppetto/core/data/FindLocalProjectsVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@

import org.geppetto.core.data.model.IExperiment;
import org.geppetto.core.data.model.IGeppettoProject;
import org.geppetto.core.data.model.IView;
import org.geppetto.core.data.model.local.LocalGeppettoProject;
import org.geppetto.core.data.model.local.LocalView;
import org.geppetto.core.utilities.LocalViewSerializer;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -85,10 +89,14 @@ public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationConte
}

});
Gson gson = builder.create();

BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8);
T project = gson.fromJson(reader, type);

builder.registerTypeAdapter(LocalGeppettoProject.class, new LocalViewSerializer());
T project = builder.create().fromJson(reader, type);
if(project.getView() == null)
{
project.setView(new LocalView(0, null));
}
for(IExperiment e : project.getExperiments())
{
e.setParentProject(project);
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/org/geppetto/core/data/IGeppettoDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.geppetto.core.data.model.ISimulatorConfiguration;
import org.geppetto.core.data.model.IUser;
import org.geppetto.core.data.model.IUserGroup;
import org.geppetto.core.data.model.IView;
import org.geppetto.core.data.model.PersistedDataType;
import org.geppetto.core.data.model.ResultsFormat;
import org.geppetto.core.data.model.UserPrivileges;
Expand Down Expand Up @@ -82,7 +83,7 @@ public interface IGeppettoDataManager

IGeppettoProject getProjectFromJson(Gson gson, String json);

IGeppettoProject getProjectFromJson(Gson gson, Reader json);
IGeppettoProject getProjectFromJson(Gson gson, Reader json, String baseURL);

List<? extends IExperiment> getExperimentsForProject(long projectId);

Expand All @@ -95,6 +96,10 @@ public interface IGeppettoDataManager
IParameter newParameter(String parameterPath, String value);

IExperiment newExperiment(String name, String description, IGeppettoProject project);

IView newView(String view, IGeppettoProject project);

IView newView(String view, IExperiment experiment);

IUser newUser(String name, String password, boolean persistent, IUserGroup group);

Expand Down Expand Up @@ -123,5 +128,7 @@ public interface IGeppettoDataManager
void saveEntity(IGeppettoProject entity);

IExperiment cloneExperiment(String name, String description,
IGeppettoProject project, IExperiment originalExperiment);
IGeppettoProject project, IExperiment originalExperiment);


}
4 changes: 4 additions & 0 deletions src/main/java/org/geppetto/core/data/model/IExperiment.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ public interface IExperiment extends IDataEntity
void updateEndDate();

boolean isPublic();

void setView(IView view);

IView getView();
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ public interface IGeppettoProject extends IDataEntity
void setVolatile(boolean volatileProject);

boolean isPublic();

void setView(IView view);

IView getView();

String getBaseURL();

void setBaseURL(String baseURL);
}
13 changes: 13 additions & 0 deletions src/main/java/org/geppetto/core/data/model/IView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.geppetto.core.data.model;

public interface IView {


long getId();

String getView();

void setView(String string);


}
Loading

0 comments on commit e96bdff

Please sign in to comment.