Package au.edu.qut.yawl.elements.state

Examples of au.edu.qut.yawl.elements.state.YIdentifier


        _engine = YEngine.getInstance();
        EngineClearer.clear(_engine);
//todo AJH:Obsoltete ????
//        String sessionHandle = _engine.connect("admin", "YAWL");
        _engine.loadSpecification(specification);
        YIdentifier id = _engine.startCase(null, null, specification.getID(), null, null);
        {
            YWorkItem itemA = (YWorkItem)_engine.getAvailableWorkItems().iterator().next();
//            _localWorklist.startOneWorkItemAndSetOthersToFired(
//                    itemA.getCaseID().toString(), itemA.getTaskID());
            _engine.startWorkItem(itemA, "admin");
View Full Code Here


        assertTrue(_condition.getName().equals("C1"));
  }


    public void testMovingIdentifiers() throws YStateException, YDataStateException, YQueryException, YSchemaBuildingException, YPersistenceException {
        YIdentifier id = new YIdentifier();
        assertTrue(id.getLocations().size() == 0);
        assertFalse(id.getLocations().contains(_condition));
        _condition.add(null, id);
        assertTrue("locations should contain C1 ",
                id.getLocations().contains(_condition) && id.getLocations().size() == 1);
        assertTrue(id.getLocations().contains(_condition));
        assertTrue(_aTask.t_enabled(id));
        YIdentifier childID = null;
        childID = (YIdentifier) _aTask.t_fire(null).get(0);

        assertTrue("locations should be empty ", id.getLocations().size() == 1);
        assertTrue(id.getLocations().iterator().next().equals(_aTask));
        assertFalse(id.getLocations().contains(_condition));
View Full Code Here

    public List getIdentifiers() {
        return _bag.getIdentifiers();
    }

    public YIdentifier removeOne(YPersistenceManager pmgr) throws YPersistenceException {
        YIdentifier identifier = (YIdentifier) getIdentifiers().get(0);
        _bag.remove(pmgr, identifier, 1);
        return identifier;
    }
View Full Code Here


    public void setUp() throws Exception {
        _workitemRepository = YWorkItemRepository.getInstance();
        _workitemRepository.clear();
        YIdentifier identifier = new YIdentifier();
        YWorkItemID workItemID = new YWorkItemID(identifier, "task-123");
        _parentWorkItem = new YWorkItem(null, "ASpecID", workItemID, false, false);
        for (int i = 0; i < 5; i++) {
            _parentWorkItem.createChild(null, identifier.createChild(null));
        }
    }
View Full Code Here

    }


    public void testGetItem() throws YPersistenceException {
        assertTrue(_workitemRepository.getEnabledWorkItems().size() == 0);
        new YWorkItem(null, "A spec", new YWorkItemID(new YIdentifier(), "task4321"), false, false);
        assertEquals(
                _workitemRepository.getWorkItem(
                        _parentWorkItem.getCaseID().toString(), _parentWorkItem.getTaskID()),
                _parentWorkItem);
        _workitemRepository.removeWorkItemFamily(_parentWorkItem);
View Full Code Here

    public synchronized void cancel(YPersistenceManager pmgr) throws YPersistenceException {
        if (_i != null) {
            List activeChildIdentifiers = _mi_active.getIdentifiers();
            Iterator iter = activeChildIdentifiers.iterator();
            while (iter.hasNext()) {
                YIdentifier identifier = (YIdentifier) iter.next();
                YNetRunner netRunner = _workItemRepository.getNetRunner(identifier);
                if (netRunner != null) {
                    netRunner.cancel(pmgr);
                }
            }
View Full Code Here

    public void testMultimergeNets() throws YDataStateException, YStateException, YQueryException, YSchemaBuildingException, YPersistenceException {
        synchronized(this){
        EngineClearer.clear(_engine);
        _engine.loadSpecification(_specification);
        YIdentifier id = _engine.startCase(null, null, _specification.getID(), null, null);
        _netRunner = (YNetRunner) _engine._caseIDToNetRunnerMap.get(id);
        try {
//            YNetRunner _netRunner = _basicEngine2.getNetRunner();
//            YIdentifier _idForBottomNet;
            //enabled btop
View Full Code Here

    public void testMultimergeWorkItems() throws YDataStateException, YStateException, YQueryException, YSchemaBuildingException, YPersistenceException {
        synchronized(this){
        EngineClearer.clear(_engine);
        _engine.loadSpecification(_specification);
        YIdentifier id = _engine.startCase(null, null, _specification.getID(), null, null);
        _netRunner = (YNetRunner) _engine._caseIDToNetRunnerMap.get(id);
        try {
//            YNetRunner _netRunner = _basicEngine2.getNetRunner();
//            YIdentifier _idForBottomNet;
            //enabled btop
View Full Code Here

        specification = (YSpecification) YMarshal.
                unmarshalSpecifications(yawlXMLFile.getAbsolutePath()).get(0);
        _engine = YEngine.getInstance();
        EngineClearer.clear(_engine);
        _engine.loadSpecification(specification);
        YIdentifier caseID = _engine.startCase(null, null, specification.getID().toString(), null, null);
        {
            YWorkItem itemA = (YWorkItem) _engine.getAvailableWorkItems().iterator().next();
            _engine.startWorkItem(itemA, "admin");

            try {
                Thread.sleep(_sleepTime);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }

            itemA = (YWorkItem) _engine.getChildrenOfWorkItem(
                    itemA).iterator().next();
            _engine.completeWorkItem(itemA, "<data/>", false);
            try {
                Thread.sleep(_sleepTime);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
        }
        {
            YWorkItem itemF = null;
            Iterator it = _engine.getAvailableWorkItems().iterator();
            while (it.hasNext()) {
                YWorkItem item = (YWorkItem) it.next();
                if (item.getTaskID().equals("F")) {
                    itemF = item;
                    break;
                }
            }
            _engine.startWorkItem(itemF, "admin");
            try {
                Thread.sleep(_sleepTime);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }

            itemF = (YWorkItem) _engine.getChildrenOfWorkItem(itemF).iterator().next();
            _engine.completeWorkItem(itemF, "<data/>", false);
            try {
                Thread.sleep(_sleepTime);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
        }
        {
            YWorkItem itemB = null;
            Iterator it = _engine.getAvailableWorkItems().iterator();
            while (it.hasNext()) {
                YWorkItem item = (YWorkItem) it.next();
                if (item.getTaskID().equals("B")) {
                    itemB = item;
                    break;
                }
            }
            _engine.startWorkItem(itemB, "admin");
            try {
                Thread.sleep(_sleepTime);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }

            itemB = (YWorkItem) _engine.getChildrenOfWorkItem(itemB).iterator().next();
            _engine.completeWorkItem(itemB, "<data/>", false);
            try {
                Thread.sleep(_sleepTime);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
        }
        {
            YWorkItem itemA = (YWorkItem) _engine.getAvailableWorkItems()
                    .iterator().next();
            //get the real net elements that contain the identifier tokens.
            List locations = caseID.getLocations();
            for (int i = 0; i < locations.size(); i++) {
                YExternalNetElement element = (YExternalNetElement) locations.get(i);
                if (element instanceof YTask) {
                    YTask task = (YTask) element;
                    Set preset = task.getPresetElements();
                    Set items = _engine.getAvailableWorkItems();
                    //If the task is enabled we test that the work items reflect this.
                    if (task.t_enabled(caseID)) {
                        boolean tokenFound = false;
                        //Check that the conitions in the preset confirm the enabled
                        //state of the task.
                        for (Iterator presetIter = preset.iterator(); presetIter.hasNext();) {
                            YCondition condition = (YCondition) presetIter.next();
                            if (condition.containsIdentifier()) {
                                tokenFound = true;
                            }
                        }
                        assertTrue("State misaligment found: task [" +
                                task + "] is enabled but has no tokens in " +
                                "its preset2.", tokenFound);
                        //Check that there is one work enabled work item to match the enabled
                        //state of the task.
                        boolean workItemFound = false;
                        for (Iterator iterator = items.iterator(); iterator.hasNext();) {
                            YWorkItem anItem = (YWorkItem) iterator.next();
                            if(anItem.getTaskID().equals(task.getID())){
                                if(! anItem.getStatus().equals(YWorkItem.statusEnabled)){
                                    fail("The work item [" + anItem + "] " +
                                            "should be enabled because the corresponding " +
                                            "task is enabled but this wokr item is in " +
                                            "the state : [" + anItem.getStatus() + "]");
                                }
                                workItemFound = true;
                            }
                            assertTrue("State misaligment found: task [" +
                                task + "] is enabled but there is no corresponding" +
                                    " work item found.", workItemFound);
                        }
                    //if the task is busy we test if the work items reflect this.
                    }else if (task.t_isBusy()) {
                        boolean tokenFound = false;
                        //Check that the locations of the id confirm the busy state of the task
                        List idlocs = caseID.getLocations();
                        for (Iterator idlocsIter = idlocs.iterator(); idlocsIter.hasNext();) {
                            YExternalNetElement netElem = (YExternalNetElement) idlocsIter.next();
                            if (netElem.getID().equals(task.getID())) {
                                tokenFound = true;
                            }
                        }
                        assertTrue("State misaligment found: task [" +
                                task + "] is busy but there is no token inside it.",
                                tokenFound);
                        //Check that there is at least one fired or executing work item
                        //to match the busy state of the task.
                        int workItemCount = 0;
                        for (Iterator iterator = items.iterator(); iterator.hasNext();) {
                            YWorkItem anItem = (YWorkItem) iterator.next();
                            if(anItem.getTaskID().equals(task.getID())){
                                if(! (anItem.getStatus().equals(YWorkItem.statusFired)
                                ||  anItem.getStatus().equals(YWorkItem.statusExecuting)
                                ||  anItem.getStatus().equals(YWorkItem.statusIsParent))){
                                    fail("The work item [" + anItem + "] " +
                                            "should be fired, executing, or isParent " +
                                            "because the corresponding " +
                                            "task is busy but this wokr item is in " +
                                            "the state : [" + anItem.getStatus() + "]");
                                }
                                workItemCount++;
                            }
                            assertTrue("State misaligment found: task [" +
                                task + "] is enabled but there is no corresponding" +
                                    " work item found.", workItemCount > 1);
                        }
                    }
                    //the task must be inactive, we test if the work items reflect this.
                    else {
                        boolean tokenNotFound = true;
                        //Check that the locations of the id confirm the
                        //task is indeed not busy
                        List idlocs = caseID.getLocations();
                        for (Iterator idlocsIter = idlocs.iterator(); idlocsIter.hasNext();) {
                            YExternalNetElement netElem = (YExternalNetElement) idlocsIter.next();
                            if (netElem.getID().equals(task.getID())) {
                                tokenNotFound = false;
                            }
View Full Code Here

        return _i != null;
    }


    public synchronized void cancel(YPersistenceManager pmgr) throws YPersistenceException {
        YIdentifier i = _i;
        super.cancel(pmgr);
        if (i != null && _decompositionPrototype != null) {
            YWorkItem workItem = _workItemRepository.getWorkItem(i.toString(), getID());
            i = null;
            if (null != workItem) {
                _workItemRepository.removeWorkItemFamily(workItem);
                //if applicable cancel yawl service
                YAWLServiceGateway wsgw = (YAWLServiceGateway) getDecompositionPrototype();
View Full Code Here

TOP

Related Classes of au.edu.qut.yawl.elements.state.YIdentifier

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.