Search in sources :

Example 16 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class ProcessLaunchMainTab method refreshVariables.

private void refreshVariables(WorkflowProcess processVersion) {
    if (responseVarNameCombo != null) {
        String responseVar = responseVarNameCombo.getText();
        responseVarNameCombo.removeAll();
        responseVarNameCombo.add("");
        for (VariableVO outputVar : processVersion.getOutputVariables()) responseVarNameCombo.add(outputVar.getVariableName());
        responseVarNameCombo.setText(responseVar);
    }
}
Also used : VariableVO(com.centurylink.mdw.model.value.variable.VariableVO)

Example 17 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method launchProcess.

public MDWStatusMessage launchProcess(WorkflowProcess processVersion, String masterRequestId, String owner, Long ownerId, List<VariableValue> variableValues, Long activityId) throws DataAccessException, XmlException, JSONException, IOException {
    Map<VariableVO, String> variables = new HashMap<>();
    for (VariableValue variableValue : variableValues) {
        variables.put(variableValue.getVariableVO(), variableValue.getValue());
    }
    MDWStatusMessageDocument statusMessageDoc = restfulServer.launchProcess(processVersion.getId(), masterRequestId, owner, ownerId, variables, activityId, project.isOldNamespaces());
    if (statusMessageDoc.getMDWStatusMessage().getStatusCode() != 0)
        throw new RemoteException("Error launching process: " + statusMessageDoc.getMDWStatusMessage().getStatusMessage());
    // audit log in separate dao since launch is multi-threaded
    UserActionVO userAction = new UserActionVO(project.getUser().getUsername(), Action.Run, processVersion.getActionEntity(), processVersion.getId(), processVersion.getLabel());
    userAction.setSource("Eclipse/RCP Designer");
    try {
        new DesignerDataAccess(dataAccess.getDesignerDataAccess()).auditLog(userAction);
    } catch (Exception ex) {
        throw new DataAccessException(-1, ex.getMessage(), ex);
    }
    return statusMessageDoc.getMDWStatusMessage();
}
Also used : UserActionVO(com.centurylink.mdw.model.value.user.UserActionVO) HashMap(java.util.HashMap) VariableValue(com.centurylink.mdw.plugin.designer.model.VariableValue) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) RemoteException(java.rmi.RemoteException) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 18 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method launchSynchronousProcess.

public String launchSynchronousProcess(WorkflowProcess processVersion, String masterRequestId, String owner, Long ownerId, List<VariableValue> variableValues, String responseVarName) throws DataAccessException, XmlException, JSONException, IOException {
    Map<VariableVO, String> variables = new HashMap<>();
    for (VariableValue variableValue : variableValues) {
        variables.put(variableValue.getVariableVO(), variableValue.getValue());
    }
    boolean oldFormat = !processVersion.getProject().checkRequiredVersion(5, 5);
    String ret = restfulServer.launchSynchronousProcess(processVersion.getId(), masterRequestId, owner, ownerId, variables, responseVarName, oldFormat);
    dataAccess.auditLog(Action.Run, processVersion);
    return ret;
}
Also used : HashMap(java.util.HashMap) VariableValue(com.centurylink.mdw.plugin.designer.model.VariableValue) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO)

Example 19 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method upgradeAssets.

/**
 * Replace obsolete implementors, and other assets (see help doc
 * upgradeAssetsDuringImport.html).
 */
public void upgradeAssets(WorkflowPackage packageVersion) throws DataAccessException, IOException {
    boolean packageUpdated = false;
    PackageVO packageVO = packageVersion.getPackageVO();
    List<ProcessVO> processVOs = packageVO.getProcesses();
    // update activity implementors
    List<ProcessVO> newProcs = new ArrayList<>();
    for (ProcessVO processVO : processVOs) {
        boolean processUpdated = false;
        ProcessVO newProc = dataAccess.getDesignerDataAccess().getProcess(processVO.getProcessId(), processVO);
        List<ActivityVO> activities = newProc.getActivities();
        if (activities != null) {
            for (ActivityVO activityVO : activities) {
                if (new ActivityUpgrader(activityVO).doUpgrade())
                    processUpdated = true;
            }
            if (newProc.getSubProcesses() != null) {
                for (ProcessVO subproc : newProc.getSubProcesses()) {
                    if (subproc.getActivities() != null) {
                        for (ActivityVO subprocActivity : subproc.getActivities()) {
                            if (new ActivityUpgrader(subprocActivity).doUpgrade())
                                processUpdated = true;
                        }
                    }
                }
            }
        }
        // update variable types
        List<VariableVO> variables = newProc.getVariables();
        if (variables != null) {
            for (VariableVO variableVO : variables) {
                String variableType = variableVO.getVariableType();
                String updatedVariableType = Compatibility.getVariableType(variableType);
                if (!updatedVariableType.equals(variableType)) {
                    variableVO.setVariableType(updatedVariableType);
                    processUpdated = true;
                }
            }
        }
        if (processUpdated) {
            int processVersion = newProc.getVersion();
            processVersion++;
            newProc.setVersion(processVersion);
            packageUpdated = true;
        }
        newProcs.add(newProc);
    }
    // Set old activity implementors in the package to hidden
    List<ActivityImplementorVO> activityImplementorVOs = packageVO.getImplementors();
    for (ActivityImplementorVO activityImplementorVO : activityImplementorVOs) {
        String activityImplClassName = activityImplementorVO.getImplementorClassName();
        if (Compatibility.isOldImplementor(activityImplClassName)) {
            activityImplementorVO.setHidden(true);
            packageUpdated = true;
        }
    }
    if (packageUpdated) {
        // update with new assets for saving
        packageVO.setProcesses(newProcs);
        List<RuleSetVO> newRuleSets = new ArrayList<>();
        for (RuleSetVO ruleSet : packageVO.getRuleSets()) newRuleSets.add(getDesignerDataAccess().getRuleSet(ruleSet.getId()));
        packageVO.setRuleSets(newRuleSets);
        int version = packageVersion.getVersion();
        version++;
        packageVersion.setVersion(version);
        // avoid forcing version
        packageVersion.setExported(false);
        // increment on save
        packageVersion.syncProcesses();
        getDesignerDataAccess().savePackage(packageVO, ProcessPersister.PersistType.IMPORT);
    }
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) ArrayList(java.util.ArrayList) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO) ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO)

