Examples of Constraint


Examples of org.jbpm.workflow.core.Constraint

        split.setMetaData("y", 2);
        split.setMetaData("width", 3);
        split.setMetaData("height", 4);
        split.setType(Split.TYPE_XOR);
        Connection connection = new ConnectionImpl(split, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
        Constraint constraint = new ConstraintImpl();
        constraint.setName("constraint1 ><&&");
        constraint.setPriority(1);
        constraint.setDialect("dialect1");
        constraint.setType("type1");
        constraint.setConstraint("constraint-text1");
        split.setConstraint(connection, constraint);
        connection = new ConnectionImpl(split, Node.CONNECTION_DEFAULT_TYPE, ruleSetNode, Node.CONNECTION_DEFAULT_TYPE);
        constraint = new ConstraintImpl();
        constraint.setName("constraint2");
        constraint.setPriority(2);
        constraint.setDialect("dialect2");
        constraint.setType("type2");
        constraint.setConstraint("constraint-text2");
        split.setConstraint(connection, constraint);
        process.addNode(split);
        new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, split, Node.CONNECTION_DEFAULT_TYPE);
       
        EventNode eventNode = new EventNode();
        eventNode.setName("action");
        eventNode.setMetaData("x", 1);
        eventNode.setMetaData("y", 2);
        eventNode.setMetaData("width", 3);
        eventNode.setMetaData("height", 4);
        eventNode.setVariableName("eventVariable");
        EventTypeFilter eventFilter = new EventTypeFilter();
        eventFilter.setType("eventType");
        eventNode.addEventFilter(eventFilter);
        process.addNode(eventNode);
       
        Join join = new Join();
        join.setName("join");
        join.setMetaData("x", 1);
        join.setMetaData("y", 2);
        join.setMetaData("width", 3);
        join.setMetaData("height", 4);
        join.setType(Join.TYPE_N_OF_M);
        join.setN("#{var1}");
        process.addNode(join);
        new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
        new ConnectionImpl(ruleSetNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
        new ConnectionImpl(eventNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
       
        MilestoneNode milestone = new MilestoneNode();
        milestone.setName("milestone");
        milestone.setMetaData("x", 1);
        milestone.setMetaData("y", 2);
        milestone.setMetaData("width", 3);
        milestone.setMetaData("height", 4);
        milestone.setConstraint("constraint");
        timer = new Timer();
        timer.setDelay("100");
        timer.setPeriod("100");
        action = new DroolsConsequenceAction("dialect", "consequence");
        milestone.addTimer(timer, action);
        timer = new Timer();
        timer.setDelay("200");
        timer.setPeriod("200");
        action = new DroolsConsequenceAction("dialect", "consequence");
        milestone.addTimer(timer, action);
        List<DroolsAction> actions = new ArrayList<DroolsAction>();
        DroolsAction action1 = new DroolsConsequenceAction("java", "System.out.println(\"action1\");");
        actions.add(action1);
        DroolsAction action2 = new DroolsConsequenceAction("java", "System.out.println(\"action2\");");
        actions.add(action2);
        milestone.setActions(ExtendedNodeImpl.EVENT_NODE_ENTER, actions);
        milestone.setActions(ExtendedNodeImpl.EVENT_NODE_EXIT, actions);
        process.addNode(milestone);
        connection = new ConnectionImpl(join, Node.CONNECTION_DEFAULT_TYPE, milestone, Node.CONNECTION_DEFAULT_TYPE);
        connection.setMetaData("bendpoints", "[10,10;20,20]");
       
        SubProcessNode subProcess = new SubProcessNode();
        subProcess.setName("subProcess");
        subProcess.setMetaData("x", 1);
        subProcess.setMetaData("y", 2);
        subProcess.setMetaData("width", 3);
        subProcess.setMetaData("height", 4);
        subProcess.setProcessId("processId");
        subProcess.setWaitForCompletion(false);
        subProcess.setIndependent(false);
        subProcess.addInMapping("subvar1", "var1");
        subProcess.addOutMapping("subvar2", "var2");
        timer = new Timer();
        timer.setDelay("100");
        timer.setPeriod("100");
        action = new DroolsConsequenceAction("dialect", "consequence");
        subProcess.addTimer(timer, action);
        timer = new Timer();
        timer.setDelay("200");
        timer.setPeriod("200");
        action = new DroolsConsequenceAction("dialect", "consequence");
        subProcess.addTimer(timer, action);
        subProcess.setActions(ExtendedNodeImpl.EVENT_NODE_ENTER, actions);
        subProcess.setActions(ExtendedNodeImpl.EVENT_NODE_EXIT, actions);
        process.addNode(subProcess);
        connection = new ConnectionImpl(milestone, Node.CONNECTION_DEFAULT_TYPE, subProcess, Node.CONNECTION_DEFAULT_TYPE);
        connection.setMetaData("bendpoints", "[10,10]");

        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setName("WorkItem");
        Work work = new WorkImpl();
        work.setName("workname");
        Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>();
        ParameterDefinition parameterDefinition = new ParameterDefinitionImpl("param1", new StringDataType());
        parameterDefinitions.add(parameterDefinition);
        parameterDefinition = new ParameterDefinitionImpl("param2", new IntegerDataType());
        parameterDefinitions.add(parameterDefinition);
        work.setParameterDefinitions(parameterDefinitions);
        work.setParameter("param1", "value1");
        work.setParameter("param2", 1);
        workItemNode.setWork(work);
        workItemNode.setWaitForCompletion(false);
        workItemNode.addInMapping("param1", "var1");
        workItemNode.addOutMapping("param2", "var2");
        timer = new Timer();
        timer.setDelay("100");
        timer.setPeriod("100");
        action = new DroolsConsequenceAction("dialect", "consequence");
        workItemNode.addTimer(timer, action);
        timer = new Timer();
        timer.setDelay("200");
        timer.setPeriod("200");
        action = new DroolsConsequenceAction("dialect", "consequence");
        workItemNode.addTimer(timer, action);
        workItemNode.setActions(ExtendedNodeImpl.EVENT_NODE_ENTER, actions);
        workItemNode.setActions(ExtendedNodeImpl.EVENT_NODE_EXIT, actions);
        process.addNode(workItemNode);
        connection = new ConnectionImpl(subProcess, Node.CONNECTION_DEFAULT_TYPE, workItemNode, Node.CONNECTION_DEFAULT_TYPE);
        connection.setMetaData("bendpoints", "[]");
       
        HumanTaskNode humanTaskNode = new HumanTaskNode();
        humanTaskNode.setName("Human Task");
        work = humanTaskNode.getWork();
        parameterDefinitions = new HashSet<ParameterDefinition>();
        parameterDefinition = new ParameterDefinitionImpl("TaskName", new StringDataType());
        parameterDefinitions.add(parameterDefinition);
        parameterDefinition = new ParameterDefinitionImpl("ActorId", new StringDataType());
        parameterDefinitions.add(parameterDefinition);
        parameterDefinition = new ParameterDefinitionImpl("Priority", new StringDataType());
        parameterDefinitions.add(parameterDefinition);
        parameterDefinition = new ParameterDefinitionImpl("Comment", new StringDataType());
        parameterDefinitions.add(parameterDefinition);
        work.setParameterDefinitions(parameterDefinitions);
        work.setParameter("TaskName", "Do something");
        work.setParameter("ActorId", "John Doe");
        humanTaskNode.setWaitForCompletion(false);
        humanTaskNode.setActions(ExtendedNodeImpl.EVENT_NODE_ENTER, actions);
        humanTaskNode.setActions(ExtendedNodeImpl.EVENT_NODE_EXIT, actions);
        process.addNode(humanTaskNode);
        connection = new ConnectionImpl(workItemNode, Node.CONNECTION_DEFAULT_TYPE, humanTaskNode, Node.CONNECTION_DEFAULT_TYPE);
       
        TimerNode timerNode = new TimerNode();
        timerNode.setName("timer");
        timerNode.setMetaData("x", 1);
        timerNode.setMetaData("y", 2);
        timerNode.setMetaData("width", 3);
        timerNode.setMetaData("height", 4);
        timer = new Timer();
        timer.setDelay("1000");
        timer.setPeriod("1000");
        timerNode.setTimer(timer);
        process.addNode(timerNode);
        new ConnectionImpl(humanTaskNode, Node.CONNECTION_DEFAULT_TYPE, timerNode, Node.CONNECTION_DEFAULT_TYPE);
       
        ForEachNode forEachNode = new ForEachNode();
        forEachNode.setName("ForEach");
        forEachNode.setCollectionExpression("collection");
        forEachNode.setVariable("variableName", new ObjectDataType());
        forEachNode.setWaitForCompletion(false);
        ActionNode subActionNode1 = new ActionNode();
        forEachNode.getCompositeNode().addNode(subActionNode1);
        ActionNode subActionNode2 = new ActionNode();
        forEachNode.getCompositeNode().addNode(subActionNode2);
        new ConnectionImpl(subActionNode1, Node.CONNECTION_DEFAULT_TYPE, subActionNode2, Node.CONNECTION_DEFAULT_TYPE);
        forEachNode.getCompositeNode().linkIncomingConnections(Node.CONNECTION_DEFAULT_TYPE, subActionNode1.getId(), Node.CONNECTION_DEFAULT_TYPE);
        forEachNode.getCompositeNode().linkOutgoingConnections(subActionNode2.getId(), Node.CONNECTION_DEFAULT_TYPE, Node.CONNECTION_DEFAULT_TYPE);
        process.addNode(forEachNode);
        new ConnectionImpl(timerNode, Node.CONNECTION_DEFAULT_TYPE, forEachNode, Node.CONNECTION_DEFAULT_TYPE);
       
        CompositeContextNode compositeNode = new CompositeContextNode();
        compositeNode.setName("Composite");
        VariableScope variableScope = new VariableScope();
        compositeNode.addContext(variableScope);
        compositeNode.setDefaultContext(variableScope);
        variableScope.setVariables(variables);
        ExceptionScope exceptionScope = new ExceptionScope();
        compositeNode.addContext(exceptionScope);
        compositeNode.setDefaultContext(exceptionScope);
        exceptionHandler = new ActionExceptionHandler();
        exceptionHandler.setFaultVariable("faultVariable");
        action = new DroolsConsequenceAction("dialect", "consequence");
        exceptionHandler.setAction(action);
        exceptionScope.setExceptionHandler("MyFault", exceptionHandler);
        exceptionHandler = new ActionExceptionHandler();
        exceptionHandler.setFaultVariable("faultVariable2");
        action = new DroolsConsequenceAction("dialect2", "consequence2");
        exceptionHandler.setAction(action);
        exceptionScope.setExceptionHandler("MyFault2", exceptionHandler);
        subActionNode1 = new ActionNode();
        compositeNode.addNode(subActionNode1);
        subActionNode2 = new ActionNode();
        compositeNode.addNode(subActionNode2);
        new ConnectionImpl(subActionNode1, Node.CONNECTION_DEFAULT_TYPE, subActionNode2, Node.CONNECTION_DEFAULT_TYPE);
        compositeNode.linkIncomingConnections(Node.CONNECTION_DEFAULT_TYPE, subActionNode1.getId(), Node.CONNECTION_DEFAULT_TYPE);
        compositeNode.linkOutgoingConnections(subActionNode2.getId(), Node.CONNECTION_DEFAULT_TYPE, Node.CONNECTION_DEFAULT_TYPE);
        process.addNode(compositeNode);
        new ConnectionImpl(forEachNode, Node.CONNECTION_DEFAULT_TYPE, compositeNode, Node.CONNECTION_DEFAULT_TYPE);
       
        EndNode endNode = new EndNode();
        endNode.setName("end");
        endNode.setTerminate(false);
        endNode.setMetaData("x", 1);
        endNode.setMetaData("y", 2);
        endNode.setMetaData("width", 3);
        endNode.setMetaData("height", 4);
        process.addNode(endNode);
       
        StateNode stateNode = new StateNode();
        stateNode.setName("state");
        stateNode.setMetaData("x", 1);
        stateNode.setMetaData("y", 2);
        stateNode.setMetaData("width", 3);
        stateNode.setMetaData("height", 4);
        timer = new Timer();
        timer.setDelay("100");
        timer.setPeriod("100");
        action = new DroolsConsequenceAction("dialect", "consequence");
        stateNode.addTimer(timer, action);
        timer = new Timer();
        timer.setDelay("200");
        timer.setPeriod("200");
        action = new DroolsConsequenceAction("dialect", "consequence");
        stateNode.addTimer(timer, action);
        actions = new ArrayList<DroolsAction>();
        action1 = new DroolsConsequenceAction("java", "System.out.println(\"action1\");");
        actions.add(action1);
        action2 = new DroolsConsequenceAction("java", "System.out.println(\"action2\");");
        actions.add(action2);
        stateNode.setActions(ExtendedNodeImpl.EVENT_NODE_ENTER, actions);
        stateNode.setActions(ExtendedNodeImpl.EVENT_NODE_EXIT, actions);
        new ConnectionImpl(compositeNode, Node.CONNECTION_DEFAULT_TYPE, stateNode, Node.CONNECTION_DEFAULT_TYPE);
        connection = new ConnectionImpl(stateNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
        constraint = new ConstraintImpl();
        constraint.setName("constraint1 ><&&");
        constraint.setPriority(1);
        constraint.setDialect("dialect1");
        constraint.setType("type1");
        constraint.setConstraint("constraint-text1 %&<>");
        stateNode.setConstraint(connection, constraint);
        connection = new ConnectionImpl(stateNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
        constraint = new ConstraintImpl();
        constraint.setName("constraint2");
        constraint.setPriority(2);
        constraint.setDialect("dialect2");
        constraint.setType("type2");
        constraint.setConstraint("constraint-text2");
        stateNode.setConstraint(connection, constraint);
        process.addNode(stateNode);
       
        String xml = XmlRuleFlowProcessDumper.INSTANCE.dump(process, true);
        if (xml == null) {
View Full Code Here

Examples of org.jdesktop.swingx.JXStatusBar.Constraint

            public void invalidateLayout(Container target) {}
           
            public void addLayoutComponent(Component comp, Object constraint) {
                //we accept an Insets, a ResizeBehavior, or a Constraint.
                if (constraint instanceof Insets) {
                    constraint = new Constraint((Insets)constraint);
                } else if (constraint instanceof Constraint.ResizeBehavior) {
                    constraint = new Constraint((Constraint.ResizeBehavior)constraint);
                }
               
                constraints.put(comp, (Constraint)constraint);
            }
           
            public Dimension preferredLayoutSize(Container parent) {
                Dimension prefSize = new Dimension();
                int count = 0;
                for (Component comp : constraints.keySet()) {
                    Constraint c = constraints.get(comp);
                    Dimension d = comp.getPreferredSize();
                    int prefWidth = 0;
                    if (c != null) {
                        Insets i = c.getInsets();
                        d.width += i.left + i.right;
                        d.height += i.top + i.bottom;
                        prefWidth = c.getFixedWidth();
                    }
                    prefSize.height = Math.max(prefSize.height, d.height);
                    prefSize.width += Math.max(d.width, prefWidth);
                   
                    //If this is not the last component, add extra space between each
                    //component (for the separator).
                    count++;
                    if (includeSeparators() && constraints.size() < count) {
                        prefSize.width += getSeparatorWidth();
                    }
                }
               
                Insets insets = parent.getInsets();
                prefSize.height += insets.top + insets.bottom;
                prefSize.width += insets.left + insets.right;
                return prefSize;
            }
           
            public void layoutContainer(Container parent) {
                /*
                 * Layout algorithm:
                 *      If the parent width is less than the sum of the preferred
                 *      widths of the components (including separators), where
                 *      preferred width means either the component preferred width +
                 *      constraint insets, or fixed width + constraint insets, then
                 *      simply layout the container from left to right and let the
                 *      right hand components flow off the parent.
                 *
                 *      Otherwise, lay out each component according to its preferred
                 *      width except for components with a FILL constraint. For these,
                 *      resize them evenly for each FILL constraint.
                 */
               
                //the insets of the parent component.
                Insets parentInsets = parent.getInsets();
                //the available width for putting components.
                int availableWidth = parent.getWidth() - parentInsets.left - parentInsets.right;
                if (includeSeparators()) {
                    //remove from availableWidth the amount of space the separators will take
                    availableWidth -= (parent.getComponentCount() - 1) * getSeparatorWidth();
                }
               
                //the preferred widths of all of the components -- where preferred
                //width mean the preferred width after calculating fixed widths and
                //constraint insets
                int[] preferredWidths = new int[parent.getComponentCount()];
                int sumPreferredWidths = 0;
                for (int i=0; i<preferredWidths.length; i++) {
                    preferredWidths[i] = getPreferredWidth(parent.getComponent(i));
                    sumPreferredWidths += preferredWidths[i];
                }
               
                //if the availableWidth is greater than the sum of preferred
                //sizes, then adjust the preferred width of each component that
                //has a FILL constraint, to evenly use up the extra space.
                if (availableWidth > sumPreferredWidths) {
                    //the number of components with a fill constraint
                    int numFilledComponents = 0;
                    for (Component comp : parent.getComponents()) {
                        Constraint c = constraints.get(comp);
                        if (c != null && c.getResizeBehavior() == Constraint.ResizeBehavior.FILL) {
                            numFilledComponents++;
                        }
                    }
                   
                    if (numFilledComponents > 0) {
                        //calculate the share of free space each FILL component will take
                        availableWidth -= sumPreferredWidths;
                        double weight = 1.0 / (double)numFilledComponents;
                        int share = (int)(availableWidth * weight);
                        int remaining = numFilledComponents;
                        for (int i=0; i<parent.getComponentCount(); i++) {
                            Component comp = parent.getComponent(i);
                            Constraint c = constraints.get(comp);
                            if (c != null && c.getResizeBehavior() == Constraint.ResizeBehavior.FILL) {
                                if (remaining > 1) {
                                    preferredWidths[i] += share;
                                    availableWidth -= share;
                                } else {
                                    preferredWidths[i] += availableWidth;
                                }
                                remaining--;
                            }
                        }
                    }
                }
               
                //now lay out the components
                int nextX = parentInsets.left;
                int height = parent.getHeight() - parentInsets.top - parentInsets.bottom;
                for (int i=0; i<parent.getComponentCount(); i++) {
                    Component comp = parent.getComponent(i);
                    Constraint c = constraints.get(comp);
                    Insets insets = c == null ? new Insets(0,0,0,0) : c.getInsets();
                    int width = preferredWidths[i] - (insets.left + insets.right);
                    int x = nextX + insets.left;
                    int y = parentInsets.top + insets.top;
                    comp.setSize(width, height);
                    comp.setLocation(x, y);
                    nextX = x + width + insets.right;
                    //If this is not the last component, add extra space
                    //for the separator
                    if (includeSeparators() && i < parent.getComponentCount() - 1) {
                        nextX += getSeparatorWidth();
                    }
                }
            }
           
            /**
             * @return the "preferred" width, where that means either
             *         comp.getPreferredSize().width + constraintInsets, or
             *         constraint.fixedWidth + constraintInsets.
             */
            private int getPreferredWidth(Component comp) {
                Constraint c = constraints.get(comp);
                if (c == null) {
                    return comp.getPreferredSize().width;
                } else {
                    Insets insets = c.getInsets();
                    assert insets != null;
                    if (c.getFixedWidth() <= 0) {
                        return comp.getPreferredSize().width + insets.left + insets.right;
                    } else {
                        return c.getFixedWidth() + insets.left + insets.right;
                    }
                }
            }
           
        };
View Full Code Here

Examples of org.jmock.Constraint

    public ConstraintsTest(String test) {
        super(test);
    }

    public void testIsNull() {
        Constraint p = new IsNull();

        assertTrue(p.eval(null));
        assertTrue(!p.eval(new Object()));
    }
View Full Code Here

Examples of org.jmock.Constraint

    }

    public void testIsSame() {
        Object o1 = new Object();
        Object o2 = new Object();
        Constraint p = new IsSame(o1);

        assertTrue(p.eval(o1));
        assertTrue(!p.eval(o2));
    }
View Full Code Here

Examples of org.jmock.Constraint

    }

    public void testIsEqual() {
        Integer i1 = new Integer(1);
        Integer i2 = new Integer(2);
        Constraint p = new IsEqual(i1);

        assertTrue(p.eval(i1));
        assertTrue(p.eval(new Integer(1)));
        assertTrue(!p.eval(i2));
    }
View Full Code Here

Examples of org.jmock.Constraint

        String[] s1 = new String[]{"a", "b"};
        String[] s2 = new String[]{"a", "b"};
        String[] s3 = new String[]{"c", "d"};
        String[] s4 = new String[]{"a", "b", "c", "d"};

        Constraint p = new IsEqual(s1);

        assertTrue("Should equal itself", p.eval(s1));
        assertTrue("Should equal a similar array", p.eval(s2));
        assertTrue("Should not equal a different array", !p.eval(s3));
        assertTrue("Should not equal a different sized array", !p.eval(s4));
    }
View Full Code Here

Examples of org.jmock.Constraint

    }

    public void testIsEqualToStringOnProxyArgument() {
        // Required for error message reporting
        Mock mockDummyInterface = new Mock(DummyInterface.class, "MockName");
        Constraint p = new IsEqual(mockDummyInterface.proxy());

        AssertMo.assertIncludes("Should get resolved toString() with no expectation error", "MockName", p.toString());
    }
