Package org.useware.kernel.model.scopes

Examples of org.useware.kernel.model.scopes.Scope


     *
     * @param targetUnit the unit from which the scope will be derived
     */
    public void activateScope(QName targetUnit) {

        Scope nextScope = getScope(targetUnit);
        int parentScopeId = getParentScopeId(targetUnit);

        Scope activeScope = parent2childScopes.get(parentScopeId);
        if(!nextScope.equals(activeScope))
        {
            System.out.println("Replace activation of scope "+activeScope+" with "+ nextScope);

            // root element might not have an active scope
            if(activeScope!=null)scopeActivationState.put(activeScope.getScopeId(), false);

            scopeActivationState.put(nextScope.getScopeId(), true);
            parent2childScopes.put(parentScopeId, nextScope);
        }
    }
View Full Code Here


    public StatementContext getContext(QName interactionUnitId) {

        final Node<Scope> self = dialog.getScopeModel().findNode(interactionUnitId);
        assert self!=null : "Unit not present in scopeModel: "+ interactionUnitId;

        Scope scope = self.getData();

        // lazy initialisation
        if(!scope2context.containsKey(scope.getScopeId()))
        {

            // extract parent scopes

            List<Node<Scope>> parentScopeNodes = self.collectParents(new NodePredicate<Scope>() {
                Set<Integer> tracked = new HashSet<Integer>();

                @Override
                public boolean appliesTo(Node<Scope> candidate) {
                    if (self.getData().getScopeId() != candidate.getData().getScopeId()) {
                        if (!tracked.contains(candidate.getData().getScopeId())) {
                            tracked.add(candidate.getData().getScopeId());
                            return true;
                        }

                        return false;
                    }

                    return false;
                }
            });

            // delegation scheme
            List<Integer> parentScopeIds = new LinkedList<Integer>();
            for(Node<Scope> parentNode : parentScopeNodes)
            {
                parentScopeIds.add(parentNode.getData().getScopeId());
            }

            scope2context.put(scope.getScopeId(),
                    new ParentDelegationContextImpl(scope, externalContext, parentScopeIds,
                            new Scopes() {
                                @Override
                                public StatementContext get(Integer scopeId) {
                                    return scope2context.get(scopeId);
                                }
                            })
            );
        }

        return scope2context.get(scope.getScopeId());
    }
View Full Code Here

     *
     * @param unitId
     * @return
     */
    public boolean isWithinActiveScope(final QName unitId) {
        final Scope scopeOfUnit = getScope(unitId);
        int parentScopeId = getParentScopeId(unitId);
        Scope activeScope = parent2childScopes.get(parentScopeId);
        boolean selfIsActive = activeScope != null && activeScope.equals(scopeOfUnit);

        if(selfIsActive) // only verify parents if necessary
        {
            Node<Scope> inactiveParentScope = dialog.getScopeModel().findNode(unitId).findParent(
                    new InActiveParentPredicate(unitId)
View Full Code Here

        return selfIsActive;
    }

    private int getParentScopeId(QName targetUnit) {
        final Scope scope = getScope(targetUnit);
        Node<Scope> parent = dialog.getScopeModel().findNode(targetUnit).findParent(new NodePredicate<Scope>() {
            @Override
            public boolean appliesTo(Node<Scope> node) {
                return node.getData().getScopeId() != scope.getScopeId();
            }
        });

        // fallback to root scope if none found
        return parent!= null ?
View Full Code Here

        }

        @Override
        public boolean appliesTo(Node<Scope> node) {

            Scope parentScope = node.getData();
            boolean isParent = parentScope.getScopeId() != scopeOfUnit.getScopeId();
            boolean isActive = scopeActivationState.get(parentScope.getScopeId())!=null
                    ? scopeActivationState.get(parentScope.getScopeId()) : false;

            if(!isActive)
            {
                System.out.println("Inactive parent scope: "+ parentScope.getScopeId() +" for "+ unitId);
            }

            return isParent && !isActive;
        }
View Full Code Here

     *
     * @param targetUnit the unit from which the scope will be derived
     */
    public void activateScope(QName targetUnit) {

        Scope nextScope = getScope(targetUnit);
        int parentScopeId = getParentScope(targetUnit).getId();

        Scope activeScope = activeChildMapping.get(parentScopeId);
        if(!nextScope.equals(activeScope))
        {
            //System.out.println("Replace activation of scope "+activeScope+" with "+ nextScope);

            // root element might not have an active scope
            if(activeScope!=null)
                activeScope.setActive(false);

            nextScope.setActive(true);
            activeChildMapping.put(parentScopeId, nextScope);

        }
View Full Code Here

        final Node<Scope> self = dialog.getScopeModel().findNode(
                dialog.findUnit(unitId).getScopeId()
        );
        assert self!=null : "Unit not present in scopeModel: "+ unitId;

        Scope scope = self.getData();

        // lazy initialisation
        if(!statementContexts.containsKey(scope.getId()))
        {

            // extract parent scopes
            LinkedList<Scope> parentScopes = new LinkedList<Scope>();
            getParentScopes(self, parentScopes);


            statementContexts.put(scope.getId(),
                    new ParentDelegationContextImpl(
                            scope, parentScopes,
                            new StateManagement() {
                                @Override
                                public StatementContext get(Integer scopeId) {
                                    return statementContexts.get(scopeId);
                                }

                                @Override
                                public StatementContext getExternal() {
                                    return externalContext;
                                }
                            })
            );
        }

        return statementContexts.get(scope.getId());
    }
View Full Code Here

    public boolean isWithinActiveScope(final QName unitId) {

        final Node<Scope> self = dialog.getScopeModel().findNode(
                dialog.findUnit(unitId).getScopeId()
        );
        final Scope scopeOfUnit = self.getData();
        int parentScopeId = getParentScope(unitId).getId();

        Scope activeScope = activeChildMapping.get(parentScopeId);
        boolean selfIsActive = activeScope != null && activeScope.equals(scopeOfUnit);

        if(selfIsActive) // only verify parents if necessary
        {
            LinkedList<Scope> parentScopes = new LinkedList<Scope>();
            getParentScopes(self, parentScopes);
View Full Code Here

TOP

Related Classes of org.useware.kernel.model.scopes.Scope

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.