Search in sources :

Example 11 with CodeTimer

use of com.centurylink.mdw.plugin.CodeTimer in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method forceUpdateProcess.

/**
 * Relies on classic designer page to update the processVO with the reloaded
 * data.
 */
public void forceUpdateProcess(WorkflowProcess processVersion, FlowchartPage flowchartPage, boolean validate, boolean lock) throws ValidationException, DataAccessException, RemoteException {
    CodeTimer timer = new CodeTimer("forceUpdateProcess()");
    Graph graph = flowchartPage.getProcess();
    graph.save_temp_vars();
    if (validate)
        new ProcessValidator(processVersion.getProcessVO()).validate(getNodeMetaInfo());
    if (!processVersion.getProject().checkRequiredVersion(5, 5))
        flowchartPage.setProcessVersions(flowchartPage.getProcess(), // not
        !processVersion.getProject().checkRequiredVersion(5, 2));
    // sure
    // why
    // this
    // was
    // ever
    // needed
    Graph reloaded = null;
    try {
        reloaded = flowchartPage.saveProcess(graph, mainFrame, PersistType.UPDATE, 0, lock);
    } catch (ValidationException ex) {
        if (ex.getMessage() != null && ex.getMessage().contains(ORA_02292))
            throw new ValidationException(INCOMPATIBLE_INSTANCES);
        else
            throw ex;
    }
    flowchartPage.setProcess(reloaded);
    processVersion.setProcessVO(reloaded.getProcessVO());
    cacheRefresh.fireRefresh(reloaded.getProcessVO().hasDynamicJavaActivity());
    timer.stopAndLog();
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) ProcessValidator(com.centurylink.mdw.designer.utils.ProcessValidator)

Example 12 with CodeTimer

use of com.centurylink.mdw.plugin.CodeTimer in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method setPackage.

public void setPackage(WorkflowPackage workflowPackage) throws DataAccessException, RemoteException {
    if (workflowPackage.isDefaultPackage())
        return;
    CodeTimer timer = new CodeTimer("setPackage()");
    Long pkgId = dataAccess.getDesignerDataAccess().savePackage(workflowPackage.getPackageVO());
    workflowPackage.getPackageVO().setPackageId(pkgId);
    workflowPackage.getProject().fireElementChangeEvent(workflowPackage, ChangeType.VERSION_CHANGE, workflowPackage.getVersionString());
    workflowPackage.fireElementChangeEvent(ChangeType.VERSION_CHANGE, workflowPackage.getVersionString());
    timer.stopAndLog();
}
Also used : CodeTimer(com.centurylink.mdw.plugin.CodeTimer)

Example 13 with CodeTimer

use of com.centurylink.mdw.plugin.CodeTimer 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)

Example 14 with CodeTimer

use of com.centurylink.mdw.plugin.CodeTimer in project mdw-designer by CenturyLinkCloud.

the class CacheRefresh method doRefresh.

public void doRefresh(boolean silent, final boolean includeDynamicJava) {
    try {
        if (silent) {
            if (workflowProject.isUpdateServerCache()) {
                // run as background job
                new Job("MDW Cache Refresh: " + restfulServer.getMdwWebUrl()) {

                    protected IStatus run(IProgressMonitor monitor) {
                        try {
                            CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
                            refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
                            timer.stopAndLog();
                        } catch (Exception ex) {
                            if (MdwPlugin.getSettings().isLogConnectErrors())
                                PluginMessages.log(ex);
                        }
                        return Status.OK_STATUS;
                    }
                }.schedule();
            }
        } else {
            String progressMsg = "Refreshing Caches and Properties for '" + workflowProject.getLabel() + "'";
            String errorMsg = "Refresh Cache";
            DesignerRunner designerRunner = new DesignerRunner(progressMsg, errorMsg, workflowProject) {

                public void perform() throws ValidationException, DataAccessException, RemoteException {
                    try {
                        CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
                        refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
                        timer.stopAndLog();
                    } catch (Exception ex) {
                        PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
                    }
                }
            };
            designerRunner.run();
            if (refreshStatusMessage == null) {
                PluginMessages.uiError(workflowProject.getName() + " Refresh Caches and Properties failed.  Make sure baseline event handlers are registered.", REFRESH_CACHES, workflowProject);
            } else if (refreshStatusMessage.getMDWStatusMessage().getStatusCode() != 0) {
                String message = refreshStatusMessage.getMDWStatusMessage().getStatusMessage();
                PluginMessages.uiMessage(workflowProject.getName() + " Refresh Caches and Properties:\n" + message, "Refresh Caches", workflowProject, PluginMessages.INFO_MESSAGE);
            }
        }
    } catch (Exception ex) {
        if (!silent)
            PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Job(org.eclipse.core.runtime.jobs.Job) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException)

Example 15 with CodeTimer

use of com.centurylink.mdw.plugin.CodeTimer in project mdw-designer by CenturyLinkCloud.

the class CacheRefresh method fireRefresh.

/**
 * Don't wait for response
 */
public void fireRefresh(final boolean includeDynamicJava) {
    if (workflowProject.isUpdateServerCache()) {
        new Thread(new Runnable() {

            public void run() {
                CodeTimer timer = new CodeTimer("fireProcessCacheRefresh()");
                try {
                    restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
                } catch (Exception ex) {
                    if (MdwPlugin.getSettings().isLogConnectErrors())
                        PluginMessages.log(ex.toString());
                    if ("true".equals(System.getProperty("mdw.designer.show.connect.stack.trace")))
                        PluginMessages.log(ex);
                }
                timer.stopAndLog();
            }
        }).start();
    }
}
Also used : CodeTimer(com.centurylink.mdw.plugin.CodeTimer) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException)

Aggregations

CodeTimer (com.centurylink.mdw.plugin.CodeTimer)15 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)7 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)6 ArrayList (java.util.ArrayList)6 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)5 Graph (com.centurylink.mdw.designer.display.Graph)4 SubGraph (com.centurylink.mdw.designer.display.SubGraph)4 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)4 RemoteException (java.rmi.RemoteException)4 HashMap (java.util.HashMap)4 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)3 Folder (com.centurylink.mdw.plugin.designer.model.Folder)3 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)3 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)3 IOException (java.io.IOException)3 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)2 TranslationException (com.centurylink.mdw.common.exception.TranslationException)2 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)2 ProcessValidator (com.centurylink.mdw.designer.utils.ProcessValidator)2 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)2