View Full Code Here

Examples of org.jmock.Constraint

        assertFalse("Should not be equal - same type different values", new IsEqual("a").equals(new IsEqual("b")));
        assertFalse("Should not be equal - different type", new IsEqual("a").equals("b"));
    }

    public void testIsGreaterThan() {
        Constraint p = new IsGreaterThan(new Integer(1));

        assertTrue(!p.eval(new Integer(0)));
        assertTrue(!p.eval(new Integer(1)));
        assertTrue(p.eval(new Integer(2)));
    }
View Full Code Here

Examples of org.jmock.Constraint

        assertTrue(!p.eval(new Integer(1)));
        assertTrue(p.eval(new Integer(2)));
    }

    public void testIsLessThan() {
        Constraint p = new IsLessThan(new Integer(1));

        assertTrue(p.eval(new Integer(0)));
        assertTrue(!p.eval(new Integer(1)));
        assertTrue(!p.eval(new Integer(2)));
    }
View Full Code Here

Examples of org.jmock.Constraint

        assertTrue(!p.eval(new Integer(1)));
        assertTrue(!p.eval(new Integer(2)));
    }

    public void testIsAnything() {
        Constraint p = new IsAnything();
        assertTrue(p.eval(null));
        assertTrue(p.eval(new Object()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.