Search in sources :

Example 1 with VariableTypeVO

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

the class DesignerProxy method getVariableInfo.

/**
 * Must be called from the UI thread.
 */
public VariableTypeVO getVariableInfo(final VariableInstanceInfo varInstInfo) {
    String varType = varInstInfo.getType();
    VariableTranslator varTrans = getVariableTranslator(varType);
    final VariableTypeVO varTypeVO = new VariableTypeVO(0L, varType, varTrans == null ? null : varTrans.getClass().getName());
    if (varInstInfo.getStringValue() != null && varTypeVO.isJavaObjectType()) {
        BusyIndicator.showWhile(MdwPlugin.getShell().getDisplay(), new Runnable() {

            public void run() {
                DocumentReference docRef = new DocumentReference(varInstInfo.getStringValue());
                try {
                    Object obj = new JavaObjectTranslator().realToObject(getDocument(docRef).getContent());
                    varTypeVO.setVariableType(obj.getClass().getName());
                    varTypeVO.setUpdateable(obj instanceof SelfSerializable);
                } catch (TranslationException ex) {
                    if (MdwPlugin.getSettings().isLogConnectErrors())
                        PluginMessages.log(ex);
                    try {
                        if (!project.checkRequiredVersion(6, 1, 1)) {
                            String path = "DocumentValue?format=xml&id=" + docRef.getDocumentId() + "&type=" + varTypeVO.getVariableType();
                            String resp = getRestfulServer().invokeResourceService(path);
                            Resource res = Resource.Factory.parse(resp, Compatibility.namespaceOptions());
                            for (Parameter param : res.getParameterList()) {
                                if ("className".equals(param.getName()))
                                    varTypeVO.setVariableType(param.getStringValue());
                                else if ("isUpdateable".equals(param.getName()))
                                    varTypeVO.setUpdateable(Boolean.parseBoolean(param.getStringValue()));
                            }
                        }
                    } catch (Exception ex2) {
                        throw new RuntimeException(ex2.getMessage(), ex2);
                    }
                }
            }
        });
    }
    return varTypeVO;
}
Also used : JavaObjectTranslator(com.centurylink.mdw.common.translator.impl.JavaObjectTranslator) Resource(com.centurylink.mdw.service.Resource) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator) TranslationException(com.centurylink.mdw.common.exception.TranslationException) 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) VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) SelfSerializable(com.centurylink.mdw.common.translator.SelfSerializable) Parameter(com.centurylink.mdw.service.Parameter) JSONObject(org.json.JSONObject) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference)

Example 2 with VariableTypeVO

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

the class DesignerProxy method getVariableTranslator.

private VariableTranslator getVariableTranslator(String varType) {
    VariableTranslator vt = null;
    VariableTypeVO vo = dataAccess.getVariableType(varType);
    if (vo != null) {
        try {
            Class<? extends VariableTranslator> cl = Class.forName(vo.getTranslatorClass()).asSubclass(VariableTranslator.class);
            vt = cl.newInstance();
        } catch (Exception ex) {
            // can't create translator
            if (MdwPlugin.getSettings().isLogConnectErrors())
                PluginMessages.log(ex);
        }
    }
    return vt;
}
Also used : VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator) 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)

Example 3 with VariableTypeVO

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

the class VariableHelper method isDocumentVariable.

/**
 * This is another cheaper way for better guessing whether the variable
 * is a document variable, when variable instance value is available
 * @param vartype
 * @param value variable instance value
 * @return
 */
public static boolean isDocumentVariable(String vartype, String value) {
    VariableTranslator translator;
    VariableTypeVO vo = VariableTypeCache.getVariableTypeVO(vartype);
    if (vo == null)
        return false;
    try {
        Class<?> cl = Class.forName(vo.getTranslatorClass());
        translator = (VariableTranslator) cl.newInstance();
        return (translator instanceof DocumentReferenceTranslator);
    } catch (Exception e) {
        if (value == null)
            return false;
        return value.startsWith("DOCUMENT:");
    }
}
Also used : VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) DocumentReferenceTranslator(com.centurylink.mdw.common.translator.DocumentReferenceTranslator) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator)

Example 4 with VariableTypeVO

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

the class VariablesSection method getVariableTypes.

