Package gov.nasa.arc.mct.components

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


        ComponentSpec reference = em.find(ComponentSpec.class, component.getComponentId());
          if (reference != null) {
          List<ComponentSpec> referencedComponents = reference.getReferencedComponents();
          for (ComponentSpec cs:referencedComponents) {
            if (cs != null) {
              AbstractComponent ac = createAbstractComponent(cs);
              references.add(ac);
            }
          }
        }
      } finally {
View Full Code Here


    AbstractComponent newAbstractComponent(ComponentSpec cs) {
      return platform.getComponentRegistry().newInstance(cs.getComponentType());
    }

    private AbstractComponent createAbstractComponent(ComponentSpec cs) {
      AbstractComponent ac = newAbstractComponent(cs);
    ComponentInitializer initializer = ac.getCapability(ComponentInitializer.class);
    initializer.setCreationDate(cs.getDateCreated());
    initializer.setCreator(cs.getCreatorUserId());
    initializer.setOwner(cs.getOwner());
    initializer.setId(cs.getComponentId());
    ac.setExternalKey(cs.getExternalKey());
    ac.setDisplayName(cs.getComponentName());
    ac.getCapability(Updatable.class).setVersion(cs.getObjVersion());
        ModelStatePersistence persister = ac.getCapability(ModelStatePersistence.class);
        if ((persister != null) && (cs.getModelInfo() != null)) {
            persister.setModelState(cs.getModelInfo());
        }
   
    // Add ac to cache
View Full Code Here

      TypedQuery<ComponentSpec> q = em.createQuery("SELECT c FROM ComponentSpec c WHERE c.externalKey = :externalKey and c.componentType = :componentType", ComponentSpec.class);
      q.setParameter("externalKey", externalKey);
      q.setParameter("componentType", componentType.getName());
      List<ComponentSpec> cs = q.getResultList();
      if (!cs.isEmpty()) {
        AbstractComponent ac = createAbstractComponent(cs.get(0));
        comp = componentType.cast(ac);
      }
    } finally {
      em.close();
    }
View Full Code Here

                        if (list != null && !list.isEmpty()) {
                          Collection<AbstractComponent> cachedComponents = new ArrayList<AbstractComponent>(list.size());
                          synchronized(list) {
                            Iterator<WeakReference<AbstractComponent>> it = list.iterator();
                            while (it.hasNext()) {
                              AbstractComponent ac = it.next().get();
                              if (ac != null) {
                                cachedComponents.add(ac);
                              } else {
                                it.remove();
                              }
View Full Code Here

 
  @Override
  public AbstractComponent getComponent(String externalKey,
      String componentType) {
    EntityManager em = entityManagerFactory.createEntityManager();
    AbstractComponent ac = null;
    try {
      TypedQuery<ComponentSpec> q = em
          .createQuery(
              "SELECT c FROM ComponentSpec c "
                  + "WHERE c.externalKey = :externalKey and c.componentType = :componentType",
View Full Code Here

        TestBaseComponent newComponent = registry.newInstance(TestBaseComponent.class,null);
       
        Assert.assertTrue(newComponent.getClass().equals(TestBaseComponent.class));
       
        // now pass a parent which is shared
        AbstractComponent parentComponent = new MockComponent() {
            @Override
            public synchronized List<AbstractComponent> getComponents() {
                return Collections.<AbstractComponent> emptyList();
            }
        };
View Full Code Here

    public void testNewCollection() {
        // Environment setup: platform, collection provider, lock manager, and component registry.
        Platform mockPlatform = Mockito.mock(Platform.class);       

        // Also need a sandbox
        AbstractComponent mockSandbox = Mockito.mock(AbstractComponent.class);
        Mockito.when(mockPlatform.getMySandbox()).thenReturn(mockSandbox);
       
        MockComponentRegistry registry = new MockComponentRegistry();
       
        // Set the platform SPI
        PlatformAccess platformAccess = new PlatformAccess();
        platformAccess.setPlatform(mockPlatform);
       
        // Case #1: test returned collection when adding selectedComponents to the new collection is successful
       
        // Setup
        TestBaseComponent collection = Mockito.mock(TestBaseComponent.class);               
        registry.setDefaultCollection(collection);
        List<AbstractComponent> selectedComponents = Collections.singletonList(Mockito.mock(AbstractComponent.class));
        registry.setExpectedResultForAddComponents(true);

        // The test
        AbstractComponent newCollection = registry.newCollection(selectedComponents);
        Assert.assertSame(newCollection, collection);
       
        // Case #2: test returned collection when adding selectedComponents to the new collection fails
       
        // Setup
View Full Code Here

       
        // Verify that persistence was not invoked
        Mockito.verifyNoMoreInteractions(mockPersistence);
       
        // Now, do a run with two bootstraps components (one global, one local)
        AbstractComponent global = new BootstrapComponent(true);
        AbstractComponent local = new BootstrapComponent(false);
        Mockito.when(mockProvider.getBootstrapComponents()).thenReturn(Arrays.asList(global, local));
       
        registry.refreshComponents(Arrays.asList(mockProvider));
       
        // Verify that persistence was invoked, including appropriate tagging
View Full Code Here

    private static void logMenuDiagnostics(ActionContextImpl context) {
        Set<JComponent> views = context.getAllTargetViewComponent();
        StringBuffer supplementInfo = new StringBuffer();
        for (JComponent view : views) {
            View viewManif = (View) view;
            AbstractComponent comp = viewManif.getManifestedComponent();
            supplementInfo.append("Component name = " + comp.getDisplayName() + ", id = "
                    + comp.getId() + ".  ");
        }
        if (context.getTargetHousing() == null) {
            supplementInfo.append("\n\n --- Context's housing object is NULL.");
        }
        Exception exc = new Exception();
View Full Code Here

            }
          
            // Perform the refresh by re-creating view
            if (doRefresh) {
                // Update component from persistence
                AbstractComponent comp = housedView.getManifestedComponent();
                comp = PlatformAccess.getPlatform().getPersistenceProvider().getComponent(comp.getComponentId());
                housedView.setManifestedComponent(comp);               
               
                // Re-create view
                ViewInfo vi = housedView.getInfo();
                if (isHousing) {
View Full Code Here

TOP

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

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.