Package gov.nasa.arc.mct.dbpersistence.dao

Examples of gov.nasa.arc.mct.dbpersistence.dao.ComponentSpec


  }
 
  @Override
  public AbstractComponent getComponent(String componentId) {
    EntityManager em = entityManagerFactory.createEntityManager();
    ComponentSpec cs = null;
    try {
      cs = em.find(ComponentSpec.class, componentId);
    } finally {
      em.close();
    }
View Full Code Here


   
    // save relationships
    // non optimal implementation as this will require a query to get the relationships
    cs.setReferencedComponents(new ArrayList<ComponentSpec>(ac.getComponents().size()));
    for (AbstractComponent c : ac.getComponents()) {
      ComponentSpec refCs = em.find(ComponentSpec.class, c.getComponentId());
      if (refCs == null) {
        // this can be null if the component has been deleted
        continue;
      }
      cs.getReferencedComponents().add(refCs);
View Full Code Here

    try {
      em.getTransaction().begin();
      // first persist all new components, without relationships, model, and view states
      for (AbstractComponent nc : componentsToPersist) {
        if (nc.getCreationDate() == null) {
          ComponentSpec cs = new ComponentSpec();
          updateComponentSpec(nc, cs, em, false);
          em.persist(cs);
        }
      }
     
View Full Code Here

  public void delete(Collection<AbstractComponent> componentsToDelete) {
    EntityManager em = entityManagerFactory.createEntityManager();
    try {
      em.getTransaction().begin();
      for (AbstractComponent component:componentsToDelete) {
        ComponentSpec componentToDelete = em.find(ComponentSpec.class, component.getComponentId());
        if (componentToDelete == null) {
          // component has already been deleted from database but not refreshed in the user interface
          continue;
        }
        TypedQuery<ComponentSpec> q = em.createNamedQuery("ComponentSpec.findReferencingComponents", ComponentSpec.class);
View Full Code Here

      AbstractComponent component) {
    List<AbstractComponent> references = new ArrayList<AbstractComponent>();
    EntityManager em = entityManagerFactory.createEntityManager();
    if (component.getComponentId() != null) {
      try {
        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);
            }
View Full Code Here

 
  private void cleanCacheIfNecessary(String componentId, int latestVersion) {
    Cache c = entityManagerFactory.getCache();
    if (c.contains(ComponentSpec.class, componentId)) {
      EntityManager em = entityManagerFactory.createEntityManager();
      ComponentSpec cs = em.find(ComponentSpec.class, componentId);
      if (cs != null && cs.getObjVersion() < latestVersion) {
        c.evict(ComponentSpec.class, componentId);
      }
      em.close();
    }
  }
View Full Code Here

       MctUsers user = new MctUsers();
       user.setUserId(userId);
       user.setDisciplineId(group);
       em.persist(user);
 
       ComponentSpec mysandboxComponentSpec = new ComponentSpec();
       updateComponentSpec(mysandbox, mysandboxComponentSpec, em, true);
       em.persist(mysandboxComponentSpec);

       TagAssociationPK tagAssociationPK = new TagAssociationPK();
       tagAssociationPK.setComponentId(mysandbox.getComponentId());
       tagAssociationPK.setTagId("bootstrap:creator");
       TagAssociation tagAssociation = new TagAssociation();
       tagAssociation.setTagAssociationPK(tagAssociationPK);
       em.persist(tagAssociation);

       ComponentSpec dropboxComponentSpec = new ComponentSpec();
       updateComponentSpec(dropbox, dropboxComponentSpec, em, true);
       em.persist(dropboxComponentSpec);
   
       ComponentSpec userDropboxes = em.find(ComponentSpec.class, userDropboxesId);
       userDropboxes.getReferencedComponents().add(dropboxComponentSpec);       
       mysandboxComponentSpec.getReferencedComponents().add(dropboxComponentSpec);
   
       em.persist(userDropboxes);
       em.persist(mysandboxComponentSpec);
       em.getTransaction().commit();
View Full Code Here

  @Override
  public Map<String, ExtendedProperties> getAllProperties(String componentId) {
    EntityManager em = entityManagerFactory.createEntityManager();
    Map<String, ExtendedProperties> properties = new HashMap<String, ExtendedProperties>();
    try {
      ComponentSpec cs = em.find(ComponentSpec.class, componentId);
      if (cs != null) {
        for (ViewState vs: cs.getViewStateCollection()) {
          properties.put(vs.getViewStatePK().getViewType(), createExtendedProperties(vs.getViewInfo()));
        }
      }
      return properties;
    } finally {
View Full Code Here

        t.setTagId(tag);
        em.persist(t);
      }

      for (AbstractComponent component:components) {
        ComponentSpec cs = em.find(ComponentSpec.class, component.getComponentId());
        TagAssociation association = new TagAssociation();
        TagAssociationPK tagPK = new TagAssociationPK();
        tagPK.setComponentId(cs.getComponentId());
        tagPK.setTagId(t.getTagId());
        association.setTagAssociationPK(tagPK);
        cs.getTagAssociationCollection().add(association);
      }
     
      em.getTransaction().commit();
    } finally {
      if(em.getTransaction().isActive())
View Full Code Here

   
    @Test
    public void testSearchClickResults() {
        FrameFixture window = WindowFinder.findFrame(TITLE).using(robot);
        final JListFixture list = window.list(new JListMatcher("Search Result List"));
        ComponentSpec cs1 = Mockito.mock(ComponentSpec.class);
        ComponentSpec cs2 = Mockito.mock(ComponentSpec.class);
        QueryResult q = new QueryResult(2, Arrays.asList(cs1, cs2));
        platformSearchUI.setQueryResult(q);
        window.button(new JButtonMatcher("Search")).click();
        Condition condition = new Condition("Results Arrived.") {
           
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.dbpersistence.dao.ComponentSpec

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.