public ConceptName(String name, Locale locale) { setName(name); setLocale(locale); }
conceptName.setLocale(!StringUtils.isBlank(localeString) ? LocaleUtility.fromSpecification(localeString) : null); conceptName.setLocalePreferred(rs.getBoolean("locale_preferred"));
private Concept createConceptWithName(String name) { Concept concept = new Concept(new Random().nextInt()); ConceptName conceptName = new ConceptName(); conceptName.setName(name); conceptName.setLocale(Context.getLocale()); conceptName.setLocalePreferred(true); concept.addName(conceptName); return concept; }
conceptName = new ConceptName(finalText, null); conceptName.setConcept(mappedConcept); conceptName.setLocale(locale == null ? Context.getLocale() : locale); conceptName.setDateCreated(new Date()); conceptName.setCreator(Context.getAuthenticatedUser());
/** * Convenient factory method to create a populated Concept name. * * @param id id for the conceptName * @param locale the locale or context locale if null * @param conceptNameType the conceptNameType of the concept * @param isLocalePreferred if this name should be marked as preferred in its locale */ private ConceptName createConceptName(int id, String name, Locale locale, ConceptNameType conceptNameType, Boolean isLocalePreferred) { ConceptName result = new ConceptName(); result.setConceptNameId(id); result.setName(name); if (locale == null) { result.setLocale(Context.getLocale()); } else { result.setLocale(locale); } result.setConceptNameType(conceptNameType); result.setLocalePreferred(isLocalePreferred); return result; }
public List<ConceptName> getMockNamesList() { ConceptName oldName1 = new ConceptName(); oldName1.setLocale(Locale.ENGLISH); oldName1.setConceptNameType(ConceptNameType.FULLY_SPECIFIED); oldName1.setName("oldName1"); oldName1.setUuid("uuid1"); ConceptName oldName2 = new ConceptName(); oldName2.setLocale(Locale.ENGLISH); oldName2.setConceptNameType(ConceptNameType.SHORT); oldName2.setName("oldName2"); oldName2.setUuid("uuid2"); List<ConceptName> oldNames = new ArrayList<ConceptName>(); oldNames.add(oldName1); oldNames.add(oldName2); return oldNames; }
conceptName.setLocale(defaultLocale); reportUpdatedName(conceptName, "The locale for ConceptName with id " + conceptName.getConceptNameId() + " (" + conceptName.getName() + ") has been set to '" + defaultLocale.getDisplayName() + "'");
@Test public void testSetNames() throws Exception { Concept instance = new Concept(); List<ConceptName> otherNames = new ArrayList<ConceptName>(); ConceptName otherName = new ConceptName(); otherName.setLocale(Locale.ENGLISH); otherName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED); otherName.setName("newName"); otherName.setUuid("newUuid"); otherNames.add(otherName); ConceptResource1_8.setNames(instance, otherNames); assertEquals(instance.getNames().size(), 1); assertTrue(instance.getNames().contains(otherName)); ConceptResource1_8.setNames(instance, getMockNamesList()); assertEquals(instance.getNames().size(), 2); assertFalse(instance.getNames().contains(otherName)); otherNames.addAll(getMockNamesList()); ConceptResource1_8.setNames(instance, otherNames); assertEquals(instance.getNames().size(), 3); assertTrue(instance.getNames().contains(otherName)); ConceptResource1_8.setNames(instance, getMockNamesList()); assertEquals(instance.getNames().size(), 2); assertFalse(instance.getNames().contains(otherName)); }