Package gov.nasa.arc.mct.policy

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


        protected boolean consultPolicy(PolicyInfo.CategoryType policyType) {
            return consultPolicy(policyType, makePolicyContext(droppedComponents, dropView.getManifestedComponent()));
        }
       
        protected boolean consultPolicy(PolicyInfo.CategoryType policyType, PolicyContext context) {
            ExecutionResult result = PlatformAccess.getPlatform().getPolicyManager().execute(
                    policyType.getKey(),
                    context);
           
            if (!result.getStatus()) {           
                message = result.getMessage();
            }
           
            return result.getStatus();
        }
View Full Code Here


    private static ResourceBundle bundle = ResourceBundle.getBundle("CanvasResourceBundle");
   
    @Override
    public ExecutionResult execute(PolicyContext context) {
        AbstractComponent component = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
        return new ExecutionResult(context, component.getWorkUnitDelegate()==null, bundle.getString("CanvasOwnedViewsPolicyMessage"));
    }
View Full Code Here

public class CanvasFilterViewPolicy implements Policy {
 
  @Override
  public ExecutionResult execute(PolicyContext context) {
    ExecutionResult trueResult = new ExecutionResult(context, true, "");

    AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
    ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
    if (!viewInfo.getViewClass().equals(CanvasManifestation.class)) {
        return trueResult;
    }
   
    if (!targetComponent.isLeaf())
      return trueResult;
    else   
      return new ExecutionResult(context, false, CanvasManifestation.class.getName()
                          + " is not applicable for component type "
                          + targetComponent.getClass().getName());
  }
View Full Code Here

        // 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

       
        // 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

            }
           
            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

        AbstractComponent component = context.getProperty("TARGET", AbstractComponent.class);
       
        // Children are only allowed if the component is not a leaf
        boolean allowed = !component.isLeaf();  
       
        return new ExecutionResult(context, allowed, "You cannot add a child component to a leaf component");
    }
View Full Code Here

     */
    @Override
    public ExecutionResult execute(PolicyContext context) {
        AbstractComponent component = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
        if (component.getClass().equals(TelemetryUserDropBoxComponent.class)) {
            return new ExecutionResult(context, false, "Can't duplicate Drop Boxes.");
        }
        return new ExecutionResult(context, true, "");
    }
View Full Code Here

    private static final String ADMIN = "admin";
    private static final String EM_STRING = "";
   
    @Override
    public ExecutionResult execute(PolicyContext context) {
        ExecutionResult trueResult = new ExecutionResult(context, true, EM_STRING);
       
        AbstractComponent component = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);       
        if (!(component instanceof TelemetryDisciplineComponent))
            return trueResult;

        ViewInfo view = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
        if (!view.getViewClass().equals(UsersManifestation.class))
            return trueResult;
       
        User currentUser = PlatformAccess.getPlatform().getCurrentUser();
        if (currentUser.getDisciplineId() == ADMIN && currentUser.getUserId() == ADMIN)
            return new ExecutionResult(context, false, "Only admin user can add new users to group " + component.getDisplayName());
        else
            return trueResult;
    }
View Full Code Here

            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
                PersistenceProvider persistenceProvider = PlatformAccess.getPlatform().getPersistenceProvider();
                boolean successfulAction = false;
                try {
                    persistenceProvider.startRelatedOperations();
                    targetComponent.addDelegateComponents(sourceComponents);
                    targetComponent.save();
                    successfulAction = true;
                } finally {
                    persistenceProvider.completeRelatedOperations(successfulAction);
                }

                if (successfulAction) {
                    if (event.getTargetManifestation() instanceof DropboxCanvasView) {
                        StringBuilder sentObjects = new StringBuilder();
                        for (AbstractComponent sourceComponent : sourceComponents)
                            sentObjects.append("\"" + sourceComponent.getExtendedDisplayName() + "\" ");
                        DropboxCanvasView dropboxManifestation = (DropboxCanvasView) event.getTargetManifestation();
                        dropboxManifestation.statusMessage.setText((sourceComponents.size() == 0) ? "No objects sent." :
                                    "Accepted at " + DateFormat.getInstance().format(new Date()) +": "+ sentObjects.toString());
                        dropboxManifestation.revalidate();
                    }
   
                    // Pull tarmanifestInfoget housing window to front.
                    event.getHousingWindow().toFront();
                }
            } else {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        OptionBox.showMessageDialog(container, result.getMessage(), "Composition Error - ", OptionBox.ERROR_MESSAGE);
                    }
                });
            }
        }
View Full Code Here

TOP

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

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.