/** * @return Returns the names. * @param includeVoided Include voided ConceptNames if true. */ public Collection<ConceptName> getNames(boolean includeVoided) { if (names == null) { names = new HashSet<>(); } return names.stream() .filter(n -> includeVoided || !n.getVoided()) .collect(Collectors.toSet()); }
/** * Returns whether the ConceptName has been voided. * * @return true if the ConceptName has been voided, false otherwise. * * @deprecated as of 2.0, use {@link #getVoided()} */ @Override @Deprecated @JsonIgnore public Boolean isVoided() { return getVoided(); }
: null); pStmt.setBoolean(3, conceptName.getLocalePreferred()); pStmt.setBoolean(4, conceptName.getVoided()); pStmt.setDate(5, conceptName.getVoided() ? new Date(System.currentTimeMillis()) : null); pStmt.setString(6, conceptName.getVoidReason()); pStmt.setObject(7, (conceptName.getVoided() && userId != null) ? userId : null, Types.INTEGER); pStmt.setInt(8, conceptName.getConceptNameId());
if (name.getVoided()) { return false;
+ "' shouldn't be a short name"); errors.reject("Concept.error.preferredName.is.shortName"); } else if (nameInLocale.getVoided()) { log.warn("Preferred name in locale '" + conceptNameLocale.toString() + "' shouldn't be a voided name"); errors.reject("Concept.error.multipleFullySpecifiedNames"); if (nameInLocale.getVoided()) { log.warn("Fully Specified name in locale '" + conceptNameLocale.toString() + "' shouldn't be a voided name");
/** * Sets the specified name as the fully specified name for the locale and the current fully * specified (if any) ceases to be the fully specified name for the locale. * * @param fullySpecifiedName the new fully specified name to set * @should set the concept name type of the specified name to fully specified * @should convert the previous fully specified name if any to a synonym * @should add the name to the list of names if it not among them before */ public void setFullySpecifiedName(ConceptName fullySpecifiedName) { if (fullySpecifiedName == null || fullySpecifiedName.getLocale() == null) { throw new APIException(CONCEPT_NAME_LOCALE_NULL, (Object[]) null); } else if (fullySpecifiedName.getVoided()) { throw new APIException("Concept.error.fullySpecifiedName.null", (Object[]) null); } ConceptName oldFullySpecifiedName = getFullySpecifiedName(fullySpecifiedName.getLocale()); if (oldFullySpecifiedName != null) { oldFullySpecifiedName.setConceptNameType(null); } fullySpecifiedName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED); //add this name, if it is new or not among this concept's names if (fullySpecifiedName.getConceptNameId() == null || !getNames().contains(fullySpecifiedName)) { addName(fullySpecifiedName); } }
if (preferredName == null || preferredName.getVoided() || preferredName.isIndexTerm()) { throw new APIException("Concept.error.preferredName.null", (Object[]) null); } else if (preferredName.getLocale() == null) {
/** * @see ConceptService#saveConcept(Concept) */ @Test public void saveConcept_shouldVoidTheConceptNameIfTheTextOfTheNameHasChanged() { Concept concept = conceptService.getConceptByName("cd4 count"); Assert.assertEquals(false, conceptService.getConceptName(1847).getVoided()); for (ConceptName cn : concept.getNames()) { if (cn.getConceptNameId().equals(1847)) { cn.setName("new name"); } } //ensure that the conceptName has actually been found and replaced Assert.assertEquals(true, concept.hasName("new name", new Locale("en", "GB"))); conceptService.saveConcept(concept); Assert.assertEquals(true, conceptService.getConceptName(1847).getVoided()); }
@Test public void validate_shouldPassIfTheDuplicateNameInTheLocaleForTheConceptBeingValidatedIsVoided() { ConceptName otherName = conceptService.getConceptName(1439); //sanity check since names should only be unique amongst preferred and fully specified names Assert.assertTrue(otherName.isFullySpecifiedName() || otherName.isPreferred()); Assert.assertFalse(otherName.getVoided()); Assert.assertFalse(otherName.getConcept().getRetired()); //change to a duplicate name in the same locale ConceptName duplicateName = conceptService.getConceptName(2477); duplicateName.setName(otherName.getName()); Concept concept = duplicateName.getConcept(); concept.setPreferredName(duplicateName); //ensure that the name has been marked as preferred in its locale Assert.assertEquals(duplicateName, concept.getPreferredName(duplicateName.getLocale())); Assert.assertTrue(duplicateName.isPreferred()); duplicateName.setVoided(true); Errors errors = new BindException(concept, "concept"); validator.validate(concept, errors); Assert.assertFalse(errors.hasErrors()); }