Package gov.nasa.arc.mct.policy

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


     * <code>PolicyInfo.CategoryType.SHOW_HIDE_CTRL_MANIFESTATION</code> policy
     * category to check if the control manifestation should be available, i.e,
     * if the twistie should be visible.
     */
    public final JComponent getControlManifestation() {
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), getManifestedComponent());       
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), getInfo());
        ExecutionResult result = PlatformAccess.getPlatform().getPolicyManager().execute(PolicyInfo.CategoryType.SHOW_HIDE_CTRL_MANIFESTATION.getKey(), policyContext);
        if (!result.getStatus())
            return null;
       
        controlManifestation = initializeControlManifestation();
View Full Code Here


        // Verify that policy allows Remove Manifestation here
        User mockUser = Mockito.mock(User.class);
        Mockito.when(mockPlatform.getCurrentUser()).thenReturn(mockUser);
        Mockito.when(mockUser.getUserId()).thenReturn(id);
       
        PolicyContext context = new PolicyContext();
        AbstractComponent mockChild = Mockito.mock(AbstractComponent.class);
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), comp);
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), Collections.singleton(mockChild));
        Assert.assertTrue(new CanRemoveComponentPolicy().execute(context).getStatus());
    }
View Full Code Here

        return getTargetComponent(actionContext) != null;
    }

    private boolean isComponentWriteableByUser(AbstractComponent component) {
        Platform p = PlatformAccess.getPlatform();
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), component);
        policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String inspectionKey = PolicyInfo.CategoryType.OBJECT_INSPECTION_POLICY_CATEGORY.getKey();
        return p.getPolicyManager().execute(inspectionKey, policyContext).getStatus();
    }
View Full Code Here

        return UIPanel;
    }
   
    private ExecutionResult checkReservedWordsNamingPolicy(String name) {
       
        PolicyContext context = new  PolicyContext();
        context.setProperty("NAME", name);
        String namingKey = PolicyInfo.CategoryType.COMPONENT_NAMING_POLICY_CATEGORY.getKey();
        ExecutionResult exResult = PolicyManagerImpl.getInstance().execute(namingKey, context);
       
        return exResult;           
    }
View Full Code Here

        Collection<ExtendedComponentTypeInfo> componentInfos = extCompRegistry.getComponentInfos();

        List<Action> subActions = new ArrayList<Action>(componentInfos.size());
        for (ExtendedComponentTypeInfo info : componentInfos) {
            if (info.isCreatable()) {
                PolicyContext policyContext = new PolicyContext();
                policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), targetComponent);
                policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
                String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();
                AbstractComponent tempComponent =  extCompRegistry.newInstance(info);
                policyContext.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), Collections.singleton(tempComponent));
                if (PolicyManagerImpl.getInstance().execute(compositionKey, policyContext).getStatus()) {
                    subActions.add(new NewTypeAction(info, targetComponent));
                }
            }
        }
View Full Code Here

    }
   
    private ExecutionResult checkReservedWordsNamingPolicy(String name) {
       
        PolicyContext context = new  PolicyContext();
        context.setProperty("NAME", name);
        String namingkey = PolicyInfo.CategoryType.COMPONENT_NAMING_POLICY_CATEGORY.getKey();
        ExecutionResult exResult = PolicyManagerImpl.getInstance().execute(namingkey, context);
       
        return exResult;           
    }
View Full Code Here

        if (!selectedComponent.canBeDeleted()) {
            return false;
        }
       
       
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), parentComponent);
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();
        PolicyManager policyManager = PlatformAccess.getPlatform().getPolicyManager();
        return policyManager.execute(compositionKey, context).getStatus();
    }
View Full Code Here

        Collection<ExtendedComponentTypeInfo> componentInfos = extCompRegistry.getComponentInfos();
        if (componentInfos.isEmpty())
            return false;

        AbstractComponent targetComponent = actionContext.getTargetComponent();
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), targetComponent);
        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

    }
   
    private ExecutionResult checkReservedWordsNamingPolicy(String name) {
       
        PolicyContext context = new  PolicyContext();
        context.setProperty("NAME", name);
        String namingKey = PolicyInfo.CategoryType.COMPONENT_NAMING_POLICY_CATEGORY.getKey();
        ExecutionResult exResult = PolicyManagerImpl.getInstance().execute(namingKey, context);
       
        return exResult;           
    }
View Full Code Here

    protected boolean isWritable(AbstractComponent targetComponent) {
        if (targetComponent == null) {
            return false;
        }
       
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), targetComponent);
        policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();

        return PlatformAccess.getPlatform().getPolicyManager().execute(compositionKey, policyContext).getStatus();
    }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.policy.PolicyContext

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.