예제 #1
0
파일: DbUtil.java 프로젝트: G1DR4/buendia
 /** Gets or creates a Concept with a given UUID and name. */
 public static Concept getConcept(String name, String uuid, String typeUuid) {
   ConceptService conceptService = Context.getConceptService();
   Concept concept = conceptService.getConceptByUuid(uuid);
   if (concept == null) {
     concept = new Concept();
     concept.setUuid(uuid);
     concept.setShortName(new ConceptName(name, new Locale("en")));
     concept.setDatatype(conceptService.getConceptDatatypeByUuid(typeUuid));
     concept.setConceptClass(conceptService.getConceptClassByUuid(ConceptClass.MISC_UUID));
     conceptService.saveConcept(concept);
   }
   return concept;
 }
예제 #2
0
  /**
   * @see FormatTag#printConcept(StringBuilder,Concept)
   * @verifies print the name with the correct name, and type
   */
  @Test
  public void printConcept_shouldPrintTheNameWithTheCorrectLocaleNameAndType() throws Exception {
    ConceptService service = Context.getConceptService();
    Locale locale = Context.getLocale();
    ConceptNameTag tag = service.getConceptNameTag(5);
    ConceptNameTag anotherTag = service.getConceptNameTag(6);
    Context.flushSession();

    Concept c = new Concept();
    c.addName(
        buildName("English fully specified", locale, true, ConceptNameType.FULLY_SPECIFIED, null));
    c.addName(buildName("English synonym", locale, false, null, null));
    c.addName(buildName("English tag", locale, false, null, tag));
    c.addName(buildName("English another tag", locale, false, null, anotherTag));
    c.setDatatype(service.getConceptDatatype(1));
    c.setConceptClass(service.getConceptClass(1));

    Context.getConceptService().saveConcept(c);

    assertPrintConcept("English fully specified", c, null, null);
    assertPrintConcept(
        "English fully specified", c, ConceptNameType.FULLY_SPECIFIED.toString(), null);
    assertPrintConcept("English tag", c, null, tag.getTag());
  }