use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class ArtifactResourceListener method resourceChanged.
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta rootDelta = event.getDelta();
IResourceDelta artifactDelta = rootDelta.findMember(tempFile.getFullPath());
if (artifactDelta != null && artifactDelta.getKind() == IResourceDelta.CHANGED && (artifactDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
// the file has been changed
final Display display = Display.getCurrent();
if (display != null) {
display.syncExec(new Runnable() {
public void run() {
byte[] newValue = PluginUtil.readFile(tempFile);
String attrVal = valueProvider.isBinary() ? encodeBase64(newValue) : new String(newValue);
if (getElement() instanceof Activity || getElement() instanceof WorkflowProcess) {
WorkflowProcess processVersion = null;
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
activity.setAttribute(valueProvider.getAttributeName(), attrVal);
processVersion = activity.getProcess();
} else {
processVersion = (WorkflowProcess) getElement();
processVersion.setAttribute(valueProvider.getAttributeName(), attrVal);
}
processVersion.fireDirtyStateChanged(true);
ProcessEditor processEditor = findProcessEditor(processVersion);
if (processEditor == null) {
try {
processEditor = openProcessEditor(processVersion);
IEditorPart tempFileEditor = findTempFileEditor(tempFile);
if (tempFileEditor != null)
processEditor.addActiveScriptEditor(tempFileEditor);
} catch (PartInitException ex) {
PluginMessages.uiError(display.getActiveShell(), ex, "Open Process", processVersion.getProject());
return;
}
}
processVersion = processEditor.getProcess();
if (processVersion.isReadOnly()) {
WorkflowProject workflowProject = getElement().getProject();
PluginMessages.uiMessage("Process for '" + getElement().getName() + "' in workflow project '" + workflowProject.getName() + "' is Read Only.", "Not Updated", workflowProject, PluginMessages.INFO_MESSAGE);
return;
}
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
// previously-opened process version
for (Node node : processEditor.getProcessCanvasWrapper().getFlowchartPage().getProcess().nodes) {
if (activity.getLogicalId() != null && activity.getLogicalId().equals(node.getAttribute("LOGICAL_ID"))) {
node.setAttribute(valueProvider.getAttributeName(), attrVal);
ActivityImpl actImpl = processVersion.getProject().getActivityImpl(node.nodet.getImplementorClassName());
element = new Activity(node, processVersion, actImpl);
}
}
activity.fireDirtyStateChanged(true);
}
processEditor.dirtyStateChanged(true);
valueProvider.afterTempFileSaved();
// process editor is open
String message = valueProvider.getArtifactTypeDescription() + " temporary file has been saved locally; however, you must still save the process for the changes to be persisted.";
String toggleMessage = "Don't show me this message again.";
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
String prefsKey = "Mdw" + valueProvider.getArtifactTypeDescription() + "SuppressSaveNag";
if (!prefsStore.getBoolean(prefsKey)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(display.getActiveShell(), "Artifact Save", message, toggleMessage, false, null, null);
prefsStore.setValue(prefsKey, dialog.getToggleState());
}
}
}
});
}
}
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class BamEventComposer method createBamDataTable.
private void createBamDataTable() {
if (attributesTableContainer != null) {
if (dataTableDirtyStateListener != null)
attributesTableContainer.removeDirtyStateListener(dataTableDirtyStateListener);
attributesTableContainer.dispose();
}
// attributes
TableT bamTable = null;
if (bamPagelet != null) {
try {
bamTable = getBamPageletTable();
} catch (BamPageletValidationException ex) {
PluginMessages.uiError(ex, "BAM Pagelet");
}
}
String label;
if (bamTable != null && (bamTable.getNAME() != null || bamTable.getLABEL() != null)) {
label = bamTable.getLABEL() == null ? bamTable.getNAME() : bamTable.getLABEL();
bamTable.setLABEL(label);
for (DropdownT dropdown : bamTable.getDROPDOWNList()) {
if ("Variables".equalsIgnoreCase(dropdown.getSOURCE())) {
WorkflowProcess processVersion = getProcess();
if (processVersion != null) {
List<String> varNames = processVersion.getNonDocRefVariableNames();
// add process variable values
for (String var : varNames) {
OptionT option = dropdown.addNewOPTION();
option.setVALUE("#{" + var + "}");
option.setStringValue(var);
}
}
}
}
}
attributesTableContainer = createAttributesTable(getWidth(), LAYOUT_COLS, bamTable);
dataTableDirtyStateListener = new DirtyStateListener() {
public void dirtyStateChanged(boolean dirty) {
if (bamMessage != null) {
bamMessage.setAttributes(attributesTableContainer.getAttributes());
Event event = new Event();
event.widget = attributesTableContainer.tableEditor.getTable();
event.data = attributesTableContainer.getAttributes();
fireModify(new ModifyEvent(event));
}
}
};
attributesTableContainer.addDirtyStateListener(dataTableDirtyStateListener);
this.layout(true);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method getAllProcessVersions.
/**
* Returns all processes, regardless of packaging or version.
*/
public List<WorkflowProcess> getAllProcessVersions() {
List<WorkflowProcess> allProcessVersions = new ArrayList<>();
for (WorkflowProcess processVersion : getAllProcesses()) {
if (processVersion.hasDescendantProcessVersions()) {
for (WorkflowProcess descendant : processVersion.getDescendantProcessVersions()) allProcessVersions.add(descendant);
} else {
allProcessVersions.add(processVersion);
}
}
Collections.sort(allProcessVersions);
return allProcessVersions;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class ProcessSearchQuery method run.
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
if (getScopedProjects().isEmpty() && getSelectedPackage() != null)
getScopedProjects().add(getSelectedPackage().getProject());
if (getScopedProjects().isEmpty()) {
String msg = "No MDW projects in search scope.";
showError(msg, "MDW Search", null);
return new Status(IStatus.WARNING, MdwPlugin.getPluginId(), 0, msg, null);
}
for (WorkflowProject project : getScopedProjects()) {
if (getSearchType().equals(SearchType.ENTITY_BY_NAME)) {
for (WorkflowProcess process : project.getAllProcessVersions()) {
String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
if ((getPattern().equals("*") || name.indexOf(getPattern()) >= 0) && (getSelectedPackage() == null || (process.getPackage() != null && process.getPackage().equals(getSelectedPackage()))))
getSearchResults().addMatchingElement(process);
}
} else if (getSearchType().equals(SearchType.ENTITY_BY_ID)) {
WorkflowProcess process = project.getProcess(new Long(getPattern()));
if (process == null && project.isRemote() && project.isFilePersist()) {
// could be archived process for remote VCS
try {
ProcessVO procVO = project.getDesignerProxy().getDesignerDataAccess().getProcessDefinition(new Long(getPattern()));
process = new WorkflowProcess(project, procVO);
} catch (Exception ex) {
PluginMessages.log(ex);
}
}
if (process != null && (getSelectedPackage() == null || (process.getPackage() != null && process.getPackage().equals(getSelectedPackage()))))
getSearchResults().addMatchingElement(process);
} else if (getSearchType().equals(SearchType.CONTAINING_ENTITY)) {
try {
for (WorkflowProcess process : project.getDesignerProxy().getProcessesUsingActivityImpl(containedEntityId, containedEntityName)) {
String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
if (getPattern().equals("*") || name.indexOf(getPattern()) >= 0)
getSearchResults().addMatchingElement(process);
}
} catch (DataAccessException ex) {
showError(ex, "Find Processes", project);
}
} else if (getSearchType().equals(SearchType.INVOKING_ENTITY)) {
try {
WorkflowProcess invoked = project.getProcess(getInvokedEntityId());
for (WorkflowProcess process : project.getDesignerProxy().findCallingProcesses(invoked)) {
String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
if (getPattern().equals("*") || name.indexOf(getPattern()) >= 0)
getSearchResults().addMatchingElement(process);
}
} catch (Exception ex) {
showError(ex, "Calling Processes", project);
}
} else if (getSearchType().equals(SearchType.INSTANCE_BY_ENTITY_ID)) {
Map<String, String> criteria = new HashMap<String, String>();
criteria.put("processId", getPattern());
searchInstances(project, criteria);
} else if (getSearchType().equals(SearchType.INSTANCE_BY_ID)) {
Map<String, String> criteria = new HashMap<String, String>();
criteria.put("id", getPattern());
searchInstances(project, criteria);
} else if (getSearchType().equals(SearchType.INSTANCE_BY_MRI)) {
Map<String, String> criteria = new HashMap<String, String>();
if (isCaseSensitive())
criteria.put("masterRequestId", getPattern());
else
criteria.put("masterRequestIdIgnoreCase", getPattern());
searchInstances(project, criteria);
} else {
showError("Unsupported search type: " + getSearchType(), "MDW Search", null);
}
}
if (getSearchResults().getMatchingElements().size() == 0)
return new Status(IStatus.WARNING, MdwPlugin.getPluginId(), 0, "No matching elements found", null);
else
return Status.OK_STATUS;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class ProcessSearchQuery method searchInstances.
private void searchInstances(final WorkflowProject project, Map<String, String> criteria) {
try {
List<ProcessInstanceVO> instances = project.getDesignerProxy().getProcessInstances(criteria);
for (ProcessInstanceVO instanceInfo : instances) {
Long processId = instanceInfo.getProcessId();
if (project.getProcess(processId) == null && instanceInfo.getOwner().equals(OwnerType.PROCESS_INSTANCE)) {
Map<String, String> newCrit = new HashMap<String, String>();
newCrit.put("id", instanceInfo.getOwnerId().toString());
instanceInfo = project.getDesignerProxy().getProcessInstances(newCrit).get(0);
processId = instanceInfo.getProcessId();
}
if (processId != null) {
WorkflowProcess processVersion = project.getProcess(processId);
if (// can
processVersion == null && project.isFilePersist()) // happen
// for
// non-vcs
// processes
// or
// Archived
// processes
{
ProcessVO processVO = new ProcessVO();
processVO.setProcessId(instanceInfo.getProcessId());
processVersion = new WorkflowProcess(project, processVO);
processVersion.setName(instanceInfo.getProcessName());
processVersion.setVersion(RuleSetVO.parseVersion(instanceInfo.getProcessVersion()));
processVO = project.getDataAccess().loadProcess(processVersion);
if (// otherwise retrieval will be
processVO != null)
// just-in-time
processVersion.setProcessVO(processVO);
}
if (processVersion != null) {
WorkflowProcess instance = new WorkflowProcess(processVersion);
instance.setProcessInstance(instanceInfo);
if (!getSearchResults().getMatchingElements().contains(instance))
getSearchResults().addMatchingElement(instance);
}
}
}
} catch (Exception ex) {
showError(ex, "Retrieve Process Instances", project);
}
}
Aggregations