Search in sources :

Example 11 with ActivityInstanceVO

use of com.centurylink.mdw.model.value.work.ActivityInstanceVO in project mdw-designer by CenturyLinkCloud.

the class TestCaseRun method translateToLegacyTestFile.

private void translateToLegacyTestFile(String procName, ProcessInstanceVO procInst, int instIndex, Map<Long, String> activityNameMap) throws IOException, DataAccessException {
    TestFile actualFile = new TestFile(null, testcase.getResultDirectory().getPath() + "/R_" + procName + "_I" + instIndex + ".txt");
    TestFile expectedFileToCreate = null;
    if (createReplace) {
        expectedFileToCreate = new TestFile(null, testcase.getCaseDirectory().getPath() + "/E_" + procName + "_I" + instIndex + ".txt");
        log.println("Creating expected results file: " + expectedFileToCreate);
    }
    TestFileLine line = new TestFileLine("PROC");
    line.addWord(Integer.toString(instIndex));
    line.addWord("#");
    line.addWord(procInst.getId().toString());
    actualFile.addLine(line);
    if (expectedFileToCreate != null)
        expectedFileToCreate.addLine(line);
    LinkedList<ActivityInstanceVO> reversedList = new LinkedList<>();
    for (ActivityInstanceVO act : procInst.getActivities()) {
        reversedList.add(0, act);
    }
    for (ActivityInstanceVO act : reversedList) {
        String status = WorkStatuses.getWorkStatuses().get(act.getStatusCode());
        String actName = activityNameMap.get(act.getDefinitionId());
        if (actName == null)
            actName = act.getDefinitionId().toString();
        line = new TestFileLine("ACT");
        line.addWord(actName);
        line.addWord(status);
        line.addWord("#");
        line.addWord(act.getId().toString());
        line.addWord(act.getStartDate());
        actualFile.addLine(line);
        if (expectedFileToCreate != null)
            expectedFileToCreate.addLine(line);
    }
    for (VariableInstanceInfo var : procInst.getVariables()) {
        line = new TestFileLine("VAR");
        line.addWord(var.getName());
        try {
            String value = var.getStringValue();
            if (VariableHelper.isDocumentVariable(var.getType(), value)) {
                DocumentReference docref = new DocumentReference(value);
                String docVal = dao.getDocumentContent(docref, var.getType());
                line.addWord(docVal);
                // pre-populate document values
                procInst.getVariable().put(var.getName(), docVal);
            } else
                line.addWord(var.getStringValue());
        } catch (Throwable e) {
            log.println("Failed to translate variable to string with the following exception");
            e.printStackTrace(log);
            line.addWord(var.getStringValue());
        }
        line.addWord("#");
        line.addWord(var.getInstanceId().toString());
        actualFile.addLine(line);
        if (expectedFileToCreate != null)
            expectedFileToCreate.addLine(line);
    }
    actualFile.save();
    if (expectedFileToCreate != null)
        expectedFileToCreate.save();
}
Also used : ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) VariableInstanceInfo(com.centurylink.mdw.model.value.variable.VariableInstanceInfo) LinkedList(java.util.LinkedList) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference)

Aggregations

ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)11 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)6 Node (com.centurylink.mdw.designer.display.Node)3 DocumentReference (com.centurylink.mdw.model.value.variable.DocumentReference)3 WorkTransitionInstanceVO (com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO)3 Graph (com.centurylink.mdw.designer.display.Graph)2 Link (com.centurylink.mdw.designer.display.Link)2 SubGraph (com.centurylink.mdw.designer.display.SubGraph)2 TaskInstanceVO (com.centurylink.mdw.model.value.task.TaskInstanceVO)2 VariableInstanceInfo (com.centurylink.mdw.model.value.variable.VariableInstanceInfo)2 ActivityInstanceDialog (com.centurylink.mdw.plugin.designer.dialogs.ActivityInstanceDialog)2 Activity (com.centurylink.mdw.plugin.designer.model.Activity)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1