Пример #1
0
  @Test
  public void addSetMembers() throws Exception {
    ConceptSetRow conceptRow = new ConceptSetRow();
    conceptRow.name = "New concept";
    conceptRow.conceptClass = "New Class";
    conceptRow.description = "some description";

    List<KeyValue> children = new ArrayList<>();
    children.add(new KeyValue("1", "Child1"));
    children.add(new KeyValue("2", "Child2"));
    conceptRow.children = children;
    Messages persistErrorMessages = conceptSetPersister.persist(conceptRow);
    assertTrue(persistErrorMessages.isEmpty());
    Context.openSession();
    Context.authenticate("admin", "test");
    Concept persistedConcept = conceptService.getConceptByName(conceptRow.name);
    assertNotNull(persistedConcept);
    assertEquals(conceptRow.name, persistedConcept.getName(Context.getLocale()).getName());
    assertEquals(conceptRow.conceptClass, persistedConcept.getConceptClass().getName());
    assertEquals("some description", persistedConcept.getDescription().getDescription());

    assertEquals(2, persistedConcept.getSetMembers().size());
    assertEquals("some description", persistedConcept.getDescription().getDescription());
    assertEquals(0, persistedConcept.getSynonyms().size());
    assertTrue(persistedConcept.isSet());
    Context.flushSession();
    Context.closeSession();
  }
 public ConceptSearchResult(Concept con) {
   this.conceptId = con.getConceptId();
   if (con.getName() != null) {
     this.conceptName = con.getName().getName();
   }
   if (con.getDescription() != null) {
     this.conceptDescription = con.getDescription().getDescription();
   }
   if (con.getConceptClass() != null) {
     this.conceptClass = con.getConceptClass().getName();
   }
   if (con.getDatatype() != null) {
     this.conceptDatatype = con.getDatatype().getName();
   }
   this.otherNames = new Vector<String>();
   for (ConceptName cn : con.getNames()) {
     this.otherNames.add(cn.getName());
   }
 }
Пример #3
0
 @Test
 public void shouldPersistNewConceptSetWithNameClassDescriptionInputOnly() throws Exception {
   ConceptSetRow conceptRow = new ConceptSetRow();
   conceptRow.name = "New concept";
   conceptRow.conceptClass = "New Class";
   conceptRow.description = "some description";
   Messages persistErrorMessages = conceptSetPersister.persist(conceptRow);
   assertTrue(persistErrorMessages.isEmpty());
   Context.openSession();
   Context.authenticate("admin", "test");
   Concept persistedConcept = conceptService.getConceptByName(conceptRow.name);
   assertNotNull(persistedConcept);
   assertEquals(conceptRow.name, persistedConcept.getName(Context.getLocale()).getName());
   assertEquals(conceptRow.conceptClass, persistedConcept.getConceptClass().getName());
   assertEquals("some description", persistedConcept.getDescription().getDescription());
   assertEquals(0, persistedConcept.getSynonyms().size());
   assertTrue(persistedConcept.isSet());
   Context.flushSession();
   Context.closeSession();
 }