コード例 #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;
 }
  @Test
  public void setPreferredConceptName_shouldSetPreferredName() throws Exception {
    metadataDeployService.installBundles(Arrays.<MetadataBundle>asList(ebolaMetadata));
    ConceptNameTag nameTag =
        MetadataUtils.existing(ConceptNameTag.class, EbolaMetadata._ConceptNameTag.PREFERRED);

    String uuid = "c607c80f-1ea9-4da3-bb88-6276ce8868dd";
    Concept weight = conceptService.getConceptByUuid(uuid);
    weight.addName(new ConceptName("Weight", Locale.ENGLISH));
    conceptService.saveConcept(weight);
    assertThat(
        conceptService.getConceptByUuid(uuid).getPreferredName(Locale.ENGLISH).getName(),
        is("WEIGHT (KG)"));

    new EbolaExampleActivator().setPreferredConceptName(conceptService, uuid, "Weight");
    assertThat(
        conceptService.getConceptByUuid(uuid).getPreferredName(Locale.ENGLISH).getName(),
        is("Weight"));
    assertThat(
        conceptService.getConceptByUuid(uuid).findNameTaggedWith(nameTag).getName(), is("Weight"));
  }