Package gov.nasa.arc.mct.services.component

Examples of gov.nasa.arc.mct.services.component.ViewInfo


       
        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());
View Full Code Here


  @Override
  public ExecutionResult execute(PolicyContext context) {
    boolean result = true;
   
    ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
 
    if (viewInfo.getViewClass().equals(NonTimePlotView.class)) {
      AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
     
      result = false;
      if (!targetComponent.isLeaf()) {
        int feeds = 0;
View Full Code Here

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @DataProvider(name="viewInfoData")
    public Object[][] viewInfoData() {
        View v1 = Mockito.mock(View.class);
        View v2 = Mockito.mock(TestingView3.class);
        ViewInfo vi = new ViewInfo(v1.getClass(),"v1", ViewType.CENTER);
        //ViewInfo vi2 = new ViewInfo(v2.getClass(), "v2", ViewType.INSPECTION);
        ViewInfo vi3 = new ViewInfo(v2.getClass(), "v2", ViewType.CENTER);
       
        return new Object[][] {
                        new Object[] {
                           new LinkedHashSet(Arrays.asList(vi,vi3)), Collections.emptySet(), ViewType.CENTER, new LinkedHashSet(Arrays.asList(vi,vi3))           
                        },
View Full Code Here

        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, ""));
View Full Code Here

        if (views.isEmpty()) {
            MCTLogger.getLogger(getClass()).warn("component " + component.getId() + "does not have a Node View");
            return;
        }

        ViewInfo nodeView = views.iterator().next();

        // Determine the desired horizontal/vertical scaling of the new window.
        double horizontalScale = 0;
        double verticalScale = 0;
View Full Code Here

public class ExecutableButtonViewPolicy implements Policy {

  @Override
  public ExecutionResult execute(PolicyContext context) {
    boolean result = true;
    ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
   
    if (ExecutableButtonManifestation.class.equals(viewInfo.getViewClass())) {
      AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), ExecutableButtonComponent.class);
      result = !ExecutableButtonComponent.class.isAssignableFrom(targetComponent.getClass());
    }
    return new ExecutionResult(context, result, null);
  }
View Full Code Here

  public void testRejectCanvasView() throws Exception {
    (new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
    AbstractComponent comp = Mockito.mock(AbstractComponent.class);
    PlotViewPolicy policy = new PlotViewPolicy();
    PolicyContext context = new PolicyContext();
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), new ViewInfo(PlotViewManifestation.class,"",ViewType.CENTER));
    Method m = policy.getClass().getDeclaredMethod("rejectCanvasView", PolicyContext.class, AbstractComponent.class);
    m.setAccessible(true);
    Mockito.when(comp.isLeaf()).thenReturn(false);
    Assert.assertEquals(m.invoke(policy, context, comp), Boolean.FALSE, "direct access to plot view role should always be true");
    context.setProperty(PolicyContext.PropertyName.VIEW_TYPE.getName(), ViewType.CENTER);
View Full Code Here

  @Test
  public void testExecute() {
    Policy policy = new PlotViewPolicy();
    PolicyContext context;
   
    ViewInfo plotViewInfo = new ViewInfo(PlotViewManifestation.class, "Plot", ViewType.OBJECT);
   
    // Plot views should be allowed for leaf component with a feed
    context = new PolicyContext();
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
        plotViewInfo);
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        leafWithAFeedComponent);   
    Assert.assertTrue(policy.execute(context).getStatus());

    // ...but not without a feed
    context = new PolicyContext();
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
        plotViewInfo);
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        leafWithOutAFeedComponent);   
    Assert.assertFalse(policy.execute(context).getStatus());
   
    // Plot view policy should not reject non-plot, ever
    for (AbstractComponent ac : new AbstractComponent[] { leafWithAFeedComponent, leafWithOutAFeedComponent, nonLeafComponent} ) {
      for (ViewType vt : ViewType.values()) {
        ViewInfo someViewInfo = new ViewInfo(NonPlotView.class, "NonPlot", vt);
        context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
            someViewInfo);
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
            ac);   
View Full Code Here

  public void setup() {
    MockitoAnnotations.initMocks(this);
   
    policy = new PlotStringPolicy();
    context = new PolicyContext();
    viewInfo = new ViewInfo(PlotViewManifestation.class, "Plot", ViewType.OBJECT);
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
        viewInfo);
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        mockProvider);
  }
View Full Code Here

  private PlotViewManifestation manifestation;

  @BeforeMethod
  public void setup() {
    MockitoAnnotations.initMocks(this);
    Mockito.when(manifestation.getInfo()).thenReturn(new ViewInfo(PlotViewManifestation.class,"",ViewType.OBJECT));
    Mockito.when(manifestation.getViewProperties()).thenReturn(new ExtendedProperties());
  }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.services.component.ViewInfo

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.