adding the ability to start a project with existing transformations

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1079 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-07-07 08:11:40 +00:00
parent 0af250d1b7
commit 31c2ac2bfc
3 changed files with 10 additions and 8 deletions

View File

@ -129,7 +129,7 @@ public abstract class GridworksBroker extends ButterflyModuleImpl {
} else if (START.equals(path)) {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
startProject(response, getParameter(request, "pid"), getUserId(request), getParameter(request, "lock"), getData(request), getParameter(request, "metadata"), getInteger(request, "rev"));
startProject(response, getParameter(request, "pid"), getUserId(request), getParameter(request, "lock"), getData(request), getParameter(request, "metadata"), getList(request, "transformations"));
} else if (OPEN.equals(path)) {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
@ -165,7 +165,7 @@ public abstract class GridworksBroker extends ButterflyModuleImpl {
protected abstract void releaseLock(HttpServletResponse response, String pid, String uid, String lock) throws Exception;
protected abstract void startProject(HttpServletResponse response, String pid, String uid, String lock, byte[] data, String metadata, int rev) throws Exception;
protected abstract void startProject(HttpServletResponse response, String pid, String uid, String lock, byte[] data, String metadata, List<String> transformations) throws Exception;
protected abstract void addTransformations(HttpServletResponse response, String pid, String uid, String lock, List<String> transformations) throws Exception;

View File

@ -308,7 +308,7 @@ public class GridworksBrokerImpl extends GridworksBroker {
// ----------------------------------------------------------------------------------------------------
@Override
protected void startProject(HttpServletResponse response, String pid, String uid, String lid, byte[] data, String metadata, int rev) throws Exception {
protected void startProject(HttpServletResponse response, String pid, String uid, String lid, byte[] data, String metadata, List<String> transformations) throws Exception {
Transaction txn = env.beginTransaction(null, null);
@ -323,7 +323,7 @@ public class GridworksBrokerImpl extends GridworksBroker {
throw new RuntimeException("The lock you have is not enough to start a project");
}
projectById.put(txn, new Project(pid, data, metadata, rev));
projectById.put(txn, new Project(pid, data, metadata, transformations));
txn.commit();
} finally {
if (txn != null) {
@ -478,7 +478,7 @@ public class GridworksBrokerImpl extends GridworksBroker {
@PrimaryKey
String pid;
List<String> transformations = new ArrayList<String>();
List<String> transformations;
byte[] data;
@ -486,11 +486,12 @@ public class GridworksBrokerImpl extends GridworksBroker {
int rev;
Project(String pid, byte[] data, String metadata, int rev) {
Project(String pid, byte[] data, String metadata, List<String> transformations) {
this.pid = pid;
this.data = data;
this.metadata = metadata;
this.rev = rev;
this.transformations = (transformations != null) ? transformations : new ArrayList<String>();
this.rev = this.transformations.size();
}
@SuppressWarnings("unused")

View File

@ -291,6 +291,7 @@ public class GridworksBrokerTests {
String user2 = "testuser2";
String data = "blah";
String metadata = "{}";
String transformations = "[]";
String rev = "0";
logger.info("--- obtain ALL lock on project ---");
@ -299,7 +300,7 @@ public class GridworksBrokerTests {
String lock = result.getString("lock");
logger.info("--- start project ---");
success(broker, request, response, START, "pid", project, "uid", user, "lock", lock, "data", data, "metadata", metadata, "rev", rev);
success(broker, request, response, START, "pid", project, "uid", user, "lock", lock, "data", data, "metadata", metadata, "transformations", transformations);
logger.info("--- verify project state contains lock ---");
result = success(broker, request, response, GET_STATE, "pid", project, "uid", user, "rev", rev);