use of edu.harvard.iq.dataverse.workflow.Workflow in project dataverse by IQSS.
the class WorkflowsAdmin method setDefault.
@Path("default/{triggerType}")
@PUT
public Response setDefault(@PathParam("triggerType") String triggerType, String identifier) {
try {
long idtf = Long.parseLong(identifier.trim());
TriggerType tt = TriggerType.valueOf(triggerType);
Optional<Workflow> wf = workflows.getWorkflow(idtf);
if (wf.isPresent()) {
workflows.setDefaultWorkflowId(tt, idtf);
return ok("Default workflow id for trigger " + tt.name() + " set to " + idtf);
} else {
return notFound("Can't find workflow with id " + idtf);
}
} catch (NumberFormatException nfe) {
return badRequest("workflow identifier has to be numeric.");
} catch (IllegalArgumentException iae) {
return badRequest("Unknown trigger type '" + triggerType + "'. Available triggers: " + Arrays.toString(TriggerType.values()));
}
}
use of edu.harvard.iq.dataverse.workflow.Workflow in project dataverse by IQSS.
the class WorkflowsAdmin method addWorkflow.
@POST
public Response addWorkflow(JsonObject jsonWorkflow) {
JsonParser jp = new JsonParser();
try {
Workflow wf = jp.parseWorkflow(jsonWorkflow);
Workflow managedWf = workflows.save(wf);
return created("/admin/workflows/" + managedWf.getId(), json(managedWf));
} catch (JsonParseException ex) {
return badRequest("Can't parse Json: " + ex.getMessage());
}
}
use of edu.harvard.iq.dataverse.workflow.Workflow in project dataverse by IQSS.
the class BriefJsonPrinterTest method testJson_Workflow.
/**
* Test of json method, of class BriefJsonPrinter.
*/
@Test
public void testJson_Workflow() {
Workflow wf = new Workflow();
wf.setId(1l);
wf.setName("Name");
BriefJsonPrinter sut = new BriefJsonPrinter();
JsonObject res = sut.json(wf).build();
assertEquals("Name", res.getString("name"));
assertEquals(1, res.getInt("id"));
assertEquals(2, res.keySet().size());
}
use of edu.harvard.iq.dataverse.workflow.Workflow in project dataverse by IQSS.
the class JsonParser method parseWorkflow.
public Workflow parseWorkflow(JsonObject json) throws JsonParseException {
Workflow retVal = new Workflow();
validate("", json, "name", ValueType.STRING);
validate("", json, "steps", ValueType.ARRAY);
retVal.setName(json.getString("name"));
JsonArray stepArray = json.getJsonArray("steps");
List<WorkflowStepData> steps = new ArrayList<>(stepArray.size());
for (JsonValue jv : stepArray) {
steps.add(parseStepData((JsonObject) jv));
}
retVal.setSteps(steps);
return retVal;
}
Aggregations