use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method getSubProcessInstances.
public List<ProcessInstanceVO> getSubProcessInstances(ProcessInstanceVO parentEmbeddedProcessInstance, Activity activity) {
try {
Long parentProcessInstanceId = parentEmbeddedProcessInstance.getId();
ProcessVO subProcessVO = new ProcessVO();
String subProcName = activity.getAttribute(WorkAttributeConstant.PROCESS_NAME);
String subProcVer = activity.getAttribute(WorkAttributeConstant.PROCESS_VERSION);
WorkflowProcess subProc = new AssetLocator(activity, AssetLocator.Type.PROCESS).getProcessVersion(new AssetVersionSpec(subProcName, subProcVer));
subProcessVO.setProcessId(subProc == null ? 0L : subProc.getId());
subProcessVO.setProcessName(subProcName);
return dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, new ProcessVO());
} catch (Exception ex) {
PluginMessages.uiError(ex, "Load SubProcess Instances", project);
return Collections.emptyList();
}
}
use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method getSubProcessInstances.
public List<ProcessInstanceVO> getSubProcessInstances(WorkflowProcess parentProcess, Activity activity) {
try {
Long parentProcessInstanceId = parentProcess.getProcessInstance().getId();
if (activity.isHeterogeneousSubProcInvoke()) {
List<ProcessInstanceVO> insts = new ArrayList<>();
String procMapStr = activity.getAttribute(WorkAttributeConstant.PROCESS_MAP);
if (procMapStr != null && !procMapStr.isEmpty()) {
List<String[]> procMap = StringHelper.parseTable(procMapStr, ',', ';', 3);
for (String[] row : procMap) {
ProcessVO subProcessVO = new ProcessVO();
AssetVersionSpec spec = new AssetVersionSpec(row[1], row[2] == null ? "0" : row[2]);
AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
WorkflowProcess found = locator.getProcessVersion(spec);
if (found != null) {
subProcessVO.setProcessId(found.getId());
subProcessVO.setProcessName(found.getName());
insts.addAll(dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO()));
} else {
PluginMessages.log(new Exception("SubProcess not found: " + row[1] + " v" + row[2]));
}
}
}
return insts;
} else if (activity.isManualTask()) {
List<ProcessInstanceVO> insts = new ArrayList<>();
String procMapStr = activity.getAttribute(TaskAttributeConstant.SERVICE_PROCESSES);
if (procMapStr != null && !procMapStr.isEmpty()) {
Map<String, String> pMap = new HashMap<>();
pMap.put("owner", OwnerType.TASK_INSTANCE);
StringBuilder sb = new StringBuilder();
sb.append("(");
if (activity.getTaskInstances() != null) {
for (TaskInstanceVO taskInst : activity.getTaskInstances()) {
if (sb.length() > 1)
sb.append(",");
sb.append(taskInst.getTaskInstanceId().toString());
}
}
sb.append(")");
pMap.put("ownerIdList", sb.toString());
insts = dataAccess.getDesignerDataAccess().getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, parentProcess.getProcessVO(), null).getItems();
}
return insts;
} else {
ProcessVO subProcessVO = new ProcessVO();
String subProcName = activity.getAttribute(WorkAttributeConstant.PROCESS_NAME);
String subProcVer = activity.getAttribute(WorkAttributeConstant.PROCESS_VERSION);
AssetVersionSpec spec = new AssetVersionSpec(subProcName, subProcVer == null ? "0" : subProcVer);
AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
WorkflowProcess subProc = locator.getProcessVersion(spec);
subProcessVO.setProcessId((subProc == null || subProc.getId() == null) ? 0L : subProc.getId());
subProcessVO.setProcessName(activity.getAttribute(WorkAttributeConstant.PROCESS_NAME));
// handle alias subprocs
String subprocAliasProcessId = activity.getAttribute(WorkAttributeConstant.ALIAS_PROCESS_ID);
if (subprocAliasProcessId != null)
subProcessVO = this.getProcessVO(new Long(subprocAliasProcessId));
return dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO());
}
} catch (Exception ex) {
PluginMessages.uiError(ex, "Load SubProcess Instances (P=" + parentProcess.getId() + ",A=" + activity.getId() + ")", project);
return Collections.emptyList();
}
}
use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class TableEditor method createTable.
private Table createTable(Composite parent) {
int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
final Table table = new Table(parent, style);
GridData gridData = new GridData(GridData.FILL_BOTH);
if (horizontalSpan == 0)
gridData.horizontalSpan = getLabel() == null ? 3 : 2;
else
gridData.horizontalSpan = horizontalSpan;
if (getType().equals(TYPE_TABLE))
gridData.heightHint = 100;
if (getHeight() != SWT.DEFAULT)
gridData.heightHint = getHeight();
if (getWidth() != DEFAULT_VALUE_WIDTH)
gridData.widthHint = getWidth();
table.setLayoutData(gridData);
table.setLinesVisible(true);
table.setHeaderVisible(true);
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
int colStyle = SWT.LEFT | colSpec.style;
if (colSpec.readOnly)
colStyle = colStyle | SWT.READ_ONLY;
TableColumn column = new TableColumn(table, colStyle, i);
column.setText(colSpec.label);
if (colSpec.hidden) {
column.setWidth(0);
column.setResizable(false);
} else {
column.setWidth(colSpec.width);
column.setResizable(colSpec.resizable);
}
if (colSpec.height != ColumnSpec.DEFAULT_ROW_HEIGHT) {
table.addListener(SWT.MeasureItem, new RowHeightListener(colSpec.height));
}
}
if (isFillWidth()) {
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
int tableWidth = table.getBounds().width;
int cumulative = 0;
TableColumn[] tableColumns = table.getColumns();
for (int i = 0; i < tableColumns.length; i++) {
if (i == tableColumns.length - 1)
tableColumns[i].setWidth(tableWidth - cumulative - 5);
cumulative += tableColumns[i].getWidth();
}
}
});
}
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
fireValueChanged(e.item.getData(), false);
}
});
// double-click handler for asset rows
int assetColIdx = -1;
for (int i = 0; i < columnSpecs.size(); i++) {
if (WorkflowAssetEditor.TYPE_ASSET.equals(columnSpecs.get(i).type))
assetColIdx = i;
}
if (assetColIdx != -1) {
final int colIdx = assetColIdx;
addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
if (newValue instanceof DefaultRowImpl) {
// is the case for double-click
DefaultRowImpl row = (DefaultRowImpl) newValue;
String name = row.getColumnValues()[colIdx];
String ver = "0";
if (columnSpecs.size() > colIdx + 1 && (PROCESS_VERSION.equals(columnSpecs.get(colIdx + 1).source) || "AssetVersion".equals(columnSpecs.get(colIdx + 1).source)))
ver = row.getColumnValues()[colIdx + 1];
if (name != null && ver != null) {
AssetVersionSpec spec = new AssetVersionSpec(name, ver);
AssetLocator.Type type = AssetLocator.Type.ASSET;
if (PROCESS.equals(columnSpecs.get(colIdx).source))
type = AssetLocator.Type.PROCESS;
else if (RuleSetVO.TASK.equals(columnSpecs.get(colIdx).source))
type = AssetLocator.Type.TASKTEMPLATE;
AssetLocator locator = new AssetLocator(getElement(), type);
locator.openAsset(spec);
}
}
}
});
}
return table;
}
Aggregations