Examples of PolicyContext


Examples of gov.nasa.arc.mct.policy.PolicyContext

        return isParentComponentModifiable(parentComponent);
    }

    private boolean isParentComponentModifiable(AbstractComponent parentComponent) {
        // Check if parent component can be modified.
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), parentComponent);
        policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();
        return PolicyManagerImpl.getInstance().execute(compositionKey, policyContext).getStatus();
    }
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

        // Manifestation is currently locked
        Mockito.doAnswer(new Answer<ExecutionResult>() {

            @Override
            public ExecutionResult answer(InvocationOnMock invocation) throws Throwable {
                ExecutionResult result = new ExecutionResult(new PolicyContext(), true, null);
                return result;
            }

        }).when(policyManager).execute(Mockito.anyString(), Mockito.any(PolicyContext.class));
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

        for (View view:selectedManifestations) {
            components.add(view.getManifestedComponent());
        }
       
        // disable use for objects which cannot be contained
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),components);
        String policyCategoryKey = PolicyInfo.CategoryType.CAN_OBJECT_BE_CONTAINED_CATEGORY.getKey();
        ExecutionResult result = PolicyManagerImpl.getInstance().execute(policyCategoryKey, context);
        return result.getStatus();
    }
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

                    View gui = (View) node.getUserObject();
                    dragComponents.add(gui.getManifestedComponent());
                }
            }
           
            PolicyContext context = new PolicyContext();
            context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),dragComponents);
            String policyCategoryKey = PolicyInfo.CategoryType.CAN_OBJECT_BE_CONTAINED_CATEGORY.getKey();
            ExecutionResult result = PolicyManagerImpl.getInstance().execute(policyCategoryKey, context);
            return result.getStatus();
        }
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

        Set<ViewInfo> possibleViewInfos =  PlatformAccess.getPlatform().getComponentRegistry().getViewInfos(getComponentTypeID(), type);
        Set<ViewInfo> filteredViewInfos = new LinkedHashSet<ViewInfo>();
       
        Platform platform = PlatformAccess.getPlatform();
        PolicyManager policyManager = platform.getPolicyManager();
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), this);
        context.setProperty(PolicyContext.PropertyName.VIEW_TYPE.getName(), type);
        for (ViewInfo viewInfo : possibleViewInfos) {
            context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), viewInfo);
            if (policyManager.execute(PolicyInfo.CategoryType.FILTER_VIEW_ROLE.getKey(), context)
                            .getStatus()) {
                filteredViewInfos.add(viewInfo);
            }
        }
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

            Collection<AbstractComponent> sourceComponents = event.getSources();

            AbstractComponent targetComponent = event.getTarget();

            // This is a composing operation
            PolicyContext context = new PolicyContext();
            context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), targetComponent);
            context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), sourceComponents);
            context.setProperty(PolicyContext.PropertyName.ACTION.getName(), Character.valueOf('w'));
            context.setProperty(PolicyContext.PropertyName.VIEW_MANIFESTATION_PROVIDER.getName(), event.getTargetManifestation());
           
            final ExecutionResult result = PlatformAccess.getPlatform().getPolicyManager().execute(PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey(), context);
            if (result.getStatus()) {
               
                // Persist
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

     */
    public final boolean canBeDeleted() {
        Platform platform = PlatformAccess.getPlatform();
        PolicyManager policyManager = platform.getPolicyManager();

        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), this);
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.CAN_DELETE_COMPONENT_POLICY_CATEGORY
                        .getKey();
        return policyManager.execute(compositionKey, context).getStatus();
    }
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

        if (isLeaf()) {
            throw new UnsupportedOperationException("components declared as leaf cannot be mutated");
        }
        Platform platform = PlatformAccess.getPlatform();
        PolicyManager policyManager = platform.getPolicyManager();
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), this);
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        context
                        .setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),
                                        childComponents);
        if (policyManager.execute(PolicyInfo.CategoryType.ACCEPT_DELEGATE_MODEL_CATEGORY.getKey(),
                        context).getStatus()) {
         
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);
        Mockito.when(mockPolicyManager.execute(Mockito.matches(PolicyInfo.CategoryType.FILTER_VIEW_ROLE.getKey()), Mockito.any(PolicyContext.class))).thenAnswer(
                        new Answer() {
                            public Object answer(InvocationOnMock invocation) {
                                Object[] args = invocation.getArguments();
                                PolicyContext pc = (PolicyContext) args[1];
                                ViewInfo vi = pc.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
                                return new ExecutionResult(pc, !filterOut.contains(vi), "");
                            }
                        }
        );
        Mockito.when(mockPolicyManager.execute(Mockito.matches(PolicyInfo.CategoryType.PREFERRED_VIEW.getKey()), Mockito.any(PolicyContext.class))).thenReturn(new ExecutionResult(new PolicyContext(),true, ""));
        Set<ViewInfo> infos = ac.getViewInfos(type);
        Assert.assertEquals(infos, expected);
    }
View Full Code Here

Examples of gov.nasa.arc.mct.policy.PolicyContext

            if (!numberOfParents.containsKey(selectedComponent.getComponentId()))  {
                numberOfParents.put(selectedComponent.getComponentId(), Integer.valueOf(selectedComponent.getReferencingComponents().size()));
            }
            // If component is the last manifestation,
            if (numberOfParents.get(selectedComponent.getComponentId()) == 1) {
                PolicyContext policyContext = new PolicyContext();
                policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), selectedComponent);
                policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
                String deleteKey = PolicyInfo.CategoryType.CAN_DELETE_COMPONENT_POLICY_CATEGORY.getKey();
                Object[] messages = new Object[2];
                JLabel label1 = new JLabel("Cannot remove");
                label1.setFont(label1.getFont().deriveFont(Font.BOLD));
                messages[0] = label1;
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.