Search in sources :

Example 1 with WorkflowTask

use of com.graphaware.nlp.workflow.task.WorkflowTask in project neo4j-nlp by graphaware.

the class WorkflowTaskProcedure method stop.

@Procedure(name = "ga.nlp.workflow.task.stop", mode = Mode.WRITE)
@Description("Start a Task")
public Stream<WorkflowInstanceItemInfo> stop(@Name(value = "name") String name) {
    try {
        WorkflowTask workflowTask = getWorkflowManager().getWorkflowTask(name);
        if (workflowTask == null) {
            throw new RuntimeException("Pipeline task not found");
        }
        TaskManager.getInstance().stop(workflowTask);
        return Stream.of(workflowTask.getInfo());
    } catch (Exception e) {
        LOG.error("ERROR in WorkflowTaskProcedure", e);
        throw new RuntimeException(e);
    }
}
Also used : WorkflowTask(com.graphaware.nlp.workflow.task.WorkflowTask) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 2 with WorkflowTask

use of com.graphaware.nlp.workflow.task.WorkflowTask in project neo4j-nlp by graphaware.

the class DynamicConfigurationTest method testLoadingInstances.

@Test
public void testLoadingInstances() throws Exception {
    resetSingleton();
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
    keyValueStore = new GraphKeyValueStore(getDatabase());
    WorkflowTask workflowInput = new WorkflowTask("test", getDatabase());
    DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
    HashMap<String, Object> properties = new HashMap<>();
    properties.put(WorkflowTaskConfiguration.WORFKLOW_INPUT_NAME, "");
    properties.put(WorkflowTaskConfiguration.WORFKLOW_OUTPUT_NAME, "");
    properties.put(WorkflowTaskConfiguration.WORFKLOW_PROCESSOR_NAME, "");
    workflowInput.setConfiguration(new WorkflowTaskConfiguration(properties));
    try (Transaction tx = getDatabase().beginTx()) {
        configuration.storeWorkflowInstanceItem(workflowInput);
        tx.success();
    }
    List<WorkflowInstanceItemInfo> pipelineInstanceItems = configuration.loadPipelineInstanceItems(WorkflowTask.WORFKLOW_TASK_KEY_PREFIX);
    assertTrue(pipelineInstanceItems.size() == 1);
    WorkflowInstanceItemInfo info = pipelineInstanceItems.get(0);
    assertTrue(info instanceof WorkflowTaskInstanceItemInfo);
    assertEquals("test", info.getName());
    assertEquals("com.graphaware.nlp.workflow.task.WorkflowTask", info.getClassName());
}
Also used : WorkflowTaskInstanceItemInfo(com.graphaware.nlp.workflow.task.WorkflowTaskInstanceItemInfo) WorkflowTaskConfiguration(com.graphaware.nlp.workflow.task.WorkflowTaskConfiguration) HashMap(java.util.HashMap) WorkflowTask(com.graphaware.nlp.workflow.task.WorkflowTask) WorkflowInstanceItemInfo(com.graphaware.nlp.dsl.result.WorkflowInstanceItemInfo) Transaction(org.neo4j.graphdb.Transaction) GraphKeyValueStore(com.graphaware.common.kv.GraphKeyValueStore) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) EmbeddedDatabaseIntegrationTest(com.graphaware.test.integration.EmbeddedDatabaseIntegrationTest) Test(org.junit.Test)

Example 3 with WorkflowTask

use of com.graphaware.nlp.workflow.task.WorkflowTask in project neo4j-nlp by graphaware.

the class WorkflowTaskProcedure method start.

@Procedure(name = "ga.nlp.workflow.task.start", mode = Mode.WRITE)
@Description("Start a Task")
public Stream<WorkflowTaskResult> start(@Name(value = "name") String name) {
    try {
        WorkflowTask workflowTask = getWorkflowManager().getWorkflowTask(name);
        if (workflowTask == null) {
            throw new RuntimeException("Pipeline task not found");
        }
        TaskManager.getInstance().execute(workflowTask);
        return Stream.of(new WorkflowTaskResult(workflowTask));
    } catch (Exception e) {
        LOG.error("ERROR in WorkflowTaskProcedure", e);
        throw new RuntimeException(e);
    }
}
Also used : WorkflowTask(com.graphaware.nlp.workflow.task.WorkflowTask) WorkflowTaskResult(com.graphaware.nlp.dsl.result.WorkflowTaskResult) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Aggregations

WorkflowTask (com.graphaware.nlp.workflow.task.WorkflowTask)3 Description (org.neo4j.procedure.Description)2 Procedure (org.neo4j.procedure.Procedure)2 GraphKeyValueStore (com.graphaware.common.kv.GraphKeyValueStore)1 WorkflowInstanceItemInfo (com.graphaware.nlp.dsl.result.WorkflowInstanceItemInfo)1 WorkflowTaskResult (com.graphaware.nlp.dsl.result.WorkflowTaskResult)1 WorkflowTaskConfiguration (com.graphaware.nlp.workflow.task.WorkflowTaskConfiguration)1 WorkflowTaskInstanceItemInfo (com.graphaware.nlp.workflow.task.WorkflowTaskInstanceItemInfo)1 EmbeddedDatabaseIntegrationTest (com.graphaware.test.integration.EmbeddedDatabaseIntegrationTest)1 HashMap (java.util.HashMap)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Test (org.junit.Test)1 Transaction (org.neo4j.graphdb.Transaction)1