-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCRUM-4305 set obsolete / internal variables explicitly when being up…
…dated. (#1629)
- Loading branch information
Showing
7 changed files
with
132 additions
and
107 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdentifierHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.alliancegenome.curation_api.services.helpers; | ||
|
||
import org.alliancegenome.curation_api.model.entities.Annotation; | ||
import org.alliancegenome.curation_api.model.entities.base.AuditedObject; | ||
import org.alliancegenome.curation_api.model.entities.base.SubmittedObject; | ||
import org.alliancegenome.curation_api.model.ingest.dto.AnnotationDTO; | ||
import org.alliancegenome.curation_api.model.ingest.dto.DiseaseAnnotationDTO; | ||
import org.alliancegenome.curation_api.model.ingest.dto.base.SubmittedObjectDTO; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class UniqueIdentifierHelper { | ||
|
||
public static <E extends AnnotationDTO> String getIdentifyingField(E annotationDTO) { | ||
if (StringUtils.isNotBlank(annotationDTO.getModEntityId())) { | ||
return "modEntityId"; | ||
} else if (StringUtils.isNotBlank(annotationDTO.getModInternalId())) { | ||
return "modInternalId"; | ||
} else { | ||
return "uniqueId"; | ||
} | ||
} | ||
|
||
public static void setObsoleteAndInternal(DiseaseAnnotationDTO dto, AuditedObject annotation) { | ||
// default obsolete value: false | ||
annotation.setObsolete(dto.getObsolete() != null && dto.getObsolete()); | ||
// default internal value: false | ||
annotation.setInternal(dto.getInternal() != null && dto.getInternal()); | ||
} | ||
|
||
public static <E extends AnnotationDTO, F extends Annotation> String setAnnotationID(E annotationDTO, F annotation, String uniqueId) { | ||
if (StringUtils.isNotBlank(annotationDTO.getModEntityId())) { | ||
annotation.setModEntityId(annotationDTO.getModEntityId()); | ||
return annotationDTO.getModEntityId(); | ||
} else if (StringUtils.isNotBlank(annotationDTO.getModInternalId())) { | ||
annotation.setModInternalId(annotationDTO.getModInternalId()); | ||
return annotationDTO.getModInternalId(); | ||
} else { | ||
return uniqueId; | ||
} | ||
} | ||
|
||
|
||
public static <E extends SubmittedObjectDTO> String getIdentifyingField(E submittedObjectDto) { | ||
if (StringUtils.isNotBlank(submittedObjectDto.getModEntityId())) { | ||
return "modEntityId"; | ||
} else if (StringUtils.isNotBlank(submittedObjectDto.getModInternalId())) { | ||
return "modInternalId"; | ||
} else { | ||
return "uniqueId"; | ||
} | ||
} | ||
|
||
public static void setObsoleteAndInternal(SubmittedObjectDTO dto, SubmittedObject submittedObject) { | ||
// default obsolete value: false | ||
submittedObject.setObsolete(dto.getObsolete() != null && dto.getObsolete()); | ||
// default internal value: false | ||
submittedObject.setInternal(dto.getInternal() != null && dto.getInternal()); | ||
} | ||
|
||
public static <E extends SubmittedObjectDTO, F extends SubmittedObject> String setAnnotationID(E submittedObjectDTO, F submittedObject, String uniqueId) { | ||
if (StringUtils.isNotBlank(submittedObjectDTO.getModEntityId())) { | ||
submittedObject.setModEntityId(submittedObjectDTO.getModEntityId()); | ||
return submittedObjectDTO.getModEntityId(); | ||
} else if (StringUtils.isNotBlank(submittedObjectDTO.getModInternalId())) { | ||
submittedObject.setModInternalId(submittedObjectDTO.getModInternalId()); | ||
return submittedObjectDTO.getModInternalId(); | ||
} else { | ||
return uniqueId; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters