Package gov.nasa.arc.mct.components

Examples of gov.nasa.arc.mct.components.ObjectManager


    protected abstract AbstractComponent getTargetComponent(ActionContextImpl actionContext);
   
    @Override
    public boolean isEnabled() {
        AbstractComponent ac = getTargetComponent(actionContext);
        ObjectManager om = ac.getCapability(ObjectManager.class);
        Set<AbstractComponent> modified = om != null ?               
                om.getAllModifiedObjects() :
                Collections.<AbstractComponent>emptySet();
       
        // Should enable if at least one object can be saved
        boolean hasWriteableComponents =
                !ac.isStale() &&
View Full Code Here


    }
   
    @Override
    public void actionPerformed(ActionEvent e) {
        AbstractComponent ac = getTargetComponent(actionContext);
        ObjectManager om = ac.getCapability(ObjectManager.class);
        Collection<AbstractComponent> modified = om != null ?
                om.getAllModifiedObjects() :
                Collections.<AbstractComponent>emptySet();

        // Assemble objects to save.
        // Make sure they pass the writeable-by-user test.
        Set<AbstractComponent> canSave = new HashSet<AbstractComponent>();
        Set<AbstractComponent> cannotSave = new HashSet<AbstractComponent>();
        for (AbstractComponent mod : modified) {
            (isComponentWriteableByUser(mod) ? canSave : cannotSave).add(mod);
        }
        if (ac.isDirty() && !ac.isStale()) {
            (isComponentWriteableByUser(ac) ? canSave : cannotSave).add(ac);
        }

        if (handleWarnings(canSave, cannotSave)) {
            try {
                PlatformAccess.getPlatform().getPersistenceProvider().persist(canSave);
            } catch (OptimisticLockException ole) {
                handleStaleObject(ac);
            }
           
            if (om != null) {
                om.notifySaved(canSave);
            }
        }
    }
View Full Code Here

                      (dirty ? "dirty " : "nonDirty ") +
                      (isObjectManager ? "objectManager " : "nonManager ") +
                      (child != null ? "parent" : "leaf");
        AbstractComponent mockComponent = Mockito.mock(AbstractComponent.class, name);
        Mockito.when(mockComponent.isDirty()).thenReturn(dirty);
        ObjectManager mockObjectManager = Mockito.mock(ObjectManager.class);
        if (isObjectManager) {
            Mockito.when(mockComponent.getCapability(ObjectManager.class)).thenReturn(mockObjectManager);
        }
        if (child != null) {
            Mockito.when(mockObjectManager.getAllModifiedObjects()).thenReturn(Collections.singleton(child));           
        } else {
            Mockito.when(mockObjectManager.getAllModifiedObjects()).thenReturn(Collections.<AbstractComponent>emptySet());
        }
        if (good) {
            goodComponents.add(mockComponent);
        }
        return mockComponent;
View Full Code Here

            for (int i = 0; i < (g ? goodChildren : badChildren); i++) {
                children.add(generateWarningComponent(g, 0, 0));
            }
        }       
        Mockito.when(mockComponent.isDirty()).thenReturn(true);
        ObjectManager mockObjectManager = Mockito.mock(ObjectManager.class);
        Mockito.when(mockComponent.getCapability(ObjectManager.class)).thenReturn(mockObjectManager);
        Mockito.when(mockObjectManager.getAllModifiedObjects()).thenReturn(children);           
       
        if (good) {
            goodComponents.add(mockComponent);
        }
        return mockComponent;
View Full Code Here

       
        // Set up inputs (manifested component)
        Mockito.when(mockComponent.isDirty()).thenReturn(isDirty || isDirtyChild);
        if (isDirtyChild) {
            AbstractComponent child = Mockito.mock(AbstractComponent.class);
            ObjectManager om = Mockito.mock(ObjectManager.class);
            Mockito.when(om.getAllModifiedObjects()).thenReturn(Collections.singleton(child));
            Mockito.when(mockComponent.handleGetCapability(ObjectManager.class)).thenReturn(om);
        }
       
        // Ensure that Persistence confirms component exists
        // (otherwise, Save option may be discarded)
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.components.ObjectManager

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.