Search in sources :

Example 1 with WorkflowActivitySpecSequence

use of org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence in project so by onap.

the class WorkflowResource method getWorkflowActivitySpecSequence.

protected List<WorkflowActivitySpecSequence> getWorkflowActivitySpecSequence(List<String> activityNames, Workflow workflow) throws Exception {
    if (activityNames == null || activityNames.isEmpty()) {
        return null;
    }
    List<WorkflowActivitySpecSequence> workflowActivitySpecs = new ArrayList<>();
    int seqNo = 1;
    for (String activityName : activityNames) {
        ActivitySpec activitySpec = activityRepo.findByName(activityName);
        if (activitySpec != null) {
            WorkflowActivitySpecSequence workflowActivitySpec = new WorkflowActivitySpecSequence();
            workflowActivitySpec.setActivitySpec(activitySpec);
            workflowActivitySpec.setWorkflow(workflow);
            workflowActivitySpec.setSeqNo(seqNo);
            seqNo++;
            workflowActivitySpecs.add(workflowActivitySpec);
        }
    }
    return workflowActivitySpecs;
}
Also used : ArrayList(java.util.ArrayList) ActivitySpec(org.onap.so.db.catalog.beans.ActivitySpec) WorkflowActivitySpecSequence(org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence)

Example 2 with WorkflowActivitySpecSequence

use of org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence in project so by onap.

the class WorkflowResourceTest method installWorkflowResource_Test.

@Transactional
@Test
public void installWorkflowResource_Test() throws Exception {
    Workflow workflow = new Workflow();
    workflow.setArtifactChecksum("12345");
    workflow.setArtifactName("myTestWorkflow1");
    workflow.setArtifactUUID("a5c59864-8407-4175-8060-de8ff95eab41");
    workflow.setBody("my body");
    workflow.setDescription("testing workflow");
    workflow.setName("myTestWorkflow1");
    workflow.setResourceTarget("vnf");
    workflow.setSource("sdc");
    workflow.setTimeoutMinutes(5000);
    workflow.setOperationName("myTestWorkflow");
    workflow.setVersion(1.0);
    VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow();
    vnfResourceWorkflow.setVnfResourceModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
    vnfResourceWorkflow.setWorkflow(workflow);
    List<VnfResourceWorkflow> vnfResourceWorkflows = new ArrayList<VnfResourceWorkflow>();
    vnfResourceWorkflows.add(vnfResourceWorkflow);
    workflow.setVnfResourceWorkflow(vnfResourceWorkflows);
    WorkflowActivitySpecSequence wfss1 = new WorkflowActivitySpecSequence();
    wfss1.setActivitySpecId(1);
    wfss1.setWorkflow(workflow);
    wfss1.setSeqNo(1);
    List<WorkflowActivitySpecSequence> wfss = new ArrayList<WorkflowActivitySpecSequence>();
    wfss.add(wfss1);
    workflow.setWorkflowActivitySpecSequence(wfss);
    workflowRepo.save(workflow);
    assertNotNull(workflow);
}
Also used : VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) ArrayList(java.util.ArrayList) Workflow(org.onap.so.db.catalog.beans.Workflow) VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) WorkflowActivitySpecSequence(org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 3 with WorkflowActivitySpecSequence

use of org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence in project so by onap.

the class WorkflowResource method installWorkflowResource.

protected void installWorkflowResource(WorkflowArtifact artifact, String vfResourceModelUuid) throws Exception {
    IArtifactInfo artifactInfo = artifact.getArtifactInfo();
    Workflow workflow = new Workflow();
    workflow.setArtifactChecksum(artifactInfo.getArtifactChecksum());
    workflow.setArtifactName(artifactInfo.getArtifactName());
    workflow.setArtifactUUID(artifactInfo.getArtifactUUID());
    workflow.setBody(artifact.getResult());
    workflow.setDescription(artifactInfo.getArtifactDescription());
    workflow.setName(getWorkflowNameFromArtifactName(artifactInfo.getArtifactName()));
    workflow.setResourceTarget(TARGET_RESOURCE_VNF);
    workflow.setSource(SOURCE_SDC);
    workflow.setTimeoutMinutes(artifactInfo.getArtifactTimeout());
    workflow.setOperationName(getWorkflowNameFromArtifactName(artifactInfo.getArtifactName()));
    workflow.setVersion(getWorkflowVersionFromArtifactName(artifactInfo.getArtifactName()));
    VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow();
    vnfResourceWorkflow.setVnfResourceModelUUID(vfResourceModelUuid);
    vnfResourceWorkflow.setWorkflow(workflow);
    List<VnfResourceWorkflow> vnfResourceWorkflows = new ArrayList<>();
    vnfResourceWorkflows.add(vnfResourceWorkflow);
    workflow.setVnfResourceWorkflow(vnfResourceWorkflows);
    List<String> activityNames = getActivityNameList(artifact.getResult());
    List<WorkflowActivitySpecSequence> wfss = getWorkflowActivitySpecSequence(activityNames, workflow);
    workflow.setWorkflowActivitySpecSequence(wfss);
    workflowRepo.save(workflow);
}
Also used : VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) ArrayList(java.util.ArrayList) VnfResourceWorkflow(org.onap.so.db.catalog.beans.VnfResourceWorkflow) Workflow(org.onap.so.db.catalog.beans.Workflow) WorkflowActivitySpecSequence(org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence)

Aggregations

ArrayList (java.util.ArrayList)3 WorkflowActivitySpecSequence (org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence)3 VnfResourceWorkflow (org.onap.so.db.catalog.beans.VnfResourceWorkflow)2 Workflow (org.onap.so.db.catalog.beans.Workflow)2 Transactional (javax.transaction.Transactional)1 Test (org.junit.Test)1 IArtifactInfo (org.onap.sdc.api.notification.IArtifactInfo)1 BaseTest (org.onap.so.asdc.BaseTest)1 ActivitySpec (org.onap.so.db.catalog.beans.ActivitySpec)1