private Map<Integer, VariableTypeVO> getVariableTypes() {
    if (variableTypes == null) {
        variableTypes = new TreeMap<Integer, VariableTypeVO>();
        List<VariableTypeVO> variableTypeVOs = getDataAccess().getVariableTypes(false);
        Collections.sort(variableTypeVOs, new Comparator<VariableTypeVO>() {

            public int compare(VariableTypeVO vt1, VariableTypeVO vt2) {
                if (vt1.getVariableType().equals(String.class.getName()) && !vt2.getVariableType().equals(String.class.getName()))
                    return -1;
                if (vt2.getVariableType().equals(String.class.getName()) && !vt1.getVariableType().equals(String.class.getName()))
                    return +1;
                if (vt1.getVariableType().startsWith("java.") && !vt2.getVariableType().startsWith("java."))
                    return -1;
                if (vt2.getVariableType().startsWith("java.") && !vt1.getVariableType().startsWith("java."))
                    return +1;
                return vt1.getVariableType().compareToIgnoreCase(vt2.getVariableType());
            }
        });
        for (int i = 0; i < variableTypeVOs.size(); i++) {
            VariableTypeVO variableTypeVO = (VariableTypeVO) variableTypeVOs.get(i);
            variableTypes.put(new Integer(i), variableTypeVO);
        }
    }
    return variableTypes;
}
Also used : VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO)

Example 5 with VariableTypeVO

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

the class ProcessLaunchConfiguration method launchProcess.

protected void launchProcess(WorkflowProcess process, String masterRequestId, String owner, Long ownerId, boolean synchronous, String responseVarName, Map<String, String> parameters, Long activityId, boolean showLogs, boolean liveView) {
    List<VariableValue> variableValues = new ArrayList<>();
    for (Map.Entry<String, String> var : parameters.entrySet()) {
        VariableVO variableVO = process.getVariable(var.getKey());
        if (var.getValue().length() > 0) {
            VariableTypeVO varType = process.getProject().getDataAccess().getVariableType(variableVO.getVariableType());
            variableValues.add(new VariableValue(variableVO, varType, var.getValue()));
        }
    }
    DesignerProxy designerProxy = process.getProject().getDesignerProxy();
    try {
        if (showLogs || liveView) {
            watch = true;
            LogWatcher logWatcher = designerProxy.getLogWatcher(MdwPlugin.getDisplay());
            if (logWatcher.isRunning()) {
                MdwPlugin.getDisplay().syncExec(new Runnable() {

                    public void run() {
                        String message = "Live View is already monitoring an existing instance.  Disconnect to monitor new instance?";
                        watch = MessageDialog.openConfirm(MdwPlugin.getDisplay().getActiveShell(), "Live View", message);
                    }
                });
            }
            if (watch) {
                logWatcher.shutdown();
                logWatcher.setMasterRequestId(masterRequestId);
                logWatcher.setProcess(process);
                logWatcher.startup(liveView);
            }
        }
        if (synchronous) {
            String response = designerProxy.launchSynchronousProcess(process, masterRequestId, owner, ownerId, variableValues, responseVarName);
            if (isWriteToConsole())
                writeToConsole("Process Launch Response", response + "\n");
        } else {
            MDWStatusMessage statusMsg = designerProxy.launchProcess(process, masterRequestId, owner, ownerId, variableValues, activityId);
            if (isWriteToConsole())
                writeToConsole("Process Launch Response", statusMsg.getStatusMessage() + "\n");
        }
    } catch (Exception ex) {
        showError(ex, "Launch Process", process.getProject());
    }
}
Also used : VariableValue(com.centurylink.mdw.plugin.designer.model.VariableValue) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)13 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)5 VariableTranslator (com.centurylink.mdw.common.translator.VariableTranslator)5 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)5 IOException (java.io.IOException)4 RemoteException (java.rmi.RemoteException)4 JSONException (org.json.JSONException)4 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)3 TranslationException (com.centurylink.mdw.common.exception.TranslationException)3 DocumentReferenceTranslator (com.centurylink.mdw.common.translator.DocumentReferenceTranslator)3 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)3 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)3 VariableValue (com.centurylink.mdw.plugin.designer.model.VariableValue)3 FileNotFoundException (java.io.FileNotFoundException)3 ArrayList (java.util.ArrayList)3 ZipException (java.util.zip.ZipException)3 XmlException (org.apache.xmlbeans.XmlException)3 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)2 CoreException (org.eclipse.core.runtime.CoreException)2 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)1