use of com.centurylink.mdw.model.value.variable.VariableInstanceInfo in project mdw-designer by CenturyLinkCloud.
the class VariableInstancesSection method getTheUninitializedVariables.
private List<VariableInstanceInfo> getTheUninitializedVariables() {
HashMap<String, String> variableNamesMap = new HashMap<String, String>();
List<String> variableInstances = new ArrayList<String>();
for (VariableVO variable : process.getProcessVO().getVariables()) {
variableNamesMap.put(variable.getVariableName(), variable.getVariableType());
}
for (VariableInstanceInfo varInst : process.getProcessInstance().getVariables()) {
variableInstances.add(varInst.getName());
}
Set<String> variableNames = variableNamesMap.keySet();
variableNames.removeAll(variableInstances);
List<VariableInstanceInfo> uninitializedVariableInstances = new ArrayList<VariableInstanceInfo>();
for (String varName : variableNames) {
VariableInstanceInfo newVarInst = new VariableInstanceInfo();
newVarInst.setName(varName);
newVarInst.setType(variableNamesMap.get(varName));
uninitializedVariableInstances.add(newVarInst);
}
return uninitializedVariableInstances;
}
use of com.centurylink.mdw.model.value.variable.VariableInstanceInfo in project mdw-designer by CenturyLinkCloud.
the class VariableInstancesSection method openDialog.
private void openDialog(VariableInstanceInfo variableInstanceInfo) {
Integer processStatus = process.getProcessInstance().getStatusCode();
VariableTypeVO varType = getType(variableInstanceInfo);
boolean readOnly = WorkStatus.STATUS_COMPLETED.equals(processStatus) || WorkStatus.STATUS_CANCELLED.equals(processStatus);
if (varType.isJavaObjectType()) {
try {
// update based on object instance or from server
varType = getDesignerProxy().getVariableInfo(variableInstanceInfo);
if (!varType.isUpdateable())
readOnly = true;
} catch (Exception ex) {
PluginMessages.log(ex);
}
}
try {
String varValue = getDesignerProxy().getVariableValue(getShell(), variableInstanceInfo, true);
VariableValueDialog variableValueDialog = new VariableValueDialog(getShell(), variableInstanceInfo, varType, varValue, readOnly);
if (variableValueDialog.open() == Dialog.OK) {
DesignerProxy designerProxy = process.getProject().getDesignerProxy();
designerProxy.updateVariableValue(process, variableInstanceInfo, variableValueDialog.getVariableValue().getValue());
List<VariableInstanceInfo> variables = process.getProcessInstance().getVariables();
List<VariableInstanceInfo> uninitializedVariables = getTheUninitializedVariables();
variables.addAll(uninitializedVariables);
tableEditor.setValue(variables);
}
} catch (Exception ex) {
PluginMessages.uiMessage(ex, "Retrieve Variable", process.getProject(), PluginMessages.VALIDATION_MESSAGE);
return;
}
}
use of com.centurylink.mdw.model.value.variable.VariableInstanceInfo in project mdw-designer by CenturyLinkCloud.
the class VariableInstancesSection method drawWidgets.
public void drawWidgets(Composite composite, WorkflowElement selection) {
process = (WorkflowProcess) selection;
tableEditor = new TableEditor(process, TableEditor.TYPE_TABLE);
tableEditor.setReadOnly(true);
tableEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
openDialog((VariableInstanceInfo) newValue);
}
});
if (columnSpecs == null)
columnSpecs = createColumnSpecs();
tableEditor.setColumnSpecs(columnSpecs);
if (contentProvider == null)
contentProvider = new VariableInstanceContentProvider();
tableEditor.setContentProvider(contentProvider);
if (labelProvider == null)
labelProvider = new VariableInstanceLabelProvider();
tableEditor.setLabelProvider(labelProvider);
tableEditor.render(composite);
}
use of com.centurylink.mdw.model.value.variable.VariableInstanceInfo in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method translateToYaml.
private String translateToYaml(Map<String, List<ProcessInstanceVO>> processInstances, Map<String, String> activityNames, boolean orderById, String newLineChars) throws IOException, DataAccessException {
YamlBuilder yaml = new YamlBuilder(newLineChars);
for (String procName : processInstances.keySet()) {
List<ProcessInstanceVO> procInsts = processInstances.get(procName);
for (int i = 0; i < procInsts.size(); i++) {
ProcessInstanceVO procInst = procInsts.get(i);
yaml.append("process: # ").append(procInst.getId()).newLine();
yaml.append(" name: ").append(procName).newLine();
yaml.append(" instance: ").append((i + 1)).newLine();
LinkedList<ActivityInstanceVO> orderedList = new LinkedList<>();
for (ActivityInstanceVO act : procInst.getActivities()) {
if (dao.getDatabaseSchemaVersion() < 6000)
orderedList.add(0, act);
else
orderedList.add(act);
}
if (orderById) {
Collections.sort(orderedList, new Comparator<ActivityInstanceVO>() {
public int compare(ActivityInstanceVO ai1, ActivityInstanceVO ai2) {
return (int) (ai1.getDefinitionId() - ai2.getDefinitionId());
}
});
}
for (ActivityInstanceVO act : orderedList) {
yaml.append(" activity: # ").append(act.getDefinitionId()).append(" \"").append(act.getStartDate()).append("\"").newLine();
String actNameKey = procInst.getProcessId() + "-" + act.getDefinitionId();
yaml.append(" name: ").appendMulti(" ", activityNames.get(actNameKey)).newLine();
yaml.append(" status: ").append(WorkStatuses.getWorkStatuses().get(act.getStatusCode())).newLine();
if (act.getStatusMessage() != null) {
String[] msgLines = act.getStatusMessage().split("\\r\\n|\\n|\\r");
String result = msgLines[0];
if (msgLines.length > 1)
result += "...";
yaml.append(" result: ").append(result).newLine();
}
}
for (VariableInstanceInfo var : procInst.getVariables()) {
yaml.append(" variable: # ").append(var.getInstanceId()).newLine();
yaml.append(" name: ").append(var.getName()).newLine();
yaml.append(" value: ");
try {
String val = var.getStringValue();
if (VariableHelper.isDocumentVariable(var.getType(), val)) {
DocumentReference docref = new DocumentReference(val);
val = dao.getDocumentContent(docref, var.getType());
// pre-populate document values
procInst.getVariable().put(var.getName(), val);
}
yaml.appendMulti(" ", val).newLine();
} catch (Throwable t) {
log.println("Failed to translate variable instance: " + var.getInstanceId() + " to string with the following exception");
t.printStackTrace(log);
yaml.append(" \"").append(var.getStringValue()).append("\"").newLine();
}
}
}
}
return yaml.toString();
}
use of com.centurylink.mdw.model.value.variable.VariableInstanceInfo 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();
}
Aggregations