Search in sources :

Example 1 with WorkflowService

use of org.onosproject.workflow.api.WorkflowService in project onos by opennetworkinglab.

the class WorkplaceStoreCommand method rmWorkplace.

/**
 * Removes workplace.
 * @param name workplace name to remove
 */
private void rmWorkplace(String name) {
    WorkflowService service = get(WorkflowService.class);
    try {
        DefaultWorkplaceDescription wpDesc = DefaultWorkplaceDescription.builder().name(name).build();
        service.removeWorkplace(wpDesc);
    } catch (WorkflowException e) {
        error(e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
    }
}
Also used : DefaultWorkplaceDescription(org.onosproject.workflow.api.DefaultWorkplaceDescription) WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException)

Example 2 with WorkflowService

use of org.onosproject.workflow.api.WorkflowService in project onos by opennetworkinglab.

the class WorkFlowTestCommand method defineInvalidWorkflow.

private void defineInvalidWorkflow() {
    WorkflowService service = get(WorkflowService.class);
    try {
        URI uri = URI.create("sample.workflow-invalid-datamodel-type");
        Workflow workflow = ImmutableListWorkflow.builder().id(uri).chain(SampleWorkflow.SampleWorklet5.class.getName()).chain(SampleWorkflow.SampleWorklet6.class.getName()).build();
        service.register(workflow);
    } catch (WorkflowException e) {
        error(e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
    }
}
Also used : WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException) SampleWorkflow(org.onosproject.workflow.impl.example.SampleWorkflow) Workflow(org.onosproject.workflow.api.Workflow) SampleWorkflow(org.onosproject.workflow.impl.example.SampleWorkflow) ImmutableListWorkflow(org.onosproject.workflow.api.ImmutableListWorkflow) URI(java.net.URI)

Example 3 with WorkflowService

use of org.onosproject.workflow.api.WorkflowService in project onos by opennetworkinglab.

the class WorkFlowTestCommand method invoke.

/**
 * Invokes workflow.
 *
 * @param workflowId    workflow id
 * @param workplaceName workplace name
 */
private void invoke(String workflowId, String workplaceName) {
    WorkflowService service = get(WorkflowService.class);
    ObjectNode dataModel = JsonNodeFactory.instance.objectNode();
    dataModel.put("count", 0);
    try {
        DefaultWorkflowDescription wfDesc = DefaultWorkflowDescription.builder().workplaceName(workplaceName).id(workflowId).data(dataModel).build();
        service.invokeWorkflow(wfDesc);
    } catch (WorkflowException e) {
        error(e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException) DefaultWorkflowDescription(org.onosproject.workflow.api.DefaultWorkflowDescription)

Example 4 with WorkflowService

use of org.onosproject.workflow.api.WorkflowService in project onos by opennetworkinglab.

the class WorkplaceStoreCommand method addEmptyWorkplace.

/**
 * Adds empty workplace.
 * @param name workplace name
 */
private void addEmptyWorkplace(String name) {
    WorkflowService service = get(WorkflowService.class);
    try {
        DefaultWorkplaceDescription wpDesc = DefaultWorkplaceDescription.builder().name(name).build();
        service.createWorkplace(wpDesc);
    } catch (WorkflowException e) {
        error(e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
    }
}
Also used : DefaultWorkplaceDescription(org.onosproject.workflow.api.DefaultWorkplaceDescription) WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException)

Example 5 with WorkflowService

use of org.onosproject.workflow.api.WorkflowService in project onos by opennetworkinglab.

the class WorkFlowCommand method invoke.

/**
 * Invokes workflow.
 * @param workflowId workflow id
 * @param workplaceName workplace name
 */
private void invoke(String workflowId, String workplaceName) {
    WorkflowService service = get(WorkflowService.class);
    try {
        DefaultWorkflowDescription wfDesc = DefaultWorkflowDescription.builder().workplaceName(workplaceName).id(workflowId).data(JsonNodeFactory.instance.objectNode()).build();
        service.invokeWorkflow(wfDesc);
    } catch (WorkflowException e) {
        error("Exception: ", e);
    }
}
Also used : WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException) DefaultWorkflowDescription(org.onosproject.workflow.api.DefaultWorkflowDescription)

Aggregations

WorkflowException (org.onosproject.workflow.api.WorkflowException)5 WorkflowService (org.onosproject.workflow.api.WorkflowService)5 DefaultWorkflowDescription (org.onosproject.workflow.api.DefaultWorkflowDescription)2 DefaultWorkplaceDescription (org.onosproject.workflow.api.DefaultWorkplaceDescription)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 URI (java.net.URI)1 ImmutableListWorkflow (org.onosproject.workflow.api.ImmutableListWorkflow)1 Workflow (org.onosproject.workflow.api.Workflow)1 SampleWorkflow (org.onosproject.workflow.impl.example.SampleWorkflow)1