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

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


  public void tagComponents(String tag,
      Collection<AbstractComponent> components) {
    EntityManager em = entityManagerFactory.createEntityManager();
    try {
      em.getTransaction().begin();
      Tag t = em.find(Tag.class, tag);
      if (t == null) {
        t = new Tag();
        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();
View Full Code Here


 
  @Test(dataProvider="taggedComponentTests")
  public void testHasTaggedComponents(String tag, boolean expectedResult) {
    List<Tag> taggedComponents = Collections.<Tag>emptyList();
    if (expectedResult) {
      Tag t = new Tag();
      t.setTagId(tag);
      t.setTagProperty("property");
      taggedComponents = Collections.singletonList(t);
    }
    em.getTransaction().begin();
    for (Tag t:taggedComponents) {
      em.persist(t);
View Full Code Here

 
  @Test
  public void testDelete() {
    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());
View Full Code Here

TOP

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

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.