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:
parent
0af250d1b7
commit
31c2ac2bfc
@ -129,7 +129,7 @@ public abstract class GridworksBroker extends ButterflyModuleImpl {
|
|||||||
} else if (START.equals(path)) {
|
} else if (START.equals(path)) {
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setHeader("Content-Type", "application/json");
|
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)) {
|
} else if (OPEN.equals(path)) {
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setHeader("Content-Type", "application/json");
|
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 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;
|
protected abstract void addTransformations(HttpServletResponse response, String pid, String uid, String lock, List<String> transformations) throws Exception;
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ public class GridworksBrokerImpl extends GridworksBroker {
|
|||||||
// ----------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@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);
|
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");
|
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();
|
txn.commit();
|
||||||
} finally {
|
} finally {
|
||||||
if (txn != null) {
|
if (txn != null) {
|
||||||
@ -478,7 +478,7 @@ public class GridworksBrokerImpl extends GridworksBroker {
|
|||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
String pid;
|
String pid;
|
||||||
|
|
||||||
List<String> transformations = new ArrayList<String>();
|
List<String> transformations;
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
|
|
||||||
@ -486,11 +486,12 @@ public class GridworksBrokerImpl extends GridworksBroker {
|
|||||||
|
|
||||||
int rev;
|
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.pid = pid;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
this.rev = rev;
|
this.transformations = (transformations != null) ? transformations : new ArrayList<String>();
|
||||||
|
this.rev = this.transformations.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@ -291,6 +291,7 @@ public class GridworksBrokerTests {
|
|||||||
String user2 = "testuser2";
|
String user2 = "testuser2";
|
||||||
String data = "blah";
|
String data = "blah";
|
||||||
String metadata = "{}";
|
String metadata = "{}";
|
||||||
|
String transformations = "[]";
|
||||||
String rev = "0";
|
String rev = "0";
|
||||||
|
|
||||||
logger.info("--- obtain ALL lock on project ---");
|
logger.info("--- obtain ALL lock on project ---");
|
||||||
@ -299,7 +300,7 @@ public class GridworksBrokerTests {
|
|||||||
String lock = result.getString("lock");
|
String lock = result.getString("lock");
|
||||||
|
|
||||||
logger.info("--- start project ---");
|
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 ---");
|
logger.info("--- verify project state contains lock ---");
|
||||||
result = success(broker, request, response, GET_STATE, "pid", project, "uid", user, "rev", rev);
|
result = success(broker, request, response, GET_STATE, "pid", project, "uid", user, "rev", rev);
|
||||||
|
Loading…
Reference in New Issue
Block a user