Package org.jbpm.ui.common.model

Examples of org.jbpm.ui.common.model.ProcessDefinition


    }
   
    @Override
    public final String showConfigurationDialog(Delegable delegable) {
        Map<String, String> variableNames = new HashMap<String, String>();
        ProcessDefinition definition = ((GraphElement) delegable).getProcessDefinition();
        for (Variable variable : definition.getVariablesList()) {
            variableNames.put(variable.getName(), variable.getFormat());
        }
        for (String swimlaneName : definition.getSwimlaneNames()) {
            variableNames.put(swimlaneName, "ru.runa.wf.web.forms.format.StringFormat");
        }
       
        ConfigurationWizardPage page = new ConfigurationWizardPage(
                variableNames,
View Full Code Here


    private static Map<Transition, String> TRANSITION_TARGETS = new HashMap<Transition, String>();

    @Override
    public ProcessDefinition parseXML(Document document) {
        TRANSITION_TARGETS.clear();
        ProcessDefinition definition = create(document.getDocumentElement(), null);

        NodeList swimlanes = document.getElementsByTagName(SWIMLANE_NODE);
        for (int i = 0; i < swimlanes.getLength(); i++) {
            Node node = swimlanes.item(i);
            create(node, definition);
        }

        NodeList startStates = document.getElementsByTagName(START_STATE_NODE);
        if (startStates.getLength() == 1) {
            Node node = startStates.item(0);
            StartState startState = create(node, definition);
            NodeList stateChilds = node.getChildNodes();
            for (int j = 0; j < stateChilds.getLength(); j++) {
                Node stateNodeChild = stateChilds.item(j);
                if (TASK_NODE.equals(stateNodeChild.getNodeName())) {
                    String swimlaneName = getAttribute(stateNodeChild, SWIMLANE_NODE);
                    Swimlane swimlane = definition.getSwimlaneByName(swimlaneName);
                    startState.setSwimlane(swimlane);
                }
            }
        }

        NodeList actionNodeNodes = document.getElementsByTagName(ACTION_NODE_NODE);
        for (int i = 0; i < actionNodeNodes.getLength(); i++) {
            Node node = actionNodeNodes.item(i);
            ActionNode actionNode = create(node, definition);
            NodeList aaa = node.getChildNodes();
            for (int k = 0; k < aaa.getLength(); k++) {
                Node a = aaa.item(k);
                if (EVENT_NODE.equals(a.getNodeName())) {
                    String eventType = getAttribute(a, "type");
                    NodeList actionNodes = a.getChildNodes();
                    for (int l = 0; l < actionNodes.getLength(); l++) {
                        Node aa = actionNodes.item(l);
                        if (ACTION_NODE.equals(aa.getNodeName())) {
                            parseAction(aa, actionNode, eventType);
                        }
                    }
                }
            }
        }

        NodeList states = document.getElementsByTagName(TASK_STATE_NODE);
        for (int i = 0; i < states.getLength(); i++) {
            Node node = states.item(i);
            NodeList nodeList = node.getChildNodes();

            int transitionsCount = 0;
            boolean hasTimeOutTransition = false;
            for (int j = 0; j < nodeList.getLength(); j++) {
                Node childNode = nodeList.item(j);
                if (TRANSITION_NODE.equals(childNode.getNodeName())) {
                  String transitionName = getAttribute(childNode, NAME_ATTR);
                  if (PluginConstants.TIMER_TRANSITION_NAME.equals(transitionName)) {
                    hasTimeOutTransition = true;
                  }
                  transitionsCount++;
                }
            }
            GraphElement state;
            if (transitionsCount == 1 && hasTimeOutTransition) {
              state = create(node, definition, "waitState");
            } else {
              state = create(node, definition);
            }

            // TODO use SAX parser instead
            NodeList stateChilds = node.getChildNodes();
            for (int j = 0; j < stateChilds.getLength(); j++) {
                Node stateNodeChild = stateChilds.item(j);
                if (TASK_NODE.equals(stateNodeChild.getNodeName())) {
                    String swimlaneName = getAttribute(stateNodeChild, SWIMLANE_NODE);
                    if (swimlaneName != null && state instanceof SwimlanedNode) {
                      Swimlane swimlane = definition.getSwimlaneByName(swimlaneName);
                      ((SwimlanedNode) state).setSwimlane(swimlane);
                      String reassign = getAttribute(stateNodeChild, REASSIGN_ATTR);
                      if (reassign != null) {
                            boolean forceReassign = Boolean.parseBoolean(reassign);
                            ((State) state).setReassignmentEnabled(forceReassign);
                      }
                    }
                   
                    NodeList aaa = stateNodeChild.getChildNodes();
                    for (int k = 0; k < aaa.getLength(); k++) {
                        Node a = aaa.item(k);
                        if (EVENT_NODE.equals(a.getNodeName())) {
                            String eventType = getAttribute(a, "type");
                            NodeList actionNodes = a.getChildNodes();
                            for (int l = 0; l < actionNodes.getLength(); l++) {
                                Node aa = actionNodes.item(l);
                                if (ACTION_NODE.equals(aa.getNodeName())) {
                                    parseAction(aa, state, eventType);
                                }
                            }
                        }
                    }
                }
                if (TIMER_NODE.equals(stateNodeChild.getNodeName())) {
                  String dueDate = getAttribute(stateNodeChild, DUEDATE_ATTR);
                    ((ITimed) state).setDueDate(dueDate);
                    NodeList actionNodes = stateNodeChild.getChildNodes();
                    for (int l = 0; l < actionNodes.getLength(); l++) {
                        Node aa = actionNodes.item(l);
                        if (ACTION_NODE.equals(aa.getNodeName())) {
                            TimerAction timerAction = new TimerAction(null);
                            timerAction.setDelegationClassName(getAttribute(aa, CLASS_ATTR));
                            timerAction.setDelegationConfiguration(getTextContent(aa));
                            timerAction.setRepeat(getAttribute(stateNodeChild, REPEAT_ATTR));
                            ((ITimed) state).setTimerAction(timerAction);
                        }
                    }
                }
            }
        }

        NodeList mailNodes = document.getElementsByTagName(MAIL_NODE);
        for (int i = 0; i < mailNodes.getLength(); i++) {
            Node node = mailNodes.item(i);
            MailNode mailNode = create(node, definition);
            mailNode.setRecipient(getAttribute(node, "to"));
            NodeList mailNodeChilds = node.getChildNodes();
            for (int j = 0; j < mailNodeChilds.getLength(); j++) {
                Node mailNodeChild = mailNodeChilds.item(i);
                if ("body".equals(mailNodeChild.getNodeName())) {
                    mailNode.setMailBody(getTextContent(mailNodeChild));
                }
                if ("subject".equals(mailNodeChild.getNodeName())) {
                    mailNode.setSubject(getTextContent(mailNodeChild));
                }
            }
        }

        NodeList forks = document.getElementsByTagName(FORK_NODE);
        for (int i = 0; i < forks.getLength(); i++) {
            Node node = forks.item(i);
            create(node, definition);
        }

        NodeList joins = document.getElementsByTagName(JOIN_NODE);
        for (int i = 0; i < joins.getLength(); i++) {
            Node node = joins.item(i);
            create(node, definition);
        }

        NodeList decisions = document.getElementsByTagName(DECISION_NODE);
        for (int i = 0; i < decisions.getLength(); i++) {
            Node node = decisions.item(i);
            create(node, definition);
        }

        NodeList processStates = document.getElementsByTagName(PROCESS_STATE_NODE);
        for (int i = 0; i < processStates.getLength(); i++) {
            Node node = processStates.item(i);
            Subprocess subprocess = create(node, definition);
            List<VariableMapping> variablesList = new ArrayList<VariableMapping>();
            NodeList nodeList = node.getChildNodes();
            for (int j = 0; j < nodeList.getLength(); j++) {
                Node childNode = nodeList.item(j);
                if (SUB_PROCESS_NODE.equals(childNode.getNodeName())) {
                    subprocess.setSubProcessName(getAttribute(childNode, NAME_ATTR));
                }
                if (VARIABLE_NODE.equals(childNode.getNodeName())) {
                    VariableMapping variable = new VariableMapping();
                    variable.setProcessVariable(getAttribute(childNode, NAME_ATTR));
                    variable.setSubprocessVariable(getAttribute(childNode, MAPPED_NAME_ATTR));
                    variable.setUsage(getAttribute(childNode, ACCESS_ATTR));
                    variablesList.add(variable);
                }
            }
            subprocess.setVariablesList(variablesList);
        }

        NodeList multiInstanceStates = document.getElementsByTagName(MULTI_INSTANCE_STATE_NODE);
        for (int i = 0; i < multiInstanceStates.getLength(); i++) {
            Node node = multiInstanceStates.item(i);
            MultiInstance multiInstance = create(node, definition);
            List<VariableMapping> variablesList = new ArrayList<VariableMapping>();
            NodeList nodeList = node.getChildNodes();
            for (int j = 0; j < nodeList.getLength(); j++) {
                Node childNode = nodeList.item(j);
                if (SUB_PROCESS_NODE.equals(childNode.getNodeName())) {
                    multiInstance.setSubProcessName(getAttribute(childNode, NAME_ATTR));
                }
                if (VARIABLE_NODE.equals(childNode.getNodeName())) {
                    VariableMapping variable = new VariableMapping();
                    variable.setProcessVariable(getAttribute(childNode, NAME_ATTR));
                    variable.setSubprocessVariable(getAttribute(childNode, MAPPED_NAME_ATTR));
                    variable.setUsage(getAttribute(childNode, ACCESS_ATTR));
                    variablesList.add(variable);
                }
            }
            multiInstance.setVariablesList(variablesList);
        }

        NodeList endStates = document.getElementsByTagName(END_STATE_NODE);
        for (int i = 0; i < endStates.getLength(); i++) {
            Node node = endStates.item(i);
            create(node, definition);
        }

        List<Transition> tmpTransitions = new ArrayList<Transition>(TRANSITION_TARGETS.keySet());
        for (Transition transition : tmpTransitions) {
            String targetName = TRANSITION_TARGETS.remove(transition);
            org.jbpm.ui.common.model.Node target = definition.getNodeByNameNotNull(targetName);
            transition.setTarget(target);
        }

        return definition;
    }
View Full Code Here

public class FormulaCellEditorProvider extends DelegableProvider {

    @Override
    protected DelegableConfigurationDialog createConfigurationDialog(Delegable delegable) {
        ProcessDefinition definition = ((GraphElement) delegable).getProcessDefinition();
        return new ConfigurationDialog(
                delegable.getDelegationConfiguration(),
                definition.getVariableNames(true));
    }
View Full Code Here

    public synchronized ProcessDefinition convert(ProcessDefinition oldDef, String newJpdlVersion) throws Exception {
        this.log = new StringBuffer("--- JPDL version update to ").append(newJpdlVersion);
        this.newJpdlVersion = newJpdlVersion;
        try {
            ProcessDefinition newDef = JpdlVersionRegistry.getElementTypeDefinition(newJpdlVersion, oldDef.getTypeName()).createElement();
            setProperties(oldDef, newDef, false);

            addElements(oldDef, newDef, org.jbpm.ui.common.model.StartState.class, "start-state");
            addElements(oldDef, newDef, org.jbpm.ui.jpdl2.model.TimerState.class, "task-node");
            addElements(oldDef, newDef, org.jbpm.ui.common.model.WaitState.class, "waitState");
            addElements(oldDef, newDef, org.jbpm.ui.common.model.Decision.class, "decision");
            addElements(oldDef, newDef, org.jbpm.ui.common.model.Fork.class, "fork");
            addElements(oldDef, newDef, org.jbpm.ui.common.model.Join.class, "join");
            addElements(oldDef, newDef, org.jbpm.ui.common.model.Subprocess.class, "process-state");
            addElements(oldDef, newDef, org.jbpm.ui.common.model.EndState.class, "end-state");
            addElements(oldDef, newDef, org.jbpm.ui.common.model.Swimlane.class, "swimlane");

            List<Variable> oldVariables = oldDef.getChildren(Variable.class);
            for (Variable oldVariable : oldVariables) {
                Variable newVariable = new Variable(oldVariable.getName(), oldVariable.getFormat(), oldVariable.isPublicVisibility());
                newDef.addChild(newVariable);
            }

            log.append(" ---");
            return newDef;
        } finally {
View Full Code Here

        List<String> names = ProcessCache.getAllProcessDefinitionNames();
        return names.toArray(new String[names.size()]);
    }

    private List<String> getProcessVariablesNames(String name) {
        ProcessDefinition definition = ProcessCache.getProcessDefinition(name);
        if (definition != null) {
            return definition.getVariableNames(true);
        }
        return new ArrayList<String>();
    }
View Full Code Here

        }
        return new ArrayList<String>();
    }

    private boolean isArrayVariable(String name, String variableName) {
        ProcessDefinition definition = ProcessCache.getProcessDefinition(name);
        if (definition != null) {
            Variable variable = definition.getVariablesMap().get(variableName);
            if (variable != null) {
                return variable.getFormat().contains("Array");
            }
        }
        return false;
View Full Code Here

public class SQLHandlerCellEditorProvider extends DelegableProvider {

    @Override
    public String showConfigurationDialog(Delegable delegable) {
        ProcessDefinition definition = ((GraphElement) delegable).getProcessDefinition();
        SQLActionHandlerConfigDialog dialog = new SQLActionHandlerConfigDialog(
                definition, delegable.getDelegationConfiguration());
        if (dialog.open() == Dialog.OK) {
            return dialog.getResult();
        }
View Full Code Here

public class BSHCellEditorProvider extends DelegableProvider implements IDecisionProvider {

    @Override
    public String showConfigurationDialog(Delegable delegable) {
        ProcessDefinition definition = ((GraphElement) delegable).getProcessDefinition();
        List<Transition> transitions = ((Decision) delegable).getLeavingTransitions();
        List<String> transitionNames = new ArrayList<String>();
        for (Transition transition : transitions) {
            transitionNames.add(transition.getName());
        }

        BSHEditorDialog dialog = new BSHEditorDialog(
                delegable.getDelegationConfiguration(),
                transitionNames,
                definition.getVariablesList());

        if (dialog.open() == Dialog.OK) {
            return dialog.getResult();
        }
        return null;
View Full Code Here

public class BSHActionHandlerProvider extends DelegableProvider {

    @Override
    protected DelegableConfigurationDialog createConfigurationDialog(Delegable delegable) {
        ProcessDefinition definition = ((GraphElement) delegable).getProcessDefinition();
        return new ConfigurationDialog(
                delegable.getDelegationConfiguration(),
                definition.getVariableNames(true));
    }
View Full Code Here

public class SwimlaneInitializerProvider extends DelegableProvider {

    @Override
    public String showConfigurationDialog(Delegable delegable) {
        Swimlane swimlane = (Swimlane) delegable;
        ProcessDefinition definition = swimlane.getProcessDefinition();

        String path = definition.getSwimlaneGUIConfiguration().getEditorPath(swimlane.getName());
        SwimlaneConfigDialog dialog = new SwimlaneConfigDialog(definition, swimlane, path);
        if (dialog.open() == IDialogConstants.OK_ID) {
            definition.getSwimlaneGUIConfiguration().putSwimlanePath(swimlane.getName(), dialog.getPath());
            return dialog.getConfiguration();
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.jbpm.ui.common.model.ProcessDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.