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

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


    Assert.assertEquals(allUsers.size(), users2.size());
    Assert.assertTrue(allUsers.containsAll(users2));
  }
 
  private ComponentSpec createComponentSpec(String id, String userId, String name, String type, String owner, List<Tag> tags, Map<String,String> views) {
    ComponentSpec cs = new ComponentSpec();
    cs.setComponentId(id);
    cs.setCreatorUserId(userId);
    cs.setComponentName(name);
    cs.setComponentType(type);
    cs.setOwner(owner);
    cs.setReferencedComponents(new ArrayList<ComponentSpec>());
    List<ViewState> viewStates = new ArrayList<ViewState>();
    for (Entry<String,String> e:views.entrySet()) {
      ViewState vs = new ViewState();
      ViewStatePK viewStatePK = new ViewStatePK();
      viewStatePK.setComponentId(cs.getComponentId());
      viewStatePK.setViewType(e.getKey());
      vs.setViewStatePK(viewStatePK);
      vs.setViewInfo(e.getValue());
      viewStates.add(vs);
    }
    cs.setViewStateCollection(viewStates);
   
    cs.setTagAssociationCollection(new ArrayList<TagAssociation>());
    for (Tag aTag:tags) {
      TagAssociation association = new TagAssociation();
      TagAssociationPK tagPK = new TagAssociationPK();
      tagPK.setComponentId(cs.getComponentId());
      tagPK.setTagId(aTag.getTagId());
      association.setTagAssociationPK(tagPK);
      association.setTagProperty(aTag.getTagProperty());
      cs.getTagAssociationCollection().add(association);
    }
   
    return cs;
  }
View Full Code Here


    em.getTransaction().begin();
    final String childId = "3";
    Tag t3 = new Tag();
    t3.setTagId("t3");
    em.persist(t3);
    ComponentSpec child = createComponentSpec(childId, "xyz", "deleted", "123", "xyz", Collections.<Tag>emptyList(), Collections.<String,String>emptyMap());
    ComponentSpec parent1 = createComponentSpec("1", "xyz", "parent1", "123", "xyz", Collections.<Tag>emptyList(), Collections.<String,String>emptyMap());
    ComponentSpec parent2 = createComponentSpec("2", "xyz", "parent2", "123", "xyz", Collections.<Tag>emptyList(), Collections.<String,String>emptyMap());
    ComponentSpec parent3 = createComponentSpec("p2", "xyz", "parent2", "123", "xyz", Collections.<Tag>singletonList(t3), Collections.<String,String>emptyMap());
   
    List<ComponentSpec> parents = Arrays.asList(parent1,parent2);
    for (ComponentSpec cs : parents) {
      cs.getReferencedComponents().add(child);
    }
    parent3.getReferencedComponents().add(child);
    em.persist(child);
    em.persist(parent1);
    em.persist(parent2);
    em.persist(parent3);
    em.getTransaction().commit();
    em.clear();
   
    int objVersion = em.find(ComponentSpec.class, "1").getObjVersion();
    em.clear();
   
    Assert.assertNotNull(em.find(Tag.class, "t3"));
    AbstractComponent parent2Component = serviceImpl.getComponent("p2");
    serviceImpl.delete(Collections.singleton(parent2Component));
    Assert.assertNotNull(em.find(Tag.class, "t3"));
   
    AbstractComponent deleted = serviceImpl.getComponent(child.getComponentId());
    serviceImpl.delete(Collections.singleton(deleted));
   
    Assert.assertNull(em.find(ComponentSpec.class, childId));
    for (ComponentSpec cs: parents) {
      ComponentSpec p = em.find(ComponentSpec.class, cs.getComponentId());
      Assert.assertEquals(p.getObjVersion(), objVersion+1);
    }
   
    AbstractComponent unsavedObj = Mockito.mock(AbstractComponent.class);
    Mockito.when(unsavedObj.getComponentId()).thenReturn("thisObjUnsaved");
    serviceImpl.delete(Collections.singleton(unsavedObj));
View Full Code Here

    Map<String, List<String>> expectedRelationships = new HashMap<String, List<String>>();
   
    // bootstrap several components
    em.getTransaction().begin();
    for (String id:componentIds) {
      ComponentSpec cs = createComponentSpec(id, "xyz", id, "123", "xyz", Collections.<Tag>emptyList(), Collections.<String,String>emptyMap());
      em.persist(cs);
    }
    for (Map<String,String> relation:relationships) {
      for (Entry<String,String> entry:relation.entrySet()) {
        ComponentSpec parent = em.find(ComponentSpec.class, entry.getKey());
        ComponentSpec child = em.find(ComponentSpec.class, entry.getValue());
        List<String> mappedRelationships = expectedRelationships.get(entry.getValue());
        if (mappedRelationships == null) {
          mappedRelationships = new ArrayList<String>();
          mappedRelationships.add(entry.getKey());
          expectedRelationships.put(entry.getValue(), mappedRelationships);
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.