예제 #1
0
  @Test
  public void getTreeSharedRoot() {
    ResolvedConceptReferenceList list1 = new ResolvedConceptReferenceList();
    ResolvedConceptReferenceList list2 = new ResolvedConceptReferenceList();

    AssociatedConcept as1 = this.createResolvedConceptReference("a");
    AssociatedConcept at1 = this.createResolvedConceptReference("b");
    this.addAssociatedConcept(as1, at1);

    AssociatedConcept as2 = this.createResolvedConceptReference("a");
    AssociatedConcept at2 = this.createResolvedConceptReference("c");
    this.addAssociatedConcept(as2, at2);

    list1.addResolvedConceptReference(as1);
    list2.addResolvedConceptReference(as2);
    KeyedGraph g1 = new KeyedGraph(list1);
    KeyedGraph g2 = new KeyedGraph(list2);

    KeyedGraph unionedGraph = g1.union(g2);

    ResolvedConceptReferenceList returnList = unionedGraph.toResolvedConceptReferenceList();
    assertEquals(1, returnList.getResolvedConceptReferenceCount());

    assertEquals("a", returnList.getResolvedConceptReference(0).getCode());

    assertEquals(
        2,
        returnList
            .getResolvedConceptReference(0)
            .getSourceOf()
            .getAssociation(0)
            .getAssociatedConcepts()
            .getAssociatedConceptCount());
  }
예제 #2
0
  @Test
  public void getDuplicates() {
    ResolvedConceptReferenceList list1 = new ResolvedConceptReferenceList();
    ResolvedConceptReferenceList list2 = new ResolvedConceptReferenceList();

    String[] codes1 = new String[] {"a", "b", "c", "d", "e", "f"};
    String[] codes2 = new String[] {"d", "e", "f"};

    for (String code : codes1) {
      list1.addResolvedConceptReference(createResolvedConceptReference(code));
    }
    for (String code : codes2) {
      list2.addResolvedConceptReference(createResolvedConceptReference(code));
    }

    KeyedGraph g1 = new KeyedGraph(list1);
    KeyedGraph g2 = new KeyedGraph(list2);

    KeyedGraph unionedGraph = g1.union(g2);

    assertEquals(6, unionedGraph.getNodes().keySet().size());
  }
예제 #3
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.LexGrid.LexBIG.Utility.Iterators.ResolvedConceptReferencesIterator
  * #next(int)
  */
 public ResolvedConceptReferenceList next(int maxToReturn)
     throws LBResourceUnavailableException, LBInvocationException {
   ResolvedConceptReferenceList returnList = new ResolvedConceptReferenceList();
   while (returnList.getResolvedConceptReferenceCount() < maxToReturn) {
     ResolvedConceptReference ref = getNextFromList();
     if (ref == null) {
       return returnList;
     } else {
       returnList.addResolvedConceptReference(ref);
     }
   }
   return returnList;
 }