Example 20 with VariableVO

use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.

the class Importer method importProcess.

public WorkflowProcess importProcess(final WorkflowPackage targetPackage, final WorkflowProcess targetProcess, final String xml) throws DataAccessException, RemoteException, XmlException, ValidationException {
    CodeTimer timer = new CodeTimer("importProcess()");
    ProcessVO importedProcessVO = null;
    int schemaVersion = dataAccess.getSchemaVersion();
    ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
    importedProcessVO = importer.importProcess(xml);
    if (targetProcess != null && !importedProcessVO.getName().equals(targetProcess.getName()))
        throw new ValidationException("Process in XML (" + importedProcessVO.getName() + ") is not " + targetProcess.getName());
    for (WorkflowProcess existing : targetPackage.getProject().getAllProcesses()) {
        if (existing.getName().equals(importedProcessVO.getName())) {
            if (existing.getVersion() == importedProcessVO.getVersion())
                throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + ".");
            if (existing.getVersion() > importedProcessVO.getVersion())
                throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + " with a version greater than the imported process (v" + importedProcessVO.getVersionString() + ").");
        }
    }
    // designer fix for backward compatibility
    ProcessWorker worker = new ProcessWorker();
    worker.convert_to_designer(importedProcessVO);
    worker.convert_from_designer(importedProcessVO, syncNodeMetaInfo(dataAccess.getDesignerDataModel().getNodeMetaInfo(), importedProcessVO));
    if (!importedProcessVO.isInRuleSet()) {
        // fix pseudo variables
        for (VariableVO varVO : importedProcessVO.getVariables()) varVO.setVariableId(null);
    }
    importedProcessVO.setPackageName(targetPackage.getName());
    WorkflowProcess alreadyInPackage = null;
    if (targetPackage.getProject().getProcess(importedProcessVO.getName()) == null)
        dataAccess.getDesignerDataAccess().createProcess(importedProcessVO);
    else {
        alreadyInPackage = targetPackage.getProcess(importedProcessVO.getName());
        dataAccess.getDesignerDataAccess().updateProcess(importedProcessVO, importedProcessVO.getVersion(), false);
    }
    ProcessVO reloaded = dataAccess.getDesignerDataAccess().getProcessDefinition(importedProcessVO.getProcessName(), importedProcessVO.getVersion());
    importedProcessVO.setProcessId(reloaded.getProcessId());
    if (targetPackage.getProject().getDataAccess().getSupportedSchemaVersion() < DataAccess.schemaVersion52)
        updateSubProcessIdAttributes(importedProcessVO);
    WorkflowProcess importedProcess = new WorkflowProcess(targetPackage.getProject(), importedProcessVO);
    dataAccess.getProcesses(false).add(importedProcess.getProcessVO());
    if (alreadyInPackage != null)
        targetPackage.removeProcess(alreadyInPackage);
    targetPackage.addProcess(importedProcess);
    importedProcess.setPackage(targetPackage);
    dataAccess.auditLog(Action.Import, importedProcess);
    timer.stopAndLog();
    return importedProcess;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) ProcessImporter(com.centurylink.mdw.dataaccess.ProcessImporter) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Aggregations

VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)34 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)9 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)7 VariableValue (com.centurylink.mdw.plugin.designer.model.VariableValue)5 IOException (java.io.IOException)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)3 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)3 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)3 VariableBinding (com.centurylink.mdw.plugin.designer.model.VariableBinding)3 ActionRequestDocument (com.centurylink.mdw.service.ActionRequestDocument)3 Parameter (com.centurylink.mdw.service.Parameter)3 XmlException (org.apache.xmlbeans.XmlException)3 JSONException (org.json.JSONException)3 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)2 SubGraph (com.centurylink.mdw.designer.display.SubGraph)2 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)2