diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml new file mode 100644 index 000000000..62c7d8f54 --- /dev/null +++ b/.github/workflows/checkstyle.yml @@ -0,0 +1,20 @@ +name: Checkstyle Action +on: pull_request + +jobs: + checkstyle_job: + runs-on: ubuntu-latest + name: Checkstyle Job + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Run check style + uses: nikitasavinov/checkstyle-action@master + with: + level: 'error' + fail_on_error: 'true' + github_token: ${{ secrets.GH_PAT }} + reporter: 'github-pr-check' + filter_mode: 'file' + checkstyle_config: checkstyle.xml + tool_name: 'reviewdog' diff --git a/Makefile b/Makefile index 42b4d77b6..468a22e58 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,9 @@ docker-run: debug: java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5045 -jar target/agr_curation_api-bootable.jar +checkstyle: + mvn checkstyle:check + test: mvn test diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 000000000..f37703c97 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/checkstyle_config.xml b/checkstyle_config.xml new file mode 100644 index 000000000..189fae825 --- /dev/null +++ b/checkstyle_config.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/pom.xml b/pom.xml index e88791f72..e7de080ac 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,8 @@ 0.5.1 3.5.0 3.0.0-M7 + 3.3.1 + 10.17.0 @@ -486,7 +488,46 @@ v@{project.version} + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + + validate + validate + + UTF-8 + true + true + true + + + check + + + + + config_loc=${basedir} + checkstyle.xml + + + + + diff --git a/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationFilter.java b/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationFilter.java index 41ae0b6fb..7919f6d13 100644 --- a/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationFilter.java +++ b/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationFilter.java @@ -41,38 +41,27 @@ public class AuthenticationFilter implements ContainerRequestFilter { @Inject - @AuthenticatedUser - Event userAuthenticatedEvent; + @AuthenticatedUser Event userAuthenticatedEvent; - @Inject - AuthenticationService authenticationService; + @Inject AuthenticationService authenticationService; - @Inject - PersonDAO personDAO; + @Inject PersonDAO personDAO; - @Inject - AllianceMemberDAO allianceMemberDAO; + @Inject AllianceMemberDAO allianceMemberDAO; - @Inject - PersonService personService; + @Inject PersonService personService; - @Inject - PersonUniqueIdHelper loggedInPersonUniqueId; + @Inject PersonUniqueIdHelper loggedInPersonUniqueId; - @ConfigProperty(name = "okta.authentication") - Instance okta_auth; + @ConfigProperty(name = "okta.authentication") Instance oktaAuth; - @ConfigProperty(name = "okta.url") - Instance okta_url; + @ConfigProperty(name = "okta.url") Instance oktaUrl; - @ConfigProperty(name = "okta.client.id") - Instance client_id; + @ConfigProperty(name = "okta.client.id") Instance clientId; - @ConfigProperty(name = "okta.client.secret") - Instance client_secret; + @ConfigProperty(name = "okta.client.secret") Instance clientSecret; - @ConfigProperty(name = "okta.api.token") - Instance api_token; + @ConfigProperty(name = "okta.api.token") Instance apiToken; // private static final String REALM = "AGR"; private static final String AUTHENTICATION_SCHEME = "Bearer"; @@ -86,8 +75,8 @@ public void filter(ContainerRequestContext requestContext) throws IOException { // Testing) // if okta_auth is on and we have okta_creds validate(token), else fail - if (okta_auth.get()) { - if (!okta_url.get().equals("\"\"") && !client_id.get().equals("\"\"") && !client_secret.get().equals("\"\"") && !api_token.get().equals("\"\"")) { + if (oktaAuth.get()) { + if (!oktaUrl.get().equals("\"\"") && !clientId.get().equals("\"\"") && !clientSecret.get().equals("\"\"") && !apiToken.get().equals("\"\"")) { String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION); @@ -97,20 +86,20 @@ public void filter(ContainerRequestContext requestContext) throws IOException { String token = authorizationHeader.substring(AUTHENTICATION_SCHEME.length()).trim(); Person person = null; - + try { Jwt jsonWebToken = authenticationService.verifyToken(token); - if(person == null) { + if (person == null) { person = validateUserToken(jsonWebToken); } - if(person == null) { + if (person == null) { person = validateAdminToken(jsonWebToken); } } catch (JwtVerificationException e) { person = personService.findPersonByApiToken(token); } - + if (person != null) { userAuthenticatedEvent.fire(person); } else { @@ -152,12 +141,12 @@ private void loginDevUser() { // Check Okta(token), Check DB ApiToken(token), else return null private Person validateUserToken(Jwt jsonWebToken) { - + String oktaUserId = (String) jsonWebToken.getClaims().get("uid"); // User Id - - if(oktaUserId != null && oktaUserId.length() > 0) { + + if (oktaUserId != null && oktaUserId.length() > 0) { String oktaEmail = (String) jsonWebToken.getClaims().get("sub"); // Subject Id - + Person authenticatedUser = personService.findPersonByOktaEmail(oktaEmail); if (authenticatedUser != null) { @@ -186,27 +175,27 @@ private Person validateUserToken(Jwt jsonWebToken) { return person; } } - + return null; } - + private Person validateAdminToken(Jwt jsonWebToken) { - + String oktaClientId = (String) jsonWebToken.getClaims().get("cid"); // Client Id - - if(oktaClientId != null && oktaClientId.length() > 0) { - + + if (oktaClientId != null && oktaClientId.length() > 0) { + Person authenticatedUser = personService.findPersonByOktaId(oktaClientId); - + if (authenticatedUser != null) { return authenticatedUser; } - + Log.info("Making OKTA call to get app info: "); - + Application app = getOktaClient(oktaClientId); - - if(app != null) { + + if (app != null) { log.debug("OKTA Authentication for Admin user via token"); String adminEmail = "admin@alliancegenome.org"; Person person = new Person(); @@ -224,14 +213,13 @@ private Person validateAdminToken(Jwt jsonWebToken) { return null; } - private User getOktaUser(String oktaId) { - Client client = Clients.builder().setOrgUrl(okta_url.get()).setClientId(client_id.get()).setClientCredentials(new TokenClientCredentials(api_token.get())).build(); + Client client = Clients.builder().setOrgUrl(oktaUrl.get()).setClientId(clientId.get()).setClientCredentials(new TokenClientCredentials(apiToken.get())).build(); return client.getUser(oktaId); } - + private Application getOktaClient(String applicationId) { - Client client = Clients.builder().setOrgUrl(okta_url.get()).setClientId(client_id.get()).setClientCredentials(new TokenClientCredentials(api_token.get())).build(); + Client client = Clients.builder().setOrgUrl(oktaUrl.get()).setClientId(clientId.get()).setClientCredentials(new TokenClientCredentials(apiToken.get())).build(); return client.getApplication(applicationId); } diff --git a/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationService.java b/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationService.java index ab8cbad5b..d53ee3267 100644 --- a/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationService.java +++ b/src/main/java/org/alliancegenome/curation_api/auth/AuthenticationService.java @@ -17,13 +17,13 @@ public class AuthenticationService { @ConfigProperty(name = "okta.url") - Instance okta_url; + Instance oktaUrl; private AccessTokenVerifier jwtVerifier; @PostConstruct public void init() { - jwtVerifier = JwtVerifiers.accessTokenVerifierBuilder().setIssuer(okta_url.get() + "/oauth2/default").setAudience("api://default").setConnectionTimeout(Duration.ofSeconds(1)) + jwtVerifier = JwtVerifiers.accessTokenVerifierBuilder().setIssuer(oktaUrl.get() + "/oauth2/default").setAudience("api://default").setConnectionTimeout(Duration.ofSeconds(1)) // .setReadTimeout(Duration.ofSeconds(1)) .build(); } diff --git a/src/main/java/org/alliancegenome/curation_api/config/RestApplication.java b/src/main/java/org/alliancegenome/curation_api/config/RestApplication.java index 897028ed7..6800ed143 100644 --- a/src/main/java/org/alliancegenome/curation_api/config/RestApplication.java +++ b/src/main/java/org/alliancegenome/curation_api/config/RestApplication.java @@ -15,9 +15,9 @@ @ApplicationPath("/api") @OpenAPIDefinition( info = @Info( - description = "

This is the Alliance Curation Java API

" + // - "

!!! Please note: Some Swagger widgets may crash this page when expanded !!!

" + // - "

For flat file of API documentation click on the link below

OpenAPI definition download

", + description = "

This is the Alliance Curation Java API

" + + "

!!! Please note: Some Swagger widgets may crash this page when expanded !!!

" + + "

For flat file of API documentation click on the link below

OpenAPI definition download

", title = "Alliance of Genome Resources Curation API ", version = "1.0 Alpha" ), diff --git a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java index 10197ae87..bda0f4497 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java @@ -1,14 +1,18 @@ package org.alliancegenome.curation_api.constants; public final class EntityFieldConstants { + + private EntityFieldConstants() { + // Hidden from view, as it is a utility class + } public static final String TAXON = "taxon.curie"; public static final String DATA_PROVIDER = "dataProvider.sourceOrganization.abbreviation"; public static final String SECONDARY_DATA_PROVIDER = "secondaryDataProvider.sourceOrganization.abbreviation"; public static final String DA_SUBJECT = "diseaseAnnotationSubject"; - public static final String DA_SUBJECT_TAXON = DA_SUBJECT+ "." + TAXON; + public static final String DA_SUBJECT_TAXON = DA_SUBJECT + "." + TAXON; public static final String PA_SUBJECT = "phenotypeAnnotationSubject"; - public static final String PA_SUBJECT_TAXON = PA_SUBJECT+ "." + TAXON; + public static final String PA_SUBJECT_TAXON = PA_SUBJECT + "." + TAXON; public static final String ALLELE_ASSOCIATION_SUBJECT_DATA_PROVIDER = "alleleAssociationSubject." + DATA_PROVIDER; public static final String CONSTRUCT_ASSOCIATION_SUBJECT_DATA_PROVIDER = "constructAssociationSubject." + DATA_PROVIDER; diff --git a/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java index b2aba7229..c2126f426 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java @@ -1,7 +1,10 @@ package org.alliancegenome.curation_api.constants; -public final class LinkMLSchemaConstants { +public class LinkMLSchemaConstants { + private LinkMLSchemaConstants() { + // Hidden from view, as it is a utility class + } public static final String LATEST_RELEASE = "2.2.3"; public static final String MIN_ONTOLOGY_RELEASE = "1.2.4"; public static final String MAX_ONTOLOGY_RELEASE = LATEST_RELEASE; diff --git a/src/main/java/org/alliancegenome/curation_api/constants/OntologyConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/OntologyConstants.java index 229e99247..4967458f9 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/OntologyConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/OntologyConstants.java @@ -1,7 +1,9 @@ package org.alliancegenome.curation_api.constants; public final class OntologyConstants { - + private OntologyConstants() { + // Hidden from view, as it is a utility class + } public static final String ZECO_AGR_SLIM_SUBSET = "ZECO_0000267"; public static final String ECO_TERM_ABBREVIATION_VOCABULARY = VocabularyConstants.ECO_TERM_ABBREVIATION_VOCABULARY; diff --git a/src/main/java/org/alliancegenome/curation_api/constants/ReferenceConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/ReferenceConstants.java index eca6e0ce7..c8e794b48 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/ReferenceConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/ReferenceConstants.java @@ -3,7 +3,9 @@ import java.util.List; public final class ReferenceConstants { - + private ReferenceConstants() { + // Hidden from view, as it is a utility class + } public static final List primaryXrefOrder = List.of("PMID", "FB", "MGI", "RGD", "SGD", "WB", "XB", "ZFIN"); public static final String RGD_OMIM_ORPHANET_REFERENCE = "AGRKB:101000000829523"; diff --git a/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java index ea716e1f2..39a44ba41 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java @@ -1,7 +1,9 @@ package org.alliancegenome.curation_api.constants; public final class ValidationConstants { - + private ValidationConstants() { + // Hidden from view, as it is a utility class + } public static final String INVALID_MESSAGE = "Not a valid entry"; public static final String INVALID_TYPE_MESSAGE = INVALID_MESSAGE + " - unexpected object type found"; public static final String OBSOLETE_MESSAGE = "Obsolete term specified"; diff --git a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java index a4622dd4c..c8b4c379a 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java @@ -1,7 +1,9 @@ package org.alliancegenome.curation_api.constants; public final class VocabularyConstants { - + private VocabularyConstants() { + // Hidden from view, as it is a utility class + } public static final String ANNOTATION_TYPE_VOCABULARY = "annotation_type"; public static final String DISEASE_QUALIFIER_VOCABULARY = "disease_qualifier"; public static final String DISEASE_GENETIC_MODIFIER_RELATION_VOCABULARY = "disease_genetic_modifier_relation"; diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/APIVersionInfoController.java b/src/main/java/org/alliancegenome/curation_api/controllers/APIVersionInfoController.java index e0d04b709..3f2d12494 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/APIVersionInfoController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/APIVersionInfoController.java @@ -28,7 +28,7 @@ public class APIVersionInfoController implements APIVersionInterface { String name; @ConfigProperty(name = "quarkus.hibernate-search-orm.elasticsearch.hosts") - String es_host; + String esHost; @ConfigProperty(name = "NET") String env; @@ -45,11 +45,13 @@ public APIVersionInfo get() { String minVersion = apiVersionInfoService.getVersionRange(version).get(0); String maxVersion = apiVersionInfoService.getVersionRange(version).get(1); String versionRange = minVersion.equals(maxVersion) ? minVersion : minVersion + " - " + maxVersion; - if (apiVersionInfoService.isPartiallyImplemented(clazz, version)) + if (apiVersionInfoService.isPartiallyImplemented(clazz, version)) { versionRange = versionRange + " (partial)"; + } linkMLClassVersions.put(clazz.getSimpleName(), versionRange); - if (version.submitted()) + if (version.submitted()) { submittedClassVersions.put(clazz.getSimpleName(), versionRange); + } } APIVersionInfo info = new APIVersionInfo(); @@ -57,7 +59,7 @@ public APIVersionInfo get() { info.setName(name); info.setAgrCurationSchemaVersions(linkMLClassVersions); info.setSubmittedClassSchemaVersions(submittedClassVersions); - info.setEsHost(es_host); + info.setEsHost(esHost); info.setEnv(env); return info; } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java index 7476761e6..17136ef31 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java @@ -8,18 +8,20 @@ import org.alliancegenome.curation_api.model.ingest.dto.AnnotationDTO; import org.alliancegenome.curation_api.services.base.BaseAnnotationDTOCrudService; -public abstract class BaseAnnotationDTOCrudController, E extends Annotation, T extends AnnotationDTO, D extends BaseSQLDAO> extends BaseEntityCrudController - implements BaseUpsertControllerInterface { +public abstract class BaseAnnotationDTOCrudController, E extends Annotation, T extends AnnotationDTO, D extends BaseSQLDAO> extends BaseEntityCrudController implements BaseUpsertControllerInterface { + @Override protected abstract void init(); private BaseAnnotationDTOCrudService service; + @Override protected void setService(S service) { super.setService(service); this.service = service; } - + + @Override public E upsert(T dto) throws ObjectUpdateException { return service.upsert(dto); } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseDocumentController.java b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseDocumentController.java index 233c8b4ac..eec3d957c 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseDocumentController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseDocumentController.java @@ -19,11 +19,13 @@ protected void setService(S service) { protected abstract void init(); + @Override public SearchResponse search(Integer page, Integer limit, HashMap params) { - if (params == null) + if (params == null) { params = new HashMap(); + } Pagination pagination = new Pagination(page, limit); return service.searchByParams(pagination, params); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseEntityCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseEntityCrudController.java index 0a33a6b99..218b17a4e 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseEntityCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseEntityCrudController.java @@ -22,22 +22,26 @@ protected void setService(S service) { protected abstract void init(); + @Override public ObjectResponse create(E entity) { return service.create(entity); } + @Override public ObjectListResponse create(List entities) { return service.create(entities); } + @Override public ObjectResponse getById(Long id) { return service.getById(id); } - + public ObjectResponse getByCurie(String curie) { return service.getByCurie(curie); } + @Override public ObjectResponse update(E entity) { return service.update(entity); } @@ -45,7 +49,8 @@ public ObjectResponse update(E entity) { public ObjectResponse deleteByCurie(String curie) { return service.deleteByCurie(curie); } - + + @Override public ObjectResponse deleteById(Long id) { return service.deleteById(id); } @@ -54,30 +59,35 @@ public SearchResponse findByField(String field, String value) { return service.findByField(field, value); } + @Override public SearchResponse find(Integer page, Integer limit, HashMap params) { - if (params == null) + if (params == null) { params = new HashMap<>(); + } Pagination pagination = new Pagination(page, limit); return service.findByParams(pagination, params); } - + + @Override public SearchResponse findForPublic(Integer page, Integer limit, HashMap params) { return find(page, limit, params); } + @Override public SearchResponse search(Integer page, Integer limit, HashMap params) { - if (params == null) + if (params == null) { params = new HashMap<>(); + } Pagination pagination = new Pagination(page, limit); return service.searchByParams(pagination, params); } + @Override public void reindex(Integer batchSizeToLoadObjects, Integer idFetchSize, Integer limitIndexedObjectsTo, Integer threadsToLoadObjects, Integer transactionTimeout, Integer typesToIndexInParallel) { service.reindex(batchSizeToLoadObjects, idFetchSize, limitIndexedObjectsTo, threadsToLoadObjects, transactionTimeout, typesToIndexInParallel); } - public void reindexEverything(Integer batchSizeToLoadObjects, Integer idFetchSize, Integer limitIndexedObjectsTo, Integer threadsToLoadObjects, Integer transactionTimeout, - Integer typesToIndexInParallel) { + public void reindexEverything(Integer batchSizeToLoadObjects, Integer idFetchSize, Integer limitIndexedObjectsTo, Integer threadsToLoadObjects, Integer transactionTimeout, Integer typesToIndexInParallel) { service.reindexEverything(batchSizeToLoadObjects, idFetchSize, limitIndexedObjectsTo, threadsToLoadObjects, transactionTimeout, typesToIndexInParallel); } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java index c0954cb26..fa5fdc9a5 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java @@ -10,18 +10,17 @@ import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.base.SubmittedObjectCrudService; -public abstract class SubmittedObjectCrudController, E extends SubmittedObject, T extends BaseDTO, D extends BaseEntityDAO> extends BaseEntityCrudController implements - BaseSubmittedObjectCrudInterface, - BaseUpsertControllerInterface -{ +public abstract class SubmittedObjectCrudController, E extends SubmittedObject, T extends BaseDTO, D extends BaseEntityDAO> extends BaseEntityCrudController implements BaseSubmittedObjectCrudInterface, BaseUpsertControllerInterface { protected SubmittedObjectCrudService service; - + + @Override protected void setService(S service) { super.setService(service); this.service = service; } - + + @Override public E upsert(T dto) throws ObjectUpdateException { return service.upsert(dto); } @@ -30,10 +29,12 @@ public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdate return service.upsert(dto, dataProvider); } + @Override public ObjectResponse getByIdentifier(String identifierString) { return service.getByIdentifier(identifierString); } - + + @Override public ObjectResponse deleteByIdentifier(String identifierString) { return service.deleteByIdentifier(identifierString); } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/AllelePhenotypeAnnotationCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/AllelePhenotypeAnnotationCrudController.java index 3b44c4914..a2710f7ae 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/AllelePhenotypeAnnotationCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/AllelePhenotypeAnnotationCrudController.java @@ -12,10 +12,9 @@ import jakarta.inject.Inject; @RequestScoped -public class AllelePhenotypeAnnotationCrudController extends BaseEntityCrudControllerimplements AllelePhenotypeAnnotationCrudInterface { +public class AllelePhenotypeAnnotationCrudController extends BaseEntityCrudController implements AllelePhenotypeAnnotationCrudInterface { - @Inject - AllelePhenotypeAnnotationService allelePhenotypeAnnotationService; + @Inject AllelePhenotypeAnnotationService allelePhenotypeAnnotationService; @Override @PostConstruct @@ -23,6 +22,7 @@ protected void init() { setService(allelePhenotypeAnnotationService); } + @Override public ObjectResponse getByIdentifier(String identifierString) { return allelePhenotypeAnnotationService.getByIdentifier(identifierString); } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/ontology/GenoTermCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/ontology/GenoTermCrudController.java index b7476e7d5..cdab7ab3d 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/ontology/GenoTermCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/ontology/GenoTermCrudController.java @@ -9,11 +9,9 @@ import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; - public class GenoTermCrudController extends BaseOntologyTermController implements GenoTermCrudInterface { - - @Inject - GenoTermService genoTermService; + + @Inject GenoTermService genoTermService; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java index d86aa2e07..4e6bec7ea 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java @@ -12,8 +12,9 @@ @ApplicationScoped public class VariantDAO extends BaseSQLDAO { - + @Inject DiseaseAnnotationDAO diseaseAnnotationDAO; + protected VariantDAO() { super(Variant.class); } @@ -21,7 +22,7 @@ protected VariantDAO() { public List findReferencingDiseaseAnnotationIds(Long variantId) { Map dgmParams = new HashMap<>(); dgmParams.put("diseaseGeneticModifiers.id", variantId); - Listresults = diseaseAnnotationDAO.findFilteredIds(dgmParams); + List results = diseaseAnnotationDAO.findFilteredIds(dgmParams); return results; } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java index e00dea7cf..83cccb87e 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java @@ -65,8 +65,8 @@ public class BaseSQLDAO extends BaseEntityDAO { @Inject protected SearchSession searchSession; @Inject protected IndexProcessDisplayService indexProcessDisplayService; - private int outerBoost = 0; - private int innerBoost = 0; + private int outerBoost; + private int innerBoost; protected BaseSQLDAO(Class myClass) { super(myClass); @@ -134,7 +134,7 @@ public E find(Long id) { return null; } } - + private List buildRestrictions(Root root, Map params, Logger.Level level) { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); List restrictions = new ArrayList<>(); @@ -157,8 +157,9 @@ private List buildRestrictions(Root root, Map para } else { Log.log(level, "Looking up via root: " + s); column = root.get(s); - if (column.getJavaType().equals(List.class)) + if (column.getJavaType().equals(List.class)) { column = root.joinList(s, JoinType.LEFT); + } } Log.log(level, "Column Alias: " + column.getAlias() + " Column Java Type: " + column.getJavaType() + " Column Model: " + column.getModel() + " Column Parent Path Alias: " + column.getParentPath().getAlias()); @@ -166,19 +167,21 @@ private List buildRestrictions(Root root, Map para } else { Log.log(level, "Looking up via root: " + key); column = root.get(key); - // Don't need to join to these tables if value is null, the isEmpty will catch the condition later + // Don't need to join to these tables if value is null, the isEmpty will catch + // the condition later Object value = params.get(key); - if(value != null) { - if (column instanceof SqmPluralValuedSimplePath) + if (value != null) { + if (column instanceof SqmPluralValuedSimplePath) { column = root.joinList(key, JoinType.LEFT); + } } } Log.log(level, "Column Alias: " + column.getAlias() + " Column Java Type: " + column.getJavaType() + " Column Model: " + column.getModel() + " Column Parent Path Alias: " + column.getParentPath().getAlias()); - + Object value = params.get(key); - - if(value == null) { + + if (value == null) { restrictions.add(builder.isEmpty(root.get(key))); } else if (value instanceof Integer) { Log.log(level, "Integer Type: " + value); @@ -204,28 +207,28 @@ private List buildRestrictions(Root root, Map para Log.info("Unsupprted Value: " + value); } } - + return restrictions; } - + public List findFilteredIds(Map params) { Logger.Level level = Level.DEBUG; - if(params.containsKey("debug")) { + if (params.containsKey("debug")) { level = params.remove("debug").equals("true") ? Level.INFO : Level.DEBUG; } - + CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery query = builder.createQuery(Long.class); Root root = query.from(myClass); - + List restrictions = buildRestrictions(root, params, level); query.orderBy(builder.asc(root.get("id"))); query.where(builder.and(restrictions.toArray(new Predicate[0]))); query.select(root.get("id")); - + List filteredIds = entityManager.createQuery(query).getResultList(); - + return filteredIds; } @@ -247,15 +250,16 @@ public SearchResponse findAllIds() { for (E entity : allQuery.getResultList()) { Long pk = returnId(entity); - if (pk != null) + if (pk != null) { primaryKeys.add(pk); + } } results.setResults(primaryKeys); results.setTotalResults(totalResults); return results; } - + private Long returnId(E entity) { Long pk = null; try { @@ -265,7 +269,7 @@ private Long returnId(E entity) { } return pk; } - + public SearchResponse findAll() { return findAll(null); } @@ -288,8 +292,9 @@ public SearchResponse findAll(Pagination pagination) { TypedQuery allQuery = entityManager.createQuery(all); if (pagination != null && pagination.getLimit() != null && pagination.getPage() != null) { int first = pagination.getPage() * pagination.getLimit(); - if (first < 0) + if (first < 0) { first = 0; + } allQuery.setFirstResult(first); allQuery.setMaxResults(pagination.getLimit()); } @@ -302,8 +307,9 @@ public SearchResponse findAll(Pagination pagination) { private void handlePersistenceException(E entity, Exception e) { ObjectResponse response = new ObjectResponse(entity); Throwable rootCause = e.getCause(); - while (rootCause.getCause() != null) + while (rootCause.getCause() != null) { rootCause = rootCause.getCause(); + } if (rootCause instanceof ConstraintViolationException) { ConstraintViolationException cve = (ConstraintViolationException) rootCause; response.setErrorMessage("Violates database constraint " + cve.getConstraintName()); @@ -349,20 +355,32 @@ public void reindexEverything(Integer batchSizeToLoadObjects, Integer idFetchSiz ProcessDisplayHelper ph = new ProcessDisplayHelper(2000); ph.addDisplayHandler(indexProcessDisplayService); ph.startProcess("Mass Index Everything"); - MassIndexer indexer = searchSession.massIndexer(annotatedClasses).batchSizeToLoadObjects(batchSizeToLoadObjects).idFetchSize(idFetchSize).dropAndCreateSchemaOnStart(true).mergeSegmentsOnFinish(false).typesToIndexInParallel(typesToIndexInParallel).threadsToLoadObjects(threadsToLoadObjects).monitor(new MassIndexingMonitor() { + MassIndexer indexer = searchSession.massIndexer(annotatedClasses) + .batchSizeToLoadObjects(batchSizeToLoadObjects) + .idFetchSize(idFetchSize) + .dropAndCreateSchemaOnStart(true) + .mergeSegmentsOnFinish(false) + .typesToIndexInParallel(typesToIndexInParallel) + .threadsToLoadObjects(threadsToLoadObjects) + .monitor(new MassIndexingMonitor() { + @Override public void documentsAdded(long increment) { } + @Override public void entitiesLoaded(long increment) { } + @Override public void addToTotalCount(long increment) { } + @Override public void documentsBuilt(long increment) { ph.progressProcess(); } + @Override public void indexingCompleted() { ph.finishProcess(); } @@ -378,13 +396,16 @@ public void indexingCompleted() { public void reindex(Class objectClass, Integer batchSizeToLoadObjects, Integer idFetchSize, Integer limitIndexedObjectsTo, Integer threadsToLoadObjects, Integer transactionTimeout, Integer typesToIndexInParallel) { Log.debug("Starting Indexing for: " + objectClass); - MassIndexer indexer = searchSession.massIndexer(objectClass).batchSizeToLoadObjects(batchSizeToLoadObjects).idFetchSize(idFetchSize).dropAndCreateSchemaOnStart(true).mergeSegmentsOnFinish(false).typesToIndexInParallel(typesToIndexInParallel).threadsToLoadObjects(threadsToLoadObjects).monitor(new MassIndexingMonitor() { + MassIndexer indexer = searchSession.massIndexer(objectClass).batchSizeToLoadObjects(batchSizeToLoadObjects).idFetchSize(idFetchSize).dropAndCreateSchemaOnStart(true).mergeSegmentsOnFinish(false).typesToIndexInParallel(typesToIndexInParallel).threadsToLoadObjects(threadsToLoadObjects) + .monitor(new MassIndexingMonitor() { ProcessDisplayHelper ph = new ProcessDisplayHelper(2000); + @Override public void documentsAdded(long increment) { } + @Override public void entitiesLoaded(long increment) { } @@ -425,10 +446,10 @@ public SearchResponse searchByField(Pagination pagination, String field, Stri public SearchResponse searchByParams(Pagination pagination, Map params) { Logger.Level level = Level.DEBUG; - if(params.containsKey("debug")) { + if (params.containsKey("debug")) { level = params.remove("debug").equals("true") ? Level.INFO : Level.DEBUG; } - + Log.log(level, "Search: " + pagination + " Params: " + params); SearchQueryOptionsStep step = searchSession.search(myClass).where(p -> { @@ -442,8 +463,9 @@ public SearchResponse searchByParams(Pagination pagination, Map f.bool().with(q -> { innerBoost = searchFilters.get(filterName).keySet().size(); for (String field : searchFilters.get(filterName).keySet()) { - if (field.equals("nonNullFields") || field.equals("nullFields")) + if (field.equals("nonNullFields") || field.equals("nullFields")) { continue; + } float boost = (outerBoost * 10000) + (innerBoost * 1000); String op = (String) searchFilters.get(filterName).get(field).get("tokenOperator"); @@ -483,14 +505,14 @@ public SearchResponse searchByParams(Pagination pagination, Map searchByParams(Pagination pagination, Map result = query.fetch(pagination.getPage() * pagination.getLimit(), pagination.getLimit()); if (aggKeys.size() > 0) { @@ -561,25 +582,25 @@ public SearchResponse searchByParams(Pagination pagination, Map findByFields(List fields, String value) { Log.debug("SqlDAO: findByFields: " + fields + " " + value); HashMap params = new HashMap<>(); - for(String field: fields) { + for (String field : fields) { params.put(field, value); } params.put("query_operator", "or"); SearchResponse results = findByParams(params); - //Log.debug("Result List: " + results); + // Log.debug("Result List: " + results); if (results.getResults().size() > 0) { return results; } else { return null; } } - + public SearchResponse findByField(String field, Object value) { Log.debug("SqlDAO: findByField: " + field + " " + value); HashMap params = new HashMap<>(); params.put(field, value); SearchResponse results = findByParams(params); - //Log.debug("Result List: " + results); + // Log.debug("Result List: " + results); if (results.getResults().size() > 0) { return results; } else { @@ -597,10 +618,10 @@ public SearchResponse findByParams(Pagination pagination, Map public SearchResponse findByParams(Pagination pagination, Map params, String orderByField) { Logger.Level level = Level.DEBUG; - if(params.containsKey("debug")) { + if (params.containsKey("debug")) { level = params.remove("debug").equals("true") ? Level.INFO : Level.DEBUG; } - + Log.log(level, "Pagination: " + pagination + " Params: " + params + " Order by: " + orderByField + " Class: " + myClass); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); @@ -610,25 +631,26 @@ public SearchResponse findByParams(Pagination pagination, Map Root countRoot = countQuery.from(myClass); Operator queryOperator = Operator.AND; - if(params.containsKey("query_operator")) { + if (params.containsKey("query_operator")) { queryOperator = params.remove("query_operator").equals("or") ? Operator.OR : Operator.AND; } - + // System.out.println("Root: " + root); List restrictions = buildRestrictions(root, params, level); List countRestrictions = buildRestrictions(countRoot, params, level); - + countQuery.select(builder.count(countRoot)); if (orderByField != null) { query.orderBy(builder.asc(root.get(orderByField))); } else { - //Metamodel metaModel = entityManager.getMetamodel(); - //IdentifiableType of = (IdentifiableType) metaModel.managedType(myClass); - //query.orderBy(builder.asc(root.get(of.getId(of.getIdType().getJavaType()).getName()))); + // Metamodel metaModel = entityManager.getMetamodel(); + // IdentifiableType of = (IdentifiableType) + // metaModel.managedType(myClass); + // query.orderBy(builder.asc(root.get(of.getId(of.getIdType().getJavaType()).getName()))); } - if(queryOperator == Operator.AND) { + if (queryOperator == Operator.AND) { query.where(builder.and(restrictions.toArray(new Predicate[0]))); countQuery.where(builder.and(countRestrictions.toArray(new Predicate[0]))); } else { @@ -639,29 +661,30 @@ public SearchResponse findByParams(Pagination pagination, Map TypedQuery allQuery = entityManager.createQuery(query); if (pagination != null && pagination.getLimit() != null && pagination.getPage() != null) { int first = pagination.getPage() * pagination.getLimit(); - if (first < 0) + if (first < 0) { first = 0; + } allQuery.setFirstResult(first); allQuery.setMaxResults(pagination.getLimit()); } - + Log.log(level, query); Log.log(level, allQuery); Log.log(level, countQuery); - + List dbResults = allQuery.getResultList(); SearchResponse results = new SearchResponse(); results.setResults(dbResults); - + if (level == Level.INFO) { results.setDebug("true"); - results.setEsQuery(((QuerySqmImpl)allQuery).getQueryString()); - results.setDbQuery(((SqmSelectStatement)query).toHqlString()); + results.setEsQuery(((QuerySqmImpl) allQuery).getQueryString()); + results.setDbQuery(((SqmSelectStatement) query).toHqlString()); } - + Long totalResults = entityManager.createQuery(countQuery).getSingleResult(); results.setTotalResults(totalResults); - + return results; } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDAO.java index 79ffd9d14..ee9e62047 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDAO.java @@ -6,10 +6,10 @@ import jakarta.enterprise.context.ApplicationScoped; @ApplicationScoped -public class AlleleFunctionalImpactSlotAnnotationDAO extends BaseSQLDAO< AlleleFunctionalImpactSlotAnnotation> { +public class AlleleFunctionalImpactSlotAnnotationDAO extends BaseSQLDAO { protected AlleleFunctionalImpactSlotAnnotationDAO() { - super( AlleleFunctionalImpactSlotAnnotation.class); + super(AlleleFunctionalImpactSlotAnnotation.class); } } diff --git a/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkDataProvider.java b/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkDataProvider.java index 63971b00c..8efc92aa0 100644 --- a/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkDataProvider.java +++ b/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkDataProvider.java @@ -6,7 +6,7 @@ public enum BackendBulkDataProvider { RGD("NCBITaxon:10116", "RGD:", 10116, "RGD", "RGD", "Rattus", false, false, false, false), MGI("NCBITaxon:10090", "MGI:", 10090, "MGI", "MGI", "Mus", true, false, true, false), - SGD("NCBITaxon:4932", "SGD:", 4932, "SGD", "SGD", "Saccharomyces", true, false, false, false ), + SGD("NCBITaxon:4932", "SGD:", 4932, "SGD", "SGD", "Saccharomyces", true, false, false, false), HUMAN("NCBITaxon:9606", "HGNC:", 9606, "RGD", "RGD", "Rattus", false, false, false, false), ZFIN("NCBITaxon:7955", "ZFIN:", 7955, "ZFIN", "ZFIN", "Danio", true, false, true, false), FB("NCBITaxon:7227", "FB:", 7227, "FB", "FB", "Drosophila", true, false, false, false), @@ -15,22 +15,20 @@ public enum BackendBulkDataProvider { XBXL("NCBITaxon:8355", "XB:", 8355, "XB", "Xenbase", "Xenopus", true, false, false, false), XBXT("NCBITaxon:8364", "XB:", 8364, "XB", "Xenbase", "Xenopus", true, false, false, false), SARSCoV2("NCBITaxon:2697049", "RefSeq", 2697049, "Alliance", "Alliance of Genome Resources", "Severe acute respiratory syndrome", false, false, false, false); - + public String canonicalTaxonCurie; public String curiePrefix; public Integer idPart; - public String sourceOrganization; //The Source Organisation Abbreviation - public String resourceDescriptor; //The organisation's name in the ResourceDescriptor file + public String sourceOrganization; // The Source Organisation Abbreviation + public String resourceDescriptor; // The organisation's name in the ResourceDescriptor file public String coreGenus; public Boolean hasInferredGenePhenotypeAnnotations; public Boolean hasAssertedGenePhenotypeAnnotations; public Boolean hasInferredAllelePhenotypeAnnotations; public Boolean hasAssertedAllelePhenotypeAnnotations; - private BackendBulkDataProvider(String canonicalTaxonCurie, String curiePrefix, Integer idPart, - String sourceOrganization, String resourceDescriptor, String coreGenus, - Boolean hasInferredGenePhenotypeAnnotations, Boolean hasAssertedGenePhenotypeAnnotations, - Boolean hasInferredAllelePhenotypeAnnotations, Boolean hasAssertedAllelePhenotypeAnnotations) { + private BackendBulkDataProvider(String canonicalTaxonCurie, String curiePrefix, Integer idPart, String sourceOrganization, String resourceDescriptor, String coreGenus, Boolean hasInferredGenePhenotypeAnnotations, Boolean hasAssertedGenePhenotypeAnnotations, + Boolean hasInferredAllelePhenotypeAnnotations, Boolean hasAssertedAllelePhenotypeAnnotations) { this.canonicalTaxonCurie = canonicalTaxonCurie; this.curiePrefix = curiePrefix; this.idPart = idPart; @@ -42,7 +40,7 @@ private BackendBulkDataProvider(String canonicalTaxonCurie, String curiePrefix, this.hasInferredAllelePhenotypeAnnotations = hasInferredAllelePhenotypeAnnotations; this.hasAssertedAllelePhenotypeAnnotations = hasAssertedAllelePhenotypeAnnotations; } - + public static String getCanonicalTaxonCurie(String dataProvider) { BackendBulkDataProvider result = null; for (BackendBulkDataProvider provider : values()) { @@ -51,19 +49,21 @@ public static String getCanonicalTaxonCurie(String dataProvider) { break; } } - if (result == null) + if (result == null) { return null; + } return result.canonicalTaxonCurie; } - + public static String getCoreGenus(String dataProvider) { for (BackendBulkDataProvider provider : values()) { - if (Objects.equals(provider.name(), dataProvider)) + if (Objects.equals(provider.name(), dataProvider)) { return provider.coreGenus; + } } return null; } - + public static String getCuriePrefixFromTaxonId(Integer id) { for (BackendBulkDataProvider provider : values()) { if (id.equals(provider.idPart)) { diff --git a/src/main/java/org/alliancegenome/curation_api/enums/ConditionRelationFmsEnum.java b/src/main/java/org/alliancegenome/curation_api/enums/ConditionRelationFmsEnum.java index a75f8f209..0e997d577 100644 --- a/src/main/java/org/alliancegenome/curation_api/enums/ConditionRelationFmsEnum.java +++ b/src/main/java/org/alliancegenome/curation_api/enums/ConditionRelationFmsEnum.java @@ -1,24 +1,26 @@ package org.alliancegenome.curation_api.enums; public enum ConditionRelationFmsEnum { + ameliorates("ameliorated_by"), exacerbates("exacerbated_by"), has_condition("has_condition"), induces("induced_by"); public String agrRelation; - + private ConditionRelationFmsEnum(String agrRelation) { this.agrRelation = agrRelation; } public static ConditionRelationFmsEnum findByName(String name) { - + for (ConditionRelationFmsEnum relation : values()) { - if (relation.name().equals(name)) + if (relation.name().equals(name)) { return relation; + } } - + return null; } } diff --git a/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java b/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java index 284a214b4..52810fb94 100644 --- a/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java +++ b/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java @@ -29,20 +29,26 @@ public boolean isNotRunning() { } public JobStatus getNextStatus() { - if (this == JobStatus.FORCED_PENDING) + if (this == JobStatus.FORCED_PENDING) { return JobStatus.FORCED_STARTED; - if (this == JobStatus.FORCED_STARTED) + } + if (this == JobStatus.FORCED_STARTED) { return JobStatus.FORCED_RUNNING; + } - if (this == JobStatus.SCHEDULED_PENDING) + if (this == JobStatus.SCHEDULED_PENDING) { return JobStatus.SCHEDULED_STARTED; - if (this == JobStatus.SCHEDULED_STARTED) + } + if (this == JobStatus.SCHEDULED_STARTED) { return JobStatus.SCHEDULED_RUNNING; + } - if (this == JobStatus.MANUAL_PENDING) + if (this == JobStatus.MANUAL_PENDING) { return JobStatus.MANUAL_STARTED; - if (this == JobStatus.MANUAL_STARTED) + } + if (this == JobStatus.MANUAL_STARTED) { return JobStatus.MANUAL_RUNNING; + } return FAILED; } diff --git a/src/main/java/org/alliancegenome/curation_api/enums/PsiMiTabPrefixEnum.java b/src/main/java/org/alliancegenome/curation_api/enums/PsiMiTabPrefixEnum.java index 177c62269..8da611930 100644 --- a/src/main/java/org/alliancegenome/curation_api/enums/PsiMiTabPrefixEnum.java +++ b/src/main/java/org/alliancegenome/curation_api/enums/PsiMiTabPrefixEnum.java @@ -27,24 +27,28 @@ public static PsiMiTabPrefixEnum findByPsiMiTabPrefix(String psiMiTabPrefix) { psiMiTabPrefix = psiMiTabPrefix.replace("/", "_"); for (PsiMiTabPrefixEnum prefix : values()) { - if (prefix.name().equals(psiMiTabPrefix)) + if (prefix.name().equals(psiMiTabPrefix)) { return prefix; + } } return null; } public static String getAllianceIdentifier(String psiMiTabIdentifier) { - if (StringUtils.isBlank(psiMiTabIdentifier)) + if (StringUtils.isBlank(psiMiTabIdentifier)) { return null; + } String[] psiMiTabIdParts = psiMiTabIdentifier.split(":"); - if (psiMiTabIdParts.length != 2) + if (psiMiTabIdParts.length != 2) { return psiMiTabIdentifier; + } PsiMiTabPrefixEnum prefix = findByPsiMiTabPrefix(psiMiTabIdParts[0]); - if (prefix == null) + if (prefix == null) { return psiMiTabIdentifier; + } return prefix.alliancePrefix + ":" + psiMiTabIdParts[1]; } diff --git a/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java b/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java index 7547e1e57..15516e435 100644 --- a/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java +++ b/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java @@ -20,11 +20,11 @@ public class ObjectUpdateException extends Exception { public ObjectUpdateException(Object updateObject, String message) { data = new ObjectUpdateExceptionData(updateObject, message, null); } - + public ObjectUpdateException(Object updateObject, Collection messages) { data = new ObjectUpdateExceptionData(updateObject, messages, null); } - + public ObjectUpdateException(Object updateObject, String message, StackTraceElement[] stackTraceElements) { data = new ObjectUpdateExceptionData(updateObject, message, stackTraceElements); } @@ -36,13 +36,13 @@ public static class ObjectUpdateExceptionData { private static ObjectMapper mapper = new RestDefaultObjectMapper().getMapper(); @JsonView({ View.FieldsOnly.class }) - private String jsonObject = null; + private String jsonObject; @JsonView({ View.FieldsOnly.class }) - private String message = null; + private String message; @JsonView({ View.FieldsOnly.class }) - private Collection messages = null; + private Collection messages; @JsonView({ View.FieldsOnly.class }) - private StackTraceElement[] stackTraceElements = null; + private StackTraceElement[] stackTraceElements; public ObjectUpdateExceptionData(Object updateObject, Collection messages, StackTraceElement[] stackTraceElements) { try { @@ -54,7 +54,7 @@ public ObjectUpdateExceptionData(Object updateObject, Collection message this.jsonObject = "{}"; } } - + public ObjectUpdateExceptionData(Object updateObject, String message, StackTraceElement[] stackTraceElements) { try { this.message = message; diff --git a/src/main/java/org/alliancegenome/curation_api/healthcheck/IndexingHealthCheck.java b/src/main/java/org/alliancegenome/curation_api/healthcheck/IndexingHealthCheck.java index 1ceb47890..82f388af9 100644 --- a/src/main/java/org/alliancegenome/curation_api/healthcheck/IndexingHealthCheck.java +++ b/src/main/java/org/alliancegenome/curation_api/healthcheck/IndexingHealthCheck.java @@ -27,22 +27,22 @@ public class IndexingHealthCheck implements HealthCheck { public HealthCheckResponse call() { HealthCheckResponseBuilder resp = null; - + resp = HealthCheckResponse.named("Elasticsearch Indexing health check").up(); - + try { IndexProcessingEvent event = indexProcessingWebsocket.getEvent(); - - if(event != null) { + + if (event != null) { resp.withData("json", mapper.writeValueAsString(event)); - - if(event instanceof StartIndexProcessingEvent) { + + if (event instanceof StartIndexProcessingEvent) { resp.withData("status", "Start Indexing"); } - if(event instanceof ProgressIndexProcessingEvent) { + if (event instanceof ProgressIndexProcessingEvent) { resp.withData("status", "Indexing"); } - if(event instanceof EndIndexProcessingEvent) { + if (event instanceof EndIndexProcessingEvent) { resp.withData("status", "Indexing Finished"); } } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/APIVersionInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/APIVersionInterface.java index 62bc0b259..b9558b04d 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/APIVersionInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/APIVersionInterface.java @@ -21,6 +21,6 @@ public interface APIVersionInterface { @GET @Path("/") @JsonView(View.FieldsOnly.class) - public APIVersionInfo get(); + APIVersionInfo get(); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/DQMSubmissionInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/DQMSubmissionInterface.java index 15480bc09..6754ac277 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/DQMSubmissionInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/DQMSubmissionInterface.java @@ -19,8 +19,6 @@ public interface DQMSubmissionInterface { @POST @Path("/submit") @Consumes(MediaType.MULTIPART_FORM_DATA) - public String update(MultipartFormDataInput input, - @DefaultValue("true") - @QueryParam("cleanUp") Boolean cleanUp); + String update(MultipartFormDataInput input, @DefaultValue("true") @QueryParam("cleanUp") Boolean cleanUp); } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/SystemControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/SystemControllerInterface.java index b4e95781e..fd3d43dda 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/SystemControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/SystemControllerInterface.java @@ -22,7 +22,7 @@ public interface SystemControllerInterface { @GET @Path("/reindexeverything") - public void reindexEverything( + void reindexEverything( @DefaultValue("1000") @QueryParam("batchSizeToLoadObjects") Integer batchSizeToLoadObjects, @DefaultValue("0") @QueryParam("idFetchSize") Integer idFetchSize, @DefaultValue("0") @QueryParam("limitIndexedObjectsTo") Integer limitIndexedObjectsTo, @@ -32,14 +32,14 @@ public void reindexEverything( @GET @Path("/sitesummary") - public ObjectResponse> getSiteSummary(); + ObjectResponse> getSiteSummary(); @GET @Path("/updatedauniqueids") - public void updateDiseaseAnnotationUniqueIds(); + void updateDiseaseAnnotationUniqueIds(); @DELETE @Path("/deletedUnusedConditionsAndExperiments") - public void deleteUnusedConditionsAndExperiments(); + void deleteUnusedConditionsAndExperiments(); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseCurieObjectCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseCurieObjectCrudInterface.java index 33f1dfb10..79b9e628d 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseCurieObjectCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseCurieObjectCrudInterface.java @@ -19,7 +19,6 @@ public interface BaseCurieObjectCrudInterface extends BaseDeleteCurieControllerInterface, BaseSearchControllerInterface, BaseFindControllerInterface, - BaseReindexControllerInterface -{ + BaseReindexControllerInterface { } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseFindControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseFindControllerInterface.java index 0625d836b..c91d24cb7 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseFindControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseFindControllerInterface.java @@ -31,7 +31,7 @@ public interface BaseFindControllerInterface { @Path("/findForPublic") @Tag(name = "Public Web API Database Searching Endpoints") @JsonView(View.ForPublic.class) - @RequestBody( + @RequestBody( description = "Post Request", content = @Content( mediaType = "application/json", @@ -47,13 +47,13 @@ public interface BaseFindControllerInterface { ) ) ) - public SearchResponse findForPublic(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse findForPublic(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @POST @Path("/find") @Tag(name = "Relational Database Browsing Endpoints") @JsonView(View.FieldsAndLists.class) - @RequestBody( + @RequestBody( description = "Post Request", content = @Content( mediaType = "application/json", @@ -69,6 +69,6 @@ public interface BaseFindControllerInterface { ) ) ) - public SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseIdCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseIdCrudInterface.java index 075d65855..fc002aeea 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseIdCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseIdCrudInterface.java @@ -19,7 +19,6 @@ public interface BaseIdCrudInterface extends BaseDeleteIdControllerInterface, BaseSearchControllerInterface, BaseFindControllerInterface, - BaseReindexControllerInterface -{ + BaseReindexControllerInterface { } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseOntologyTermCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseOntologyTermCrudInterface.java index 6c57dda6d..1902d4fcd 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseOntologyTermCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseOntologyTermCrudInterface.java @@ -29,38 +29,37 @@ public interface BaseOntologyTermCrudInterface extends BaseDeleteCurieControllerInterface, BaseSearchControllerInterface, BaseFindControllerInterface, - BaseReindexControllerInterface -{ + BaseReindexControllerInterface { - public void init(); + void init(); @POST @Path("/bulk/owl") @Consumes(MediaType.APPLICATION_XML) - public String updateTerms(@DefaultValue("true") @QueryParam("async") boolean async, @RequestBody String fullText); + String updateTerms(@DefaultValue("true") @QueryParam("async") boolean async, @RequestBody String fullText); @GET @Path("/rootNodes") @JsonView(View.FieldsOnly.class) - public ObjectListResponse getRootNodes(); + ObjectListResponse getRootNodes(); @GET @Path("/{curie}/descendants") @JsonView(View.FieldsOnly.class) - public ObjectListResponse getDescendants(@PathParam("curie") String curie); + ObjectListResponse getDescendants(@PathParam("curie") String curie); @GET @Path("/{curie}/children") @JsonView(View.FieldsOnly.class) - public ObjectListResponse getChildren(@PathParam("curie") String curie); + ObjectListResponse getChildren(@PathParam("curie") String curie); @GET @Path("/{curie}/parents") @JsonView(View.FieldsOnly.class) - public ObjectListResponse getParents(@PathParam("curie") String curie); + ObjectListResponse getParents(@PathParam("curie") String curie); @GET @Path("/{curie}/ancestors") @JsonView(View.FieldsOnly.class) - public ObjectListResponse getAncestors(@PathParam("curie") String curie); + ObjectListResponse getAncestors(@PathParam("curie") String curie); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseReindexControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseReindexControllerInterface.java index 75cd2acd5..982a05463 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseReindexControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseReindexControllerInterface.java @@ -17,7 +17,7 @@ public interface BaseReindexControllerInterface { @GET @Path("/reindex") @Tag(name = "Reindex Endpoints") - public void reindex( + void reindex( @DefaultValue("1000") @QueryParam("batchSizeToLoadObjects") Integer batchSizeToLoadObjects, @DefaultValue("0") @QueryParam("idFetchSize") Integer idFetchSize, @DefaultValue("0") @QueryParam("limitIndexedObjectsTo") Integer limitIndexedObjectsTo, diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSearchControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSearchControllerInterface.java index 24613417e..fb4237ccb 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSearchControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSearchControllerInterface.java @@ -30,7 +30,7 @@ public interface BaseSearchControllerInterface { @Path("/search") @Tag(name = "Elastic Search Browsing Endpoints") @JsonView({ View.FieldsAndLists.class }) - @RequestBody( + @RequestBody( description = "Post Request", content = @Content( mediaType = "application/json", @@ -46,6 +46,6 @@ public interface BaseSearchControllerInterface { ) ) ) - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSubmittedObjectCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSubmittedObjectCrudInterface.java index cd779bc67..4e6676879 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSubmittedObjectCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseSubmittedObjectCrudInterface.java @@ -19,7 +19,6 @@ public interface BaseSubmittedObjectCrudInterface ext BaseDeleteIdentifierControllerInterface, BaseSearchControllerInterface, BaseFindControllerInterface, - BaseReindexControllerInterface -{ + BaseReindexControllerInterface { } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java index 990f51045..07efff0e9 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java @@ -15,5 +15,5 @@ public interface BaseUpsertControllerInterface { @POST @Path("/") @JsonView(View.FieldsOnly.class) - @RequestBody( + @RequestBody( description = "Post Request", content = @Content( mediaType = "application/json", @@ -44,12 +44,12 @@ public interface BaseCreateControllerInterface { ) ) ) - public ObjectResponse create(E entity); + ObjectResponse create(E entity); @POST @Path("/multiple") @JsonView(View.FieldsOnly.class) - @RequestBody( + @RequestBody( description = "Post Request", content = @Content( mediaType = "application/json", @@ -65,6 +65,6 @@ public interface BaseCreateControllerInterface { ) ) ) - public ObjectListResponse create(List entities); + ObjectListResponse create(List entities); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteCurieControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteCurieControllerInterface.java index 795db31ee..307f57378 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteCurieControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteCurieControllerInterface.java @@ -34,6 +34,6 @@ public interface BaseDeleteCurieControllerInterface { ) ) ) - public ObjectResponse deleteByCurie(@PathParam("curie") String curie); + ObjectResponse deleteByCurie(@PathParam("curie") String curie); } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdControllerInterface.java index 844c9679a..947c2f761 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdControllerInterface.java @@ -34,6 +34,6 @@ public interface BaseDeleteIdControllerInterface { ) ) ) - public ObjectResponse deleteById(@PathParam("id") Long id); + ObjectResponse deleteById(@PathParam("id") Long id); } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdentifierControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdentifierControllerInterface.java index e70c99397..b1ceb5a5e 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdentifierControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseDeleteIdentifierControllerInterface.java @@ -34,5 +34,5 @@ public interface BaseDeleteIdentifierControllerInterface deleteByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse deleteByIdentifier(@PathParam("identifierString") String identifierString); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadCurieControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadCurieControllerInterface.java index 866856e28..afd47b724 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadCurieControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadCurieControllerInterface.java @@ -34,6 +34,6 @@ public interface BaseReadCurieControllerInterface { ) ) ) - public ObjectResponse getByCurie(@PathParam("curie") String curie); + ObjectResponse getByCurie(@PathParam("curie") String curie); } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdControllerInterface.java index fb84d534a..8a5e7c9eb 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdControllerInterface.java @@ -34,6 +34,6 @@ public interface BaseReadIdControllerInterface { ) ) ) - public ObjectResponse getById(@PathParam("id") Long id); + ObjectResponse getById(@PathParam("id") Long id); } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdentifierControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdentifierControllerInterface.java index 827ac2192..5bea803ed 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdentifierControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseReadIdentifierControllerInterface.java @@ -34,6 +34,6 @@ public interface BaseReadIdentifierControllerInterface ) ) ) - public ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseUpdateControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseUpdateControllerInterface.java index e3179b890..1155b41be 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseUpdateControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/crud/BaseUpdateControllerInterface.java @@ -25,7 +25,7 @@ public interface BaseUpdateControllerInterface { @PUT @Path("/") @JsonView(View.FieldsOnly.class) - @RequestBody( + @RequestBody( description = "Put Request", content = @Content( mediaType = "application/json", @@ -41,6 +41,6 @@ public interface BaseUpdateControllerInterface { ) ) ) - public ObjectResponse update(E entity); + ObjectResponse update(E entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMDiseaseAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMDiseaseAnnotationCrudInterface.java index b9fc34e43..116260ffd 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMDiseaseAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMDiseaseAnnotationCrudInterface.java @@ -31,23 +31,23 @@ public interface AGMDiseaseAnnotationCrudInterface extends BaseIdCrudInterface getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @PUT @Path("/") @JsonView(View.DiseaseAnnotation.class) - public ObjectResponse update(AGMDiseaseAnnotation entity); + ObjectResponse update(AGMDiseaseAnnotation entity); @Override @POST @Path("/") @JsonView(View.DiseaseAnnotation.class) - public ObjectResponse create(AGMDiseaseAnnotation entity); + ObjectResponse create(AGMDiseaseAnnotation entity); @POST @Path("/bulk/{dataProvider}/annotationFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateAgmDiseaseAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); + APIResponse updateAgmDiseaseAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMPhenotypeAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMPhenotypeAnnotationCrudInterface.java index 21c5d7cd3..43f5133fc 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMPhenotypeAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AGMPhenotypeAnnotationCrudInterface.java @@ -26,19 +26,19 @@ public interface AGMPhenotypeAnnotationCrudInterface extends BaseIdCrudInterface @GET @Path("/findBy/{identifier}") @JsonView(View.FieldsAndLists.class) - public ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @PUT @Path("/") @JsonView(View.PhenotypeAnnotationView.class) - public ObjectResponse update(AGMPhenotypeAnnotation entity); + ObjectResponse update(AGMPhenotypeAnnotation entity); @Override @POST @Path("/") @JsonView(View.PhenotypeAnnotationView.class) - public ObjectResponse create(AGMPhenotypeAnnotation entity); + ObjectResponse create(AGMPhenotypeAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AffectedGenomicModelCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AffectedGenomicModelCrudInterface.java index d0fe65d45..2daacf189 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AffectedGenomicModelCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AffectedGenomicModelCrudInterface.java @@ -39,38 +39,38 @@ public interface AffectedGenomicModelCrudInterface extends BaseSubmittedObjectCr @POST @Path("/bulk/{dataProvider}/agms") @JsonView(View.FieldsAndLists.class) - public APIResponse updateAGMs(@PathParam("dataProvider") String dataProvider, List agmData); + APIResponse updateAGMs(@PathParam("dataProvider") String dataProvider, List agmData); @Override @GET @Path("/{identifierString}") @JsonView(View.AffectedGenomicModelView.class) - public ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); @Override @PUT @Path("/") @JsonView(View.AffectedGenomicModelView.class) - public ObjectResponse update(AffectedGenomicModel entity); + ObjectResponse update(AffectedGenomicModel entity); @Override @POST @Path("/") @JsonView(View.AffectedGenomicModelView.class) - public ObjectResponse create(AffectedGenomicModel entity); + ObjectResponse create(AffectedGenomicModel entity); @Override @POST @Path("/find") @Tag(name = "Relational Database Browsing Endpoints") @JsonView(View.AffectedGenomicModelView.class) - public SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @Override @POST @Path("/search") @Tag(name = "Elastic Search Browsing Endpoints") @JsonView({ View.AffectedGenomicModelView.class }) - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleCrudInterface.java index d237e72d1..a36be86a1 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleCrudInterface.java @@ -36,43 +36,43 @@ public interface AlleleCrudInterface extends BaseSubmittedObjectCrudInterface alleleData); + APIResponse updateAlleles(@PathParam("dataProvider") String dataProvider, List alleleData); @Override @GET @Path("/{identifierString}") @JsonView(View.AlleleDetailView.class) - public ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); @Override @PUT @Path("/") @JsonView(View.AlleleView.class) - public ObjectResponse update(Allele entity); + ObjectResponse update(Allele entity); @PUT @Path("/updateDetail") @JsonView(View.AlleleDetailView.class) - public ObjectResponse updateDetail(Allele entity); + ObjectResponse updateDetail(Allele entity); @Override @POST @Path("/") @JsonView(View.AlleleView.class) - public ObjectResponse create(Allele entity); + ObjectResponse create(Allele entity); @Override @POST @Path("/find") @Tag(name = "Relational Database Browsing Endpoints") @JsonView(View.AlleleView.class) - public SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @Override @POST @Path("/search") @Tag(name = "Elastic Search Browsing Endpoints") @JsonView({ View.AlleleView.class }) - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleDiseaseAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleDiseaseAnnotationCrudInterface.java index 898d96b36..a9abe4c02 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleDiseaseAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AlleleDiseaseAnnotationCrudInterface.java @@ -31,23 +31,23 @@ public interface AlleleDiseaseAnnotationCrudInterface extends BaseIdCrudInterfac @GET @Path("/findBy/{identifier}") @JsonView(View.FieldsAndLists.class) - public ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @PUT @Path("/") @JsonView(View.DiseaseAnnotation.class) - public ObjectResponse update(AlleleDiseaseAnnotation entity); + ObjectResponse update(AlleleDiseaseAnnotation entity); @Override @POST @Path("/") @JsonView(View.DiseaseAnnotation.class) - public ObjectResponse create(AlleleDiseaseAnnotation entity); + ObjectResponse create(AlleleDiseaseAnnotation entity); @POST @Path("/bulk/{dataProvider}/annotationFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateAlleleDiseaseAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); + APIResponse updateAlleleDiseaseAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AllelePhenotypeAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AllelePhenotypeAnnotationCrudInterface.java index c3144fbc0..52e27cfde 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AllelePhenotypeAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/AllelePhenotypeAnnotationCrudInterface.java @@ -26,18 +26,18 @@ public interface AllelePhenotypeAnnotationCrudInterface extends BaseIdCrudInterf @GET @Path("/findBy/{identifier}") @JsonView(View.FieldsAndLists.class) - public ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @PUT @Path("/") @JsonView(View.PhenotypeAnnotationView.class) - public ObjectResponse update(AllelePhenotypeAnnotation entity); + ObjectResponse update(AllelePhenotypeAnnotation entity); @Override @POST @Path("/") @JsonView(View.PhenotypeAnnotationView.class) - public ObjectResponse create(AllelePhenotypeAnnotation entity); + ObjectResponse create(AllelePhenotypeAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java index b142bd4d2..1bf4ebeda 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java @@ -7,10 +7,10 @@ public interface BaseUpsertServiceInterface { - public default E upsert(T dto) throws ObjectUpdateException { + default E upsert(T dto) throws ObjectUpdateException { return upsert(dto, null); } - public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException; + E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException; -} \ No newline at end of file +} diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ConstructCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ConstructCrudInterface.java index 66b80f3fd..4cc40f21f 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ConstructCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ConstructCrudInterface.java @@ -32,23 +32,23 @@ public interface ConstructCrudInterface extends BaseSubmittedObjectCrudInterface @GET @Path("/{identifierString}") @JsonView(View.ConstructView.class) - public ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); @Override @PUT @Path("/") @JsonView(View.ConstructView.class) - public ObjectResponse update(Construct entity); + ObjectResponse update(Construct entity); @Override @POST @Path("/") @JsonView(View.ConstructView.class) - public ObjectResponse create(Construct entity); + ObjectResponse create(Construct entity); @POST @Path("/bulk/{dataProvider}/constructs") @JsonView(View.FieldsAndLists.class) - public APIResponse updateConstructs(@PathParam("dataProvider") String dataProvider, List constructData); + APIResponse updateConstructs(@PathParam("dataProvider") String dataProvider, List constructData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DataProviderCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DataProviderCrudInterface.java index ba3625fd2..d02bf8305 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DataProviderCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DataProviderCrudInterface.java @@ -23,7 +23,7 @@ public interface DataProviderCrudInterface extends BaseIdCrudInterface validate(DataProvider entity); + ObjectResponse validate(DataProvider entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DiseaseAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DiseaseAnnotationCrudInterface.java index f811fb0b7..ea617cabe 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DiseaseAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/DiseaseAnnotationCrudInterface.java @@ -31,13 +31,13 @@ public interface DiseaseAnnotationCrudInterface extends BaseIdCrudInterface getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @POST @Path("/search") @JsonView(View.DiseaseAnnotation.class) @Tag(name = "Elastic Search Disease Annotations") - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ExperimentalConditionCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ExperimentalConditionCrudInterface.java index febddb4ac..fc503c4f6 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ExperimentalConditionCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ExperimentalConditionCrudInterface.java @@ -24,6 +24,6 @@ public interface ExperimentalConditionCrudInterface extends BaseIdCrudInterface< @GET @Path("/findBy/{conditionSummary}") @JsonView(View.FieldsAndLists.class) - public ObjectResponse get(@PathParam("conditionSummary") String conditionSummary); + ObjectResponse get(@PathParam("conditionSummary") String conditionSummary); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneCrudInterface.java index 11733fae7..829803391 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneCrudInterface.java @@ -41,37 +41,37 @@ public interface GeneCrudInterface extends BaseSubmittedObjectCrudInterface getByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); @POST @Path("/bulk/{dataProvider}/genes") @JsonView(View.FieldsAndLists.class) - public APIResponse updateGenes(@PathParam("dataProvider") String dataProvider, List geneData); + APIResponse updateGenes(@PathParam("dataProvider") String dataProvider, List geneData); @Override @PUT @Path("/") @JsonView(View.GeneView.class) - public ObjectResponse update(Gene entity); + ObjectResponse update(Gene entity); @Override @POST @Path("/") @JsonView(View.GeneView.class) - public ObjectResponse create(Gene entity); + ObjectResponse create(Gene entity); @Override @POST @Path("/find") @Tag(name = "Relational Database Browsing Endpoints") @JsonView(View.GeneView.class) - public SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @Override @POST @Path("/search") @Tag(name = "Elastic Search Browsing Endpoints") @JsonView({ View.GeneView.class }) - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneDiseaseAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneDiseaseAnnotationCrudInterface.java index 18e410813..eef748044 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneDiseaseAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneDiseaseAnnotationCrudInterface.java @@ -31,23 +31,23 @@ public interface GeneDiseaseAnnotationCrudInterface extends BaseIdCrudInterface< @GET @Path("/findBy/{identifier}") @JsonView(View.FieldsAndLists.class) - public ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @PUT @Path("/") @JsonView(View.DiseaseAnnotation.class) - public ObjectResponse update(GeneDiseaseAnnotation entity); + ObjectResponse update(GeneDiseaseAnnotation entity); @Override @POST @Path("/") @JsonView(View.DiseaseAnnotation.class) - public ObjectResponse create(GeneDiseaseAnnotation entity); + ObjectResponse create(GeneDiseaseAnnotation entity); @POST @Path("/bulk/{dataProvider}/annotationFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateGeneDiseaseAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); + APIResponse updateGeneDiseaseAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneGeneticInteractionCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneGeneticInteractionCrudInterface.java index 0edd089fc..69235236a 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneGeneticInteractionCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneGeneticInteractionCrudInterface.java @@ -34,18 +34,18 @@ public interface GeneGeneticInteractionCrudInterface extends BaseIdCrudInterface @GET @Path("/findBy/{identifier}") @JsonView(View.GeneInteractionView.class) - public ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @POST @Path("/search") @JsonView(View.GeneInteractionView.class) @Tag(name = "Elastic Search Gene Genetic Interactions") - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @POST @Path("/bulk/interactionFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateInteractions(List interactionData); + APIResponse updateInteractions(List interactionData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneInteractionCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneInteractionCrudInterface.java index b1e00e384..e9bcf2ac8 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneInteractionCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneInteractionCrudInterface.java @@ -31,13 +31,13 @@ public interface GeneInteractionCrudInterface extends BaseIdCrudInterface getByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); @Override @POST @Path("/search") @JsonView(View.GeneInteractionView.class) @Tag(name = "Elastic Search Gene Interactions") - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneMolecularInteractionCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneMolecularInteractionCrudInterface.java index c2e0498d0..f9067a221 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneMolecularInteractionCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneMolecularInteractionCrudInterface.java @@ -34,18 +34,18 @@ public interface GeneMolecularInteractionCrudInterface extends BaseIdCrudInterfa @GET @Path("/findBy/{identifier}") @JsonView(View.GeneInteractionView.class) - public ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @POST @Path("/search") @JsonView(View.GeneInteractionView.class) @Tag(name = "Elastic Search Gene Molecular Interactions") - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @POST @Path("/bulk/interactionFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateInteractions(List interactionData); + APIResponse updateInteractions(List interactionData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GenePhenotypeAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GenePhenotypeAnnotationCrudInterface.java index 9ec5757ae..25edba83f 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GenePhenotypeAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GenePhenotypeAnnotationCrudInterface.java @@ -26,19 +26,19 @@ public interface GenePhenotypeAnnotationCrudInterface extends BaseIdCrudInterfac @GET @Path("/findBy/{identifier}") @JsonView(View.FieldsAndLists.class) - public ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @PUT @Path("/") @JsonView(View.PhenotypeAnnotationView.class) - public ObjectResponse update(GenePhenotypeAnnotation entity); + ObjectResponse update(GenePhenotypeAnnotation entity); @Override @POST @Path("/") @JsonView(View.PhenotypeAnnotationView.class) - public ObjectResponse create(GenePhenotypeAnnotation entity); + ObjectResponse create(GenePhenotypeAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneToGeneParalogyCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneToGeneParalogyCrudInterface.java index 4c7c9bf83..d200be8fc 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneToGeneParalogyCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GeneToGeneParalogyCrudInterface.java @@ -1,14 +1,14 @@ package org.alliancegenome.curation_api.interfaces.crud; -import org.alliancegenome.curation_api.model.ingest.dto.fms.ParalogyIngestFmsDTO; import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; import org.alliancegenome.curation_api.model.entities.GeneToGeneParalogy; +import org.alliancegenome.curation_api.model.ingest.dto.fms.ParalogyIngestFmsDTO; import org.alliancegenome.curation_api.response.APIResponse; import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.tags.Tag; import com.fasterxml.jackson.annotation.JsonView; -import org.eclipse.microprofile.openapi.annotations.tags.Tag; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; @@ -25,6 +25,6 @@ public interface GeneToGeneParalogyCrudInterface extends BaseIdCrudInterface { @POST @Path("/bulk/moleculefile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateMolecules(MoleculeIngestFmsDTO moleculeData); + APIResponse updateMolecules(MoleculeIngestFmsDTO moleculeData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/NoteCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/NoteCrudInterface.java index 89e7712e1..54583dd9f 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/NoteCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/NoteCrudInterface.java @@ -25,16 +25,16 @@ public interface NoteCrudInterface extends BaseIdCrudInterface { @POST @Path("/validate") @JsonView(View.NoteView.class) - public ObjectResponse validate(Note entity); + ObjectResponse validate(Note entity); @Override @GET @JsonView(View.NoteView.class) @Path("/{id}") - public ObjectResponse getById(@PathParam("id") Long id); + ObjectResponse getById(@PathParam("id") Long id); @POST @Path("/") @JsonView(View.NoteView.class) - public ObjectResponse create(Note entity); + ObjectResponse create(Note entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/PhenotypeAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/PhenotypeAnnotationCrudInterface.java index 449db976b..50240ea42 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/PhenotypeAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/PhenotypeAnnotationCrudInterface.java @@ -34,18 +34,18 @@ public interface PhenotypeAnnotationCrudInterface extends BaseIdCrudInterface getByIdentifier(@PathParam("identifier") String identifier); + ObjectResponse getByIdentifier(@PathParam("identifier") String identifier); @Override @POST @Path("/search") @JsonView(View.PhenotypeAnnotationView.class) @Tag(name = "Elastic Search Phenotype Annotations") - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @POST @Path("/bulk/{dataProvider}/annotationFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updatePhenotypeAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); + APIResponse updatePhenotypeAnnotations(@PathParam("dataProvider") String dataProvider, List annotationData); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ReferenceCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ReferenceCrudInterface.java index 74348220e..388f5bb62 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ReferenceCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ReferenceCrudInterface.java @@ -23,10 +23,10 @@ public interface ReferenceCrudInterface extends BaseCurieObjectCrudInterface synchroniseReference(@PathParam("id") Long id); + ObjectResponse synchroniseReference(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ResourceDescriptorPageCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ResourceDescriptorPageCrudInterface.java index 2ce8c70bd..1a595da77 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ResourceDescriptorPageCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ResourceDescriptorPageCrudInterface.java @@ -29,5 +29,5 @@ public interface ResourceDescriptorPageCrudInterface extends BaseIdCrudInterface @Path("/search") @JsonView(View.ResourceDescriptorPageView.class) @Tag(name = "Elastic Search Browsing Endpoints") - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java index 7cea4a313..b8e76f289 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java @@ -36,38 +36,38 @@ public interface VariantCrudInterface extends BaseSubmittedObjectCrudInterface alleleData); + APIResponse updateVariants(@PathParam("dataProvider") String dataProvider, List alleleData); @Override @GET @JsonView(View.VariantView.class) @Path("/{identifierString}") - public ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); @Override @PUT @Path("/") @JsonView(View.VariantView.class) - public ObjectResponse update(Variant entity); + ObjectResponse update(Variant entity); @Override @POST @Path("/") @JsonView(View.VariantView.class) - public ObjectResponse create(Variant entity); + ObjectResponse create(Variant entity); @Override @POST @Path("/find") @Tag(name = "Relational Database Browsing Endpoints") @JsonView(View.VariantView.class) - public SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @Override @POST @Path("/search") @Tag(name = "Elastic Search Browsing Endpoints") @JsonView({ View.VariantView.class }) - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyCrudInterface.java index 1698f4760..36c2aee6d 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyCrudInterface.java @@ -36,6 +36,6 @@ public interface VocabularyCrudInterface extends BaseIdCrudInterface @GET @Path("/findBy/{name}") @JsonView(View.FieldsAndLists.class) - public ObjectResponse findByName(@PathParam("name") String name); + ObjectResponse findByName(@PathParam("name") String name); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermCrudInterface.java index 159f17f9d..c4f117b3f 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermCrudInterface.java @@ -35,32 +35,31 @@ public interface VocabularyTermCrudInterface extends BaseIdCrudInterface search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, - @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @Override @GET @Path("/{id}") @JsonView(View.VocabularyTermView.class) - public ObjectResponse getById(@PathParam("id") Long id); + ObjectResponse getById(@PathParam("id") Long id); @GET @Path("/findBy") @JsonView(View.VocabularyTermView.class) - public ObjectResponse getTermInVocabulary(@QueryParam("vocabularyName") String vocabularyName, @QueryParam("termName") String termName); + ObjectResponse getTermInVocabulary(@QueryParam("vocabularyName") String vocabularyName, @QueryParam("termName") String termName); @GET @Path("/findInSet") @JsonView(View.VocabularyTermView.class) - public ObjectResponse getTermInVocabularyTermSet(@QueryParam("vocabularyTermSetName") String vocabularyTermSetName, @QueryParam("termName") String termName); + ObjectResponse getTermInVocabularyTermSet(@QueryParam("vocabularyTermSetName") String vocabularyTermSetName, @QueryParam("termName") String termName); @PUT @Path("/") @JsonView(View.VocabularyTermUpdate.class) - public ObjectResponse update(VocabularyTerm entity); + ObjectResponse update(VocabularyTerm entity); @POST @Path("/") @JsonView(VocabularyTermView.class) - public ObjectResponse create(VocabularyTerm entity); + ObjectResponse create(VocabularyTerm entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermSetCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermSetCrudInterface.java index 436ab96f7..7b72cd127 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermSetCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VocabularyTermSetCrudInterface.java @@ -45,27 +45,25 @@ public interface VocabularyTermSetCrudInterface extends BaseIdCrudInterface update(VocabularyTermSet entity); + ObjectResponse update(VocabularyTermSet entity); @Override @POST @Path("/") @JsonView(View.VocabularyTermSetView.class) - public ObjectResponse create(VocabularyTermSet entity); + ObjectResponse create(VocabularyTermSet entity); @Override @POST @Path("/find") @Tag(name = "Relational Database Browsing Endpoints") @JsonView(View.VocabularyTermSetView.class) - public SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, - @RequestBody HashMap params); + SearchResponse find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @Override @POST @Path("/search") @Tag(name = "Elastic Search Browsing Endpoints") @JsonView({ View.VocabularyTermSetView.class }) - public SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, - @RequestBody HashMap params); + SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java index 372834ebe..f27af281e 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java @@ -30,15 +30,15 @@ public interface AlleleGeneAssociationCrudInterface extends BaseIdCrudInterface< @POST @Path("/bulk/{dataProvider}/associationFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateAlleleGeneAssociations(@PathParam("dataProvider") String dataProvider, List associationData); + APIResponse updateAlleleGeneAssociations(@PathParam("dataProvider") String dataProvider, List associationData); @GET @Path("/findBy") @JsonView(View.FieldsAndLists.class) - public ObjectResponse getAssociation(@QueryParam("alleleId") Long alleleId, @QueryParam("relationName") String relationName, @QueryParam("geneId") Long geneId); + ObjectResponse getAssociation(@QueryParam("alleleId") Long alleleId, @QueryParam("relationName") String relationName, @QueryParam("geneId") Long geneId); @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleGeneAssociation entity); + ObjectResponse validate(AlleleGeneAssociation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java index 2688b1ed5..ae8b777c7 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java @@ -30,15 +30,15 @@ public interface ConstructGenomicEntityAssociationCrudInterface extends BaseIdCr @POST @Path("/bulk/{dataProvider}/associationFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateConstructGenomicEntityAssociations(@PathParam("dataProvider") String dataProvider, List associationData); + APIResponse updateConstructGenomicEntityAssociations(@PathParam("dataProvider") String dataProvider, List associationData); @GET @Path("/findBy") @JsonView(View.FieldsAndLists.class) - public ObjectResponse getAssociation(@QueryParam("constructId") Long constructId, @QueryParam("relationName") String relationName, @QueryParam("genomicEntityId") Long genomicEntityId); + ObjectResponse getAssociation(@QueryParam("constructId") Long constructId, @QueryParam("relationName") String relationName, @QueryParam("genomicEntityId") Long genomicEntityId); @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(ConstructGenomicEntityAssociation entity); + ObjectResponse validate(ConstructGenomicEntityAssociation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java index 0fc9fab57..b1f856ab7 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java @@ -24,6 +24,6 @@ public interface BulkFMSLoadCrudInterface extends BaseIdCrudInterface restartLoad(@PathParam("id") Long id); + ObjectResponse restartLoad(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java index 340e63575..3a8bd1c47 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java @@ -24,5 +24,5 @@ public interface BulkLoadFileCrudInterface extends BaseIdCrudInterface restartLoadFile(@PathParam("id") Long id); + ObjectResponse restartLoadFile(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java index 7da9fc718..a9a202735 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java @@ -24,5 +24,5 @@ public interface BulkLoadFileHistoryCrudInterface extends BaseIdCrudInterface restartLoad(@PathParam("id") Long id); + ObjectResponse restartLoad(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java index 652c6ef8c..d5827eca7 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java @@ -24,5 +24,5 @@ public interface BulkURLLoadCrudInterface extends BaseIdCrudInterface restartLoad(@PathParam("id") Long id); + ObjectResponse restartLoad(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ontology/EcoTermCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ontology/EcoTermCrudInterface.java index 37185c926..d7089d9d9 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ontology/EcoTermCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ontology/EcoTermCrudInterface.java @@ -18,6 +18,6 @@ public interface EcoTermCrudInterface extends BaseOntologyTermCrudInterface validate(AlleleDatabaseStatusSlotAnnotation entity); + ObjectResponse validate(AlleleDatabaseStatusSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationCrudInterface.java index 39c0bc511..a9b4b7108 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleFullNameSlotAnnotationCrudInterface extends BaseIdCrudInt @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleFullNameSlotAnnotation entity); + ObjectResponse validate(AlleleFullNameSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationCrudInterface.java index 9a9a6a1fd..fb765ccf2 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleFunctionalImpactSlotAnnotationCrudInterface extends BaseI @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleFunctionalImpactSlotAnnotation entity); + ObjectResponse validate(AlleleFunctionalImpactSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationCrudInterface.java index b7b62a61f..07667b02e 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleGermlineTransmissionStatusSlotAnnotationCrudInterface ext @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleGermlineTransmissionStatusSlotAnnotation entity); + ObjectResponse validate(AlleleGermlineTransmissionStatusSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationCrudInterface.java index 86a309d4b..a87388f82 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleInheritanceModeSlotAnnotationCrudInterface extends BaseId @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleInheritanceModeSlotAnnotation entity); + ObjectResponse validate(AlleleInheritanceModeSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationCrudInterface.java index 1d4157491..918065004 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleMutationTypeSlotAnnotationCrudInterface extends BaseIdCru @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleMutationTypeSlotAnnotation entity); + ObjectResponse validate(AlleleMutationTypeSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationCrudInterface.java index 1879b011f..664ac290b 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleNomenclatureEventSlotAnnotationCrudInterface extends Base @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleNomenclatureEventSlotAnnotation entity); + ObjectResponse validate(AlleleNomenclatureEventSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationCrudInterface.java index 4e8685d30..01cca87e3 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleSecondaryIdSlotAnnotationCrudInterface extends BaseIdCrud @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleSecondaryIdSlotAnnotation entity); + ObjectResponse validate(AlleleSecondaryIdSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationCrudInterface.java index 74abe5dc0..48302ca31 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleSymbolSlotAnnotationCrudInterface extends BaseIdCrudInter @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleSymbolSlotAnnotation entity); + ObjectResponse validate(AlleleSymbolSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationCrudInterface.java index 2343fca29..8eecd8b02 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface AlleleSynonymSlotAnnotationCrudInterface extends BaseIdCrudInte @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(AlleleSynonymSlotAnnotation entity); + ObjectResponse validate(AlleleSynonymSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationCrudInterface.java index 21f333683..d128a1bf9 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface ConstructComponentSlotAnnotationCrudInterface extends BaseIdCru @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(ConstructComponentSlotAnnotation entity); + ObjectResponse validate(ConstructComponentSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationCrudInterface.java index 77d3ba750..82e40e2fb 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface ConstructFullNameSlotAnnotationCrudInterface extends BaseIdCrud @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(ConstructFullNameSlotAnnotation entity); + ObjectResponse validate(ConstructFullNameSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationCrudInterface.java index 7ea054e7c..670cb267a 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface ConstructSymbolSlotAnnotationCrudInterface extends BaseIdCrudIn @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(ConstructSymbolSlotAnnotation entity); + ObjectResponse validate(ConstructSymbolSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationCrudInterface.java index f9da774c3..7cde780cf 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface ConstructSynonymSlotAnnotationCrudInterface extends BaseIdCrudI @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(ConstructSynonymSlotAnnotation entity); + ObjectResponse validate(ConstructSynonymSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationCrudInterface.java index df228b57b..f68361624 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface GeneFullNameSlotAnnotationCrudInterface extends BaseIdCrudInter @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(GeneFullNameSlotAnnotation entity); + ObjectResponse validate(GeneFullNameSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationCrudInterface.java index b95086a95..09757baf0 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface GeneSecondaryIdSlotAnnotationCrudInterface extends BaseIdCrudIn @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(GeneSecondaryIdSlotAnnotation entity); + ObjectResponse validate(GeneSecondaryIdSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationCrudInterface.java index 51573c1a7..e8f604200 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface GeneSymbolSlotAnnotationCrudInterface extends BaseIdCrudInterfa @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(GeneSymbolSlotAnnotation entity); + ObjectResponse validate(GeneSymbolSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationCrudInterface.java index bdb84c5de..73cb9a2f4 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface GeneSynonymSlotAnnotationCrudInterface extends BaseIdCrudInterf @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(GeneSynonymSlotAnnotation entity); + ObjectResponse validate(GeneSynonymSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationCrudInterface.java index d014c8ae2..ee6ea2d51 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationCrudInterface.java @@ -23,5 +23,5 @@ public interface GeneSystematicNameSlotAnnotationCrudInterface extends BaseIdCru @POST @Path("/validate") @JsonView(View.FieldsAndLists.class) - public ObjectResponse validate(GeneSystematicNameSlotAnnotation entity); + ObjectResponse validate(GeneSystematicNameSlotAnnotation entity); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/curationreports/CurationReportCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/curationreports/CurationReportCrudInterface.java index 1b9f4f82a..d3cc9de5d 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/curationreports/CurationReportCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/curationreports/CurationReportCrudInterface.java @@ -24,11 +24,11 @@ public interface CurationReportCrudInterface extends BaseIdCrudInterface getById(@PathParam("id") Long id); + ObjectResponse getById(@PathParam("id") Long id); @GET @Path("/restart/{id}") @JsonView(View.FieldsOnly.class) - public ObjectResponse restartReport(@PathParam("id") Long id); + ObjectResponse restartReport(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/fms/DataFileRESTInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/fms/DataFileRESTInterface.java index 46aa0b8ee..7877f72ff 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/fms/DataFileRESTInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/fms/DataFileRESTInterface.java @@ -25,26 +25,26 @@ public interface DataFileRESTInterface { @GET @Path("/{id}") - public DataFile get(@Parameter(in = ParameterIn.PATH, name = "id", description = "Long Id or md5Sum", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("id") String id); + DataFile get(@Parameter(in = ParameterIn.PATH, name = "id", description = "Long Id or md5Sum", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("id") String id); @GET @Path("/all") - public List getDataFiles(); + List getDataFiles(); @GET @Path("/by/{dataType}") - public List getDataTypeFiles(@PathParam("dataType") String dataType, + List getDataTypeFiles(@PathParam("dataType") String dataType, @DefaultValue("false") @Parameter(in = ParameterIn.QUERY, name = "latest", description = "Latest File or All", required = false, schema = @Schema(type = SchemaType.BOOLEAN)) @QueryParam("latest") Boolean latest); @GET @Path("/by/release/{releaseVersion}") - public List getDataFilesByRelease(@PathParam("releaseVersion") String releaseVersion, + List getDataFilesByRelease(@PathParam("releaseVersion") String releaseVersion, @DefaultValue("false") @Parameter(in = ParameterIn.QUERY, name = "latest", description = "Latest File or All", required = false, schema = @Schema(type = SchemaType.BOOLEAN)) @QueryParam("latest") Boolean latest); @GET @Path("/by/{dataType}/{dataSubtype}") @Operation(summary = "Get list of DataFile's", description = "Get list of DataFile's") - public List getDataTypeSubTypeFiles( + List getDataTypeSubTypeFiles( @Parameter(in = ParameterIn.PATH, name = "dataType", description = "Data Type Name", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("dataType") String dataType, @Parameter(in = ParameterIn.PATH, name = "dataSubtype", description = "Data Sub Type Name", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("dataSubtype") String dataSubType, @DefaultValue("false") @Parameter(in = ParameterIn.QUERY, name = "latest", description = "Latest File or All", required = false, schema = @Schema(type = SchemaType.BOOLEAN)) @QueryParam("latest") Boolean latest); @@ -52,7 +52,7 @@ public List getDataTypeSubTypeFiles( @GET @Path("/by/{releaseVersion}/{dataType}/{dataSubtype}") @Operation(summary = "Get list of DataFile's", description = "Get list of DataFile's") - public List getReleaseDataTypeSubTypeFiles( + List getReleaseDataTypeSubTypeFiles( @Parameter(in = ParameterIn.PATH, name = "releaseVersion", description = "Release Version Name", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("releaseVersion") String releaseVersion, @Parameter(in = ParameterIn.PATH, name = "dataType", description = "Data Type Name", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("dataType") String dataType, @Parameter(in = ParameterIn.PATH, name = "dataSubtype", description = "Data Sub Type Name", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("dataSubtype") String dataSubType, diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/ncbi/NCBIRESTInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/ncbi/NCBIRESTInterface.java index 8a3e6fdbe..5a162277e 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/ncbi/NCBIRESTInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/ncbi/NCBIRESTInterface.java @@ -16,5 +16,5 @@ public interface NCBIRESTInterface { @GET @Path("/esummary.fcgi") - public NCBITaxonResponseDTO getTaxonFromNCBI(@QueryParam("db") String db, @QueryParam("retmode") String retmode, @QueryParam("id") String id); + NCBITaxonResponseDTO getTaxonFromNCBI(@QueryParam("db") String db, @QueryParam("retmode") String retmode, @QueryParam("id") String id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/okta/OktaTokenInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/okta/OktaTokenInterface.java index 5d6e6b904..7411a0dc5 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/okta/OktaTokenInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/okta/OktaTokenInterface.java @@ -12,5 +12,5 @@ public interface OktaTokenInterface { @POST @Path("/token") - public OktaToken getClientCredentialsAccessToken(@HeaderParam("Authorization") String authorization, @FormParam("grant_type") String grantType, @FormParam("scope") String scope); + OktaToken getClientCredentialsAccessToken(@HeaderParam("Authorization") String authorization, @FormParam("grant_type") String grantType, @FormParam("scope") String scope); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonInterface.java index 569d0f03d..ef2e61a95 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonInterface.java @@ -25,15 +25,15 @@ public interface PersonInterface { @Path("/") @Operation(hidden = true) @JsonView(View.FieldsOnly.class) - public ObjectResponse create(Person entity); + ObjectResponse create(Person entity); @GET @Path("/") @JsonView(View.PersonSettingView.class) - public Person getLoggedInPerson(); + Person getLoggedInPerson(); @GET @Path("/regenapitoken") - public Person regenApiToken(); + Person regenApiToken(); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonSettingInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonSettingInterface.java index 9dacd6a37..9733e77d6 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonSettingInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/person/PersonSettingInterface.java @@ -28,16 +28,16 @@ public interface PersonSettingInterface { @GET @Path("/{settingsKey}") @JsonView(View.PersonSettingView.class) - public ObjectResponse getUserSetting(@PathParam("settingsKey") String settingsKey); + ObjectResponse getUserSetting(@PathParam("settingsKey") String settingsKey); @PUT @Path("/{settingsKey}") @JsonView(View.PersonSettingView.class) - public ObjectResponse saveUserSetting(@PathParam("settingsKey") String settingsKey, @RequestBody Map settingsMap); + ObjectResponse saveUserSetting(@PathParam("settingsKey") String settingsKey, @RequestBody Map settingsMap); @DELETE @Path("/{settingsKey}") @JsonView(View.PersonSettingView.class) - public ObjectResponse deleteUserSetting(@PathParam("settingsKey") String settingsKey); + ObjectResponse deleteUserSetting(@PathParam("settingsKey") String settingsKey); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java b/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java index d302a01e2..6042e6459 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java @@ -63,7 +63,7 @@ public class JobScheduler { @ConfigProperty(name = "reindex.schedulingEnabled", defaultValue = "false") Boolean reindexSchedulingEnabled; - private ZonedDateTime lastCheck = null; + private ZonedDateTime lastCheck; private Semaphore sem = new Semaphore(1); @PostConstruct @@ -79,13 +79,16 @@ public void init() { if (bf.getBulkloadStatus() == null || bf.getBulkloadStatus().isRunning() || bf.getBulkloadStatus().isStarted() || bf.getLocalFilePath() != null) { if (bf.getLocalFilePath() != null) { File file = new File(bf.getLocalFilePath()); - if (file.exists()) + if (file.exists()) { file.delete(); + } } bf.setLocalFilePath(null); bf.setErrorMessage("Failed due to server start up: Process never finished before the server restarted"); bf.setBulkloadStatus(JobStatus.FAILED); - if(isFirst) slackNotifier.slackalert(bf); // Only notify on the first failed file not all the failed files under a load + if (isFirst) { + slackNotifier.slackalert(bf); // Only notify on the first failed file not all the failed files under a load + } bulkLoadFileDAO.merge(bf); } isFirst = false; @@ -108,26 +111,26 @@ public void init() { @Scheduled(every = "1s") public void scheduleCronGroupJobs() { if (loadSchedulingEnabled) { - if(sem.tryAcquire()) { + if (sem.tryAcquire()) { ZonedDateTime start = ZonedDateTime.now(); - //Log.info("scheduleGroupJobs: Scheduling Enabled: " + loadSchedulingEnabled); + // Log.info("scheduleGroupJobs: Scheduling Enabled: " + loadSchedulingEnabled); SearchResponse groups = groupDAO.findAll(); for (BulkLoadGroup g : groups.getResults()) { if (g.getLoads().size() > 0) { for (BulkLoad b : g.getLoads()) { if (b instanceof BulkScheduledLoad bsl) { if (bsl.getScheduleActive() != null && bsl.getScheduleActive() && bsl.getCronSchedule() != null && !bsl.getBulkloadStatus().isRunning()) { - + CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ); CronParser parser = new CronParser(cronDefinition); try { Cron unixCron = parser.parse(bsl.getCronSchedule()); unixCron.validate(); - + if (lastCheck != null) { ExecutionTime executionTime = ExecutionTime.forCron(unixCron); ZonedDateTime nextExecution = executionTime.nextExecution(lastCheck).get(); - + if (lastCheck.isBefore(nextExecution) && start.isAfter(nextExecution)) { Log.info("Need to run Cron: " + bsl.getName()); bsl.setSchedulingErrorMessage(null); @@ -186,21 +189,28 @@ public void pendingFileJobs(@Observes PendingBulkLoadFileJobEvent event) { @Scheduled(cron = "0 0 0 ? * SAT") public void cleanUpFileExceptions() { SearchResponse groups = groupDAO.findAll(); - + Comparator c = new Comparator() { + @Override public int compare(BulkLoadFile blf1, BulkLoadFile blf2) { - if (blf1.getDateLastLoaded() == null && blf2.getDateLastLoaded() == null) { return 0; } - if (blf1.getDateLastLoaded() == null) { return 1; } - if (blf2.getDateLastLoaded() == null) { return -1; } + if (blf1.getDateLastLoaded() == null && blf2.getDateLastLoaded() == null) { + return 0; + } + if (blf1.getDateLastLoaded() == null) { + return 1; + } + if (blf2.getDateLastLoaded() == null) { + return -1; + } return blf2.getDateLastLoaded().compareTo(blf1.getDateLastLoaded()); } }; - + int historyExceptionsToKeep = 3; - + ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.startProcess("Bulk Load File History Exception Cleanup"); - + for (BulkLoadGroup g : groups.getResults()) { Log.debug("Group Clean Up: " + g.getName()); if (g.getLoads().size() > 0) { @@ -210,8 +220,8 @@ public int compare(BulkLoadFile blf1, BulkLoadFile blf2) { if (b.getLoadFiles().size() > historyExceptionsToKeep) { for (int i = historyExceptionsToKeep; i < b.getLoadFiles().size(); i++) { Log.debug("File Clean Up: " + b.getLoadFiles().get(i).getDateLastLoaded()); - for(BulkLoadFileHistory h: b.getLoadFiles().get(i).getHistory()) { - for(BulkLoadFileException e: h.getExceptions()) { + for (BulkLoadFileHistory h : b.getLoadFiles().get(i).getHistory()) { + for (BulkLoadFileException e : h.getExceptions()) { bulkLoadFileExceptionDAO.remove(e.getId()); ph.progressProcess(); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java index 333fe2975..c5287f92e 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java @@ -22,12 +22,9 @@ @ApplicationScoped public class AgmDiseaseAnnotationExecutor extends LoadFileExecutor { - @Inject - AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; - @Inject - DiseaseAnnotationService diseaseAnnotationService; - @Inject - AGMDiseaseAnnotationService agmDiseaseAnnotationService; + @Inject AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; + @Inject DiseaseAnnotationService diseaseAnnotationService; + @Inject AGMDiseaseAnnotationService agmDiseaseAnnotationService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -36,10 +33,14 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { log.info("Running with dataProvider: " + dataProvider.name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, AGMDiseaseAnnotationDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List annotations = ingestDto.getDiseaseAgmIngestSet(); - if (annotations == null) annotations = new ArrayList<>(); + if (annotations == null) { + annotations = new ArrayList<>(); + } List annotationIdsLoaded = new ArrayList<>(); List annotationIdsBefore = new ArrayList<>(); @@ -47,20 +48,21 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { annotationIdsBefore.addAll(agmDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); annotationIdsBefore.removeIf(Objects::isNull); } - + bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); - + createHistory(history, bulkLoadFile); - + runLoad(agmDiseaseAnnotationService, history, dataProvider, annotations, annotationIdsLoaded); - - if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "AGM disease annotation", bulkLoadFile.getMd5Sum()); + + if (cleanUp) { + runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "AGM disease annotation", bulkLoadFile.getMd5Sum()); + } history.finishLoad(); finalSaveHistory(history); } - } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java index 950d076e9..d209c526d 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java @@ -20,14 +20,11 @@ @ApplicationScoped public class AgmExecutor extends LoadFileExecutor { - @Inject - AffectedGenomicModelDAO affectedGenomicModelDAO; + @Inject AffectedGenomicModelDAO affectedGenomicModelDAO; - @Inject - AffectedGenomicModelService affectedGenomicModelService; - - @Inject - NcbiTaxonTermService ncbiTaxonTermService; + @Inject AffectedGenomicModelService affectedGenomicModelService; + + @Inject NcbiTaxonTermService ncbiTaxonTermService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -35,11 +32,15 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.info("Running with: " + manual.getDataProvider().name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, AffectedGenomicModelDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List agms = ingestDto.getAgmIngestSet(); - if (agms == null) agms = new ArrayList<>(); - + if (agms == null) { + agms = new ArrayList<>(); + } + BackendBulkDataProvider dataProvider = manual.getDataProvider(); List agmIdsLoaded = new ArrayList<>(); @@ -48,21 +49,22 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { agmIdsBefore.addAll(affectedGenomicModelService.getIdsByDataProvider(dataProvider.name())); Log.debug("runLoad: Before: total " + agmIdsBefore.size()); } - + bulkLoadFile.setRecordCount(agms.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); - + BulkLoadFileHistory history = new BulkLoadFileHistory(agms.size()); createHistory(history, bulkLoadFile); - + runLoad(affectedGenomicModelService, history, dataProvider, agms, agmIdsLoaded); - - if(cleanUp) runCleanup(affectedGenomicModelService, history, bulkLoadFile, agmIdsBefore, agmIdsLoaded); - + + if (cleanUp) { + runCleanup(affectedGenomicModelService, history, bulkLoadFile, agmIdsBefore, agmIdsLoaded); + } + history.finishLoad(); finalSaveHistory(history); } - } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java index 4b72c6c8f..6a838ecff 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java @@ -22,12 +22,9 @@ @ApplicationScoped public class AlleleDiseaseAnnotationExecutor extends LoadFileExecutor { - @Inject - AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; - @Inject - AlleleDiseaseAnnotationService alleleDiseaseAnnotationService; - @Inject - DiseaseAnnotationService diseaseAnnotationService; + @Inject AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; + @Inject AlleleDiseaseAnnotationService alleleDiseaseAnnotationService; + @Inject DiseaseAnnotationService diseaseAnnotationService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -36,10 +33,14 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { log.info("Running with dataProvider: " + dataProvider.name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, AlleleDiseaseAnnotationDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List annotations = ingestDto.getDiseaseAlleleIngestSet(); - if (annotations == null) annotations = new ArrayList<>(); + if (annotations == null) { + annotations = new ArrayList<>(); + } List annotationIdsLoaded = new ArrayList<>(); List annotationIdsBefore = new ArrayList<>(); @@ -47,18 +48,20 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { annotationIdsBefore.addAll(alleleDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); annotationIdsBefore.removeIf(Objects::isNull); } - + bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); createHistory(history, bulkLoadFile); runLoad(alleleDiseaseAnnotationService, history, dataProvider, annotations, annotationIdsLoaded); - - if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "allele disease annotation", bulkLoadFile.getMd5Sum()); + + if (cleanUp) { + runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "allele disease annotation", bulkLoadFile.getMd5Sum()); + } history.finishLoad(); - + finalSaveHistory(history); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java index a5c97a0a9..299040b12 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java @@ -19,10 +19,8 @@ @ApplicationScoped public class AlleleExecutor extends LoadFileExecutor { - @Inject - AlleleDAO alleleDAO; - @Inject - AlleleService alleleService; + @Inject AlleleDAO alleleDAO; + @Inject AlleleService alleleService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -30,27 +28,33 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.info("Running with: " + manual.getDataProvider().name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, AlleleDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List alleles = ingestDto.getAlleleIngestSet(); - if (alleles == null) alleles = new ArrayList<>(); - + if (alleles == null) { + alleles = new ArrayList<>(); + } + BackendBulkDataProvider dataProvider = manual.getDataProvider(); - + List alleleIdsLoaded = new ArrayList<>(); List alleleIdsBefore = new ArrayList<>(); if (cleanUp) { alleleIdsBefore.addAll(alleleService.getIdsByDataProvider(dataProvider.name())); Log.debug("runLoad: Before: total " + alleleIdsBefore.size()); } - + bulkLoadFile.setRecordCount(alleles.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); - + BulkLoadFileHistory history = new BulkLoadFileHistory(alleles.size()); createHistory(history, bulkLoadFile); runLoad(alleleService, history, dataProvider, alleles, alleleIdsLoaded); - if(cleanUp) runCleanup(alleleService, history, bulkLoadFile, alleleIdsBefore, alleleIdsLoaded); + if (cleanUp) { + runCleanup(alleleService, history, bulkLoadFile, alleleIdsBefore, alleleIdsLoaded); + } history.finishLoad(); finalSaveHistory(history); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java index e04e2c627..6f354b5d2 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java @@ -28,7 +28,7 @@ @JBossLog @ApplicationScoped public class BulkLoadJobExecutor { - + @Inject BulkLoadFileDAO bulkLoadFileDAO; @Inject AlleleDiseaseAnnotationExecutor alleleDiseaseAnnotationExecutor; diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java index ef8b17b48..c60ea8105 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java @@ -24,14 +24,11 @@ @ApplicationScoped public class ConstructExecutor extends LoadFileExecutor { - @Inject - ConstructDAO constructDAO; + @Inject ConstructDAO constructDAO; - @Inject - ConstructService constructService; - - @Inject - NcbiTaxonTermService ncbiTaxonTermService; + @Inject ConstructService constructService; + + @Inject NcbiTaxonTermService ncbiTaxonTermService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -39,32 +36,38 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.info("Running with: " + manual.getDataProvider().name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, ConstructDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List constructs = ingestDto.getConstructIngestSet(); - if (constructs == null) constructs = new ArrayList<>(); - + if (constructs == null) { + constructs = new ArrayList<>(); + } + BackendBulkDataProvider dataProvider = manual.getDataProvider(); - + List constructIdsLoaded = new ArrayList<>(); List constructIdsBefore = new ArrayList<>(); if (cleanUp) { constructIdsBefore.addAll(constructService.getConstructIdsByDataProvider(dataProvider)); Log.debug("runLoad: Before: total " + constructIdsBefore.size()); } - + bulkLoadFile.setRecordCount(constructs.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); - + BulkLoadFileHistory history = new BulkLoadFileHistory(constructs.size()); createHistory(history, bulkLoadFile); - + runLoad(constructService, history, dataProvider, constructs, constructIdsLoaded); - - if(cleanUp) runCleanup(constructService, history, dataProvider.name(), constructIdsBefore, constructIdsLoaded, bulkLoadFile.getMd5Sum()); - + + if (cleanUp) { + runCleanup(constructService, history, dataProvider.name(), constructIdsBefore, constructIdsLoaded, bulkLoadFile.getMd5Sum()); + } + history.finishLoad(); - + finalSaveHistory(history); } @@ -78,8 +81,8 @@ private void runCleanup(ConstructService service, BulkLoadFileHistory history, S List idsToRemove = ListUtils.subtract(constructIdsBefore, distinctAfter); Log.debug("runLoad: Remove: " + dataProviderName + " " + idsToRemove.size()); - history.setTotalDeleteRecords((long)idsToRemove.size()); - + history.setTotalDeleteRecords((long) idsToRemove.size()); + ProcessDisplayHelper ph = new ProcessDisplayHelper(1000); ph.startProcess("Deletion/deprecation of constructs linked to unloaded " + dataProviderName, idsToRemove.size()); for (Long id : idsToRemove) { diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java index f4104f8cb..28f08255d 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java @@ -22,12 +22,9 @@ @ApplicationScoped public class GeneDiseaseAnnotationExecutor extends LoadFileExecutor { - @Inject - GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; - @Inject - GeneDiseaseAnnotationService geneDiseaseAnnotationService; - @Inject - DiseaseAnnotationService diseaseAnnotationService; + @Inject GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; + @Inject GeneDiseaseAnnotationService geneDiseaseAnnotationService; + @Inject DiseaseAnnotationService diseaseAnnotationService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -36,10 +33,14 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { log.info("Running with dataProvider: " + dataProvider.name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, GeneDiseaseAnnotationDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List annotations = ingestDto.getDiseaseGeneIngestSet(); - if (annotations == null) annotations = new ArrayList<>(); + if (annotations == null) { + annotations = new ArrayList<>(); + } List annotationIdsLoaded = new ArrayList<>(); List annotationIdsBefore = new ArrayList<>(); @@ -47,16 +48,18 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { annotationIdsBefore.addAll(geneDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); annotationIdsBefore.removeIf(Objects::isNull); } - - bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); + + bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); - + BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); createHistory(history, bulkLoadFile); - + runLoad(geneDiseaseAnnotationService, history, dataProvider, annotations, annotationIdsLoaded); - - if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "gene disease annotation", bulkLoadFile.getMd5Sum()); + + if (cleanUp) { + runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "gene disease annotation", bulkLoadFile.getMd5Sum()); + } history.finishLoad(); finalSaveHistory(history); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java index 7f85c74c1..b5c9339db 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java @@ -21,14 +21,11 @@ @ApplicationScoped public class GeneExecutor extends LoadFileExecutor { - @Inject - GeneDAO geneDAO; + @Inject GeneDAO geneDAO; - @Inject - GeneService geneService; + @Inject GeneService geneService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -37,10 +34,14 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { log.info("Running with dataProvider : " + dataProvider.name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, GeneDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List genes = ingestDto.getGeneIngestSet(); - if (genes == null) genes = new ArrayList<>(); + if (genes == null) { + genes = new ArrayList<>(); + } List geneIdsLoaded = new ArrayList<>(); List geneIdsBefore = new ArrayList<>(); @@ -48,18 +49,20 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { geneIdsBefore.addAll(geneService.getIdsByDataProvider(dataProvider)); log.debug("runLoad: Before: total " + geneIdsBefore.size()); } - + bulkLoadFile.setRecordCount(genes.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(genes.size()); - + runLoad(geneService, history, dataProvider, genes, geneIdsLoaded); - if(cleanUp) runCleanup(geneService, history, bulkLoadFile, geneIdsBefore, geneIdsLoaded); - + if (cleanUp) { + runCleanup(geneService, history, bulkLoadFile, geneIdsBefore, geneIdsLoaded); + } + history.finishLoad(); - + finalSaveHistory(history); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java index 5daffeb84..9ae74fa71 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java @@ -43,7 +43,9 @@ public void execLoad(BulkLoadFile bulkLoadFile) { boolean success = runLoad(geneGeneticInteractionService, history, null, interactionData, interactionIdsLoaded); - if(success) runCleanup(geneInteractionService, history, interactionIdsBefore, interactionIdsLoaded, bulkLoadFile.getMd5Sum()); + if (success) { + runCleanup(geneInteractionService, history, interactionIdsBefore, interactionIdsLoaded, bulkLoadFile.getMd5Sum()); + } history.finishLoad(); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java index 5e978338d..48b0d61c6 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java @@ -24,31 +24,28 @@ @ApplicationScoped public class GeneMolecularInteractionExecutor extends LoadFileExecutor { - @Inject - GeneMolecularInteractionDAO geneMolecularInteractionDAO; - @Inject - GeneMolecularInteractionService geneMolecularInteractionService; - @Inject - GeneInteractionService geneInteractionService; - + @Inject GeneMolecularInteractionDAO geneMolecularInteractionDAO; + @Inject GeneMolecularInteractionService geneMolecularInteractionService; + @Inject GeneInteractionService geneInteractionService; + public void execLoad(BulkLoadFile bulkLoadFile) { try { - + CsvSchema psiMiTabSchema = CsvSchemaBuilder.psiMiTabSchema(); CsvMapper csvMapper = new CsvMapper(); - MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS) - .readerFor(PsiMiTabDTO.class).with(psiMiTabSchema) - .readValues(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath()))); + MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(PsiMiTabDTO.class).with(psiMiTabSchema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath()))); List interactionData = it.readAll(); - + BulkLoadFileHistory history = new BulkLoadFileHistory(interactionData.size()); createHistory(history, bulkLoadFile); List interactionIdsLoaded = new ArrayList<>(); List interactionIdsBefore = geneMolecularInteractionDAO.findAllIds().getResults(); - + boolean success = runLoad(geneMolecularInteractionService, history, null, interactionData, interactionIdsLoaded); - - if(success) runCleanup(geneInteractionService, history, interactionIdsBefore, interactionIdsLoaded, bulkLoadFile.getMd5Sum()); + + if (success) { + runCleanup(geneInteractionService, history, interactionIdsBefore, interactionIdsLoaded, bulkLoadFile.getMd5Sum()); + } history.finishLoad(); finalSaveHistory(history); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java index 740a49acf..c335da66d 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java @@ -45,39 +45,32 @@ public class LoadFileExecutor { - @Inject - protected ObjectMapper mapper; - @Inject - protected LoadProcessDisplayService loadProcessDisplayService; - @Inject - protected BulkLoadFileDAO bulkLoadFileDAO; - @Inject - BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; - @Inject - BulkLoadFileExceptionDAO bulkLoadFileExceptionDAO; - @Inject - APIVersionInfoService apiVersionInfoService; - @Inject - SlackNotifier slackNotifier; + @Inject protected ObjectMapper mapper; + @Inject protected LoadProcessDisplayService loadProcessDisplayService; + @Inject protected BulkLoadFileDAO bulkLoadFileDAO; + @Inject BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; + @Inject BulkLoadFileExceptionDAO bulkLoadFileExceptionDAO; + @Inject APIVersionInfoService apiVersionInfoService; + @Inject SlackNotifier slackNotifier; protected void createHistory(BulkLoadFileHistory history, BulkLoadFile bulkLoadFile) { - if(bulkLoadFile != null) { + if (bulkLoadFile != null) { history.setBulkLoadFile(bulkLoadFile); } bulkLoadFileHistoryDAO.persist(history); - if(bulkLoadFile != null) { + if (bulkLoadFile != null) { bulkLoadFile.getHistory().add(history); bulkLoadFileDAO.merge(bulkLoadFile); } } - + protected void updateHistory(BulkLoadFileHistory history) { bulkLoadFileHistoryDAO.merge(history); } - + protected void finalSaveHistory(BulkLoadFileHistory history) { bulkLoadFileHistoryDAO.merge(history); - for (BulkLoadFileException e: history.getExceptions()) { + for (BulkLoadFileException e : history.getExceptions()) { bulkLoadFileExceptionDAO.merge(e); } } @@ -90,13 +83,15 @@ protected void addException(BulkLoadFileHistory history, ObjectUpdateExceptionDa } protected String getVersionNumber(String versionString) { - if (StringUtils.isBlank(versionString)) + if (StringUtils.isBlank(versionString)) { return null; - if (versionString.startsWith("v")) + } + if (versionString.startsWith("v")) { return versionString.substring(1); + } return versionString; } - + private List getVersionParts(String version) { List stringParts = new ArrayList(Arrays.asList(version.split("\\."))); List intParts = new ArrayList(); @@ -108,12 +103,13 @@ private List getVersionParts(String version) { return null; } } - - while (intParts.size() < 3) { intParts.add(0); } - + + while (intParts.size() < 3) { + intParts.add(0); + } + return intParts; } - protected boolean checkSchemaVersion(BulkLoadFile bulkLoadFile, Class dtoClass) { if (bulkLoadFile.getLinkMLSchemaVersion() == null) { @@ -132,15 +128,18 @@ protected boolean checkSchemaVersion(BulkLoadFile bulkLoadFile, Class dtoClas } return true; } - + protected IngestDTO readIngestFile(BulkLoadFile bulkLoadFile, Class dtoClass) { try { IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) + if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) { bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, dtoClass)) return null; + } + + if (!checkSchemaVersion(bulkLoadFile, dtoClass)) { + return null; + } return ingestDto; } catch (Exception e) { @@ -149,59 +148,72 @@ protected IngestDTO readIngestFile(BulkLoadFile bulkLoadFile, Class dtoClass) } return null; } - + protected boolean validSchemaVersion(String submittedSchemaVersion, Class dtoClass) { - + List versionRange = apiVersionInfoService.getVersionRange(dtoClass.getAnnotation(AGRCurationSchemaVersion.class)); List minVersionParts = getVersionParts(versionRange.get(0)); List maxVersionParts = getVersionParts(versionRange.get(1)); List fileVersionParts = getVersionParts(submittedSchemaVersion); - - if (minVersionParts == null || maxVersionParts == null || fileVersionParts == null) + + if (minVersionParts == null || maxVersionParts == null || fileVersionParts == null) { return false; - + } + // check not lower than min version - if (fileVersionParts.get(0) < minVersionParts.get(0)) return false; + if (fileVersionParts.get(0) < minVersionParts.get(0)) { + return false; + } if (fileVersionParts.get(0).equals(minVersionParts.get(0))) { - if (fileVersionParts.get(1) < minVersionParts.get(1)) return false; + if (fileVersionParts.get(1) < minVersionParts.get(1)) { + return false; + } if (fileVersionParts.get(1).equals(minVersionParts.get(1))) { - if (fileVersionParts.get(2) < minVersionParts.get(2)) return false; + if (fileVersionParts.get(2) < minVersionParts.get(2)) { + return false; + } } } // check not higher than max version - if (fileVersionParts.get(0) > maxVersionParts.get(0)) return false; + if (fileVersionParts.get(0) > maxVersionParts.get(0)) { + return false; + } if (fileVersionParts.get(0).equals(maxVersionParts.get(0))) { - if (fileVersionParts.get(1) > maxVersionParts.get(1)) return false; + if (fileVersionParts.get(1) > maxVersionParts.get(1)) { + return false; + } if (fileVersionParts.get(1).equals(maxVersionParts.get(1))) { - if (fileVersionParts.get(2) > maxVersionParts.get(2)) return false; + if (fileVersionParts.get(2) > maxVersionParts.get(2)) { + return false; + } } } - + return true; } - - + public APIResponse runLoadApi(BaseUpsertServiceInterface service, String dataProviderName, List objectList) { List idsLoaded = new ArrayList<>(); BulkLoadFileHistory history = new BulkLoadFileHistory(objectList.size()); BackendBulkDataProvider dataProvider = null; - if(dataProviderName != null) { + if (dataProviderName != null) { dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); } runLoad(service, history, dataProvider, objectList, idsLoaded); history.finishLoad(); return new LoadHistoryResponce(history); } - + protected boolean runLoad(BaseUpsertServiceInterface service, BulkLoadFileHistory history, BackendBulkDataProvider dataProvider, List objectList, List idsAdded) { ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); String loadMessage = objectList.get(0).getClass().getSimpleName() + " update"; - if (dataProvider != null) + if (dataProvider != null) { loadMessage = loadMessage + " for " + dataProvider.name(); + } ph.startProcess(loadMessage, objectList.size()); - - for(T dtoObject: objectList) { + + for (T dtoObject : objectList) { try { E dbObject = service.upsert(dtoObject, dataProvider); history.incrementCompleted(); @@ -209,15 +221,15 @@ protected boolean runLoad(BaseUpser idsAdded.add(dbObject.getId()); } } catch (ObjectUpdateException e) { - //e.printStackTrace(); + // e.printStackTrace(); history.incrementFailed(); addException(history, e.getData()); } catch (Exception e) { - //e.printStackTrace(); + // e.printStackTrace(); history.incrementFailed(); addException(history, new ObjectUpdateExceptionData(dtoObject, e.getMessage(), e.getStackTrace())); } - if(history.getErrorRate() > 0.25) { + if (history.getErrorRate() > 0.25) { Log.error("Failure Rate > 25% aborting load"); finalSaveHistory(history); return false; @@ -239,8 +251,8 @@ protected boolean runLoad(BaseUpser List idsToRemove = ListUtils.subtract(annotationIdsBefore, distinctAfter); Log.debug("runLoad: Remove: " + dataProviderName + " " + idsToRemove.size()); - history.setTotalDeleteRecords((long)idsToRemove.size()); - + history.setTotalDeleteRecords((long) idsToRemove.size()); + ProcessDisplayHelper ph = new ProcessDisplayHelper(10000); ph.startProcess("Deletion/deprecation of annotations linked to unloaded " + dataProviderName, idsToRemove.size()); for (Long id : idsToRemove) { @@ -257,7 +269,7 @@ protected boolean runLoad(BaseUpser } ph.finishProcess(); } - + protected > void runCleanup(S service, BulkLoadFileHistory history, BulkLoadFile bulkLoadFile, List idsBefore, List idsAfter) { BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); String dataProviderName = manual.getDataProvider().name(); @@ -269,8 +281,8 @@ protected boolean runLoad(BaseUpser List idsToRemove = ListUtils.subtract(idsBefore, distinctAfter); Log.debug("runLoad: Remove: " + dataProviderName + " " + idsToRemove.size()); - history.setTotalDeleteRecords((long)idsToRemove.size()); - + history.setTotalDeleteRecords((long) idsToRemove.size()); + ProcessDisplayHelper ph = new ProcessDisplayHelper(10000); ph.startProcess("Deletion/deprecation of primary objects " + dataProviderName, idsToRemove.size()); for (Long id : idsToRemove) { @@ -286,9 +298,9 @@ protected boolean runLoad(BaseUpser ph.progressProcess(); } ph.finishProcess(); - + } - + protected > void runCleanup(S service, BulkLoadFileHistory history, String dataProviderName, List idsBefore, List idsAfter, String md5sum) { Log.debug("runLoad: After: " + dataProviderName + " " + idsAfter.size()); @@ -298,8 +310,8 @@ protected boolean runLoad(BaseUpser List idsToRemove = ListUtils.subtract(idsBefore, distinctAfter); Log.debug("runLoad: Remove: " + dataProviderName + " " + idsToRemove.size()); - history.setTotalDeleteRecords((long)idsToRemove.size()); - + history.setTotalDeleteRecords((long) idsToRemove.size()); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.startProcess("Deletion/deprecation of associations " + dataProviderName, idsToRemove.size()); for (Long id : idsToRemove) { @@ -315,9 +327,9 @@ protected boolean runLoad(BaseUpser ph.progressProcess(); } ph.finishProcess(); - + } - + protected void runCleanup(GeneInteractionService service, BulkLoadFileHistory history, List idsBefore, List idsAfter, String md5sum) { Log.debug("runLoad: After: " + idsAfter.size()); @@ -327,8 +339,8 @@ protected void runCleanup(GeneInteractionService service, BulkLoadFileHistory hi List idsToRemove = ListUtils.subtract(idsBefore, distinctAfter); Log.debug("runLoad: Remove: " + idsToRemove.size()); - history.setTotalDeleteRecords((long)idsToRemove.size()); - + history.setTotalDeleteRecords((long) idsToRemove.size()); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.startProcess("Deletion/deprecation of interactions", idsToRemove.size()); for (Long id : idsToRemove) { @@ -345,7 +357,7 @@ protected void runCleanup(GeneInteractionService service, BulkLoadFileHistory hi } ph.finishProcess(); } - + protected void failLoad(BulkLoadFile bulkLoadFile, Exception e) { Set errorMessages = new LinkedHashSet(); errorMessages.add(e.getMessage()); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java index 05f447f1f..be0e58972 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java @@ -17,8 +17,7 @@ @ApplicationScoped public class MoleculeExecutor extends LoadFileExecutor { - @Inject - MoleculeService moleculeService; + @Inject MoleculeService moleculeService; public void execLoad(BulkLoadFile bulkLoadFile) { try { @@ -28,8 +27,9 @@ public void execLoad(BulkLoadFile bulkLoadFile) { AGRCurationSchemaVersion version = Molecule.class.getAnnotation(AGRCurationSchemaVersion.class); bulkLoadFile.setLinkMLSchemaVersion(version.max()); } - if (moleculeData.getMetaData() != null && StringUtils.isNotBlank(moleculeData.getMetaData().getRelease())) + if (moleculeData.getMetaData() != null && StringUtils.isNotBlank(moleculeData.getMetaData().getRelease())) { bulkLoadFile.setAllianceMemberReleaseVersion(moleculeData.getMetaData().getRelease()); + } bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(moleculeData.getData().size()); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java index ec19184df..f6cc9d2b3 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java @@ -128,7 +128,8 @@ public void execLoad(BulkLoadFile bulkLoadFile) throws Exception { processTerms(bulkLoadFile, emapaTermService, config); } case GO -> { - config.setLoadOnlyIRIPrefix("GO"); // GO has to have both prefix and namespaces as obsolete terms do not show up in the namespace's + config.setLoadOnlyIRIPrefix("GO"); // GO has to have both prefix and namespaces as obsolete terms do not show up in + // the namespace's config.getAltNameSpaces().add("biological_process"); config.getAltNameSpaces().add("molecular_function"); config.getAltNameSpaces().add("cellular_component"); @@ -274,17 +275,17 @@ private void processTerms(BulkLoadFile bulkLoadFile, OntologyBulkLoadType ontolo ph1.startProcess(bulkLoadFile.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Closure", termMap.size()); for (Entry entry : termMap.entrySet()) { service.processUpdateRelationships(entry.getValue()); - //Thread.sleep(5000); + // Thread.sleep(5000); ph1.progressProcess(); } ph1.finishProcess(); - + ProcessDisplayHelper ph2 = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); ph2.startProcess(bulkLoadFile.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Counts", termMap.size()); for (Entry entry : termMap.entrySet()) { service.processCounts(entry.getValue()); - //Thread.sleep(5000); + // Thread.sleep(5000); ph2.progressProcess(); } ph2.finishProcess(); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java index 6c23a5ee3..36f52a22e 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java @@ -32,38 +32,38 @@ @ApplicationScoped public class OrthologyExecutor extends LoadFileExecutor { - @Inject - GeneToGeneOrthologyGeneratedService generatedOrthologyService; + @Inject GeneToGeneOrthologyGeneratedService generatedOrthologyService; public void execLoad(BulkLoadFile bulkLoadFile) { try { BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); - + OrthologyIngestFmsDTO orthologyData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), OrthologyIngestFmsDTO.class); bulkLoadFile.setRecordCount(orthologyData.getData().size()); - + AGRCurationSchemaVersion version = GeneToGeneOrthologyGenerated.class.getAnnotation(AGRCurationSchemaVersion.class); bulkLoadFile.setLinkMLSchemaVersion(version.max()); - if (orthologyData.getMetaData() != null && StringUtils.isNotBlank(orthologyData.getMetaData().getRelease())) + if (orthologyData.getMetaData() != null && StringUtils.isNotBlank(orthologyData.getMetaData().getRelease())) { bulkLoadFile.setAllianceMemberReleaseVersion(orthologyData.getMetaData().getRelease()); - + } + List> orthoPairsLoaded = new ArrayList<>(); String dataProviderAbbreviation = fms.getFmsDataSubType(); List orthoPairsBefore = generatedOrthologyService.getAllOrthologyPairsBySubjectGeneDataProvider(dataProviderAbbreviation); log.debug("runLoad: Before: total " + orthoPairsBefore.size()); - + bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(orthologyData.getData().size()); - + createHistory(history, bulkLoadFile); - + runLoad(history, fms.getFmsDataSubType(), orthologyData, orthoPairsLoaded); - + runCleanup(history, fms.getFmsDataSubType(), orthoPairsBefore, orthoPairsLoaded); history.finishLoad(); - + finalSaveHistory(history); } catch (Exception e) { @@ -72,25 +72,24 @@ public void execLoad(BulkLoadFile bulkLoadFile) { } } - private void runCleanup(BulkLoadFileHistory history, String dataProvider, List orthoPairsBefore, List> orthoPairsAfter) { Log.debug("runLoad: After: " + dataProvider + " " + orthoPairsAfter.size()); - + List> transformedPairsBefore = new ArrayList<>(); for (Object[] pair : orthoPairsBefore) { transformedPairsBefore.add(Pair.of((String) pair[0], (String) pair[1])); } List> distinctAfter = orthoPairsAfter.stream().distinct().collect(Collectors.toList()); Log.debug("runLoad: Distinct: " + dataProvider + " " + distinctAfter.size()); - + List> pairsToRemove = ListUtils.subtract(transformedPairsBefore, distinctAfter); Log.debug("runLoad: Remove: " + dataProvider + " " + pairsToRemove.size()); - history.setTotalDeleteRecords((long)pairsToRemove.size()); - + history.setTotalDeleteRecords((long) pairsToRemove.size()); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.startProcess("Deletion/deprecation of orthology pairs " + dataProvider, pairsToRemove.size()); - for (Pair pairToRemove : pairsToRemove) { + for (Pair pairToRemove : pairsToRemove) { try { generatedOrthologyService.removeNonUpdated(pairToRemove); history.incrementDeleted(); @@ -103,7 +102,6 @@ private void runCleanup(BulkLoadFileHistory history, String dataProvider, List> orthoPairsAdded) { ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); @@ -113,8 +111,9 @@ private void runLoad(BulkLoadFileHistory history, String dataProvider, Orthology try { GeneToGeneOrthologyGenerated orthoPair = generatedOrthologyService.upsert(orthoPairDTO); history.incrementCompleted(); - if (orthoPairsAdded != null) + if (orthoPairsAdded != null) { orthoPairsAdded.add(Pair.of(orthoPair.getSubjectGene().getCurie(), orthoPair.getObjectGene().getCurie())); + } } catch (ObjectUpdateException e) { history.incrementFailed(); addException(history, e.getData()); @@ -128,15 +127,15 @@ private void runLoad(BulkLoadFileHistory history, String dataProvider, Orthology ph.finishProcess(); } - + // Gets called from the API directly public APIResponse runLoad(String dataProvider, OrthologyIngestFmsDTO dto) { List> orthoPairsAdded = new ArrayList<>(); - + BulkLoadFileHistory history = new BulkLoadFileHistory(dto.getData().size()); runLoad(history, dataProvider, dto, orthoPairsAdded); history.finishLoad(); - + return new LoadHistoryResponce(history); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java index ddb955d5d..51eb8c6f8 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java @@ -1,8 +1,5 @@ package org.alliancegenome.curation_api.jobs.executors; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; - import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; @@ -17,18 +14,20 @@ import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.ParalogyFmsDTO; import org.alliancegenome.curation_api.model.ingest.dto.fms.ParalogyIngestFmsDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; import org.alliancegenome.curation_api.services.GeneToGeneParalogyService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import org.alliancegenome.curation_api.response.APIResponse; -import org.alliancegenome.curation_api.response.LoadHistoryResponce; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; @ApplicationScoped public class ParalogyExecutor extends LoadFileExecutor { - @Inject - GeneToGeneParalogyService geneToGeneParalogyService; + @Inject GeneToGeneParalogyService geneToGeneParalogyService; public void execLoad(BulkLoadFile bulkLoadFile) { try { @@ -39,8 +38,9 @@ public void execLoad(BulkLoadFile bulkLoadFile) { AGRCurationSchemaVersion version = GeneToGeneParalogy.class.getAnnotation(AGRCurationSchemaVersion.class); bulkLoadFile.setLinkMLSchemaVersion(version.max()); - if (paralogyData.getMetaData() != null && StringUtils.isNotBlank(paralogyData.getMetaData().getRelease())) + if (paralogyData.getMetaData() != null && StringUtils.isNotBlank(paralogyData.getMetaData().getRelease())) { bulkLoadFile.setAllianceMemberReleaseVersion(paralogyData.getMetaData().getRelease()); + } List> paralogyPairsLoaded = new ArrayList<>(); // String dataProviderAbbreviation = fms.getFmsDataSubType(); @@ -84,8 +84,7 @@ private void runLoad(BulkLoadFileHistory history, String dataProvider, ParalogyI addException(history, e.getData()); } catch (Exception e) { history.incrementFailed(); - addException(history, - new ObjectUpdateExceptionData(paralogyPairDTO, e.getMessage(), e.getStackTrace())); + addException(history, new ObjectUpdateExceptionData(paralogyPairDTO, e.getMessage(), e.getStackTrace())); } updateHistory(history); ph.progressProcess(); @@ -93,7 +92,7 @@ private void runLoad(BulkLoadFileHistory history, String dataProvider, ParalogyI ph.finishProcess(); } - + public APIResponse runLoad(String dataProvider, ParalogyIngestFmsDTO paralogyData) { List> paralogyPairsAdded = new ArrayList<>(); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java index 897e4397f..c85a13dba 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java @@ -28,56 +28,55 @@ @ApplicationScoped public class PhenotypeAnnotationExecutor extends LoadFileExecutor { - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; public void execLoad(BulkLoadFile bulkLoadFile) { try { - + BulkFMSLoad fmsLoad = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fmsLoad.getFmsDataSubType()); - + PhenotypeIngestFmsDTO phenotypeData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), PhenotypeIngestFmsDTO.class); bulkLoadFile.setRecordCount(phenotypeData.getData().size()); if (bulkLoadFile.getLinkMLSchemaVersion() == null) { AGRCurationSchemaVersion version = Molecule.class.getAnnotation(AGRCurationSchemaVersion.class); bulkLoadFile.setLinkMLSchemaVersion(version.max()); } - if (phenotypeData.getMetaData() != null && StringUtils.isNotBlank(phenotypeData.getMetaData().getRelease())) + if (phenotypeData.getMetaData() != null && StringUtils.isNotBlank(phenotypeData.getMetaData().getRelease())) { bulkLoadFile.setAllianceMemberReleaseVersion(phenotypeData.getMetaData().getRelease()); + } bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(phenotypeData.getData().size()); createHistory(history, bulkLoadFile); List annotationIdsLoaded = new ArrayList<>(); List annotationIdsBefore = phenotypeAnnotationService.getAnnotationIdsByDataProvider(dataProvider); - + runLoad(history, phenotypeData.getData(), annotationIdsLoaded, dataProvider); - + runCleanup(phenotypeAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "phenotype annotation", bulkLoadFile.getMd5Sum()); history.finishLoad(); - + finalSaveHistory(history); } catch (Exception e) { e.printStackTrace(); } } - + // Gets called from the API directly public APIResponse runLoad(String dataProviderName, List annotations) { List annotationIdsLoaded = new ArrayList<>(); - + BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); runLoad(history, annotations, annotationIdsLoaded, dataProvider); history.finishLoad(); - + return new LoadHistoryResponce(history); } - private void runLoad(BulkLoadFileHistory history, List annotations, List idsAdded, BackendBulkDataProvider dataProvider) { ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); @@ -85,15 +84,16 @@ private void runLoad(BulkLoadFileHistory history, List annotati loadPrimaryAnnotations(history, annotations, idsAdded, dataProvider, ph); loadSecondaryAnnotations(history, annotations, idsAdded, dataProvider, ph); - + ph.finishProcess(); } - + private void loadSecondaryAnnotations(BulkLoadFileHistory history, List annotations, List idsAdded, BackendBulkDataProvider dataProvider, ProcessDisplayHelper ph) { for (PhenotypeFmsDTO dto : annotations) { - if (CollectionUtils.isEmpty(dto.getPrimaryGeneticEntityIds())) + if (CollectionUtils.isEmpty(dto.getPrimaryGeneticEntityIds())) { continue; + } try { phenotypeAnnotationService.addInferredOrAssertedEntities(dto, idsAdded, dataProvider); @@ -109,22 +109,23 @@ private void loadSecondaryAnnotations(BulkLoadFileHistory history, List annotations, List idsAdded, BackendBulkDataProvider dataProvider, ProcessDisplayHelper ph) { for (PhenotypeFmsDTO dto : annotations) { - if (CollectionUtils.isNotEmpty(dto.getPrimaryGeneticEntityIds())) + if (CollectionUtils.isNotEmpty(dto.getPrimaryGeneticEntityIds())) { continue; + } try { Long primaryAnnotationId = phenotypeAnnotationService.upsertPrimaryAnnotation(dto, dataProvider); if (primaryAnnotationId != null) { history.incrementCompleted(); - if (idsAdded != null) + if (idsAdded != null) { idsAdded.add(primaryAnnotationId); - } + } + } } catch (ObjectUpdateException e) { history.incrementFailed(); addException(history, e.getData()); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ResourceDescriptorExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ResourceDescriptorExecutor.java index 61b5e826f..d1d9647ee 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ResourceDescriptorExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ResourceDescriptorExecutor.java @@ -25,19 +25,18 @@ @JBossLog @ApplicationScoped public class ResourceDescriptorExecutor extends LoadFileExecutor { - - @Inject - ResourceDescriptorService resourceDescriptorService; + + @Inject ResourceDescriptorService resourceDescriptorService; public void execLoad(BulkLoadFile bulkLoadFile) throws Exception { log.info("Loading ResourceDescriptor File"); - + File rdFile = new File(bulkLoadFile.getLocalFilePath()); ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); CollectionType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, ResourceDescriptorDTO.class); List dtos = mapper.readValue(new GZIPInputStream(new FileInputStream(rdFile)), listType); - + List rdNamesBefore = resourceDescriptorService.getAllNames(); List rdNamesAfter = new ArrayList<>(); BulkLoadFileHistory history = new BulkLoadFileHistory(dtos.size()); @@ -54,11 +53,11 @@ public void execLoad(BulkLoadFile bulkLoadFile) throws Exception { addException(history, new ObjectUpdateExceptionData(dto, e.getMessage(), e.getStackTrace())); } }); - + history.finishLoad(); finalSaveHistory(history); resourceDescriptorService.removeNonUpdatedResourceDescriptors(rdNamesBefore, rdNamesAfter); - + log.info("Loading ResourceDescriptorFileFinished"); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java index df38ffa7a..224e737c2 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java @@ -19,10 +19,8 @@ @ApplicationScoped public class VariantExecutor extends LoadFileExecutor { - @Inject - VariantDAO variantDAO; - @Inject - VariantService variantService; + @Inject VariantDAO variantDAO; + @Inject VariantService variantService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -30,35 +28,40 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.info("Running with: " + manual.getDataProvider().name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, VariantDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List variants = ingestDto.getVariantIngestSet(); - if (variants == null) variants = new ArrayList<>(); - + if (variants == null) { + variants = new ArrayList<>(); + } + BackendBulkDataProvider dataProvider = manual.getDataProvider(); - + List variantIdsLoaded = new ArrayList<>(); List variantIdsBefore = new ArrayList<>(); if (cleanUp) { variantIdsBefore.addAll(variantService.getIdsByDataProvider(dataProvider.name())); Log.debug("runLoad: Before: total " + variantIdsBefore.size()); } - + bulkLoadFile.setRecordCount(variants.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); - + BulkLoadFileHistory history = new BulkLoadFileHistory(variants.size()); createHistory(history, bulkLoadFile); - + runLoad(variantService, history, dataProvider, variants, variantIdsLoaded); - - if(cleanUp) runCleanup(variantService, history, bulkLoadFile, variantIdsBefore, variantIdsLoaded); - + + if (cleanUp) { + runCleanup(variantService, history, bulkLoadFile, variantIdsBefore, variantIdsLoaded); + } + history.finishLoad(); - + finalSaveHistory(history); } - } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java index 88d310650..b3813cb7a 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java @@ -21,9 +21,8 @@ @ApplicationScoped public class AlleleGeneAssociationExecutor extends LoadFileExecutor { - @Inject - AlleleGeneAssociationService alleleGeneAssociationService; - + @Inject AlleleGeneAssociationService alleleGeneAssociationService; + public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); @@ -31,31 +30,36 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { log.info("Running with dataProvider: " + dataProvider.name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, AlleleGeneAssociationDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List associations = ingestDto.getAlleleGeneAssociationIngestSet(); - if (associations == null) associations = new ArrayList<>(); + if (associations == null) { + associations = new ArrayList<>(); + } - List associationIdsLoaded = new ArrayList<>(); List associationIdsBefore = new ArrayList<>(); if (cleanUp) { associationIdsBefore.addAll(alleleGeneAssociationService.getAssociationsByDataProvider(dataProvider)); associationIdsBefore.removeIf(Objects::isNull); } - + bulkLoadFile.setRecordCount(associations.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); createHistory(history, bulkLoadFile); - + runLoad(alleleGeneAssociationService, history, dataProvider, associations, associationIdsLoaded); - - if(cleanUp) runCleanup(alleleGeneAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, bulkLoadFile.getMd5Sum()); + + if (cleanUp) { + runCleanup(alleleGeneAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, bulkLoadFile.getMd5Sum()); + } history.finishLoad(); - + finalSaveHistory(history); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java index f9587fbf3..c4065f86c 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java @@ -22,10 +22,8 @@ @ApplicationScoped public class ConstructGenomicEntityAssociationExecutor extends LoadFileExecutor { - @Inject - ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; - @Inject - ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; + @Inject ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; + @Inject ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { @@ -34,30 +32,35 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { log.info("Running with dataProvider: " + dataProvider.name()); IngestDTO ingestDto = readIngestFile(bulkLoadFile, ConstructGenomicEntityAssociationDTO.class); - if (ingestDto == null) return; - + if (ingestDto == null) { + return; + } + List associations = ingestDto.getConstructGenomicEntityAssociationIngestSet(); - if (associations == null) associations = new ArrayList<>(); + if (associations == null) { + associations = new ArrayList<>(); + } - List associationIdsLoaded = new ArrayList<>(); List associationIdsBefore = new ArrayList<>(); if (cleanUp) { associationIdsBefore.addAll(constructGenomicEntityAssociationService.getAssociationsByDataProvider(dataProvider)); associationIdsBefore.removeIf(Objects::isNull); } - + bulkLoadFile.setRecordCount(associations.size() + bulkLoadFile.getRecordCount()); bulkLoadFileDAO.merge(bulkLoadFile); BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); createHistory(history, bulkLoadFile); runLoad(constructGenomicEntityAssociationService, history, dataProvider, associations, associationIdsLoaded); - - if(cleanUp) runCleanup(constructGenomicEntityAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, bulkLoadFile.getMd5Sum()); + + if (cleanUp) { + runCleanup(constructGenomicEntityAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, bulkLoadFile.getMd5Sum()); + } history.finishLoad(); - + finalSaveHistory(history); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java index 998b52847..ddc80dd89 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java @@ -19,14 +19,14 @@ public class BulkLoadFMSProcessor extends BulkLoadProcessor { public void processBulkFMSLoad(@Observes StartedBulkLoadJobEvent load) { BulkLoad bulkLoad = bulkLoadDAO.find(load.getId()); - if(bulkLoad instanceof BulkFMSLoad bulkFMSLoad) { - + if (bulkLoad instanceof BulkFMSLoad bulkFMSLoad) { + Log.info("processBulkFMSLoad: " + load.getId()); startLoad(bulkFMSLoad); - + if (bulkFMSLoad.getFmsDataType() != null && bulkFMSLoad.getFmsDataSubType() != null) { List files = fmsDataFileService.getDataFiles(bulkFMSLoad.getFmsDataType(), bulkFMSLoad.getFmsDataSubType()); - + if (files.size() == 1) { DataFile df = files.get(0); String s3Url = df.getS3Url(); @@ -39,7 +39,7 @@ public void processBulkFMSLoad(@Observes StartedBulkLoadJobEvent load) { log.warn("Issue pulling files from the FMS: " + bulkFMSLoad.getFmsDataType() + " " + bulkFMSLoad.getFmsDataSubType()); endLoad(bulkFMSLoad, "Issue pulling files from the FMS: " + bulkFMSLoad.getFmsDataType() + " " + bulkFMSLoad.getFmsDataSubType(), JobStatus.FAILED); } - + } else { log.error("Load: " + bulkFMSLoad.getName() + " failed: FMS Params are missing"); endLoad(bulkFMSLoad, "Load: " + bulkFMSLoad.getName() + " failed: FMS Params are missing", JobStatus.FAILED); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java index ccda53e51..d930edc24 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java @@ -25,9 +25,10 @@ public class BulkLoadManualProcessor extends BulkLoadProcessor { public void processBulkManualLoad(@Observes StartedBulkLoadJobEvent load) { BulkLoad bulkLoad = bulkLoadDAO.find(load.getId()); - if(bulkLoad instanceof BulkManualLoad bulkURLLoad) { + if (bulkLoad instanceof BulkManualLoad bulkURLLoad) { Log.info("processBulkManualLoad: " + load.getId()); - // We do nothing because at the load level we don't try to figure out what the next file to run is + // We do nothing because at the load level we don't try to figure out what the + // next file to run is } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java index 6ea37bb26..d861e60ff 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java @@ -2,7 +2,6 @@ import java.io.File; import java.time.OffsetDateTime; -import java.util.List; import org.alliancegenome.curation_api.dao.loads.BulkFMSLoadDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadDAO; @@ -16,7 +15,6 @@ import org.alliancegenome.curation_api.jobs.util.SlackNotifier; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoad; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; -import org.alliancegenome.curation_api.model.fms.DataFile; import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.fms.DataFileService; import org.alliancegenome.curation_api.util.FileTransferHelper; @@ -28,55 +26,39 @@ public class BulkLoadProcessor { - @ConfigProperty(name = "bulk.data.loads.s3Bucket") - String s3Bucket = null; - - @ConfigProperty(name = "bulk.data.loads.s3PathPrefix") - String s3PathPrefix = null; - - @ConfigProperty(name = "bulk.data.loads.s3AccessKey") - String s3AccessKey = null; - - @ConfigProperty(name = "bulk.data.loads.s3SecretKey") - String s3SecretKey = null; - - @Inject - DataFileService fmsDataFileService; - - @Inject - BulkLoadDAO bulkLoadDAO; - @Inject - BulkManualLoadDAO bulkManualLoadDAO; - @Inject - BulkLoadFileDAO bulkLoadFileDAO; - @Inject - BulkFMSLoadDAO bulkFMSLoadDAO; - @Inject - BulkURLLoadDAO bulkURLLoadDAO; - - @Inject - BulkLoadJobExecutor bulkLoadJobExecutor; - - @Inject - SlackNotifier slackNotifier; - - @Inject - Event pendingFileJobEvents; - - protected FileTransferHelper fileHelper = new FileTransferHelper(); + @ConfigProperty(name = "bulk.data.loads.s3Bucket") String s3Bucket; + @ConfigProperty(name = "bulk.data.loads.s3PathPrefix") String s3PathPrefix; + @ConfigProperty(name = "bulk.data.loads.s3AccessKey") String s3AccessKey; + @ConfigProperty(name = "bulk.data.loads.s3SecretKey") String s3SecretKey; - private String processFMS(String dataType, String dataSubType) { - List files = fmsDataFileService.getDataFiles(dataType, dataSubType); + @Inject DataFileService fmsDataFileService; - if (files.size() == 1) { - DataFile df = files.get(0); - return df.getS3Url(); - } else { - Log.warn("Files: " + files); - Log.warn("Issue pulling files from the FMS: " + dataType + " " + dataSubType); - } - return null; - } + @Inject BulkLoadDAO bulkLoadDAO; + @Inject BulkManualLoadDAO bulkManualLoadDAO; + @Inject BulkLoadFileDAO bulkLoadFileDAO; + @Inject BulkFMSLoadDAO bulkFMSLoadDAO; + @Inject BulkURLLoadDAO bulkURLLoadDAO; + + @Inject BulkLoadJobExecutor bulkLoadJobExecutor; + + @Inject SlackNotifier slackNotifier; + + @Inject Event pendingFileJobEvents; + + protected FileTransferHelper fileHelper = new FileTransferHelper(); + +// private String processFMS(String dataType, String dataSubType) { +// List files = fmsDataFileService.getDataFiles(dataType, dataSubType); +// +// if (files.size() == 1) { +// DataFile df = files.get(0); +// return df.getS3Url(); +// } else { +// Log.warn("Files: " + files); +// Log.warn("Issue pulling files from the FMS: " + dataType + " " + dataSubType); +// } +// return null; +// } public void syncWithS3(BulkLoadFile bulkLoadFile) { Log.info("Syncing with S3"); @@ -111,7 +93,7 @@ public void syncWithS3(BulkLoadFile bulkLoadFile) { } Log.info("Syncing with S3 Finished"); } - + protected void processFilePath(BulkLoad bulkLoad, String localFilePath) { processFilePath(bulkLoad, localFilePath, false); } @@ -146,7 +128,9 @@ protected void processFilePath(BulkLoad bulkLoad, String localFilePath, Boolean Log.info(load.getBulkloadStatus()); bulkLoadFile.setLocalFilePath(localFilePath); - if(cleanUp) bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); + if (cleanUp) { + bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); + } bulkLoadFileDAO.persist(bulkLoadFile); } else if (load.getBulkloadStatus().isForced()) { bulkLoadFile = bulkLoadFiles.getResults().get(0); @@ -169,7 +153,9 @@ protected void processFilePath(BulkLoad bulkLoad, String localFilePath, Boolean if (!load.getLoadFiles().contains(bulkLoadFile)) { load.getLoadFiles().add(bulkLoadFile); } - if(cleanUp) bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); + if (cleanUp) { + bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); + } bulkLoadFileDAO.merge(bulkLoadFile); bulkLoadDAO.merge(load); Log.info("Firing Pending Bulk File Event: " + bulkLoadFile.getId()); @@ -193,7 +179,7 @@ protected void endLoad(BulkLoad load, String message, JobStatus status) { BulkLoad bulkLoad = bulkLoadDAO.find(load.getId()); bulkLoad.setErrorMessage(message); bulkLoad.setBulkloadStatus(status); - if(status != JobStatus.FINISHED) { + if (status != JobStatus.FINISHED) { slackNotifier.slackalert(bulkLoad); } bulkLoadDAO.merge(bulkLoad); @@ -215,7 +201,7 @@ protected void endLoadFile(BulkLoadFile bulkLoadFile, String message, JobStatus bulkLoadFile.setErrorMessage(message); bulkLoadFile.setBulkloadStatus(status); bulkLoadFile.setDateLastLoaded(OffsetDateTime.now()); - if(status != JobStatus.FINISHED) { + if (status != JobStatus.FINISHED) { slackNotifier.slackalert(bulkLoadFile); } bulkLoadFileDAO.merge(bulkLoadFile); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java index f22ba210b..822cc5a79 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java @@ -16,25 +16,24 @@ @ApplicationScoped public class BulkLoadURLProcessor extends BulkLoadProcessor { - @Inject - BulkLoadDAO bulkLoadDAO; - + @Inject BulkLoadDAO bulkLoadDAO; + public void processBulkURLLoad(@Observes StartedBulkLoadJobEvent load) { - + BulkLoad bulkLoad = bulkLoadDAO.find(load.getId()); - if(bulkLoad instanceof BulkURLLoad bulkURLLoad) { + if (bulkLoad instanceof BulkURLLoad bulkURLLoad) { Log.info("processBulkURLLoad: " + load.getId()); startLoad(bulkURLLoad); - + if (bulkURLLoad.getBulkloadUrl() != null && bulkURLLoad.getBulkloadUrl().length() > 0) { String filePath = fileHelper.saveIncomingURLFile(bulkURLLoad.getBulkloadUrl()); String localFilePath = fileHelper.compressInputFile(filePath); - - if(filePath == null) { + + if (filePath == null) { log.info("Load: " + bulkURLLoad.getName() + " failed"); endLoad(bulkURLLoad, "Load: " + bulkURLLoad.getName() + " failed: to download URL: " + bulkURLLoad.getBulkloadUrl(), JobStatus.FAILED); - } else if(localFilePath == null) { + } else if (localFilePath == null) { log.info("Load: " + bulkURLLoad.getName() + " failed"); endLoad(bulkURLLoad, "Load: " + bulkURLLoad.getName() + " failed: to save local file: " + filePath, JobStatus.FAILED); } else { diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java index f71cfcf58..62b163f9b 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java @@ -14,10 +14,10 @@ @ApplicationScoped public class StartLoadProcessor extends BulkLoadProcessor { - @Inject - BulkLoadFileDAO bulkLoadFileDAO; + @Inject BulkLoadFileDAO bulkLoadFileDAO; - public void bulkLoadFile(@Observes StartedBulkLoadFileJobEvent event) { // An @Observes method should not be in a super class as then it gets run for every child class + public void bulkLoadFile(@Observes StartedBulkLoadFileJobEvent event) { // An @Observes method should not be in a super class as then it gets run for + // every child class BulkLoadFile bulkLoadFile = bulkLoadFileDAO.find(event.getId()); if (!bulkLoadFile.getBulkloadStatus().isStarted()) { Log.warn("bulkLoadFile: Job is not started returning: " + bulkLoadFile.getBulkloadStatus()); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportJobExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportJobExecutor.java index 4640468b4..a61f58e9f 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportJobExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportJobExecutor.java @@ -27,29 +27,15 @@ @ApplicationScoped public class ReportJobExecutor { - @Inject - CurationReportHistoryService curationReportHistoryService; + @Inject CurationReportHistoryService curationReportHistoryService; - @ConfigProperty(name = "reports.s3Bucket") - String s3Bucket = null; - - @ConfigProperty(name = "reports.s3PathPrefix") - String s3PathPrefix = null; - - @ConfigProperty(name = "reports.s3AccessKey") - String s3AccessKey = null; - - @ConfigProperty(name = "reports.s3SecretKey") - String s3SecretKey = null; - - @ConfigProperty(name = "quarkus.datasource.jdbc.url") - String db_jdbc_url = null; - - @ConfigProperty(name = "quarkus.datasource.username") - String db_username = null; - - @ConfigProperty(name = "quarkus.datasource.password") - String db_password = null; + @ConfigProperty(name = "reports.s3Bucket") String s3Bucket; + @ConfigProperty(name = "reports.s3PathPrefix") String s3PathPrefix; + @ConfigProperty(name = "reports.s3AccessKey") String s3AccessKey; + @ConfigProperty(name = "reports.s3SecretKey") String s3SecretKey; + @ConfigProperty(name = "quarkus.datasource.jdbc.url") String dbJdbcUrl; + @ConfigProperty(name = "quarkus.datasource.username") String dbUsername; + @ConfigProperty(name = "quarkus.datasource.password") String dbPassword; protected FileTransferHelper fileHelper = new FileTransferHelper(); @@ -73,9 +59,9 @@ public void process(CurationReport curationReport) throws Exception { // Set parameter values and validate task.setParameterValue("db_driver", "org.postgresql.Driver"); - task.setParameterValue("db_jdbc_url", db_jdbc_url); - task.setParameterValue("db_username", db_username); - task.setParameterValue("db_password", db_password); + task.setParameterValue("db_jdbc_url", dbJdbcUrl); + task.setParameterValue("db_username", dbUsername); + task.setParameterValue("db_password", dbPassword); task.validateParameters(); CurationReportHistory history = new CurationReportHistory(); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportProcessor.java index 6b30d193c..0f92ea4e9 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportProcessor.java @@ -14,16 +14,12 @@ public class ReportProcessor { - @Inject - EventBus bus; + @Inject EventBus bus; - @Inject - CurationReportGroupDAO curationReportGroupDAO; - @Inject - CurationReportDAO curationReportDAO; + @Inject CurationReportGroupDAO curationReportGroupDAO; + @Inject CurationReportDAO curationReportDAO; - @Inject - ReportJobExecutor reportJobExecutor; + @Inject ReportJobExecutor reportJobExecutor; protected FileTransferHelper fileHelper = new FileTransferHelper(); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportScheduler.java b/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportScheduler.java index 81fb44374..26a5d219d 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportScheduler.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/reports/ReportScheduler.java @@ -26,18 +26,14 @@ @ApplicationScoped public class ReportScheduler { - @Inject - EventBus bus; + @Inject EventBus bus; - @Inject - CurationReportGroupDAO curationReportGroupDAO; - @Inject - CurationReportDAO curationReportDAO; + @Inject CurationReportGroupDAO curationReportGroupDAO; + @Inject CurationReportDAO curationReportDAO; - @ConfigProperty(name = "reports.schedulingEnabled") - Boolean schedulingEnabled; + @ConfigProperty(name = "reports.schedulingEnabled") Boolean schedulingEnabled; - private ZonedDateTime lastCheck = null; + private ZonedDateTime lastCheck; @PostConstruct public void init() { @@ -63,7 +59,7 @@ public void init() { } } - //@Scheduled(every = "1s") + // @Scheduled(every = "1s") public void scheduleGroupJobs() { if (schedulingEnabled) { ZonedDateTime start = ZonedDateTime.now(); @@ -105,13 +101,14 @@ public void scheduleGroupJobs() { } } - //@Scheduled(every = "1s") + // @Scheduled(every = "1s") public void runGroupJobs() { SearchResponse reportGroups = curationReportGroupDAO.findAll(); for (CurationReportGroup group : reportGroups.getResults()) { for (CurationReport cr : group.getCurationReports()) { - if (cr.getCurationReportStatus() == null) + if (cr.getCurationReportStatus() == null) { cr.setCurationReportStatus(JobStatus.FINISHED); + } if (cr.getCurationReportStatus().isPending()) { cr.setCurationReportStatus(cr.getCurationReportStatus().getNextStatus()); curationReportDAO.merge(cr); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java b/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java index 2ad61f019..87778e0a4 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java @@ -3,7 +3,9 @@ import com.fasterxml.jackson.dataformat.csv.CsvSchema; public class CsvSchemaBuilder { - + private CsvSchemaBuilder() { + // Hidden from view, as it is a utility class + } public static CsvSchema psiMiTabSchema() { CsvSchema schema = CsvSchema.builder() .setColumnSeparator('\t') diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java b/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java index bfc381b7b..fd8cbeb32 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java @@ -21,52 +21,44 @@ @ApplicationScoped public class SlackNotifier { - - @ConfigProperty(name = "net", defaultValue="\"\"") - Instance systemName; - @ConfigProperty(name = "slack.token") - Instance slackToken; - @ConfigProperty(name = "slack.channels") - Instance> slackChannels; - + + @ConfigProperty(name = "net", defaultValue = "\"\"") Instance systemName; + @ConfigProperty(name = "slack.token") Instance slackToken; + @ConfigProperty(name = "slack.channels") Instance> slackChannels; + private void slackalert(String groupName, String loadName, String message, List fields) { - - if(!systemName.get().equals("\"\"") && !slackToken.get().equals("\"\"")) { + + if (!systemName.get().equals("\"\"") && !slackToken.get().equals("\"\"")) { Slack slack = Slack.getInstance(); - + MethodsClient methods = slack.methods(slackToken.get()); - + String systemNameString = systemName.get(); - + try { - for(String channel : slackChannels.get()) { - + for (String channel : slackChannels.get()) { + Attachment attachment = new Attachment(); attachment.setServiceName(groupName); attachment.setPretext("An error has occured on Curation " + systemNameString); attachment.setTitle(loadName); - if(systemNameString.equals("production")) { + if (systemNameString.equals("production")) { attachment.setTitleLink("https://curation.alliancegenome.org/#/dataloads"); attachment.setServiceUrl("https://curation.alliancegenome.org/#/dataloads"); - } - else { + } else { attachment.setTitleLink("https://" + systemNameString + "-curation.alliancegenome.org/#/dataloads"); attachment.setServiceUrl("https://" + systemNameString + "-curation.alliancegenome.org/#/dataloads"); } attachment.setFooter("Failure Time: "); attachment.setTs(String.valueOf((new Date()).getTime() / 1000)); attachment.setColor("danger"); - if(fields != null) { + if (fields != null) { attachment.setFields(fields); } List attachments = new ArrayList<>(); attachments.add(attachment); - ChatPostMessageRequest request = ChatPostMessageRequest.builder() - .channel(channel) - .text(message) - .attachments(attachments) - .build(); + ChatPostMessageRequest request = ChatPostMessageRequest.builder().channel(channel).text(message).attachments(attachments).build(); methods.chatPostMessage(request); } slack.close(); @@ -78,48 +70,38 @@ private void slackalert(String groupName, String loadName, String message, List< } public void slackalert(BulkLoad bulkLoad) { - - if(bulkLoad.getBulkloadStatus() == JobStatus.FAILED) { - + + if (bulkLoad.getBulkloadStatus() == JobStatus.FAILED) { + List fields = new ArrayList<>(); fields.add(new Field("Load Type", String.valueOf(bulkLoad.getBackendBulkLoadType()), true)); - if(bulkLoad.getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { + if (bulkLoad.getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { fields.add(new Field("Ontology Type", String.valueOf(bulkLoad.getOntologyType()), true)); } slackalert( - - bulkLoad.getGroup().getName(), - bulkLoad.getName(), - bulkLoad.getErrorMessage(), - fields - ); + + bulkLoad.getGroup().getName(), bulkLoad.getName(), bulkLoad.getErrorMessage(), fields); } } public void slackalert(BulkLoadFile bulkLoadFile) { - - - if(bulkLoadFile.getBulkloadStatus() == JobStatus.FAILED) { + + if (bulkLoadFile.getBulkloadStatus() == JobStatus.FAILED) { List fields = new ArrayList<>(); fields.add(new Field("Load Type", String.valueOf(bulkLoadFile.getBulkLoad().getBackendBulkLoadType()), true)); - if(bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { + if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { fields.add(new Field("Ontology Type", String.valueOf(bulkLoadFile.getBulkLoad().getOntologyType()), true)); } fields.add(new Field("MD5Sum", bulkLoadFile.getMd5Sum(), true)); fields.add(new Field("File Size", String.valueOf(bulkLoadFile.getFileSize()), true)); - if(bulkLoadFile.getLinkMLSchemaVersion() != null) { + if (bulkLoadFile.getLinkMLSchemaVersion() != null) { fields.add(new Field("LinkML Version", bulkLoadFile.getLinkMLSchemaVersion(), true)); } - if(bulkLoadFile.getAllianceMemberReleaseVersion() != null) { + if (bulkLoadFile.getAllianceMemberReleaseVersion() != null) { fields.add(new Field("Alliance Member Release Version", bulkLoadFile.getAllianceMemberReleaseVersion(), false)); } - - slackalert( - bulkLoadFile.getBulkLoad().getGroup().getName(), - bulkLoadFile.getBulkLoad().getName(), - bulkLoadFile.getErrorMessage(), - fields - ); + + slackalert(bulkLoadFile.getBulkLoad().getGroup().getName(), bulkLoadFile.getBulkLoad().getName(), bulkLoadFile.getErrorMessage(), fields); } } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/main/Main.java b/src/main/java/org/alliancegenome/curation_api/main/Main.java index c2446b93a..bfa94d987 100644 --- a/src/main/java/org/alliancegenome/curation_api/main/Main.java +++ b/src/main/java/org/alliancegenome/curation_api/main/Main.java @@ -5,7 +5,9 @@ @QuarkusMain public class Main { - + private Main() { + // Hidden from view, as it is a utility class + } public static void main(String[] args) { System.out.println("Running main method of quarkus"); Quarkus.run(args); diff --git a/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanAndNullValueBridge.java b/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanAndNullValueBridge.java index 212196545..2a8f5461f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanAndNullValueBridge.java +++ b/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanAndNullValueBridge.java @@ -6,8 +6,9 @@ public class BooleanAndNullValueBridge implements ValueBridge { @Override public String toIndexedValue(Boolean value, ValueBridgeToIndexedValueContext context) { - if (value == null) + if (value == null) { return null; + } return value ? "true" : "false"; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanValueBridge.java b/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanValueBridge.java index 052cd135f..80a17e384 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanValueBridge.java +++ b/src/main/java/org/alliancegenome/curation_api/model/bridges/BooleanValueBridge.java @@ -6,8 +6,9 @@ public class BooleanValueBridge implements ValueBridge { @Override public String toIndexedValue(Boolean value, ValueBridgeToIndexedValueContext context) { - if (value == null) + if (value == null) { return "false"; + } return value ? "true" : "false"; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/bridges/FreeTextValueBridge.java b/src/main/java/org/alliancegenome/curation_api/model/bridges/FreeTextValueBridge.java index 1fdbe4d2b..b90e780ce 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/bridges/FreeTextValueBridge.java +++ b/src/main/java/org/alliancegenome/curation_api/model/bridges/FreeTextValueBridge.java @@ -6,8 +6,9 @@ public class FreeTextValueBridge implements ValueBridge { @Override public String toIndexedValue(String value, ValueBridgeToIndexedValueContext context) { - if (value == null) + if (value == null) { return null; + } return value.length() > 1000 ? value.substring(0, 1000) : value; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/bridges/OffsetDateTimeValueBridge.java b/src/main/java/org/alliancegenome/curation_api/model/bridges/OffsetDateTimeValueBridge.java index 5ea2227f8..23364412c 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/bridges/OffsetDateTimeValueBridge.java +++ b/src/main/java/org/alliancegenome/curation_api/model/bridges/OffsetDateTimeValueBridge.java @@ -8,8 +8,9 @@ public class OffsetDateTimeValueBridge implements ValueBridge { @Override public String toIndexedValue(OffsetDateTime value, ValueBridgeToIndexedValueContext context) { - if (value == null) + if (value == null) { return null; + } return value.toString(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/document/LiteratureReference.java b/src/main/java/org/alliancegenome/curation_api/model/document/LiteratureReference.java index 211784e68..571f627b0 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/document/LiteratureReference.java +++ b/src/main/java/org/alliancegenome/curation_api/model/document/LiteratureReference.java @@ -47,6 +47,7 @@ public class LiteratureReference extends BaseDocument { public String citationShort; @JsonView({ View.FieldsOnly.class }) - public List cross_references; + @JsonProperty("cross_references") + public List crossReferences; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java index f9ad8c657..04a191917 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java @@ -112,8 +112,9 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { @Override @JsonIgnore public String getSubjectCurie() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; + } return diseaseAnnotationSubject.getCurie(); } @@ -121,10 +122,12 @@ public String getSubjectCurie() { @Override @JsonIgnore public String getSubjectTaxonCurie() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; - if (diseaseAnnotationSubject.getTaxon() == null) + } + if (diseaseAnnotationSubject.getTaxon() == null) { return null; + } return diseaseAnnotationSubject.getTaxon().getCurie(); } @@ -132,8 +135,9 @@ public String getSubjectTaxonCurie() { @Override @JsonIgnore public String getSubjectIdentifier() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; + } return diseaseAnnotationSubject.getIdentifier(); } @@ -141,10 +145,12 @@ public String getSubjectIdentifier() { @Override @JsonIgnore public String getSubjectSpeciesName() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; - if (diseaseAnnotationSubject.getTaxon() == null) + } + if (diseaseAnnotationSubject.getTaxon() == null) { return null; + } return diseaseAnnotationSubject.getTaxon().getGenusSpecies(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java index a8f29c0cc..a4b288a67 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java @@ -112,8 +112,9 @@ public class AGMPhenotypeAnnotation extends PhenotypeAnnotation { @Override @JsonIgnore public String getSubjectCurie() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; + } return phenotypeAnnotationSubject.getCurie(); } @@ -121,10 +122,12 @@ public String getSubjectCurie() { @Override @JsonIgnore public String getSubjectTaxonCurie() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; - if (phenotypeAnnotationSubject.getTaxon() == null) + } + if (phenotypeAnnotationSubject.getTaxon() == null) { return null; + } return phenotypeAnnotationSubject.getTaxon().getCurie(); } @@ -132,8 +135,9 @@ public String getSubjectTaxonCurie() { @Override @JsonIgnore public String getSubjectIdentifier() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; + } return phenotypeAnnotationSubject.getIdentifier(); } @@ -141,10 +145,12 @@ public String getSubjectIdentifier() { @Override @JsonIgnore public String getSubjectSpeciesName() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; - if (phenotypeAnnotationSubject.getTaxon() == null) + } + if (phenotypeAnnotationSubject.getTaxon() == null) { return null; + } return phenotypeAnnotationSubject.getTaxon().getGenusSpecies(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java index 289c5c4a2..6033c5acc 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java @@ -50,12 +50,24 @@ @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = { "alleleGeneAssociations", "alleleDiseaseAnnotations", "alleleMutationTypes", "alleleSymbol", "alleleFullName", "alleleSynonyms", "alleleSecondaryIds", "alleleInheritanceModes", "alleleFunctionalImpacts", "alleleGermlineTransmissionStatus", "alleleDatabaseStatus", "alleleNomenclatureEvents" }, callSuper = true) +@ToString( + exclude = { + "alleleGeneAssociations", "alleleDiseaseAnnotations", "alleleMutationTypes", "alleleSymbol", "alleleFullName", "alleleSynonyms", + "alleleSecondaryIds", "alleleInheritanceModes", "alleleFunctionalImpacts", "alleleGermlineTransmissionStatus", "alleleDatabaseStatus", + "alleleNomenclatureEvents" + }, + callSuper = true +) @AGRCurationSchemaVersion(min = "1.7.3", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }, partial = true) -@Table(indexes = { @Index(name = "allele_inCollection_index", columnList = "inCollection_id"), }) +@Table(indexes = { @Index(name = "allele_inCollection_index", columnList = "inCollection_id") }) public class Allele extends GenomicEntity { - @IndexedEmbedded(includePaths = {"primaryCrossReferenceCurie", "crossReferences.referencedCurie", "crossReferences.displayName", "curie", "primaryCrossReferenceCurie_keyword", "crossReferences.referencedCurie_keyword", "crossReferences.displayName_keyword", "curie_keyword"}) + @IndexedEmbedded( + includePaths = { + "primaryCrossReferenceCurie", "crossReferences.referencedCurie", "crossReferences.displayName", "curie", "primaryCrossReferenceCurie_keyword", + "crossReferences.referencedCurie_keyword", "crossReferences.displayName_keyword", "curie_keyword" + } + ) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @Fetch(FetchMode.JOIN) @@ -88,25 +100,44 @@ public class Allele extends GenomicEntity { @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List alleleMutationTypes; - @IndexedEmbedded(includePaths = { "inheritanceMode.name", "phenotypeTerm.curie", "phenotypeTerm.name", "phenotypeStatement", "evidence.curie", "inheritanceMode.name_keyword", "phenotypeTerm.curie_keyword", "phenotypeTerm.name_keyword", "phenotypeStatement_keyword", "evidence.curie_keyword"}) + @IndexedEmbedded( + includePaths = { + "inheritanceMode.name", "phenotypeTerm.curie", "phenotypeTerm.name", "phenotypeStatement", "evidence.curie", "inheritanceMode.name_keyword", + "phenotypeTerm.curie_keyword", "phenotypeTerm.name_keyword", "phenotypeStatement_keyword", "evidence.curie_keyword" + } + ) @OneToMany(mappedBy = "singleAllele", cascade = CascadeType.ALL, orphanRemoval = true) @JsonManagedReference @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List alleleInheritanceModes; - @IndexedEmbedded(includePaths = { "displayText", "formatText", "nameType.name", "synonymScope.name", "evidence.curie", "displayText_keyword", "formatText_keyword", "nameType.name_keyword", "synonymScope.name_keyword", "evidence.curie_keyword"}) + @IndexedEmbedded(includePaths = { + "displayText", "formatText", "nameType.name", "synonymScope.name", "evidence.curie", "displayText_keyword", + "formatText_keyword", "nameType.name_keyword", "synonymScope.name_keyword", "evidence.curie_keyword" + } + ) @OneToOne(mappedBy = "singleAllele", cascade = CascadeType.ALL, orphanRemoval = true) @JsonManagedReference @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private AlleleSymbolSlotAnnotation alleleSymbol; - @IndexedEmbedded(includePaths = { "displayText", "formatText", "nameType.name", "synonymScope.name", "evidence.curie", "displayText_keyword", "formatText_keyword", "nameType.name_keyword", "synonymScope.name_keyword", "evidence.curie_keyword"}) + @IndexedEmbedded( + includePaths = { + "displayText", "formatText", "nameType.name", "synonymScope.name", "evidence.curie", "displayText_keyword", + "formatText_keyword", "nameType.name_keyword", "synonymScope.name_keyword", "evidence.curie_keyword" + } + ) @OneToOne(mappedBy = "singleAllele", cascade = CascadeType.ALL, orphanRemoval = true) @JsonManagedReference @JsonView({ View.FieldsOnly.class }) private AlleleFullNameSlotAnnotation alleleFullName; - @IndexedEmbedded(includePaths = { "displayText", "formatText", "nameType.name", "synonymScope.name", "evidence.curie", "displayText_keyword", "formatText_keyword", "nameType.name_keyword", "synonymScope.name_keyword", "evidence.curie_keyword"}) + @IndexedEmbedded( + includePaths = { + "displayText", "formatText", "nameType.name", "synonymScope.name", "evidence.curie", "displayText_keyword", "formatText_keyword", "nameType.name_keyword", + "synonymScope.name_keyword", "evidence.curie_keyword" + } + ) @OneToMany(mappedBy = "singleAllele", cascade = CascadeType.ALL, orphanRemoval = true) @JsonManagedReference @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) @@ -124,7 +155,13 @@ public class Allele extends GenomicEntity { @JsonView({ View.FieldsOnly.class }) private AlleleGermlineTransmissionStatusSlotAnnotation alleleGermlineTransmissionStatus; - @IndexedEmbedded(includePaths = { "functionalImpacts.name", "phenotypeTerm.curie", "phenotypeTerm.name", "phenotypeStatement","evidence.curie", "functionalImpacts.name_keyword", "phenotypeTerm.curie_keyword", "phenotypeTerm.name_keyword", "phenotypeStatement_keyword", "evidence.curie_keyword"}) + @IndexedEmbedded( + includePaths = { + "functionalImpacts.name", "phenotypeTerm.curie", "phenotypeTerm.name", "phenotypeStatement", "evidence.curie", + "functionalImpacts.name_keyword", "phenotypeTerm.curie_keyword", "phenotypeTerm.name_keyword", "phenotypeStatement_keyword", + "evidence.curie_keyword" + } + ) @OneToMany(mappedBy = "singleAllele", cascade = CascadeType.ALL, orphanRemoval = true) @JsonManagedReference @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) @@ -142,16 +179,21 @@ public class Allele extends GenomicEntity { @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List alleleNomenclatureEvents; - @IndexedEmbedded(includePaths = {"alleleGeneAssociationObject.curie", "alleleGeneAssociationObject.geneSymbol.displayText", "alleleGeneAssociationObject.geneSymbol.formatText", "alleleGeneAssociationObject.geneFullName.displayText", "alleleGeneAssociationObject.geneFullName.formatText", - "alleleGeneAssociationObject.curie_keyword", "alleleGeneAssociationObject.geneSymbol.displayText_keyword", "alleleGeneAssociationObject.geneSymbol.formatText_keyword", "alleleGeneAssociationObject.geneFullName.displayText_keyword", "alleleGeneAssociationObject.geneFullName.formatText_keyword", - "alleleGeneAssociationObject.modEntityId", "alleleGeneAssociationObject.modInternalId", "alleleGeneAssociationObject.modEntityId_keyword", "alleleGeneAssociationObject.modInternalId_keyword" }) + @IndexedEmbedded( + includePaths = { + "alleleGeneAssociationObject.curie", "alleleGeneAssociationObject.geneSymbol.displayText", "alleleGeneAssociationObject.geneSymbol.formatText", "alleleGeneAssociationObject.geneFullName.displayText", + "alleleGeneAssociationObject.geneFullName.formatText", "alleleGeneAssociationObject.curie_keyword", "alleleGeneAssociationObject.geneSymbol.displayText_keyword", + "alleleGeneAssociationObject.geneSymbol.formatText_keyword", "alleleGeneAssociationObject.geneFullName.displayText_keyword", "alleleGeneAssociationObject.geneFullName.formatText_keyword", + "alleleGeneAssociationObject.modEntityId", "alleleGeneAssociationObject.modInternalId", "alleleGeneAssociationObject.modEntityId_keyword", "alleleGeneAssociationObject.modInternalId_keyword" + } + ) @OneToMany(mappedBy = "alleleAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.AlleleDetailView.class }) private List alleleGeneAssociations; @IndexedEmbedded(includePaths = {"freeText", "freeText_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) @JoinTable(indexes = { @Index(name = "allele_note_allele_index", columnList = "allele_id"), diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java index 249b4aecb..0be4353c5 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java @@ -93,8 +93,9 @@ public class AlleleDiseaseAnnotation extends DiseaseAnnotation { @Override @JsonIgnore public String getSubjectCurie() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; + } return diseaseAnnotationSubject.getCurie(); } @@ -102,10 +103,12 @@ public String getSubjectCurie() { @Override @JsonIgnore public String getSubjectTaxonCurie() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; - if (diseaseAnnotationSubject.getTaxon() == null) + } + if (diseaseAnnotationSubject.getTaxon() == null) { return null; + } return diseaseAnnotationSubject.getTaxon().getCurie(); } @@ -113,8 +116,9 @@ public String getSubjectTaxonCurie() { @Override @JsonIgnore public String getSubjectIdentifier() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; + } return diseaseAnnotationSubject.getIdentifier(); } @@ -122,10 +126,12 @@ public String getSubjectIdentifier() { @Override @JsonIgnore public String getSubjectSpeciesName() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; - if (diseaseAnnotationSubject.getTaxon() == null) + } + if (diseaseAnnotationSubject.getTaxon() == null) { return null; + } return diseaseAnnotationSubject.getTaxon().getGenusSpecies(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java index 976162f8d..ddee7fca3 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java @@ -90,8 +90,9 @@ public class AllelePhenotypeAnnotation extends PhenotypeAnnotation { @Override @JsonIgnore public String getSubjectCurie() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; + } return phenotypeAnnotationSubject.getCurie(); } @@ -99,10 +100,12 @@ public String getSubjectCurie() { @Override @JsonIgnore public String getSubjectTaxonCurie() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; - if (phenotypeAnnotationSubject.getTaxon() == null) + } + if (phenotypeAnnotationSubject.getTaxon() == null) { return null; + } return phenotypeAnnotationSubject.getTaxon().getCurie(); } @@ -110,8 +113,9 @@ public String getSubjectTaxonCurie() { @Override @JsonIgnore public String getSubjectIdentifier() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; + } return phenotypeAnnotationSubject.getIdentifier(); } @@ -119,10 +123,12 @@ public String getSubjectIdentifier() { @Override @JsonIgnore public String getSubjectSpeciesName() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; - if (phenotypeAnnotationSubject.getTaxon() == null) + } + if (phenotypeAnnotationSubject.getTaxon() == null) { return null; + } return phenotypeAnnotationSubject.getTaxon().getGenusSpecies(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java index 8c2321374..c03342b0f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java @@ -46,10 +46,10 @@ @Index(name = "annotation_uniqueId_index", columnList = "uniqueId"), @Index(name = "annotation_modEntityId_index", columnList = "modEntityId"), @Index(name = "annotation_modInternalId_index", columnList = "modInternalId"), - @Index(name = "annotation_dataprovider_index", columnList = "dataProvider_id"), + @Index(name = "annotation_dataprovider_index", columnList = "dataProvider_id") }, uniqueConstraints = { @UniqueConstraint(name = "annotation_modentityid_uk", columnNames = "modEntityId"), - @UniqueConstraint(name = "annotation_modinternalid_uk", columnNames = "modInternalId"), + @UniqueConstraint(name = "annotation_modinternalid_uk", columnNames = "modInternalId") } ) public class Annotation extends SingleReferenceAssociation { @@ -94,9 +94,9 @@ public class Annotation extends SingleReferenceAssociation { "references.primaryCrossReferenceCurie_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { @Index(name = "annotation_note_annotation_index", columnList = "annotation_id"), @Index(name = "annotation_note_relatednotes_index",columnList = "relatednotes_id")}) + @JoinTable(indexes = { @Index(name = "annotation_note_annotation_index", columnList = "annotation_id"), @Index(name = "annotation_note_relatednotes_index", columnList = "relatednotes_id")}) private List relatedNotes; @IndexedEmbedded(includePaths = {"sourceOrganization.abbreviation", "sourceOrganization.fullName", "sourceOrganization.shortName", "crossReference.displayName", "crossReference.referencedCurie", diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/BiologicalEntity.java b/src/main/java/org/alliancegenome/curation_api/model/entities/BiologicalEntity.java index dfe6f3891..e62b0940c 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/BiologicalEntity.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/BiologicalEntity.java @@ -45,7 +45,7 @@ @Index(name = "biologicalentity_updatedby_index", columnList = "updatedBy_id"), @Index(name = "biologicalentity_modentityid_index", columnList = "modentityid"), @Index(name = "biologicalentity_modinternalid_index", columnList = "modinternalid"), - @Index(name = "biologicalentity_dataprovider_index", columnList = "dataprovider_id"), + @Index(name = "biologicalentity_dataprovider_index", columnList = "dataprovider_id") }, uniqueConstraints = { @UniqueConstraint(name = "biologicalentity_curie_uk", columnNames = "curie"), diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ConditionRelation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ConditionRelation.java index 1c51e1a21..3b62c484a 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ConditionRelation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ConditionRelation.java @@ -70,8 +70,9 @@ public class ConditionRelation extends UniqueIdAuditedObject { private List conditions; public void addExperimentCondition(ExperimentalCondition experimentalCondition) { - if (conditions == null) + if (conditions == null) { conditions = new ArrayList<>(); + } conditions.add(experimentalCondition); } @@ -79,4 +80,4 @@ public static class Constant { public static final String HANDLE_STANDARD = "Standard"; public static final String HANDLE_GENERIC_CONTROL = "Generic_control"; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java index a087080bf..1e0ffb75e 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java @@ -74,9 +74,13 @@ public class Construct extends Reagent { @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) private List constructComponents; - @IndexedEmbedded(includePaths = {"constructGenomicEntityAssociationObject.curie", "constructGenomicEntityAssociationObject.modEntityId", "constructGenomicEntityAssociationObject.modInternalId", "constructGenomicEntityAssociationObject.name", "constructGenomicEntityAssociationObject.symbol", "relation.name", - "constructGenomicEntityAssociationObject.curie_keyword", "constructGenomicEntityAssociationObject.modEntityId_keyword", "constructGenomicEntityAssociationObject.modInternalId_keyword", "constructGenomicEntityAssociationObject.name_keyword", "constructGenomicEntityAssociationObject.symbol_keyword", "relation.name_keyword"}) + @IndexedEmbedded(includePaths = { + "constructGenomicEntityAssociationObject.curie", "constructGenomicEntityAssociationObject.modEntityId", "constructGenomicEntityAssociationObject.modInternalId", + "constructGenomicEntityAssociationObject.name", "constructGenomicEntityAssociationObject.symbol", "relation.name", "constructGenomicEntityAssociationObject.curie_keyword", + "constructGenomicEntityAssociationObject.modEntityId_keyword", "constructGenomicEntityAssociationObject.modInternalId_keyword", "constructGenomicEntityAssociationObject.name_keyword", + "constructGenomicEntityAssociationObject.symbol_keyword", "relation.name_keyword" + }) @OneToMany(mappedBy = "constructAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) private List constructGenomicEntityAssociations; -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java b/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java index 735ab9fd8..58da2a1a1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java @@ -60,10 +60,11 @@ public class CrossReference extends AuditedObject { private ResourceDescriptorPage resourceDescriptorPage; public String getPrefix() { - if (referencedCurie.indexOf(":") == -1) + if (referencedCurie.indexOf(":") == -1) { return referencedCurie; + } return referencedCurie.substring(0, referencedCurie.indexOf(":")); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/DataProvider.java b/src/main/java/org/alliancegenome/curation_api/model/entities/DataProvider.java index ae55deca9..f257facaa 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/DataProvider.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/DataProvider.java @@ -42,7 +42,7 @@ public class DataProvider extends AuditedObject { @IndexedEmbedded(includeDepth = 1) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToOne(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private CrossReference crossReference; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java index df13662b0..ee4752671 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java @@ -53,7 +53,7 @@ @Index(name = "DiseaseAnnotation_annotationType_index", columnList = "annotationType_id"), @Index(name = "DiseaseAnnotation_geneticSex_index", columnList = "geneticSex_id"), @Index(name = "DiseaseAnnotation_secondaryDataProvider_index", columnList = "secondaryDataProvider_id"), - @Index(name = "DiseaseAnnotation_diseaseGeneticModifierRelation_index", columnList = "diseaseGeneticModifierRelation_id"), + @Index(name = "DiseaseAnnotation_diseaseGeneticModifierRelation_index", columnList = "diseaseGeneticModifierRelation_id") }) public abstract class DiseaseAnnotation extends Annotation { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java index e306e5616..895590f95 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java @@ -38,7 +38,7 @@ @ToString(exclude = { "geneDiseaseAnnotations", "geneGeneAssociations", "geneSymbol", "geneFullName", "geneSystematicName", "geneSynonyms", "geneSecondaryIds", "alleleGeneAssociations" }, callSuper = true) @Schema(name = "Gene", description = "POJO that represents the Gene") @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }, partial = true) -@Table(indexes = { @Index(name = "gene_genetype_index", columnList = "geneType_id"), }) +@Table(indexes = { @Index(name = "gene_genetype_index", columnList = "geneType_id") }) public class Gene extends GenomicEntity { @ManyToOne @@ -81,9 +81,13 @@ public class Gene extends GenomicEntity { @JsonView({ View.FieldsAndLists.class, View.GeneView.class }) private List geneSecondaryIds; - @IndexedEmbedded(includePaths = {"alleleAssociationSubject.curie", "alleleAssociationSubject.alleleSymbol.displayText", "alleleAssociationSubject.alleleSymbol.formatText", "alleleAssociationSubject.alleleFullName.displayText", "alleleAssociationSubject.alleleFullName.formatText", - "alleleAssociationSubject.curie_keyword", "alleleAssociationSubject.alleleSymbol.displayText_keyword", "alleleAssociationSubject.alleleSymbol.formatText_keyword", "alleleAssociationSubject.alleleFullName.displayText_keyword", "alleleAssociationSubject.alleleFullName.formatText_keyword", - "alleleAssociationSubject.modEntityId", "alleleAssociationSubject.modInternalId", "alleleAssociationSubject.modEntityId_keyword", "alleleAssociationSubject.modInternalId_keyword"}) + @IndexedEmbedded( + includePaths = {"alleleAssociationSubject.curie", "alleleAssociationSubject.alleleSymbol.displayText", "alleleAssociationSubject.alleleSymbol.formatText", "alleleAssociationSubject.alleleFullName.displayText", + "alleleAssociationSubject.alleleFullName.formatText", "alleleAssociationSubject.curie_keyword", "alleleAssociationSubject.alleleSymbol.displayText_keyword", "alleleAssociationSubject.alleleSymbol.formatText_keyword", + "alleleAssociationSubject.alleleFullName.displayText_keyword", "alleleAssociationSubject.alleleFullName.formatText_keyword", "alleleAssociationSubject.modEntityId", "alleleAssociationSubject.modInternalId", + "alleleAssociationSubject.modEntityId_keyword", "alleleAssociationSubject.modInternalId_keyword" + } + ) @OneToMany(mappedBy = "alleleGeneAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.GeneDetailView.class }) private List alleleGeneAssociations; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java index 49041fe37..61754add1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java @@ -60,8 +60,9 @@ public class GeneDiseaseAnnotation extends DiseaseAnnotation { @Override @JsonIgnore public String getSubjectCurie() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; + } return diseaseAnnotationSubject.getCurie(); } @@ -69,10 +70,12 @@ public String getSubjectCurie() { @Override @JsonIgnore public String getSubjectTaxonCurie() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; - if (diseaseAnnotationSubject.getTaxon() == null) + } + if (diseaseAnnotationSubject.getTaxon() == null) { return null; + } return diseaseAnnotationSubject.getTaxon().getCurie(); } @@ -80,8 +83,9 @@ public String getSubjectTaxonCurie() { @Override @JsonIgnore public String getSubjectIdentifier() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; + } return diseaseAnnotationSubject.getIdentifier(); } @@ -89,10 +93,12 @@ public String getSubjectIdentifier() { @Override @JsonIgnore public String getSubjectSpeciesName() { - if (diseaseAnnotationSubject == null) + if (diseaseAnnotationSubject == null) { return null; - if (diseaseAnnotationSubject.getTaxon() == null) + } + if (diseaseAnnotationSubject.getTaxon() == null) { return null; + } return diseaseAnnotationSubject.getTaxon().getGenusSpecies(); } } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java index 44d8f8394..3d4363626 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java @@ -47,7 +47,7 @@ @Index(name = "geneinteraction_interactorarole_index", columnList = "interactorarole_id"), @Index(name = "geneinteraction_interactorbrole_index", columnList = "interactorbrole_id"), @Index(name = "geneinteraction_interactoratype_index", columnList = "interactoratype_id"), - @Index(name = "geneinteraction_interactorbtype_index", columnList = "interactorbtype_id"), + @Index(name = "geneinteraction_interactorbtype_index", columnList = "interactorbtype_id") }) public abstract class GeneInteraction extends GeneGeneAssociation { @@ -66,7 +66,7 @@ public abstract class GeneInteraction extends GeneGeneAssociation { @IndexedEmbedded(includePaths = {"referencedCurie", "displayName", "referencedCurie_keyword", "displayName_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JoinTable(indexes = { @Index(columnList = "geneinteraction_id, crossreferences_id", name = "geneinteraction_crossreference_gi_xref_index"), @Index(columnList = "geneinteraction_id", name = "geneinteraction_crossreference_geneinteraction_index"), diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java index bbfdf0860..ad9fc2d83 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java @@ -58,8 +58,9 @@ public class GenePhenotypeAnnotation extends PhenotypeAnnotation { @Override @JsonIgnore public String getSubjectCurie() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; + } return phenotypeAnnotationSubject.getCurie(); } @@ -67,10 +68,12 @@ public String getSubjectCurie() { @Override @JsonIgnore public String getSubjectTaxonCurie() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; - if (phenotypeAnnotationSubject.getTaxon() == null) + } + if (phenotypeAnnotationSubject.getTaxon() == null) { return null; + } return phenotypeAnnotationSubject.getTaxon().getCurie(); } @@ -78,8 +81,9 @@ public String getSubjectTaxonCurie() { @Override @JsonIgnore public String getSubjectIdentifier() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; + } return phenotypeAnnotationSubject.getIdentifier(); } @@ -87,10 +91,12 @@ public String getSubjectIdentifier() { @Override @JsonIgnore public String getSubjectSpeciesName() { - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { return null; - if (phenotypeAnnotationSubject.getTaxon() == null) + } + if (phenotypeAnnotationSubject.getTaxon() == null) { return null; + } return phenotypeAnnotationSubject.getTaxon().getGenusSpecies(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java index bc733e6ba..4963e9bfb 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java @@ -30,7 +30,7 @@ public class GenomicEntity extends BiologicalEntity { @IndexedEmbedded(includePaths = {"referencedCurie", "displayName", "resourceDescriptorPage.name", "referencedCurie_keyword", "displayName_keyword", "resourceDescriptorPage.name_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JoinTable(indexes = { @Index(columnList = "genomicentity_id, crossreferences_id", name = "genomicentity_crossreference_ge_xref_index"), @Index(columnList = "genomicentity_id", name = "genomicentity_crossreference_genomicentity_index"), @@ -41,10 +41,12 @@ public class GenomicEntity extends BiologicalEntity { private List crossReferences; - @IndexedEmbedded(includePaths = {"constructAssociationSubject.curie", "constructAssociationSubject.constructSymbol.displayText", "constructAssociationSubject.constructSymbol.formatText", - "constructAssociationSubject.constructFullName.displayText", "constructAssociationSubject.constructFullName.formatText", "constructAssociationSubject.modEntityId", - "constructAssociationSubject.curie_keyword", "constructAssociationSubject.constructSymbol.displayText_keyword", "constructAssociationSubject.constructSymbol.formatText_keyword", - "constructAssociationSubject.constructFullName.displayText_keyword", "constructAssociationSubject.constructFullName.formatText_keyword", "constructAssociationSubject.modEntityId_keyword",}) + @IndexedEmbedded(includePaths = { + "constructAssociationSubject.curie", "constructAssociationSubject.constructSymbol.displayText", "constructAssociationSubject.constructSymbol.formatText", + "constructAssociationSubject.constructFullName.displayText", "constructAssociationSubject.constructFullName.formatText", "constructAssociationSubject.modEntityId", + "constructAssociationSubject.curie_keyword", "constructAssociationSubject.constructSymbol.displayText_keyword", "constructAssociationSubject.constructSymbol.formatText_keyword", + "constructAssociationSubject.constructFullName.displayText_keyword", "constructAssociationSubject.constructFullName.formatText_keyword", "constructAssociationSubject.modEntityId_keyword" + }) @OneToMany(mappedBy = "constructGenomicEntityAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.GeneDetailView.class }) private List constructGenomicEntityAssociations; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/InformationContentEntity.java b/src/main/java/org/alliancegenome/curation_api/model/entities/InformationContentEntity.java index c40f7af82..53c5c24a2 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/InformationContentEntity.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/InformationContentEntity.java @@ -29,7 +29,7 @@ indexes = { @Index(name = "informationcontententity_curie_index", columnList = "curie"), @Index(name = "informationcontententity_createdby_index", columnList = "createdBy_id"), - @Index(name = "informationcontententity_updatedby_index", columnList = "updatedBy_id"), + @Index(name = "informationcontententity_updatedby_index", columnList = "updatedBy_id") }, uniqueConstraints = { @UniqueConstraint(name = "informationcontententity_curie_uk", columnNames = "curie") @@ -37,4 +37,4 @@ ) public class InformationContentEntity extends CurieObject { -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Person.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Person.java index cbdf10ca1..4c59f94b3 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Person.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Person.java @@ -36,7 +36,7 @@ @Index(name = "person_createdby_index", columnList = "createdBy_id"), @Index(name = "person_updatedby_index", columnList = "updatedBy_id"), @Index(name = "person_uniqueid_index", columnList = "uniqueid"), - @Index(name = "person_allianceMember_index", columnList = "allianceMember_id"), + @Index(name = "person_allianceMember_index", columnList = "allianceMember_id") }) public class Person extends Agent { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java index 4153bd9d7..9c18cc45f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java @@ -71,7 +71,7 @@ public abstract class PhenotypeAnnotation extends Annotation { @IndexedEmbedded(includePaths = {"referencedCurie", "displayName", "referencedCurie_keyword", "displayName_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToOne(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private CrossReference crossReference; @@ -88,4 +88,4 @@ public abstract class PhenotypeAnnotation extends Annotation { public String getDataProviderString() { return dataProvider.getSourceOrganization().getAbbreviation(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java index cf4e896b3..555ffdfa1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java @@ -43,7 +43,7 @@ @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @Schema(name = "Reference", description = "POJO that represents the Reference") -@AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = {InformationContentEntity.class}, partial = true) +@AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { InformationContentEntity.class }, partial = true) public class Reference extends InformationContentEntity { @IndexedEmbedded(includeDepth = 1) @@ -51,17 +51,17 @@ public class Reference extends InformationContentEntity { @ManyToMany @Fetch(FetchMode.JOIN) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "reference_crossreference_reference_index", columnList = "Reference_id"), - @Index(name = "reference_crossreference_crossreferences_index", columnList = "crossReferences_id") - }) - @EqualsAndHashCode.Include - private List crossReferences; + @JoinTable( + indexes = { + @Index(name = "reference_crossreference_reference_index", columnList = "Reference_id"), + @Index(name = "reference_crossreference_crossreferences_index", columnList = "crossReferences_id") + } + ) + @EqualsAndHashCode.Include private List crossReferences; - @JsonView({View.FieldsOnly.class}) + @JsonView({ View.FieldsOnly.class }) @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") - @KeywordField(name = "shortCitation_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") - private String shortCitation; + @KeywordField(name = "shortCitation_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") private String shortCitation; /** * Retrieve PMID if available in the crossReference collection otherwise MOD ID @@ -69,18 +69,20 @@ public class Reference extends InformationContentEntity { @Transient @JsonIgnore public String getReferenceID() { - if (CollectionUtils.isEmpty(getCrossReferences())) + if (CollectionUtils.isEmpty(getCrossReferences())) { return null; - + } + for (String prefix : ReferenceConstants.primaryXrefOrder) { Optional opt = getCrossReferences().stream().filter(reference -> reference.getReferencedCurie().startsWith(prefix + ":")).findFirst(); - if (opt.isPresent()) + if (opt.isPresent()) { return opt.map(CrossReference::getReferencedCurie).orElse(null); + } } - + List referencedCuries = getCrossReferences().stream().map(CrossReference::getReferencedCurie).collect(Collectors.toList()); Collections.sort(referencedCuries); - + return referencedCuries.get(0); } } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Species.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Species.java index 0b0d9398e..065853fc4 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Species.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Species.java @@ -44,7 +44,7 @@ @Index(name = "species_createdby_index", columnList = "createdBy_id"), @Index(name = "species_updatedby_index", columnList = "updatedBy_id") }) -@AGRCurationSchemaVersion(min = "2.0.0", max = LinkMLSchemaConstants.LATEST_RELEASE,dependencies = { AuditedObject.class }) +@AGRCurationSchemaVersion(min = "2.0.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) public class Species extends AuditedObject { @IndexedEmbedded(includePaths = {"name", "curie", "name_keyword", "curie_keyword"}) @@ -73,7 +73,7 @@ public class Species extends AuditedObject { @KeywordField(name = "commonNames_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @ElementCollection @JsonView({ View.FieldsAndLists.class}) - @JoinTable(indexes = @Index(name ="species_commonnames_species_id_index",columnList = "species_id")) + @JoinTable(indexes = @Index(name = "species_commonnames_species_id_index", columnList = "species_id")) private List commonNames; @IndexedEmbedded(includeDepth = 2) @@ -89,5 +89,7 @@ public class Species extends AuditedObject { //@FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") //@KeywordField(name = "assembly_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @JsonView({ View.FieldsOnly.class }) + //CHECKSTYLE:OFF: MemberName private String assembly_curie; + //CHECKSTYLE:ON: MemberName } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java index 8df2d5a44..8fc1491e6 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java @@ -63,7 +63,7 @@ public class Variant extends GenomicEntity { "references.primaryCrossReferenceCurie_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.VariantView.class }) @JoinTable(indexes = { @Index(name = "variant_note_variant_index", columnList = "variant_id"), @@ -71,4 +71,4 @@ public class Variant extends GenomicEntity { }) private List relatedNotes; -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Vocabulary.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Vocabulary.java index 857e9b883..46a7a4f99 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Vocabulary.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Vocabulary.java @@ -44,7 +44,7 @@ }, uniqueConstraints = { @UniqueConstraint(name = "vocabulary_name_uk", columnNames = "name"), - @UniqueConstraint(name = "vocabulary_vocabularyLabel_uk", columnNames = "vocabularyLabel"), + @UniqueConstraint(name = "vocabulary_vocabularyLabel_uk", columnNames = "vocabularyLabel") } ) public class Vocabulary extends AuditedObject { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTermSet.java b/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTermSet.java index 8824a7769..a8ba2af9d 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTermSet.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTermSet.java @@ -44,7 +44,7 @@ @Index(name = "vocabularytermset_updatedby_id_index", columnList = "updatedby_id"), @Index(name = "vocabularytermset_vocabularytermsetvocabulary_id_index", columnList = "vocabularytermsetvocabulary_id") }, uniqueConstraints = { - @UniqueConstraint(name = "vocabularytermset_vocabularyLabel_uk", columnNames = "vocabularyLabel"), + @UniqueConstraint(name = "vocabularytermset_vocabularyLabel_uk", columnNames = "vocabularyLabel") } ) @AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java index b49009acd..9e7e01a3b 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java @@ -29,27 +29,31 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AlleleGenomicEntityAssociation.class }) @Schema(name = "AlleleGeneAssociation", description = "POJO representing an association between an allele and a gene") -@Table(indexes = { +@Table( + indexes = { @Index(name = "allelegeneassociation_alleleassociationsubject_index", columnList = "alleleassociationsubject_id"), @Index(name = "allelegeneassociation_allelegeneassociationobject_index", columnList = "allelegeneassociationobject_id") - }) + } +) public class AlleleGeneAssociation extends AlleleGenomicEntityAssociation { - @IndexedEmbedded(includePaths = {"curie", "alleleSymbol.displayText", "alleleSymbol.formatText", "alleleFullName.displayText", "alleleFullName.formatText", - "curie_keyword", "alleleSymbol.displayText_keyword", "alleleSymbol.formatText_keyword", "alleleFullName.displayText_keyword", "alleleFullName.formatText_keyword", - "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) + @IndexedEmbedded(includePaths = { + "curie", "alleleSymbol.displayText", "alleleSymbol.formatText", "alleleFullName.displayText", "alleleFullName.formatText", + "curie_keyword", "alleleSymbol.displayText_keyword", "alleleSymbol.formatText_keyword", "alleleFullName.displayText_keyword", + "alleleFullName.formatText_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword" }) @ManyToOne @JsonView({ View.FieldsOnly.class }) @JsonIgnoreProperties("alleleGeneAssociations") @Fetch(FetchMode.JOIN) private Allele alleleAssociationSubject; - - @IndexedEmbedded(includePaths = {"curie", "geneSymbol.displayText", "geneSymbol.formatText", "geneFullName.displayText", "geneFullName.formatText", - "curie_keyword", "geneSymbol.displayText_keyword", "geneSymbol.formatText_keyword", "geneFullName.displayText_keyword", "geneFullName.formatText_keyword", - "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) + + @IndexedEmbedded(includePaths = { "curie", "geneSymbol.displayText", "geneSymbol.formatText", "geneFullName.displayText", + "geneFullName.formatText", "curie_keyword", "geneSymbol.displayText_keyword", "geneSymbol.formatText_keyword", + "geneFullName.displayText_keyword", "geneFullName.formatText_keyword", "modEntityId", "modEntityId_keyword", + "modInternalId", "modInternalId_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne @JsonView({ View.FieldsOnly.class, View.AlleleView.class }) - @JsonIgnoreProperties({"alleleGeneAssociations", "constructGenomicEntityAssociations"}) + @JsonIgnoreProperties({ "alleleGeneAssociations", "constructGenomicEntityAssociations" }) private Gene alleleGeneAssociationObject; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java index 49f55de0c..db25b7827 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java @@ -30,30 +30,28 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) @Schema(name = "AlleleGenomicEntityAssociation", description = "POJO representing an association between an allele and a genomic entity") -@Table(indexes = { - @Index(name = "allelegenomicentityassociation_relation_index", columnList = "relation_id") -}) +@Table( + indexes = { + @Index(name = "allelegenomicentityassociation_relation_index", columnList = "relation_id") + } +) public class AlleleGenomicEntityAssociation extends EvidenceAssociation { - @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexedEmbedded(includePaths = { "name", "name_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne @JsonView({ View.FieldsOnly.class, View.AlleleView.class }) private VocabularyTerm relation; - @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "abbreviation", - "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "abbreviation_keyword" }) + @IndexedEmbedded(includePaths = { "curie", "name", "secondaryIdentifiers", "synonyms.name", "abbreviation", "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "abbreviation_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne @JsonView({ View.FieldsOnly.class }) private ECOTerm evidenceCode; - - @IndexedEmbedded(includePaths = {"freeText", "noteType.name", "references.curie", - "references.primaryCrossReferenceCurie", "freeText_keyword", "noteType.name_keyword", "references.curie_keyword", - "references.primaryCrossReferenceCurie_keyword" - }) + + @IndexedEmbedded(includePaths = { "freeText", "noteType.name", "references.curie", "references.primaryCrossReferenceCurie", "freeText_keyword", "noteType.name_keyword", "references.curie_keyword", "references.primaryCrossReferenceCurie_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToOne(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsOnly.class }) private Note relatedNote; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java index 138cb6b2c..7cfb82130 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java @@ -45,10 +45,11 @@ }) public class ConstructGenomicEntityAssociation extends EvidenceAssociation { - @IndexedEmbedded(includePaths = {"curie", "constructSymbol.displayText", "constructSymbol.formatText", - "constructFullName.displayText", "constructFullName.formatText", "modEntityId", "modInternalId", - "curie_keyword", "constructSymbol.displayText_keyword", "constructSymbol.formatText_keyword", - "constructFullName.displayText_keyword", "constructFullName.formatText_keyword", "modEntityId_keyword", "modInternalId_keyword"}) + @IndexedEmbedded(includePaths = { + "curie", "constructSymbol.displayText", "constructSymbol.formatText", + "constructFullName.displayText", "constructFullName.formatText", "modEntityId", "modInternalId", + "curie_keyword", "constructSymbol.displayText_keyword", "constructSymbol.formatText_keyword", + "constructFullName.displayText_keyword", "constructFullName.formatText_keyword", "modEntityId_keyword", "modInternalId_keyword"}) @ManyToOne @JsonView({ View.FieldsOnly.class }) @JsonIgnoreProperties("constructGenomicEntityAssociations") @@ -73,7 +74,7 @@ public class ConstructGenomicEntityAssociation extends EvidenceAssociation { "references.primaryCrossReferenceCurie_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) @JoinTable(indexes = { @Index(name = "cgeassociation_note_cgeassociation_index", columnList = "constructgenomicentityassociation_id"), diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/base/SubmittedObject.java b/src/main/java/org/alliancegenome/curation_api/model/entities/base/SubmittedObject.java index 620aec042..1593f965e 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/base/SubmittedObject.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/base/SubmittedObject.java @@ -45,34 +45,40 @@ public class SubmittedObject extends CurieObject { @JsonView({ View.FieldsOnly.class }) private String modInternalId; - @IndexedEmbedded(includePaths = {"sourceOrganization.abbreviation", "sourceOrganization.fullName", "sourceOrganization.shortName", "crossReference.displayName", "crossReference.referencedCurie", - "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword"}) + @IndexedEmbedded(includePaths = { + "sourceOrganization.abbreviation", "sourceOrganization.fullName", "sourceOrganization.shortName", "crossReference.displayName", "crossReference.referencedCurie", + "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword" + }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class }) private DataProvider dataProvider; - @Transient @JsonIgnore public String getIdentifier() { - if (StringUtils.isNotBlank(curie)) + if (StringUtils.isNotBlank(curie)) { return curie; - if (StringUtils.isNotBlank(modEntityId)) + } + if (StringUtils.isNotBlank(modEntityId)) { return modEntityId; - if (StringUtils.isNotBlank(modInternalId)) + } + if (StringUtils.isNotBlank(modInternalId)) { return modInternalId; + } return null; } @Transient @JsonIgnore public String getSubmittedIdentifier() { - if (StringUtils.isNotBlank(modEntityId)) + if (StringUtils.isNotBlank(modEntityId)) { return modEntityId; - if (StringUtils.isNotBlank(modInternalId)) + } + if (StringUtils.isNotBlank(modInternalId)) { return modInternalId; + } return null; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java index dd0687e2e..6e437f466 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java @@ -45,7 +45,7 @@ @Index(name = "bulkload_updatedby_index", columnList = "updatedBy_id"), @Index(name = "bulkload_backendBulkLoadType_index", columnList = "backendBulkLoadType"), @Index(name = "bulkload_ontologyType_index", columnList = "ontologyType"), - @Index(name = "bulkload_bulkloadStatus_index", columnList = "bulkloadStatus"), + @Index(name = "bulkload_bulkloadStatus_index", columnList = "bulkloadStatus") } ) public abstract class BulkLoad extends AuditedObject { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java index 0edac2a37..49a4d5551 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java @@ -45,7 +45,7 @@ @Index(name = "bulkloadfile_bulkLoad_index", columnList = "bulkLoad_id"), @Index(name = "bulkloadfile_createdby_index", columnList = "createdBy_id"), @Index(name = "bulkloadfile_updatedby_index", columnList = "updatedBy_id"), - @Index(name = "bulkloadfile_bulkloadStatus_index", columnList = "bulkloadStatus"), + @Index(name = "bulkloadfile_bulkloadStatus_index", columnList = "bulkloadStatus") } ) public class BulkLoadFile extends AuditedObject { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileException.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileException.java index cdd893bd0..bff525d65 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileException.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileException.java @@ -33,7 +33,7 @@ indexes = { @Index(name = "bulkloadfileexception_bulkLoadFileHistory_index", columnList = "bulkLoadFileHistory_id"), @Index(name = "bulkloadfileexception_createdby_index", columnList = "createdBy_id"), - @Index(name = "bulkloadfileexception_updatedby_index", columnList = "updatedBy_id"), + @Index(name = "bulkloadfileexception_updatedby_index", columnList = "updatedBy_id") } ) //TODO: define this class in LinkML once class definition matured diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java index 06305f67a..a27624c4e 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java @@ -36,7 +36,7 @@ indexes = { @Index(name = "bulkloadfilehistory_bulkLoadFile_index", columnList = "bulkLoadFile_id"), @Index(name = "bulkloadfilehistory_createdby_index", columnList = "createdBy_id"), - @Index(name = "bulkloadfilehistory_updatedby_index", columnList = "updatedBy_id"), + @Index(name = "bulkloadfilehistory_updatedby_index", columnList = "updatedBy_id") } ) public class BulkLoadFileHistory extends AuditedObject { @@ -48,25 +48,25 @@ public class BulkLoadFileHistory extends AuditedObject { private LocalDateTime loadFinished; @JsonView({ View.FieldsOnly.class }) - private Long totalRecords = 0l; + private Long totalRecords; @JsonView({ View.FieldsOnly.class }) - private Long failedRecords = 0l; + private Long failedRecords; @JsonView({ View.FieldsOnly.class }) - private Long completedRecords = 0l; + private Long completedRecords; @JsonView({ View.FieldsOnly.class }) - private Long totalDeleteRecords = 0l; + private Long totalDeleteRecords; @JsonView({ View.FieldsOnly.class }) - private Long deletedRecords = 0l; + private Long deletedRecords; @JsonView({ View.FieldsOnly.class }) - private Long deleteFailedRecords = 0l; + private Long deleteFailedRecords; @JsonView({ View.FieldsOnly.class }) - private Double errorRate = 0.0; + private Double errorRate; @ManyToOne @OnDelete(action = OnDeleteAction.CASCADE) @@ -83,7 +83,7 @@ public BulkLoadFileHistory(long totalRecords) { @Transient public void incrementCompleted() { - if(errorRate > 0) { + if (errorRate > 0) { errorRate -= 1d / 1000d; } completedRecords++; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/NCBITaxonTerm.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/NCBITaxonTerm.java index fd81018ed..3bd269774 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/NCBITaxonTerm.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/NCBITaxonTerm.java @@ -23,10 +23,11 @@ public class NCBITaxonTerm extends OntologyTerm { @Transient @JsonIgnore public String getGenusSpecies() { - if (name == null) + if (name == null) { return null; + } String[] nameParts = name.split(" "); return nameParts[0] + " " + nameParts[1]; } - + } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java index d5001493b..134613a09 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java @@ -48,7 +48,7 @@ indexes = { @Index(name = "ontologyterm_curie_index", columnList = "curie"), @Index(name = "ontologyterm_createdby_index", columnList = "createdBy_id"), - @Index(name = "ontologyterm_updatedby_index", columnList = "updatedBy_id"), + @Index(name = "ontologyterm_updatedby_index", columnList = "updatedBy_id") }, uniqueConstraints = { @UniqueConstraint(name = "ontologyterm_curie_uk", columnNames = "curie") @@ -148,30 +148,34 @@ public class OntologyTerm extends CurieObject { @Transient public void addIsaChild(OntologyTerm term) { - if (isaChildren == null) + if (isaChildren == null) { isaChildren = new HashSet(); + } isaChildren.add(term); } @Transient public void addIsaParent(OntologyTerm term) { - if (isaParents == null) + if (isaParents == null) { isaParents = new HashSet(); + } isaParents.add(term); } @Transient public void addIsaDescendant(OntologyTerm term) { - if (isaDescendants == null) + if (isaDescendants == null) { isaDescendants = new HashSet(); + } isaDescendants.add(term); } @Transient public void addIsaAncestor(OntologyTerm term) { - if (isaAncestors == null) + if (isaAncestors == null) { isaAncestors = new HashSet(); + } isaAncestors.add(term); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java index 090397126..5086889cb 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "AlleleFullNameSlotAnnotation", description = "POJO representing an allele full name slot annotation") -@Table(indexes = { @Index(name = "allelefullname_singleallele_index", columnList = "singleallele_id"), }) +@Table(indexes = { @Index(name = "allelefullname_singleallele_index", columnList = "singleallele_id") }) public class AlleleFullNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java index e8aaee170..6ea256d75 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java @@ -54,7 +54,7 @@ public class AlleleFunctionalImpactSlotAnnotation extends SlotAnnotation { @ManyToMany @Fetch(FetchMode.SELECT) @JoinTable(indexes = { @Index(name = "allelefunctionalimpactsa_vocabterm_afisa_index", columnList = "allelefunctionalimpactslotannotation_id"), - @Index(name = "allelefunctionalimpactsa_vocabterm_functionalimpacts_index", columnList = "functionalimpacts_id"), }) + @Index(name = "allelefunctionalimpactsa_vocabterm_functionalimpacts_index", columnList = "functionalimpacts_id") }) @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List functionalImpacts; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java index 1c0f0e0fc..d23436f00 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java @@ -46,7 +46,7 @@ public class AlleleMutationTypeSlotAnnotation extends SlotAnnotation { @ManyToMany @Fetch(FetchMode.SELECT) @JoinTable(indexes = { @Index(name = "allelemutationtypesa_soterm_amsa_index", columnList = "allelemutationtypeslotannotation_id"), - @Index(name = "allelemutationtypesa_soterm_mutationtypes_index", columnList = "mutationtypes_id"), }) + @Index(name = "allelemutationtypesa_soterm_mutationtypes_index", columnList = "mutationtypes_id") }) @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List mutationTypes; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java index 727014b2d..c61be7b64 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java @@ -23,7 +23,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleSecondaryIdSlotAnnotation", description = "POJO representing an allele secondary ID slot annotation") -@Table(indexes = { @Index(name = "allelesecondaryid_singleallele_index", columnList = "singleallele_id"), }) +@Table(indexes = { @Index(name = "allelesecondaryid_singleallele_index", columnList = "singleallele_id") }) public class AlleleSecondaryIdSlotAnnotation extends SecondaryIdSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java index cbc11f4eb..c384b2836 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "AlleleSymbolSlotAnnotation", description = "POJO representing an allele symbol slot annotation") -@Table(indexes = { @Index(name = "allelesymbol_singleallele_index", columnList = "singleallele_id"), }) +@Table(indexes = { @Index(name = "allelesymbol_singleallele_index", columnList = "singleallele_id") }) public class AlleleSymbolSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java index f2e2f9c25..d04b130da 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "AlleleSynonymSlotAnnotation", description = "POJO representing an allele synonym slot annotation") -@Table(indexes = { @Index(name = "allelesynonym_singleallele_index", columnList = "singleallele_id"), }) +@Table(indexes = { @Index(name = "allelesynonym_singleallele_index", columnList = "singleallele_id") }) public class AlleleSynonymSlotAnnotation extends NameSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java index 1846cb3c5..eb0422054 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java @@ -83,6 +83,11 @@ public class ConstructComponentSlotAnnotation extends SlotAnnotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToMany @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) - @JoinTable(indexes = { @Index(name = "constructcomponentsa_note_ccsa_index", columnList = "constructcomponentslotannotation_id"), @Index(name = "constructcomponentsa_note_relatednotes_index",columnList = "relatednotes_id")}) + @JoinTable( + indexes = { + @Index(name = "constructcomponentsa_note_ccsa_index", columnList = "constructcomponentslotannotation_id"), + @Index(name = "constructcomponentsa_note_relatednotes_index", columnList = "relatednotes_id") + } + ) private List relatedNotes; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java index 8e7c90eb4..6eca7ca3d 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "ConstructFullNameSlotAnnotation", description = "POJO representing a construct full name slot annotation") -@Table(indexes = { @Index(name = "constructfullname_singleconstruct_index", columnList = "singleconstruct_id"), }) +@Table(indexes = { @Index(name = "constructfullname_singleconstruct_index", columnList = "singleconstruct_id") }) public class ConstructFullNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java index c1aa33fa7..fe6926c4a 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "ConstructSymbolSlotAnnotation", description = "POJO representing a construct symbol slot annotation") -@Table(indexes = { @Index(name = "constructsymbol_singleconstruct_index", columnList = "singleconstruct_id"), }) +@Table(indexes = { @Index(name = "constructsymbol_singleconstruct_index", columnList = "singleconstruct_id") }) public class ConstructSymbolSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java index dc4582151..82f895f76 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "ConstructSynonymSlotAnnotation", description = "POJO representing a construct synonym slot annotation") -@Table(indexes = { @Index(name = "constructsynonym_singleconstruct_index", columnList = "singleconstruct_id"), }) +@Table(indexes = { @Index(name = "constructsynonym_singleconstruct_index", columnList = "singleconstruct_id") }) public class ConstructSynonymSlotAnnotation extends NameSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java index 0a1d9f935..630da4b8c 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneFullNameSlotAnnotation", description = "POJO representing a gene full name slot annotation") -@Table(indexes = { @Index(name = "genefullname_singlegene_index", columnList = "singlegene_id"), }) +@Table(indexes = { @Index(name = "genefullname_singlegene_index", columnList = "singlegene_id") }) public class GeneFullNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java index 46df33a11..de66ef259 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java @@ -23,7 +23,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.7.2", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "GeneSecondaryIdSlotAnnotation", description = "POJO representing a gene secondary ID slot annotation") -@Table(indexes = { @Index(name = "genesecondaryid_singlegene_index", columnList = "singlegene_id"), }) +@Table(indexes = { @Index(name = "genesecondaryid_singlegene_index", columnList = "singlegene_id") }) public class GeneSecondaryIdSlotAnnotation extends SecondaryIdSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java index e7ef28b8f..b55cf3898 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneSymbolSlotAnnotation", description = "POJO representing a gene symbol slot annotation") -@Table(indexes = { @Index(name = "genesymbol_singlegene_index", columnList = "singlegene_id"), }) +@Table(indexes = { @Index(name = "genesymbol_singlegene_index", columnList = "singlegene_id") }) public class GeneSymbolSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java index 1b1a8521b..22ee85268 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneSynonymSlotAnnotation", description = "POJO representing a gene synonym slot annotation") -@Table(indexes = { @Index(name = "genesynonym_singlegene_index", columnList = "singlegene_id"), }) +@Table(indexes = { @Index(name = "genesynonym_singlegene_index", columnList = "singlegene_id") }) public class GeneSynonymSlotAnnotation extends NameSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java index 8f750f48a..72042e3b0 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java @@ -22,7 +22,7 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneSystematicNameSlotAnnotation", description = "POJO representing a gene systematic name slot annotation") -@Table(indexes = { @Index(name = "genesystematicname_singlegene_index", columnList = "singlegene_id"), }) +@Table(indexes = { @Index(name = "genesystematicname_singlegene_index", columnList = "singlegene_id") }) public class GeneSystematicNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/mati/Identifier.java b/src/main/java/org/alliancegenome/curation_api/model/mati/Identifier.java index c7c871bdf..9955ce565 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/mati/Identifier.java +++ b/src/main/java/org/alliancegenome/curation_api/model/mati/Identifier.java @@ -1,5 +1,7 @@ package org.alliancegenome.curation_api.model.mati; +import com.fasterxml.jackson.annotation.JsonProperty; + import lombok.AllArgsConstructor; import lombok.Data; @@ -7,7 +9,9 @@ @AllArgsConstructor public class Identifier { private Long counter; - private String subdomain_code; - private String subdomain_name; + @JsonProperty("subdomain_code") + private String subdomainCode; + @JsonProperty("subdomain_name") + private String subdomainName; private String curie; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/okta/OktaToken.java b/src/main/java/org/alliancegenome/curation_api/model/okta/OktaToken.java index 0a7d5969a..5bccdead1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/okta/OktaToken.java +++ b/src/main/java/org/alliancegenome/curation_api/model/okta/OktaToken.java @@ -1,12 +1,17 @@ package org.alliancegenome.curation_api.model.okta; +import com.fasterxml.jackson.annotation.JsonProperty; + import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor public class OktaToken { - private String token_type; - private Integer expires_in; - private String access_token; + @JsonProperty("token_type") + private String tokenType; + @JsonProperty("expires_in") + private Integer expiresIn; + @JsonProperty("access_token") + private String accessToken; } diff --git a/src/main/java/org/alliancegenome/curation_api/response/APIResponse.java b/src/main/java/org/alliancegenome/curation_api/response/APIResponse.java index 3b3669d60..fe3f6a434 100644 --- a/src/main/java/org/alliancegenome/curation_api/response/APIResponse.java +++ b/src/main/java/org/alliancegenome/curation_api/response/APIResponse.java @@ -15,36 +15,35 @@ @Data public class APIResponse { - @JsonView({ View.FieldsOnly.class }) - private String errorMessage; + @JsonView({ View.FieldsOnly.class }) private String errorMessage; + + @JsonView({ View.FieldsOnly.class }) private Map errorMessages; - @JsonView({ View.FieldsOnly.class }) - private Map errorMessages; - @org.eclipse.microprofile.graphql.Ignore - @JsonView({ View.FieldsOnly.class }) - private Map supplementalData = new HashMap<>(); + @JsonView({ View.FieldsOnly.class }) private Map supplementalData = new HashMap<>(); - @JsonView({ View.FieldsOnly.class }) - private String requestDuration; + @JsonView({ View.FieldsOnly.class }) private String requestDuration; public void addErrorMessage(String fieldName, String errorMessage) { - if (errorMessages == null) + if (errorMessages == null) { errorMessages = new HashMap<>(3); + } errorMessages.put(fieldName, errorMessage); } public void addErrorMessages(Map newErrorMessages) { if (newErrorMessages != null) { - if (errorMessages == null) + if (errorMessages == null) { errorMessages = new HashMap<>(); + } errorMessages.putAll(newErrorMessages); } } - + public void addErrorMessages(String fieldName, Object fieldErrorMessages) { SupplementalDataHelper.addFieldErrorMessages(supplementalData, fieldName, fieldErrorMessages); } + public void addErrorMessages(String fieldName, Integer rowIndex, Object fieldErrorMessages) { SupplementalDataHelper.addRowFieldErrorMessages(supplementalData, fieldName, rowIndex, fieldErrorMessages); } @@ -54,15 +53,17 @@ public boolean hasErrors() { } public String errorMessagesString() { - if (errorMessages == null) + if (errorMessages == null) { return null; + } return errorMessages.entrySet().stream().map(m -> m.getKey() + " - " + m.getValue()).sorted().collect(Collectors.joining(" | ")); } - + public void convertErrorMessagesToMap() { - if (errorMessages == null) + if (errorMessages == null) { return; - + } + for (Map.Entry reportedError : errorMessages.entrySet()) { SupplementalDataHelper.addFieldErrorMessages(supplementalData, reportedError.getKey(), reportedError.getValue()); } @@ -70,7 +71,7 @@ public void convertErrorMessagesToMap() { public void convertMapToErrorMessages(String fieldName) { String consolidatedMessages = SupplementalDataHelper.convertMapToFieldErrorMessages(supplementalData, fieldName); - if(consolidatedMessages != null) { + if (consolidatedMessages != null) { addErrorMessage(fieldName, consolidatedMessages); } } diff --git a/src/main/java/org/alliancegenome/curation_api/response/SupplementalDataHelper.java b/src/main/java/org/alliancegenome/curation_api/response/SupplementalDataHelper.java index a5878bc78..e39980b32 100644 --- a/src/main/java/org/alliancegenome/curation_api/response/SupplementalDataHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/response/SupplementalDataHelper.java @@ -13,11 +13,15 @@ public class SupplementalDataHelper { + private SupplementalDataHelper() { + // Hidden from view, as it is a utility class + } + public static final String ERROR_MAP = "errorMap"; - + public static void addFieldErrorMessages(Map supplementalData, String fieldName, Object fieldErrorMessages) { Map errorMap = getErrorMap(supplementalData); - if(!errorMap.containsKey(fieldName)) { + if (!errorMap.containsKey(fieldName)) { errorMap.put(fieldName, fieldErrorMessages); } else { Log.debug("Error Map already contains errors for field: " + fieldName); @@ -29,44 +33,48 @@ public static void addRowFieldErrorMessages(Map supplementalData Map fieldErrorMap = getFieldErrorMap(supplementalData, fieldName); fieldErrorMap.put(Integer.toString(rowIndex), fieldErrorMessages); } - + private static Map getFieldErrorMap(Map supplementalData, String fieldName) { Map errorMap = getErrorMap(supplementalData); - + Map fieldErrorMap = (Map) errorMap.get(fieldName); if (fieldErrorMap == null) { fieldErrorMap = new LinkedHashMap<>(); errorMap.put(fieldName, fieldErrorMap); } - return (Map)errorMap.get(fieldName); + return (Map) errorMap.get(fieldName); } private static Map getErrorMap(Map supplementalData) { - if(!supplementalData.containsKey(ERROR_MAP)) { + if (!supplementalData.containsKey(ERROR_MAP)) { supplementalData.put(ERROR_MAP, new LinkedHashMap<>()); } - return (Map)supplementalData.get(ERROR_MAP); + return (Map) supplementalData.get(ERROR_MAP); } public static String convertMapToFieldErrorMessages(Map supplementalData, String fieldName) { - if(!supplementalData.containsKey(ERROR_MAP)) return null; + if (!supplementalData.containsKey(ERROR_MAP)) { + return null; + } Map errorMap = (Map) supplementalData.get(ERROR_MAP); Map fieldErrorMap = (Map) errorMap.get(fieldName); - if (fieldErrorMap == null) + if (fieldErrorMap == null) { return null; - + } + Map> consolidatedErrors = new LinkedHashMap<>(); for (Map.Entry fieldRowError : fieldErrorMap.entrySet()) { Map subfieldErrors = (Map) fieldRowError.getValue(); for (Map.Entry subfieldError : subfieldErrors.entrySet()) { Set uniqueSubfieldErrors = consolidatedErrors.get(subfieldError.getKey()); - if (uniqueSubfieldErrors == null) + if (uniqueSubfieldErrors == null) { uniqueSubfieldErrors = new HashSet<>(); + } uniqueSubfieldErrors.add(subfieldError.getValue()); consolidatedErrors.put(subfieldError.getKey(), uniqueSubfieldErrors); } } - + List consolidatedMessages = new ArrayList<>(); for (Map.Entry> consolidatedError : consolidatedErrors.entrySet()) { consolidatedMessages.add(consolidatedError.getKey() + " - " + consolidatedError.getValue().stream().sorted().collect(Collectors.joining("/"))); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java index dfe46d5fa..04cb2e379 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java @@ -21,16 +21,11 @@ @RequestScoped public class AGMDiseaseAnnotationService extends BaseAnnotationDTOCrudService { - @Inject - AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; - @Inject - AGMDiseaseAnnotationValidator agmDiseaseValidator; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - DiseaseAnnotationService diseaseAnnotationService; - @Inject - AGMDiseaseAnnotationDTOValidator agmDiseaseAnnotationDtoValidator; + @Inject AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; + @Inject AGMDiseaseAnnotationValidator agmDiseaseValidator; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject DiseaseAnnotationService diseaseAnnotationService; + @Inject AGMDiseaseAnnotationDTOValidator agmDiseaseAnnotationDtoValidator; @Override @PostConstruct @@ -72,8 +67,7 @@ public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataPro } @Override - public AGMDiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, - String loadDescription, Boolean deprecate) { - return (AGMDiseaseAnnotation) diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(id, throwApiError, loadDescription, deprecate); + public AGMDiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { + return (AGMDiseaseAnnotation) diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(id, throwApiError, loadDescription, deprecate); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java index d8d2af8c9..fc59ea6ba 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java @@ -21,14 +21,10 @@ @RequestScoped public class AGMPhenotypeAnnotationService extends BaseAnnotationCrudService { - @Inject - AGMPhenotypeAnnotationDAO agmPhenotypeAnnotationDAO; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; - @Inject - AGMPhenotypeAnnotationFmsDTOValidator agmPhenotypeAnnotationFmsDtoValidator; + @Inject AGMPhenotypeAnnotationDAO agmPhenotypeAnnotationDAO; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; + @Inject AGMPhenotypeAnnotationFmsDTOValidator agmPhenotypeAnnotationFmsDtoValidator; @Override @PostConstruct @@ -53,7 +49,7 @@ public AGMPhenotypeAnnotation upsertPrimaryAnnotation(AffectedGenomicModel subje AGMPhenotypeAnnotation annotation = agmPhenotypeAnnotationFmsDtoValidator.validatePrimaryAnnotation(subject, dto, dataProvider); return agmPhenotypeAnnotationDAO.persist(annotation); } - + @Transactional public void addInferredOrAssertedEntities(AffectedGenomicModel primaryAnnotationSubject, PhenotypeFmsDTO secondaryAnnotationDto, List idsAdded, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { AGMPhenotypeAnnotation annotation = agmPhenotypeAnnotationFmsDtoValidator.validateInferredOrAssertedEntities(primaryAnnotationSubject, secondaryAnnotationDto, idsAdded, dataProvider); @@ -73,8 +69,7 @@ public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataPro } @Override - public AGMPhenotypeAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, - String loadDescription, Boolean deprecate) { + public AGMPhenotypeAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { return (AGMPhenotypeAnnotation) phenotypeAnnotationService.deprecateOrDeleteAnnotationAndNotes(id, throwApiError, loadDescription, deprecate); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/APIVersionInfoService.java b/src/main/java/org/alliancegenome/curation_api/services/APIVersionInfoService.java index 2cac2617c..a49560397 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/APIVersionInfoService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/APIVersionInfoService.java @@ -15,14 +15,16 @@ public class APIVersionInfoService { public Boolean isPartiallyImplemented(Class clazz, AGRCurationSchemaVersion version) { - if (version.partial()) + if (version.partial()) { return true; + } Set> dependencyClasses = getDependencyClasses(version); for (Class dependencyClass : dependencyClasses) { AGRCurationSchemaVersion dependencyVersion = dependencyClass.getAnnotation(AGRCurationSchemaVersion.class); - if (dependencyVersion.partial()) + if (dependencyVersion.partial()) { return true; + } } return false; @@ -58,14 +60,17 @@ private String getLowestVersion(String version1, String version2) { List vParts1 = getVersionParts(version1); List vParts2 = getVersionParts(version2); - if (vParts1.get(0) < vParts2.get(0)) + if (vParts1.get(0) < vParts2.get(0)) { return version1; + } if (vParts1.get(0).equals(vParts2.get(0))) { - if (vParts1.get(1) < vParts2.get(1)) + if (vParts1.get(1) < vParts2.get(1)) { return version1; + } if (vParts1.get(1).equals(vParts2.get(1))) { - if (vParts1.get(2) < vParts2.get(2)) + if (vParts1.get(2) < vParts2.get(2)) { return version1; + } } } return version2; @@ -100,4 +105,4 @@ private Set> getDependencyClasses(AGRCurationSchemaVersion version) { return dependencyClasses; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java index 8eab130e1..9c2a19d1f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java @@ -33,36 +33,28 @@ @RequestScoped public class AffectedGenomicModelService extends SubmittedObjectCrudService { - @Inject - AffectedGenomicModelDAO agmDAO; - @Inject - AlleleDAO alleleDAO; - @Inject - AffectedGenomicModelValidator agmValidator; - @Inject - AffectedGenomicModelDTOValidator agmDtoValidator; - @Inject - DiseaseAnnotationService diseaseAnnotationService; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; - @Inject - PersonService personService; - @Inject - ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; + @Inject AffectedGenomicModelDAO agmDAO; + @Inject AlleleDAO alleleDAO; + @Inject AffectedGenomicModelValidator agmValidator; + @Inject AffectedGenomicModelDTOValidator agmDtoValidator; + @Inject DiseaseAnnotationService diseaseAnnotationService; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; + @Inject PersonService personService; + @Inject ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; @Override @PostConstruct protected void init() { setSQLDao(agmDAO); } - + @Override @Transactional public ObjectResponse update(AffectedGenomicModel uiEntity) { AffectedGenomicModel dbEntity = agmDAO.persist(agmValidator.validateAffectedGenomicModelUpdate(uiEntity)); return new ObjectResponse(dbEntity); } - + @Override @Transactional public ObjectResponse create(AffectedGenomicModel uiEntity) { @@ -74,8 +66,9 @@ public ObjectResponse create(AffectedGenomicModel uiEntity public AffectedGenomicModel upsert(AffectedGenomicModelDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { AffectedGenomicModel agm = agmDtoValidator.validateAffectedGenomicModelDTO(dto, dataProvider); - if (agm == null) + if (agm == null) { return null; + } return agmDAO.persist(agm); } @@ -88,20 +81,23 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { Boolean anyReferencingEntities = false; for (Long daId : referencingDAIds) { DiseaseAnnotation referencingDA = diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(daId, false, loadDescription, true); - if (referencingDA != null) + if (referencingDA != null) { anyReferencingEntities = true; + } } List referencingPAIds = agmDAO.findReferencingPhenotypeAnnotations(id); for (Long paId : referencingPAIds) { PhenotypeAnnotation referencingPA = phenotypeAnnotationService.deprecateOrDeleteAnnotationAndNotes(paId, false, loadDescription, true); - if (referencingPA != null) + if (referencingPA != null) { anyReferencingEntities = true; + } } if (CollectionUtils.isNotEmpty(agm.getConstructGenomicEntityAssociations())) { for (ConstructGenomicEntityAssociation association : agm.getConstructGenomicEntityAssociations()) { association = constructGenomicEntityAssociationService.deprecateOrDeleteAssociation(association.getId(), false, loadDescription, true); - if (association != null) + if (association != null) { anyReferencingEntities = true; + } } } @@ -119,7 +115,7 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { log.error("Failed getting AGM: " + id); } } - + public List getIdsByDataProvider(String dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java index 31bb40225..343959930 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java @@ -20,14 +20,10 @@ @RequestScoped public class AlleleDiseaseAnnotationService extends BaseAnnotationDTOCrudService { - @Inject - AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; - @Inject - AlleleDiseaseAnnotationValidator alleleDiseaseValidator; - @Inject - AlleleDiseaseAnnotationDTOValidator alleleDiseaseAnnotationDtoValidator; - @Inject - DiseaseAnnotationService diseaseAnnotationService; + @Inject AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; + @Inject AlleleDiseaseAnnotationValidator alleleDiseaseValidator; + @Inject AlleleDiseaseAnnotationDTOValidator alleleDiseaseAnnotationDtoValidator; + @Inject DiseaseAnnotationService diseaseAnnotationService; @Override @PostConstruct @@ -67,10 +63,9 @@ public ObjectResponse deleteById(Long id) { public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { return diseaseAnnotationService.getAnnotationIdsByDataProvider(alleleDiseaseAnnotationDAO, dataProvider); } - + @Override - public AlleleDiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, - String loadDescription, Boolean deprecate) { + public AlleleDiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { return (AlleleDiseaseAnnotation) diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(id, throwApiError, loadDescription, deprecate); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java index 7cb434b62..fa88e3132 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java @@ -20,15 +20,11 @@ @RequestScoped public class AllelePhenotypeAnnotationService extends BaseAnnotationCrudService { - - @Inject - AllelePhenotypeAnnotationDAO allelePhenotypeAnnotationDAO; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; - @Inject - AllelePhenotypeAnnotationFmsDTOValidator allelePhenotypeAnnotationFmsDtoValidator; + + @Inject AllelePhenotypeAnnotationDAO allelePhenotypeAnnotationDAO; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; + @Inject AllelePhenotypeAnnotationFmsDTOValidator allelePhenotypeAnnotationFmsDtoValidator; @Override @PostConstruct @@ -53,7 +49,7 @@ public AllelePhenotypeAnnotation upsertPrimaryAnnotation(Allele subject, Phenoty AllelePhenotypeAnnotation annotation = allelePhenotypeAnnotationFmsDtoValidator.validatePrimaryAnnotation(subject, dto, dataProvider); return allelePhenotypeAnnotationDAO.persist(annotation); } - + @Transactional public void addInferredOrAssertedEntities(Allele primaryAnnotationSubject, PhenotypeFmsDTO secondaryAnnotationDto, List idsAdded, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { AllelePhenotypeAnnotation annotation = allelePhenotypeAnnotationFmsDtoValidator.validateInferredOrAssertedEntities(primaryAnnotationSubject, secondaryAnnotationDto, idsAdded, dataProvider); @@ -73,8 +69,7 @@ public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataPro } @Override - public AllelePhenotypeAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, - String loadDescription, Boolean deprecate) { + public AllelePhenotypeAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { return (AllelePhenotypeAnnotation) phenotypeAnnotationService.deprecateOrDeleteAnnotationAndNotes(id, throwApiError, loadDescription, deprecate); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java index 61e6ecf15..bad894779 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java @@ -55,13 +55,13 @@ public ObjectResponse update(Allele uiEntity) { Allele dbEntity = alleleValidator.validateAlleleUpdate(uiEntity, false); return new ObjectResponse(dbEntity); } - + @Transactional public ObjectResponse updateDetail(Allele uiEntity) { Allele dbEntity = alleleValidator.validateAlleleUpdate(uiEntity, true); return new ObjectResponse(dbEntity); } - + @Override @Transactional public ObjectResponse create(Allele uiEntity) { @@ -72,7 +72,7 @@ public ObjectResponse create(Allele uiEntity) { public Allele upsert(AlleleDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { return alleleDtoValidator.validateAlleleDTO(dto, dataProvider); } - + @Override @Transactional public ObjectResponse deleteById(Long id) { @@ -80,7 +80,7 @@ public ObjectResponse deleteById(Long id) { ObjectResponse ret = new ObjectResponse<>(); return ret; } - + @Transactional public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { Allele allele = alleleDAO.find(id); @@ -89,28 +89,32 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { Boolean anyReferencingEntities = false; for (Long daId : referencingDAIds) { DiseaseAnnotation referencingDA = diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(daId, false, loadDescription, true); - if (referencingDA != null) + if (referencingDA != null) { anyReferencingEntities = true; + } } List referencingPAIds = alleleDAO.findReferencingPhenotypeAnnotations(id); for (Long paId : referencingPAIds) { PhenotypeAnnotation referencingPA = phenotypeAnnotationService.deprecateOrDeleteAnnotationAndNotes(paId, false, loadDescription, true); - if (referencingPA != null) + if (referencingPA != null) { anyReferencingEntities = true; + } } if (CollectionUtils.isNotEmpty(allele.getAlleleGeneAssociations())) { for (AlleleGeneAssociation association : allele.getAlleleGeneAssociations()) { association = alleleGeneAssociationService.deprecateOrDeleteAssociation(association.getId(), false, loadDescription, true); - if (association != null) + if (association != null) { anyReferencingEntities = true; + } } } if (CollectionUtils.isNotEmpty(allele.getConstructGenomicEntityAssociations())) { for (ConstructGenomicEntityAssociation association : allele.getConstructGenomicEntityAssociations()) { association = constructGenomicEntityAssociationService.deprecateOrDeleteAssociation(association.getId(), false, loadDescription, true); - if (association != null) + if (association != null) { anyReferencingEntities = true; + } } } if (anyReferencingEntities) { @@ -127,7 +131,7 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { log.error("Failed getting allele: " + id); } } - + public List getIdsByDataProvider(String dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider); diff --git a/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java b/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java index 2f17fec9f..9d171bae4 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java @@ -14,8 +14,7 @@ @RequestScoped public class BiologicalEntityService extends SubmittedObjectCrudService { - @Inject - BiologicalEntityDAO biologicalEntityDAO; + @Inject BiologicalEntityDAO biologicalEntityDAO; @Override @PostConstruct @@ -24,11 +23,11 @@ protected void init() { } @Override - public BiologicalEntity upsert(BiologicalEntityDTO dto, BackendBulkDataProvider dataProvider) - throws ObjectUpdateException { + public BiologicalEntity upsert(BiologicalEntityDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { return null; } @Override - public void removeOrDeprecateNonUpdated(Long id, String loadDescription) {} + public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ConditionRelationService.java b/src/main/java/org/alliancegenome/curation_api/services/ConditionRelationService.java index cad27769f..ba4606561 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ConditionRelationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ConditionRelationService.java @@ -27,16 +27,11 @@ @RequestScoped public class ConditionRelationService extends BaseEntityCrudService { - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - ConditionRelationValidator conditionRelationValidator; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - ZecoTermDAO zecoTermDAO; - @Inject - ReferenceService referenceService; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject ConditionRelationValidator conditionRelationValidator; + @Inject VocabularyTermService vocabularyTermService; + @Inject ZecoTermDAO zecoTermDAO; + @Inject ReferenceService referenceService; @Override @PostConstruct @@ -99,7 +94,8 @@ public SearchResponse getConditionRelationSearchResponse(Hash SearchResponse conditionRelationSearchResponse = conditionRelationDAO.findByField(key, referenceID); Optional standardOptional = Optional.empty(); Optional genericOptional = Optional.empty(); - // add standard experiments (standard, generic_control) if not present as per ZFIN requirement + // add standard experiments (standard, generic_control) if not present as per + // ZFIN requirement if (conditionRelationSearchResponse != null) { standardOptional = conditionRelationSearchResponse.getResults().stream().filter(conditionRelation -> conditionRelation.getHandle().equals(ConditionRelation.Constant.HANDLE_STANDARD)).findFirst(); genericOptional = conditionRelationSearchResponse.getResults().stream().filter(conditionRelation -> conditionRelation.getHandle().equals(ConditionRelation.Constant.HANDLE_GENERIC_CONTROL)).findFirst(); @@ -121,7 +117,7 @@ public SearchResponse getConditionRelationSearchResponse(Hash public void deleteUnusedConditions(List inUseCrIds) { ProcessDisplayHelper pdh = new ProcessDisplayHelper(); - + List crIds = conditionRelationDAO.findAllIds().getResults(); pdh.startProcess("Delete unused Conditions", crIds.size()); crIds.forEach(crId -> { diff --git a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java index 2d0211829..357905829 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java @@ -33,20 +33,13 @@ @RequestScoped public class ConstructService extends SubmittedObjectCrudService { - @Inject - ConstructDAO constructDAO; - @Inject - ConstructValidator constructValidator; - @Inject - ConstructDTOValidator constructDtoValidator; - @Inject - ConstructService constructService; - @Inject - PersonService personService; - @Inject - ConstructComponentSlotAnnotationDAO constructComponentDAO; - @Inject - ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; + @Inject ConstructDAO constructDAO; + @Inject ConstructValidator constructValidator; + @Inject ConstructDTOValidator constructDtoValidator; + @Inject ConstructService constructService; + @Inject PersonService personService; + @Inject ConstructComponentSlotAnnotationDAO constructComponentDAO; + @Inject ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; @Override @PostConstruct @@ -59,8 +52,9 @@ public ObjectResponse getByIdentifier(String identifier) { Construct construct = findByIdentifierString(identifier); if (construct == null) { SearchResponse response = findByField("uniqueId", identifier); - if (response != null) + if (response != null) { construct = response.getSingleResult(); + } } return new ObjectResponse(construct); } @@ -93,7 +87,7 @@ public ObjectResponse deleteById(Long id) { ObjectResponse ret = new ObjectResponse<>(); return ret; } - + @Transactional public Construct removeOrDeprecateNonUpdated(Long id, Boolean throwApiError, String loadDescription) { Construct construct = constructDAO.find(id); @@ -108,13 +102,14 @@ public Construct removeOrDeprecateNonUpdated(Long id, Boolean throwApiError, Str log.error(errorMessage); return null; } - + Boolean anyReferencingEntities = false; if (CollectionUtils.isNotEmpty(construct.getConstructGenomicEntityAssociations())) { for (ConstructGenomicEntityAssociation association : construct.getConstructGenomicEntityAssociations()) { association = constructGenomicEntityAssociationService.deprecateOrDeleteAssociation(association.getId(), false, loadDescription, true); - if (association != null) + if (association != null) { anyReferencingEntities = true; + } } } @@ -139,14 +134,15 @@ public Construct removeOrDeprecateNonUpdated(Long id, Boolean throwApiError, Str } @Override - public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { } + public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { + } public List getConstructIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); List constructIds = constructDAO.findFilteredIds(params); constructIds.removeIf(Objects::isNull); - + return constructIds; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java b/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java index 9a38bf9be..21aa5a345 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java @@ -21,10 +21,8 @@ @RequestScoped public class CrossReferenceService extends BaseEntityCrudService { - @Inject - CrossReferenceDAO crossReferenceDAO; - @Inject - ResourceDescriptorPageService resourceDescriptorPageService; + @Inject CrossReferenceDAO crossReferenceDAO; + @Inject ResourceDescriptorPageService resourceDescriptorPageService; @Override @PostConstruct @@ -37,14 +35,14 @@ public List getMergedFmsXrefList(List fmsC if (CollectionUtils.isNotEmpty(fmsCrossReferences)) { for (CrossReferenceFmsDTO fmsXref : fmsCrossReferences) { String xrefCurie = fmsXref.getCurie(); - if (CollectionUtils.isEmpty(fmsXref.getPages())) + if (CollectionUtils.isEmpty(fmsXref.getPages())) { fmsXref.getPages().add("default"); + } for (String xrefPage : fmsXref.getPages()) { CrossReference xref = new CrossReference(); xref.setReferencedCurie(xrefCurie); xref.setDisplayName(xrefCurie); - String prefix = xrefCurie.indexOf(":") == -1 ? xrefCurie : - xrefCurie.substring(0, xrefCurie.indexOf(":")); + String prefix = xrefCurie.indexOf(":") == -1 ? xrefCurie : xrefCurie.substring(0, xrefCurie.indexOf(":")); ResourceDescriptorPage rdp = resourceDescriptorPageService.getPageForResourceDescriptor(prefix, xrefPage); if (rdp != null) { xref.setResourceDescriptorPage(rdp); @@ -53,10 +51,10 @@ public List getMergedFmsXrefList(List fmsC } } } - + return getUpdatedXrefList(incomingXrefs, existingXrefs); } - + @Transactional public List getUpdatedXrefList(List incomingXrefs, List existingXrefs) { Map existingXrefMap = new HashMap<>(); @@ -65,7 +63,7 @@ public List getUpdatedXrefList(List incomingXref existingXrefMap.put(getCrossReferenceUniqueId(existingXref), existingXref); } } - + List finalXrefs = new ArrayList<>(); if (CollectionUtils.isNotEmpty(incomingXrefs)) { for (CrossReference incomingXref : incomingXrefs) { @@ -77,12 +75,10 @@ public List getUpdatedXrefList(List incomingXref } } } - + return finalXrefs; } - - - + public CrossReference updateCrossReference(CrossReference oldXref, CrossReference newXref) { oldXref.setDisplayName(newXref.getDisplayName()); oldXref.setCreatedBy(newXref.getCreatedBy()); @@ -91,16 +87,17 @@ public CrossReference updateCrossReference(CrossReference oldXref, CrossReferenc oldXref.setDateUpdated(newXref.getDateUpdated()); oldXref.setInternal(newXref.getInternal()); oldXref.setObsolete(newXref.getObsolete()); - + return oldXref; } - + public String getCrossReferenceUniqueId(CrossReference xref) { - if (xref == null) + if (xref == null) { return null; - if (xref.getResourceDescriptorPage() == null) + } + if (xref.getResourceDescriptorPage() == null) { return xref.getReferencedCurie(); - return StringUtils.join( - List.of(xref.getReferencedCurie(), xref.getResourceDescriptorPage().getId()), "|"); + } + return StringUtils.join(List.of(xref.getReferencedCurie(), xref.getResourceDescriptorPage().getId()), "|"); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java b/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java index f27b5e24e..cb0807349 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java @@ -1,6 +1,5 @@ package org.alliancegenome.curation_api.services; - import org.alliancegenome.curation_api.auth.AuthenticatedUser; import org.alliancegenome.curation_api.dao.CrossReferenceDAO; import org.alliancegenome.curation_api.dao.DataProviderDAO; @@ -24,19 +23,13 @@ public class DataProviderService extends BaseEntityCrudService { @Inject - @AuthenticatedUser - protected Person authenticatedPerson; - @Inject - PersonService personService; - @Inject - DataProviderDAO dataProviderDAO; - @Inject - OrganizationDAO organizationDAO; - @Inject - DataProviderValidator dataProviderValidator; - @Inject - CrossReferenceDAO crossReferenceDAO; - + @AuthenticatedUser protected Person authenticatedPerson; + @Inject PersonService personService; + @Inject DataProviderDAO dataProviderDAO; + @Inject OrganizationDAO organizationDAO; + @Inject DataProviderValidator dataProviderValidator; + @Inject CrossReferenceDAO crossReferenceDAO; + @Override @PostConstruct protected void init() { @@ -48,30 +41,31 @@ public DataProvider createAffiliatedModDataProvider() { AllianceMember member = authenticatedPerson.getAllianceMember(); if (member == null) { return createAllianceDataProvider(); - } - + } + return createDataProvider(member); } - + @Transactional public DataProvider createOrganizationDataProvider(String organizationAbbreviation) { SearchResponse orgResponse = organizationDAO.findByField("abbreviation", organizationAbbreviation); - if (orgResponse == null || orgResponse.getSingleResult() == null) + if (orgResponse == null || orgResponse.getSingleResult() == null) { return null; + } Organization member = orgResponse.getSingleResult(); - + return createDataProvider(member); } - + public DataProvider createAllianceDataProvider() { return createOrganizationDataProvider("Alliance"); } - + private DataProvider createDataProvider(Organization member) { DataProvider dataProvider = new DataProvider(); - + dataProvider.setSourceOrganization(member); - + CrossReference xref = new CrossReference(); xref.setDisplayName(member.getAbbreviation()); xref.setReferencedCurie(member.getAbbreviation()); @@ -80,12 +74,13 @@ private DataProvider createDataProvider(Organization member) { return dataProviderDAO.persist(dataProvider); } - + @Transactional public ObjectResponse upsert(DataProvider uiEntity) { ObjectResponse response = dataProviderValidator.validateDataProvider(uiEntity, null, true); - if (response.getEntity() == null) + if (response.getEntity() == null) { return response; + } return new ObjectResponse(response.getEntity()); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java index 475cc47be..e840b66d2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java @@ -28,21 +28,17 @@ @RequestScoped public class DiseaseAnnotationService extends BaseAnnotationCrudService { - @Inject - DiseaseAnnotationDAO diseaseAnnotationDAO; - @Inject - PersonService personService; - @Inject - DiseaseAnnotationUniqueIdUpdateHelper uniqueIdUpdateHelper; - @Inject - PersonDAO personDAO; + @Inject DiseaseAnnotationDAO diseaseAnnotationDAO; + @Inject PersonService personService; + @Inject DiseaseAnnotationUniqueIdUpdateHelper uniqueIdUpdateHelper; + @Inject PersonDAO personDAO; @Override @PostConstruct protected void init() { setSQLDao(diseaseAnnotationDAO); } - + @Override @Transactional public ObjectResponse deleteById(Long id) { @@ -94,17 +90,18 @@ public void updateUniqueIds() { public List getAllReferencedConditionRelationIds() { return getAllReferencedConditionRelationIds(diseaseAnnotationDAO); } - + protected > List getAnnotationIdsByDataProvider(D dao, BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); - - if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) + + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { params.put(EntityFieldConstants.DA_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); - + } + List annotationIds = dao.findFilteredIds(params); annotationIds.removeIf(Objects::isNull); - + if (StringUtils.equals(dataProvider.toString(), "HUMAN")) { Map newParams = new HashMap<>(); newParams.put(EntityFieldConstants.SECONDARY_DATA_PROVIDER, dataProvider.sourceOrganization); @@ -112,7 +109,7 @@ protected > List getAnnotationIdsByDataProvider(D List additionalIds = dao.findFilteredIds(newParams); annotationIds.addAll(additionalIds); } - + return annotationIds; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ExperimentalConditionService.java b/src/main/java/org/alliancegenome/curation_api/services/ExperimentalConditionService.java index 60f5eb407..052fde520 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ExperimentalConditionService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ExperimentalConditionService.java @@ -19,10 +19,8 @@ @RequestScoped public class ExperimentalConditionService extends BaseEntityCrudService { - @Inject - ExperimentalConditionDAO experimentalConditionDAO; - @Inject - ExperimentalConditionValidator experimentalConditionValidator; + @Inject ExperimentalConditionDAO experimentalConditionDAO; + @Inject ExperimentalConditionValidator experimentalConditionValidator; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java index 7493e18af..2b65f3b1c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java @@ -20,14 +20,10 @@ @RequestScoped public class GeneDiseaseAnnotationService extends BaseAnnotationDTOCrudService { - @Inject - GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; - @Inject - GeneDiseaseAnnotationValidator geneDiseaseValidator; - @Inject - GeneDiseaseAnnotationDTOValidator geneDiseaseAnnotationDtoValidator; - @Inject - DiseaseAnnotationService diseaseAnnotationService; + @Inject GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; + @Inject GeneDiseaseAnnotationValidator geneDiseaseValidator; + @Inject GeneDiseaseAnnotationDTOValidator geneDiseaseAnnotationDtoValidator; + @Inject DiseaseAnnotationService diseaseAnnotationService; @Override @PostConstruct @@ -69,8 +65,7 @@ public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataPro } @Override - public GeneDiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, - String loadDescription, Boolean deprecate) { + public GeneDiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { return (GeneDiseaseAnnotation) diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(id, throwApiError, loadDescription, deprecate); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java index f19696561..af65d76cc 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java @@ -20,17 +20,15 @@ @RequestScoped public class GeneGeneticInteractionService extends BaseEntityCrudService implements BaseUpsertServiceInterface { - @Inject - GeneGeneticInteractionDAO geneGeneticInteractionDAO; - @Inject - GeneGeneticInteractionFmsDTOValidator geneGeneticInteractionValidator; - + @Inject GeneGeneticInteractionDAO geneGeneticInteractionDAO; + @Inject GeneGeneticInteractionFmsDTOValidator geneGeneticInteractionValidator; + @Override @PostConstruct protected void init() { setSQLDao(geneGeneticInteractionDAO); } - + public ObjectResponse getByIdentifier(String identifier) { GeneGeneticInteraction interaction = findByAlternativeFields(List.of("interactionId", "uniqueId"), identifier); return new ObjectResponse(interaction); diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneInteractionService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneInteractionService.java index f5b73bf15..3b2d66153 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneInteractionService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneInteractionService.java @@ -19,19 +19,16 @@ @RequestScoped public class GeneInteractionService extends BaseEntityCrudService { - @Inject - GeneInteractionDAO geneInteractionDAO; - @Inject - PersonService personService; - @Inject - PersonDAO personDAO; - + @Inject GeneInteractionDAO geneInteractionDAO; + @Inject PersonService personService; + @Inject PersonDAO personDAO; + @Override @PostConstruct protected void init() { setSQLDao(geneInteractionDAO); } - + public ObjectResponse getByIdentifer(String identifier) { GeneInteraction interaction = findByAlternativeFields(List.of("interactionId", "uniqueId"), identifier); return new ObjectResponse(interaction); @@ -69,6 +66,6 @@ public GeneInteraction deprecateOrDeleteInteraction(Long id, Boolean throwApiErr } return null; - + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java index d1cfae0c2..c0ff26fab 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java @@ -20,17 +20,15 @@ @RequestScoped public class GeneMolecularInteractionService extends BaseEntityCrudService implements BaseUpsertServiceInterface { - @Inject - GeneMolecularInteractionDAO geneMolecularInteractionDAO; - @Inject - GeneMolecularInteractionFmsDTOValidator geneMolInteractionValidator; - + @Inject GeneMolecularInteractionDAO geneMolecularInteractionDAO; + @Inject GeneMolecularInteractionFmsDTOValidator geneMolInteractionValidator; + @Override @PostConstruct protected void init() { setSQLDao(geneMolecularInteractionDAO); } - + public ObjectResponse getByIdentifier(String identifier) { return new ObjectResponse<>(findByAlternativeFields(List.of("interactionId", "uniqueId"), identifier)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java index 328e23b2f..986883f5b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java @@ -21,14 +21,10 @@ @RequestScoped public class GenePhenotypeAnnotationService extends BaseAnnotationCrudService { - @Inject - GenePhenotypeAnnotationDAO genePhenotypeAnnotationDAO; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; - @Inject - GenePhenotypeAnnotationFmsDTOValidator genePhenotypeAnnotationFmsDtoValidator; + @Inject GenePhenotypeAnnotationDAO genePhenotypeAnnotationDAO; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; + @Inject GenePhenotypeAnnotationFmsDTOValidator genePhenotypeAnnotationFmsDtoValidator; @Override @PostConstruct @@ -53,7 +49,7 @@ public GenePhenotypeAnnotation upsertPrimaryAnnotation(Gene subject, PhenotypeFm GenePhenotypeAnnotation annotation = genePhenotypeAnnotationFmsDtoValidator.validatePrimaryAnnotation(subject, dto, dataProvider); return genePhenotypeAnnotationDAO.persist(annotation); } - + @Override @Transactional public ObjectResponse deleteById(Long id) { @@ -67,8 +63,7 @@ public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataPro } @Override - public GenePhenotypeAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, - String loadDescription, Boolean deprecate) { + public GenePhenotypeAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { return (GenePhenotypeAnnotation) phenotypeAnnotationService.deprecateOrDeleteAnnotationAndNotes(id, throwApiError, loadDescription, deprecate); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java index cfcb368c5..c533260c2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java @@ -38,26 +38,16 @@ @RequestScoped public class GeneService extends SubmittedObjectCrudService { - @Inject - GeneDAO geneDAO; - @Inject - GeneValidator geneValidator; - @Inject - GeneDTOValidator geneDtoValidator; - @Inject - DiseaseAnnotationService diseaseAnnotationService; - @Inject - PersonService personService; - @Inject - GeneToGeneOrthologyService orthologyService; - @Inject - AlleleGeneAssociationService alleleGeneAssociationService; - @Inject - ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; - @Inject - GeneInteractionService geneInteractionService; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; + @Inject GeneDAO geneDAO; + @Inject GeneValidator geneValidator; + @Inject GeneDTOValidator geneDtoValidator; + @Inject DiseaseAnnotationService diseaseAnnotationService; + @Inject PersonService personService; + @Inject GeneToGeneOrthologyService orthologyService; + @Inject AlleleGeneAssociationService alleleGeneAssociationService; + @Inject ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; + @Inject GeneInteractionService geneInteractionService; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; @Override @PostConstruct @@ -83,7 +73,7 @@ public ObjectResponse create(Gene uiEntity) { public Gene upsert(GeneDTO dto) throws ObjectUpdateException { return upsert(dto, null); } - + @Override public Gene upsert(GeneDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { return geneDtoValidator.validateGeneDTO(dto, dataProvider); @@ -96,7 +86,7 @@ public ObjectResponse deleteById(Long id) { ObjectResponse ret = new ObjectResponse<>(); return ret; } - + @Transactional public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { Gene gene = geneDAO.find(id); @@ -105,44 +95,50 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { Boolean anyReferencingEntities = false; for (Long daId : referencingDAIds) { DiseaseAnnotation referencingDA = diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(daId, false, loadDescription, true); - if (referencingDA != null) + if (referencingDA != null) { anyReferencingEntities = true; + } } List referencingPAIds = geneDAO.findReferencingPhenotypeAnnotations(id); for (Long paId : referencingPAIds) { PhenotypeAnnotation referencingPA = phenotypeAnnotationService.deprecateOrDeleteAnnotationAndNotes(paId, false, loadDescription, true); - if (referencingPA != null) + if (referencingPA != null) { anyReferencingEntities = true; + } } List referencingOrthologyPairs = geneDAO.findReferencingOrthologyPairs(id); for (Long orthId : referencingOrthologyPairs) { GeneToGeneOrthology referencingOrthoPair = orthologyService.deprecateOrthologyPair(orthId, loadDescription); - if (referencingOrthoPair != null) + if (referencingOrthoPair != null) { anyReferencingEntities = true; + } } List referencingInteractions = geneDAO.findReferencingInteractions(id); for (Long interactionId : referencingInteractions) { GeneInteraction referencingInteraction = geneInteractionService.deprecateOrDeleteInteraction(interactionId, false, loadDescription, true); - if (referencingInteraction != null) + if (referencingInteraction != null) { anyReferencingEntities = true; + } } if (CollectionUtils.isNotEmpty(gene.getAlleleGeneAssociations())) { for (AlleleGeneAssociation association : gene.getAlleleGeneAssociations()) { association = alleleGeneAssociationService.deprecateOrDeleteAssociation(association.getId(), false, loadDescription, true); - if (association != null) + if (association != null) { anyReferencingEntities = true; + } } } if (CollectionUtils.isNotEmpty(gene.getConstructGenomicEntityAssociations())) { for (ConstructGenomicEntityAssociation association : gene.getConstructGenomicEntityAssociations()) { association = constructGenomicEntityAssociationService.deprecateOrDeleteAssociation(association.getId(), false, loadDescription, true); - if (association != null) + if (association != null) { anyReferencingEntities = true; + } } } - + if (anyReferencingEntities) { gene.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); gene.setDateUpdated(OffsetDateTime.now()); @@ -153,14 +149,15 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { } } else { log.error("Failed getting gene: " + id); - } + } } public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); - if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { params.put(EntityFieldConstants.TAXON, dataProvider.canonicalTaxonCurie); + } List ids = geneDAO.findFilteredIds(params); ids.removeIf(Objects::isNull); diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java index a3f712959..adca1c3a6 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java @@ -16,10 +16,8 @@ @RequestScoped public class GeneToGeneParalogyService extends BaseEntityCrudService implements BaseUpsertServiceInterface { - @Inject - GeneToGeneParalogyDAO geneToGeneParalogyDAO; - @Inject - ParalogyFmsDTOValidator paralogyFmsDtoValidator; + @Inject GeneToGeneParalogyDAO geneToGeneParalogyDAO; + @Inject ParalogyFmsDTOValidator paralogyFmsDtoValidator; @Override @PostConstruct @@ -27,8 +25,7 @@ protected void init() { setSQLDao(geneToGeneParalogyDAO); } - public GeneToGeneParalogy upsert(ParalogyFmsDTO paralogyData, BackendBulkDataProvider backendBulkDataProvider) - throws ObjectUpdateException { + public GeneToGeneParalogy upsert(ParalogyFmsDTO paralogyData, BackendBulkDataProvider backendBulkDataProvider) throws ObjectUpdateException { return paralogyFmsDtoValidator.validateParalogyFmsDTO(paralogyData); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java b/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java index 490912ffb..7a9779d9e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java @@ -14,8 +14,7 @@ @RequestScoped public class GenomicEntityService extends SubmittedObjectCrudService { - @Inject - GenomicEntityDAO genomicEntityDAO; + @Inject GenomicEntityDAO genomicEntityDAO; @Override @PostConstruct @@ -27,14 +26,14 @@ protected void init() { public GenomicEntity upsert(GenomicEntityDTO dto) throws ObjectUpdateException { return null; } - + @Override public GenomicEntity upsert(GenomicEntityDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { return null; } @Override - public void removeOrDeprecateNonUpdated(Long id, String loadDescription) {} - + public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/InformationContentEntityService.java b/src/main/java/org/alliancegenome/curation_api/services/InformationContentEntityService.java index d25829b24..645bdacb0 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/InformationContentEntityService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/InformationContentEntityService.java @@ -11,10 +11,8 @@ @RequestScoped public class InformationContentEntityService extends BaseEntityCrudService { - @Inject - InformationContentEntityDAO informationContentEntityDAO; - @Inject - ReferenceService referenceService; + @Inject InformationContentEntityDAO informationContentEntityDAO; + @Inject ReferenceService referenceService; @Override @PostConstruct @@ -24,8 +22,9 @@ protected void init() { public InformationContentEntity retrieveFromDbOrLiteratureService(String curieOrXref) { InformationContentEntity ice = findByCurie(curieOrXref); - if (ice == null) + if (ice == null) { ice = referenceService.retrieveFromDbOrLiteratureService(curieOrXref); + } return ice; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/LiteratureReferenceService.java b/src/main/java/org/alliancegenome/curation_api/services/LiteratureReferenceService.java index 49aa3dcbb..6c296b24b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/LiteratureReferenceService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/LiteratureReferenceService.java @@ -11,8 +11,7 @@ @RequestScoped public class LiteratureReferenceService extends BaseDocumentService { - @Inject - LiteratureReferenceDAO literatureReferenceDAO; + @Inject LiteratureReferenceDAO literatureReferenceDAO; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java b/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java index 0dfe1fd09..4d9fa076e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java @@ -99,28 +99,33 @@ public Molecule upsert(MoleculeFmsDTO dto, BackendBulkDataProvider backendBulkDa molecule.setName(dto.getName()); String inchi = null; - if (StringUtils.isNotBlank(dto.getInchi())) + if (StringUtils.isNotBlank(dto.getInchi())) { inchi = dto.getInchi(); + } molecule.setInchi(inchi); String inchikey = null; - if (StringUtils.isNotBlank(dto.getInchikey())) + if (StringUtils.isNotBlank(dto.getInchikey())) { inchikey = dto.getInchikey(); + } molecule.setInchiKey(inchikey); String iupac = null; - if (StringUtils.isNotBlank(dto.getIupac())) + if (StringUtils.isNotBlank(dto.getIupac())) { iupac = dto.getIupac(); + } molecule.setIupac(iupac); String formula = null; - if (StringUtils.isNotBlank(dto.getFormula())) + if (StringUtils.isNotBlank(dto.getFormula())) { formula = dto.getFormula(); + } molecule.setFormula(formula); String smiles = null; - if (StringUtils.isNotBlank(dto.getSmiles())) + if (StringUtils.isNotBlank(dto.getSmiles())) { smiles = dto.getSmiles(); + } molecule.setSmiles(smiles); if (CollectionUtils.isNotEmpty(dto.getSynonyms())) { @@ -177,5 +182,4 @@ public Molecule upsert(MoleculeFmsDTO dto, BackendBulkDataProvider backendBulkDa } - } diff --git a/src/main/java/org/alliancegenome/curation_api/services/NoteService.java b/src/main/java/org/alliancegenome/curation_api/services/NoteService.java index bb4783822..5cdf624ea 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/NoteService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/NoteService.java @@ -14,10 +14,8 @@ @RequestScoped public class NoteService extends BaseEntityCrudService { - @Inject - NoteDAO noteDAO; - @Inject - NoteValidator noteValidator; + @Inject NoteDAO noteDAO; + @Inject NoteValidator noteValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(Note uiEntity) { Note dbEntity = noteValidator.validateNote(uiEntity, null, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(noteDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/OrganizationService.java b/src/main/java/org/alliancegenome/curation_api/services/OrganizationService.java index e1e1ec25c..3b4d20b4b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/OrganizationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/OrganizationService.java @@ -17,13 +17,12 @@ @RequestScoped public class OrganizationService extends BaseEntityCrudService { - @Inject - OrganizationDAO organizationDAO; + @Inject OrganizationDAO organizationDAO; - Date orgRequest = null; + Date orgRequest; HashMap orgIdCacheMap = new HashMap<>(); HashMap orgAbbrCacheMap = new HashMap<>(); - + @Override @PostConstruct protected void init() { @@ -31,11 +30,11 @@ protected void init() { } public ObjectResponse getById(Long id) { - + Organization org = null; - - if(orgRequest != null) { - if(orgIdCacheMap.containsKey(id)) { + + if (orgRequest != null) { + if (orgIdCacheMap.containsKey(id)) { org = orgIdCacheMap.get(id); } else { Log.debug("Org not cached, caching org: (" + id + ")"); @@ -51,26 +50,28 @@ public ObjectResponse getById(Long id) { response.setEntity(org); return response; } - + public ObjectResponse getByAbbr(String abbr) { - + Organization org = null; SearchResponse orgResponse = null; - - if(orgRequest != null) { - if(orgAbbrCacheMap.containsKey(abbr)) { + + if (orgRequest != null) { + if (orgAbbrCacheMap.containsKey(abbr)) { org = orgAbbrCacheMap.get(abbr); } else { Log.debug("Org not cached, caching org: (" + abbr + ")"); orgResponse = organizationDAO.findByField("abbreviation", abbr); - if (orgResponse != null) + if (orgResponse != null) { org = orgResponse.getSingleResult(); + } orgAbbrCacheMap.put(abbr, org); } } else { orgResponse = organizationDAO.findByField("abbreviation", abbr); - if (orgResponse != null) + if (orgResponse != null) { org = orgResponse.getSingleResult(); + } orgRequest = new Date(); } @@ -78,5 +79,5 @@ public ObjectResponse getByAbbr(String abbr) { response.setEntity(org); return response; } - + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/PersonService.java b/src/main/java/org/alliancegenome/curation_api/services/PersonService.java index 87f613695..cb45b2f8d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/PersonService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/PersonService.java @@ -20,14 +20,12 @@ @RequestScoped public class PersonService extends BaseEntityCrudService { - @Inject - PersonDAO personDAO; - @Inject - PersonValidator personValidator; + @Inject PersonDAO personDAO; + @Inject PersonValidator personValidator; - Date personRequest = null; + Date personRequest; HashMap personCacheMap = new HashMap<>(); - + @Override @PostConstruct protected void init() { @@ -37,8 +35,8 @@ protected void init() { @Transactional public Person fetchByUniqueIdOrCreate(String uniqueId) { Person person = null; - if(personRequest != null) { - if(personCacheMap.containsKey(uniqueId)) { + if (personRequest != null) { + if (personCacheMap.containsKey(uniqueId)) { person = personCacheMap.get(uniqueId); } else { Log.debug("Person not cached, caching uniqueId: (" + uniqueId + ")"); @@ -51,7 +49,7 @@ public Person fetchByUniqueIdOrCreate(String uniqueId) { } return person; } - + private Person findPersonByUniqueIdOrCreateDB(String uniqueId) { SearchResponse personResponse = personDAO.findByField("uniqueId", uniqueId); if (personResponse != null && personResponse.getResults().size() > 0) { @@ -76,7 +74,7 @@ public ObjectResponse update(Person uiEntity) { Person dbEntity = personValidator.validatePerson(uiEntity); return new ObjectResponse<>(personDAO.persist(dbEntity)); } - + public Person findPersonByApiToken(String apiToken) { SearchResponse resp = personDAO.findByField("apiToken", apiToken); if (resp != null && resp.getTotalResults() == 1) { @@ -84,7 +82,7 @@ public Person findPersonByApiToken(String apiToken) { } return null; } - + public Person findPersonByOktaEmail(String email) { SearchResponse resp = personDAO.findByField("oktaEmail", email); if (resp != null && resp.getTotalResults() == 1) { @@ -92,7 +90,7 @@ public Person findPersonByOktaEmail(String email) { } return null; } - + public Person findPersonByOktaId(String oktaId) { SearchResponse resp = personDAO.findByField("oktaId", oktaId); if (resp != null && resp.getTotalResults() == 1) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/PersonSettingService.java b/src/main/java/org/alliancegenome/curation_api/services/PersonSettingService.java index 81eebb39a..6d31b4a96 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/PersonSettingService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/PersonSettingService.java @@ -11,8 +11,7 @@ @RequestScoped public class PersonSettingService extends BaseEntityCrudService { - @Inject - PersonSettingDAO personSettingDAO; + @Inject PersonSettingDAO personSettingDAO; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java index 83e29b095..301714378 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java @@ -41,37 +41,26 @@ @RequestScoped public class PhenotypeAnnotationService extends BaseAnnotationCrudService { - @Inject - PhenotypeAnnotationDAO phenotypeAnnotationDAO; - @Inject - AGMPhenotypeAnnotationDAO agmPhenotypeAnnotationDAO; - @Inject - GenePhenotypeAnnotationDAO genePhenotypeAnnotationDAO; - @Inject - AllelePhenotypeAnnotationDAO allelePhenotypeAnnotationDAO; - @Inject - PersonService personService; - @Inject - PersonDAO personDAO; - @Inject - GenomicEntityService genomicEntityService; - @Inject - ReferenceService referenceService; - @Inject - AGMPhenotypeAnnotationService agmPhenotypeAnnotationService; - @Inject - GenePhenotypeAnnotationService genePhenotypeAnnotationService; - @Inject - AllelePhenotypeAnnotationService allelePhenotypeAnnotationService; + @Inject PhenotypeAnnotationDAO phenotypeAnnotationDAO; + @Inject AGMPhenotypeAnnotationDAO agmPhenotypeAnnotationDAO; + @Inject GenePhenotypeAnnotationDAO genePhenotypeAnnotationDAO; + @Inject AllelePhenotypeAnnotationDAO allelePhenotypeAnnotationDAO; + @Inject PersonService personService; + @Inject PersonDAO personDAO; + @Inject GenomicEntityService genomicEntityService; + @Inject ReferenceService referenceService; + @Inject AGMPhenotypeAnnotationService agmPhenotypeAnnotationService; + @Inject GenePhenotypeAnnotationService genePhenotypeAnnotationService; + @Inject AllelePhenotypeAnnotationService allelePhenotypeAnnotationService; HashMap> unprocessedAnnotationsMap = new HashMap<>(); - + @Override @PostConstruct protected void init() { setSQLDao(phenotypeAnnotationDAO); } - + @Override @Transactional public ObjectResponse deleteById(Long id) { @@ -118,7 +107,7 @@ public PhenotypeAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean public List getAllReferencedConditionRelationIds() { return getAllReferencedConditionRelationIds(phenotypeAnnotationDAO); } - + public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { List existingPhenotypeAnnotationIds = new ArrayList<>(); existingPhenotypeAnnotationIds.addAll(getAnnotationIdsByDataProvider(agmPhenotypeAnnotationDAO, dataProvider)); @@ -126,27 +115,29 @@ public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataPro existingPhenotypeAnnotationIds.addAll(getAnnotationIdsByDataProvider(allelePhenotypeAnnotationDAO, dataProvider)); return existingPhenotypeAnnotationIds; } - + protected > List getAnnotationIdsByDataProvider(D dao, BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); - - if(StringUtils.equals(dataProvider.sourceOrganization, "RGD") || StringUtils.equals(dataProvider.sourceOrganization, "XB")) + + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD") || StringUtils.equals(dataProvider.sourceOrganization, "XB")) { params.put(EntityFieldConstants.PA_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); - + } + List annotationIds = dao.findFilteredIds(params); - + return annotationIds; } - + public Long upsertPrimaryAnnotation(PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { - if (StringUtils.isBlank(dto.getObjectId())) + if (StringUtils.isBlank(dto.getObjectId())) { throw new ObjectValidationException(dto, "objectId - " + ValidationConstants.REQUIRED_MESSAGE); + } GenomicEntity phenotypeAnnotationSubject = genomicEntityService.findByIdentifierString(dto.getObjectId()); - if (phenotypeAnnotationSubject == null) + if (phenotypeAnnotationSubject == null) { throw new ObjectValidationException(dto, "objectId - " + ValidationConstants.INVALID_MESSAGE + " (" + dto.getObjectId() + ")"); - - + } + if (phenotypeAnnotationSubject instanceof AffectedGenomicModel) { AGMPhenotypeAnnotation annotation = agmPhenotypeAnnotationService.upsertPrimaryAnnotation((AffectedGenomicModel) phenotypeAnnotationSubject, dto, dataProvider); return annotation.getId(); @@ -159,15 +150,16 @@ public Long upsertPrimaryAnnotation(PhenotypeFmsDTO dto, BackendBulkDataProvider } else { throw new ObjectValidationException(dto, "objectId - " + ValidationConstants.INVALID_TYPE_MESSAGE + " (" + dto.getObjectId() + ")"); } - + } public void addInferredOrAssertedEntities(PhenotypeFmsDTO dto, List idsAdded, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { for (String primaryGeneticEntityCurie : dto.getPrimaryGeneticEntityIds()) { GenomicEntity primaryAnnotationSubject = genomicEntityService.findByIdentifierString(primaryGeneticEntityCurie); - if (primaryAnnotationSubject == null) + if (primaryAnnotationSubject == null) { throw new ObjectValidationException(dto, "primaryGeneticEntityIds - " + ValidationConstants.INVALID_MESSAGE + " (" + primaryGeneticEntityCurie + ")"); - + } + if (primaryAnnotationSubject instanceof AffectedGenomicModel) { agmPhenotypeAnnotationService.addInferredOrAssertedEntities((AffectedGenomicModel) primaryAnnotationSubject, dto, idsAdded, dataProvider); } else if (primaryAnnotationSubject instanceof Allele) { @@ -176,6 +168,6 @@ public void addInferredOrAssertedEntities(PhenotypeFmsDTO dto, List idsAdd throw new ObjectValidationException(dto, "primaryGeneticEntityIds - " + ValidationConstants.INVALID_TYPE_MESSAGE + " (" + primaryGeneticEntityCurie + ")"); } } - } - + } + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java b/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java index 711321967..db4455628 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java @@ -18,10 +18,8 @@ @RequestScoped public class ReferenceService extends BaseEntityCrudService { - @Inject - ReferenceDAO referenceDAO; - @Inject - ReferenceSynchronisationHelper refSyncHelper; + @Inject ReferenceDAO referenceDAO; + @Inject ReferenceSynchronisationHelper refSyncHelper; @Override @PostConstruct @@ -36,14 +34,14 @@ public ObjectResponse synchroniseReference(Long id) { public void synchroniseReferences() { refSyncHelper.synchroniseReferences(); } - + @Override public ObjectResponse getByCurie(String curie) { Reference reference = retrieveFromDbOrLiteratureService(curie); ObjectResponse ret = new ObjectResponse(reference); return ret; } - + @Transactional public Reference retrieveFromDbOrLiteratureService(String curieOrXref) { Reference reference = null; @@ -55,21 +53,25 @@ public Reference retrieveFromDbOrLiteratureService(String curieOrXref) { List nonObsoleteRefs = new ArrayList<>(); if (response != null && response.getReturnedRecords() > 0) { response.getResults().forEach(ref -> { - if (!ref.getObsolete()) + if (!ref.getObsolete()) { nonObsoleteRefs.add(ref); + } }); } - if (nonObsoleteRefs.size() == 1) + if (nonObsoleteRefs.size() == 1) { reference = nonObsoleteRefs.get(0); + } } - if (reference != null && (!reference.getObsolete() || curieOrXref.startsWith("AGRKB:"))) + if (reference != null && (!reference.getObsolete() || curieOrXref.startsWith("AGRKB:"))) { return reference; + } reference = refSyncHelper.retrieveFromLiteratureService(curieOrXref); - if (reference == null) + if (reference == null) { return null; + } return referenceDAO.persist(reference); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorPageService.java b/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorPageService.java index 4a30c0af2..ade494d88 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorPageService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorPageService.java @@ -19,14 +19,12 @@ @RequestScoped public class ResourceDescriptorPageService extends BaseEntityCrudService { - @Inject - ResourceDescriptorPageDAO resourceDescriptorPageDAO; - @Inject - ResourceDescriptorService resourceDescriptorService; - + @Inject ResourceDescriptorPageDAO resourceDescriptorPageDAO; + @Inject ResourceDescriptorService resourceDescriptorService; + HashMap resourceRequestMap = new HashMap<>(); HashMap> resourcePageCacheMap = new HashMap<>(); - + @Override @PostConstruct protected void init() { @@ -36,50 +34,52 @@ protected void init() { public ResourceDescriptorPage getPageForResourceDescriptor(String resourceDescriptorPrefix, String pageName) { ResourceDescriptorPage page = null; - - if(resourceRequestMap.get(resourceDescriptorPrefix) != null) { - + + if (resourceRequestMap.get(resourceDescriptorPrefix) != null) { + HashMap pageMap = resourcePageCacheMap.get(resourceDescriptorPrefix); - - if(pageMap == null) { + + if (pageMap == null) { Log.debug("Vocab not cached, caching vocab: " + resourceDescriptorPrefix); pageMap = new HashMap<>(); resourcePageCacheMap.put(resourceDescriptorPrefix, pageMap); } - if(pageMap.containsKey(pageName)) { + if (pageMap.containsKey(pageName)) { page = pageMap.get(pageName); } else { Log.debug("page not cached, caching page: " + resourceDescriptorPrefix + "(" + pageName + ")"); page = getPageForResourceDescriptorFromDB(resourceDescriptorPrefix, pageName); pageMap.put(pageName, page); } - + } else { page = getPageForResourceDescriptorFromDB(resourceDescriptorPrefix, pageName); resourceRequestMap.put(resourceDescriptorPrefix, new Date()); } - - if (page != null && page.getResourceDescriptor() != null && page.getResourceDescriptor().getSynonyms() != null) + + if (page != null && page.getResourceDescriptor() != null && page.getResourceDescriptor().getSynonyms() != null) { page.getResourceDescriptor().getSynonyms().size(); - + } + return page; } - - + private ResourceDescriptorPage getPageForResourceDescriptorFromDB(String resourceDescriptorPrefix, String pageName) { - + ObjectResponse rdResponse = resourceDescriptorService.getByPrefixOrSynonym(resourceDescriptorPrefix); - if (rdResponse == null || rdResponse.getEntity() == null || CollectionUtils.isEmpty(rdResponse.getEntity().getResourcePages())) + if (rdResponse == null || rdResponse.getEntity() == null || CollectionUtils.isEmpty(rdResponse.getEntity().getResourcePages())) { return null; - + } + for (ResourceDescriptorPage page : rdResponse.getEntity().getResourcePages()) { - if (Objects.equals(page.getName(), pageName)) + if (Objects.equals(page.getName(), pageName)) { return page; + } } - + return null; } - + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java b/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java index b2259c4ac..545ff6d59 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java @@ -24,20 +24,18 @@ @RequestScoped public class ResourceDescriptorService extends BaseEntityCrudService { - @Inject - ResourceDescriptorDAO resourceDescriptorDAO; - @Inject - ResourceDescriptorDTOValidator resourceDescriptorDtoValidator; - - Date prefixRequest = null; + @Inject ResourceDescriptorDAO resourceDescriptorDAO; + @Inject ResourceDescriptorDTOValidator resourceDescriptorDtoValidator; + + Date prefixRequest; HashMap prefixCacheMap = new HashMap<>(); - + @Override @PostConstruct protected void init() { setSQLDao(resourceDescriptorDAO); } - + public List getAllNames() { List names = resourceDescriptorDAO.findAllNames(); names.removeIf(Objects::isNull); @@ -47,10 +45,11 @@ public List getAllNames() { @Transactional public ResourceDescriptor upsert(ResourceDescriptorDTO dto) throws ObjectUpdateException { ResourceDescriptor rd = resourceDescriptorDtoValidator.validateResourceDescriptorDTO(dto); - - if (rd == null) + + if (rd == null) { return null; - + } + return resourceDescriptorDAO.persist(rd); } @@ -65,20 +64,20 @@ public void removeNonUpdatedResourceDescriptors(List rdNamesBefore, List } } - public ObjectResponse getByPrefixOrSynonym(String prefix) { - + List lookupFields = List.of("prefix", "synonyms"); - + ResourceDescriptor rd = null; - if(prefixRequest != null) { - if(prefixCacheMap.containsKey(prefix)) { + if (prefixRequest != null) { + if (prefixCacheMap.containsKey(prefix)) { rd = prefixCacheMap.get(prefix); } else { Log.debug("RD not cached, caching rd: (" + prefix + ")"); rd = findByAlternativeFields(lookupFields, prefix); - if (rd != null) + if (rd != null) { prefixCacheMap.put(prefix, rd); + } } } else { rd = findByAlternativeFields(lookupFields, prefix); diff --git a/src/main/java/org/alliancegenome/curation_api/services/SpeciesService.java b/src/main/java/org/alliancegenome/curation_api/services/SpeciesService.java index 2dd81c248..9549fc136 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/SpeciesService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/SpeciesService.java @@ -1,6 +1,5 @@ package org.alliancegenome.curation_api.services; - import org.alliancegenome.curation_api.dao.SpeciesDAO; import org.alliancegenome.curation_api.model.entities.Species; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; @@ -12,8 +11,7 @@ @RequestScoped public class SpeciesService extends BaseEntityCrudService { - @Inject - SpeciesDAO speciesDAO; + @Inject SpeciesDAO speciesDAO; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java index f8783e39a..1bc415c37 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java @@ -47,7 +47,7 @@ public ObjectResponse update(Variant uiEntity) { Variant dbEntity = variantValidator.validateVariantUpdate(uiEntity); return new ObjectResponse(dbEntity); } - + @Override @Transactional public ObjectResponse create(Variant uiEntity) { @@ -58,7 +58,7 @@ public ObjectResponse create(Variant uiEntity) { public Variant upsert(VariantDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { return variantDtoValidator.validateVariantDTO(dto, dataProvider); } - + @Transactional public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { Variant variant = variantDAO.find(id); @@ -67,8 +67,9 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { Boolean anyReferencingEntities = false; for (Long daId : referencingDAIds) { DiseaseAnnotation referencingDA = diseaseAnnotationService.deprecateOrDeleteAnnotationAndNotes(daId, false, loadDescription, true); - if (referencingDA != null) + if (referencingDA != null) { anyReferencingEntities = true; + } } if (anyReferencingEntities) { if (!variant.getObsolete()) { @@ -84,7 +85,7 @@ public void removeOrDeprecateNonUpdated(Long id, String loadDescription) { log.error("Failed getting variant: " + id); } } - + public List getIdsByDataProvider(String dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider); diff --git a/src/main/java/org/alliancegenome/curation_api/services/VocabularyService.java b/src/main/java/org/alliancegenome/curation_api/services/VocabularyService.java index 61e8f65bd..f8f75c09c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VocabularyService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VocabularyService.java @@ -14,10 +14,8 @@ @RequestScoped public class VocabularyService extends BaseEntityCrudService { - @Inject - VocabularyDAO vocabularyDAO; - @Inject - VocabularyValidator vocabularyValidator; + @Inject VocabularyDAO vocabularyDAO; + @Inject VocabularyValidator vocabularyValidator; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermService.java b/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermService.java index 57fdf034d..9d0036cc2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermService.java @@ -20,17 +20,15 @@ @RequestScoped public class VocabularyTermService extends BaseEntityCrudService { - @Inject - VocabularyTermDAO vocabularyTermDAO; - @Inject - VocabularyTermValidator vocabularyTermValidator; + @Inject VocabularyTermDAO vocabularyTermDAO; + @Inject VocabularyTermValidator vocabularyTermValidator; HashMap termRequestMap = new HashMap<>(); HashMap> vocabTermCacheMap = new HashMap<>(); - + HashMap termSetRequestMap = new HashMap<>(); HashMap> vocabTermSetCacheMap = new HashMap<>(); - + @Override @PostConstruct protected void init() { @@ -40,23 +38,24 @@ protected void init() { public ObjectResponse getTermInVocabulary(String vocabularyLabel, String termName) { VocabularyTerm term = null; - - if(termRequestMap.containsKey(vocabularyLabel)) { + + if (termRequestMap.containsKey(vocabularyLabel)) { HashMap termMap = vocabTermCacheMap.get(vocabularyLabel); - - if(termMap == null) { + + if (termMap == null) { Log.debug("Vocab not cached, caching vocab: " + vocabularyLabel); termMap = new HashMap<>(); vocabTermCacheMap.put(vocabularyLabel, termMap); } - if(termMap.containsKey(termName)) { + if (termMap.containsKey(termName)) { term = termMap.get(termName); } else { Log.debug("Term not cached, caching term: " + vocabularyLabel + "(" + termName + ")"); term = getTermInVocabularyFromDB(vocabularyLabel, termName); - if (term != null) + if (term != null) { term.getSynonyms().size(); + } termMap.put(termName, term); } } else { @@ -67,29 +66,30 @@ public ObjectResponse getTermInVocabulary(String vocabularyLabel ObjectResponse response = new ObjectResponse<>(); response.setEntity(term); return response; - + } public ObjectResponse getTermInVocabularyTermSet(String vocabularyTermSetLabel, String termName) { VocabularyTerm term = null; - - if(termSetRequestMap.containsKey(vocabularyTermSetLabel)) { + + if (termSetRequestMap.containsKey(vocabularyTermSetLabel)) { HashMap termMap = vocabTermSetCacheMap.get(vocabularyTermSetLabel); - - if(termMap == null) { + + if (termMap == null) { Log.debug("Vocab not cached, caching vocab: " + vocabularyTermSetLabel); termMap = new HashMap<>(); vocabTermSetCacheMap.put(vocabularyTermSetLabel, termMap); } - if(termMap.containsKey(termName)) { + if (termMap.containsKey(termName)) { term = termMap.get(termName); } else { Log.debug("Term not cached, caching term: " + vocabularyTermSetLabel + "(" + termName + ")"); term = getTermInVocabularyTermSetFromDB(vocabularyTermSetLabel, termName); - if (term != null) + if (term != null) { term.getSynonyms().size(); + } termMap.put(termName, term); } } else { @@ -100,21 +100,25 @@ public ObjectResponse getTermInVocabularyTermSet(String vocabula ObjectResponse response = new ObjectResponse(); response.setEntity(term); return response; - + } - + private VocabularyTerm getTermInVocabularyFromDB(String vocabularyLabel, String termName) { Map params = new HashMap<>(); params.put("name", termName); - if(vocabularyLabel != null) params.put("vocabulary.vocabularyLabel", vocabularyLabel); + if (vocabularyLabel != null) { + params.put("vocabulary.vocabularyLabel", vocabularyLabel); + } SearchResponse resp = vocabularyTermDAO.findByParams(params); return resp.getSingleResult(); } - + private VocabularyTerm getTermInVocabularyTermSetFromDB(String vocabularyTermSetLabel, String termName) { Map params = new HashMap<>(); params.put("name", termName); - if(vocabularyTermSetLabel != null) params.put("vocabularyTermSets.vocabularyLabel", vocabularyTermSetLabel); + if (vocabularyTermSetLabel != null) { + params.put("vocabularyTermSets.vocabularyLabel", vocabularyTermSetLabel); + } SearchResponse resp = vocabularyTermDAO.findByParams(params); return resp.getSingleResult(); } @@ -133,5 +137,4 @@ public ObjectResponse update(VocabularyTerm uiEntity) { return new ObjectResponse<>(vocabularyTermDAO.persist(dbEntity)); } - } diff --git a/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermSetService.java b/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermSetService.java index 34f91eeac..aaa0ab96d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermSetService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VocabularyTermSetService.java @@ -14,10 +14,8 @@ @RequestScoped public class VocabularyTermSetService extends BaseEntityCrudService { - @Inject - VocabularyTermSetDAO vocabularyTermSetDAO; - @Inject - VocabularyTermSetValidator vocabularyTermSetValidator; + @Inject VocabularyTermSetDAO vocabularyTermSetDAO; + @Inject VocabularyTermSetValidator vocabularyTermSetValidator; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java index 41eaea4b0..de3fb386b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -37,24 +37,16 @@ @JBossLog @RequestScoped -public class AlleleGeneAssociationService extends BaseAssociationDTOCrudService implements BaseUpsertServiceInterface{ - - @Inject - AlleleGeneAssociationDAO alleleGeneAssociationDAO; - @Inject - AlleleGeneAssociationValidator alleleGeneAssociationValidator; - @Inject - AlleleGeneAssociationDTOValidator alleleGeneAssociationDtoValidator; - @Inject - AlleleDAO alleleDAO; - @Inject - NoteDAO noteDAO; - @Inject - GeneDAO geneDAO; - @Inject - PersonService personService; - @Inject - PersonDAO personDAO; +public class AlleleGeneAssociationService extends BaseAssociationDTOCrudService implements BaseUpsertServiceInterface { + + @Inject AlleleGeneAssociationDAO alleleGeneAssociationDAO; + @Inject AlleleGeneAssociationValidator alleleGeneAssociationValidator; + @Inject AlleleGeneAssociationDTOValidator alleleGeneAssociationDtoValidator; + @Inject AlleleDAO alleleDAO; + @Inject NoteDAO noteDAO; + @Inject GeneDAO geneDAO; + @Inject PersonService personService; + @Inject PersonDAO personDAO; @Override @PostConstruct @@ -65,8 +57,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleGeneAssociation uiEntity) { AlleleGeneAssociation dbEntity = alleleGeneAssociationValidator.validateAlleleGeneAssociation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } dbEntity = alleleGeneAssociationDAO.persist(dbEntity); addAssociationToAllele(dbEntity); addAssociationToGene(dbEntity); @@ -85,7 +78,7 @@ public AlleleGeneAssociation upsert(AlleleGeneAssociationDTO dto, BackendBulkDat addAssociationToAllele(association); addAssociationToGene(association); } - + return association; } @@ -94,14 +87,14 @@ public List getAssociationsByDataProvider(BackendBulkDataProvider dataProv params.put(EntityFieldConstants.ALLELE_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); List associationIds = alleleGeneAssociationDAO.findFilteredIds(params); associationIds.removeIf(Objects::isNull); - + return associationIds; } @Transactional public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { AlleleGeneAssociation association = alleleGeneAssociationDAO.find(id); - + if (association == null) { String errorMessage = "Could not find AlleleGeneAssociation with id: " + id; if (throwApiError) { @@ -125,17 +118,19 @@ public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throw } return association; } - + Long noteId = null; - if (association.getRelatedNote() != null) + if (association.getRelatedNote() != null) { noteId = association.getRelatedNote().getId(); + } alleleGeneAssociationDAO.remove(association.getId()); - if (noteId != null) + if (noteId != null) { noteDAO.remove(noteId); - + } + return null; } - + public ObjectResponse getAssociation(Long alleleId, String relationName, Long geneId) { AlleleGeneAssociation association = null; @@ -145,35 +140,42 @@ public ObjectResponse getAssociation(Long alleleId, Strin params.put("alleleGeneAssociationObject.id", geneId); SearchResponse resp = alleleGeneAssociationDAO.findByParams(params); - if (resp != null && resp.getSingleResult() != null) + if (resp != null && resp.getSingleResult() != null) { association = resp.getSingleResult(); - + } + ObjectResponse response = new ObjectResponse<>(); response.setEntity(association); - + return response; } - + private void addAssociationToAllele(AlleleGeneAssociation association) { Allele allele = association.getAlleleAssociationSubject(); List currentAssociations = allele.getAlleleGeneAssociations(); - if (currentAssociations == null) + if (currentAssociations == null) { currentAssociations = new ArrayList<>(); + } List currentAssociationIds = currentAssociations.stream().map(AlleleGeneAssociation::getId).collect(Collectors.toList()); - if (!currentAssociationIds.contains(association.getId())); - currentAssociations.add(association); + if (!currentAssociationIds.contains(association.getId())) { + // + } + currentAssociations.add(association); allele.setAlleleGeneAssociations(currentAssociations); alleleDAO.persist(allele); } - + private void addAssociationToGene(AlleleGeneAssociation association) { Gene gene = association.getAlleleGeneAssociationObject(); List currentAssociations = gene.getAlleleGeneAssociations(); - if (currentAssociations == null) + if (currentAssociations == null) { currentAssociations = new ArrayList<>(); + } List currentAssociationIds = currentAssociations.stream().map(AlleleGeneAssociation::getId).collect(Collectors.toList()); - if (!currentAssociationIds.contains(association.getId())); - currentAssociations.add(association); + if (!currentAssociationIds.contains(association.getId())) { + // + } + currentAssociations.add(association); gene.setAlleleGeneAssociations(currentAssociations); geneDAO.persist(gene); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java index 43e945d20..a119998d2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java @@ -28,30 +28,23 @@ import org.alliancegenome.curation_api.services.validation.associations.constructAssociations.ConstructGenomicEntityAssociationValidator; import org.alliancegenome.curation_api.services.validation.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTOValidator; +import io.quarkus.logging.Log; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; import jakarta.inject.Inject; import jakarta.transaction.Transactional; -import lombok.extern.jbosslog.JBossLog; -@JBossLog @RequestScoped -public class ConstructGenomicEntityAssociationService extends BaseAssociationDTOCrudService implements BaseUpsertServiceInterface{ - - @Inject - ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; - @Inject - ConstructGenomicEntityAssociationValidator constructGenomicEntityAssociationValidator; - @Inject - ConstructGenomicEntityAssociationDTOValidator constructGenomicEntityAssociationDtoValidator; - @Inject - ConstructDAO constructDAO; - @Inject - GenomicEntityDAO genomicEntityDAO; - @Inject - PersonService personService; - @Inject - PersonDAO personDAO; +public class ConstructGenomicEntityAssociationService extends BaseAssociationDTOCrudService + implements BaseUpsertServiceInterface { + + @Inject ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; + @Inject ConstructGenomicEntityAssociationValidator constructGenomicEntityAssociationValidator; + @Inject ConstructGenomicEntityAssociationDTOValidator constructGenomicEntityAssociationDtoValidator; + @Inject ConstructDAO constructDAO; + @Inject GenomicEntityDAO genomicEntityDAO; + @Inject PersonService personService; + @Inject PersonDAO personDAO; @Override @PostConstruct @@ -62,8 +55,9 @@ protected void init() { @Transactional public ObjectResponse upsert(ConstructGenomicEntityAssociation uiEntity) { ConstructGenomicEntityAssociation dbEntity = constructGenomicEntityAssociationValidator.validateConstructGenomicEntityAssociation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } dbEntity = constructGenomicEntityAssociationDAO.persist(dbEntity); addAssociationToConstruct(dbEntity); addAssociationToGenomicEntity(dbEntity); @@ -82,7 +76,7 @@ public ConstructGenomicEntityAssociation upsert(ConstructGenomicEntityAssociatio addAssociationToConstruct(association); addAssociationToGenomicEntity(association); } - + return association; } @@ -91,14 +85,14 @@ public List getAssociationsByDataProvider(BackendBulkDataProvider dataProv params.put(EntityFieldConstants.CONSTRUCT_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); List associationIds = constructGenomicEntityAssociationDAO.findFilteredIds(params); associationIds.removeIf(Objects::isNull); - + return associationIds; } @Transactional public ConstructGenomicEntityAssociation deprecateOrDeleteAssociation(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { ConstructGenomicEntityAssociation association = constructGenomicEntityAssociationDAO.find(id); - + if (association == null) { String errorMessage = "Could not find ConstructGenomicEntityAssociation with id: " + id; if (throwApiError) { @@ -106,7 +100,7 @@ public ConstructGenomicEntityAssociation deprecateOrDeleteAssociation(Long id, B response.addErrorMessage("id", errorMessage); throw new ApiErrorException(response); } - log.error(errorMessage); + Log.error(errorMessage); return null; } if (deprecate) { @@ -121,50 +115,57 @@ public ConstructGenomicEntityAssociation deprecateOrDeleteAssociation(Long id, B return constructGenomicEntityAssociationDAO.persist(association); } } - + constructGenomicEntityAssociationDAO.remove(association.getId()); - + return null; } - + public ObjectResponse getAssociation(Long constructId, String relationName, Long genomicEntityId) { ConstructGenomicEntityAssociation association = null; - + Map params = new HashMap<>(); params.put("constructAssociationSubject.id", constructId); params.put("relation.name", relationName); params.put("constructGenomicEntityAssociationObject.id", genomicEntityId); SearchResponse resp = constructGenomicEntityAssociationDAO.findByParams(params); - if (resp != null && resp.getSingleResult() != null) + if (resp != null && resp.getSingleResult() != null) { association = resp.getSingleResult(); - + } + ObjectResponse response = new ObjectResponse<>(); response.setEntity(association); - + return response; } - + private void addAssociationToConstruct(ConstructGenomicEntityAssociation association) { Construct construct = association.getConstructAssociationSubject(); List currentAssociations = construct.getConstructGenomicEntityAssociations(); - if (currentAssociations == null) + if (currentAssociations == null) { currentAssociations = new ArrayList<>(); + } List currentAssociationIds = currentAssociations.stream().map(ConstructGenomicEntityAssociation::getId).collect(Collectors.toList()); - if (!currentAssociationIds.contains(association.getId())); - currentAssociations.add(association); + if (!currentAssociationIds.contains(association.getId())) { + // + } + currentAssociations.add(association); construct.setConstructGenomicEntityAssociations(currentAssociations); constructDAO.persist(construct); } - + private void addAssociationToGenomicEntity(ConstructGenomicEntityAssociation association) { GenomicEntity genomicEntity = association.getConstructGenomicEntityAssociationObject(); List currentAssociations = genomicEntity.getConstructGenomicEntityAssociations(); - if (currentAssociations == null) + if (currentAssociations == null) { currentAssociations = new ArrayList<>(); + } List currentAssociationIds = currentAssociations.stream().map(ConstructGenomicEntityAssociation::getId).collect(Collectors.toList()); - if (!currentAssociationIds.contains(association.getId())); - currentAssociations.add(association); + if (!currentAssociationIds.contains(association.getId())) { + // + } + currentAssociations.add(association); genomicEntity.setConstructGenomicEntityAssociations(currentAssociations); genomicEntityDAO.persist(genomicEntity); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationCrudService.java b/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationCrudService.java index aa20aa2b3..ac7c83352 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationCrudService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationCrudService.java @@ -12,16 +12,17 @@ public abstract class BaseAnnotationCrudService> extends BaseEntityCrudService { + @Override protected abstract void init(); public abstract E deprecateOrDeleteAnnotationAndNotes(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate); protected List getAllReferencedConditionRelationIds(D dao) { ProcessDisplayHelper pdh = new ProcessDisplayHelper(); - + List daIds = dao.findAllIds().getResults(); pdh.startProcess("Checking DAs for referenced Conditions ", daIds.size()); - + List conditionRelationIds = new ArrayList<>(); daIds.forEach(daId -> { E annotation = dao.find(daId); @@ -32,7 +33,7 @@ protected List getAllReferencedConditionRelationIds(D dao) { pdh.progressProcess(); }); pdh.finishProcess(); - + return conditionRelationIds; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationDTOCrudService.java b/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationDTOCrudService.java index c937ab40e..52d568fe1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationDTOCrudService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/BaseAnnotationDTOCrudService.java @@ -6,7 +6,8 @@ import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; public abstract class BaseAnnotationDTOCrudService> extends BaseAnnotationCrudService implements BaseUpsertServiceInterface { - + + @Override protected abstract void init(); - + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java b/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java index 20a9284c3..72c961f8a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java @@ -26,8 +26,7 @@ protected void setSQLDao(BaseSQLDAO dao) { } @Inject - @AuthenticatedUser - protected Person authenticatedPerson; + @AuthenticatedUser protected Person authenticatedPerson; protected abstract void init(); @@ -58,13 +57,13 @@ public ObjectResponse getByCurie(String curie) { ObjectResponse ret = new ObjectResponse(object); return ret; } - + public ObjectResponse getByIdentifier(String identifier) { E object = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId", "uniqueId"), identifier); ObjectResponse ret = new ObjectResponse(object); return ret; } - + public E findByCurie(String curie) { if (curie != null) { SearchResponse response = findByField("curie", curie); @@ -80,7 +79,7 @@ public E findByCurie(String curie) { return null; } } - + public E findByAlternativeFields(List fields, String value) { if (value != null) { SearchResponse response = dao.findByFields(fields, value); @@ -89,14 +88,14 @@ public E findByAlternativeFields(List fields, String value) { return null; } E entity = response.getSingleResult(); - //Log.debug("Entity Found: " + entity); + // Log.debug("Entity Found: " + entity); return entity; } else { Log.debug("Input Param is null: " + value); return null; } } - + @Transactional public ObjectResponse update(E entity) { // log.info("Authed Person: " + authenticatedPerson); @@ -105,23 +104,23 @@ public ObjectResponse update(E entity) { return ret; } - @Transactional public ObjectResponse deleteByCurie(String curie) { E object = findByCurie(curie); - if (object != null) + if (object != null) { dao.remove(object.getId()); + } ObjectResponse ret = new ObjectResponse<>(object); return ret; } - + @Transactional public ObjectResponse deleteById(Long id) { E object = dao.remove(id); ObjectResponse ret = new ObjectResponse<>(object); return ret; } - + public SearchResponse findByField(String field, String value) { return dao.findByField(field, value); } @@ -142,8 +141,7 @@ public void reindex(Integer batchSizeToLoadObjects, Integer idFetchSize, Integer dao.reindex(batchSizeToLoadObjects, idFetchSize, limitIndexedObjectsTo, threadsToLoadObjects, transactionTimeout, typesToIndexInParallel); } - public void reindexEverything(Integer batchSizeToLoadObjects, Integer idFetchSize, Integer limitIndexedObjectsTo, Integer threadsToLoadObjects, Integer transactionTimeout, - Integer typesToIndexInParallel) { + public void reindexEverything(Integer batchSizeToLoadObjects, Integer idFetchSize, Integer limitIndexedObjectsTo, Integer threadsToLoadObjects, Integer transactionTimeout, Integer typesToIndexInParallel) { dao.reindexEverything(batchSizeToLoadObjects, idFetchSize, limitIndexedObjectsTo, threadsToLoadObjects, transactionTimeout, typesToIndexInParallel); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java b/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java index 1d83dd505..7b56e26b3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java @@ -24,21 +24,17 @@ public abstract class BaseOntologyTermService> extends BaseEntityCrudService> { - @Inject - CrossReferenceDAO crossReferenceDAO; - @Inject - SynonymDAO synonymDAO; - @Inject - CrossReferenceService crossReferenceService; + @Inject CrossReferenceDAO crossReferenceDAO; + @Inject SynonymDAO synonymDAO; + @Inject CrossReferenceService crossReferenceService; @Inject - @AuthenticatedUser - Person authenticatedPerson; + @AuthenticatedUser Person authenticatedPerson; - public E findByCurieOrSecondaryId(String id) { + public E findByCurieOrSecondaryId(String id) { return findByAlternativeFields(List.of("curie", "secondaryIdentifiers"), id); } - + @Transactional public E processUpdate(E inTerm) { @@ -63,7 +59,7 @@ public E processUpdate(E inTerm) { handleSynonyms(term, inTerm); handleCrossReferences(term, inTerm); - if(newTerm) { + if (newTerm) { return dao.persist(term); } else { return term; @@ -75,7 +71,7 @@ public E processUpdateRelationships(E inTerm) { E term = findByCurie(inTerm.getCurie()); HashSet parentSet = new HashSet<>(); - if(inTerm.getIsaParents() != null) { + if (inTerm.getIsaParents() != null) { inTerm.getIsaParents().forEach(o -> { E parent = findByCurie(o.getCurie()); parentSet.add(parent); @@ -84,18 +80,17 @@ public E processUpdateRelationships(E inTerm) { term.setIsaParents(parentSet); HashSet ancestorsSet = new HashSet<>(); - if(inTerm.getIsaAncestors() != null) { + if (inTerm.getIsaAncestors() != null) { inTerm.getIsaAncestors().forEach(o -> { E ancestor = findByCurie(o.getCurie()); ancestorsSet.add(ancestor); }); } term.setIsaAncestors(ancestorsSet); - + return term; } - - + @Transactional public E processCounts(E inTerm) { E term = findByCurie(inTerm.getCurie()); @@ -103,8 +98,6 @@ public E processCounts(E inTerm) { term.setDescendantCount(term.getIsaDescendants().size()); return term; } - - private void handleDefinitionUrls(OntologyTerm dbTerm, OntologyTerm incomingTerm) { Set currentDefinitionUrls; @@ -140,7 +133,7 @@ public ObjectListResponse getRootNodes() { HashMap params = new HashMap<>(); params.put("isaParents", null); SearchResponse rootNodesRes = dao.findByParams(params); - if(rootNodesRes != null) { + if (rootNodesRes != null) { return new ObjectListResponse(rootNodesRes.getResults()); } else { return new ObjectListResponse(); @@ -281,7 +274,7 @@ private void handleSecondaryIds(OntologyTerm dbTerm, OntologyTerm incomingTerm) }); } - + private void handleCrossReferences(OntologyTerm dbTerm, OntologyTerm incomingTerm) { List currentIds; if (dbTerm.getCrossReferences() == null) { @@ -289,7 +282,7 @@ private void handleCrossReferences(OntologyTerm dbTerm, OntologyTerm incomingTer } else { currentIds = dbTerm.getCrossReferences().stream().map(CrossReference::getId).collect(Collectors.toList()); } - + List mergedIds; if (incomingTerm.getCrossReferences() == null) { mergedIds = new ArrayList<>(); @@ -299,7 +292,7 @@ private void handleCrossReferences(OntologyTerm dbTerm, OntologyTerm incomingTer mergedIds = mergedCrossReferences.stream().map(CrossReference::getId).collect(Collectors.toList()); dbTerm.setCrossReferences(mergedCrossReferences); } - + for (Long currentId : currentIds) { if (!mergedIds.contains(currentId)) { crossReferenceDAO.remove(currentId); diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/SubmittedObjectCrudService.java b/src/main/java/org/alliancegenome/curation_api/services/base/SubmittedObjectCrudService.java index 9d928efcb..b2870a22a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/SubmittedObjectCrudService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/SubmittedObjectCrudService.java @@ -21,8 +21,9 @@ public ObjectResponse getByIdentifier(String identifier) { @Transactional public ObjectResponse deleteByIdentifier(String identifierString) { E object = findByIdentifierString(identifierString); - if (object != null) + if (object != null) { dao.remove(object.getId()); + } ObjectResponse ret = new ObjectResponse<>(object); return ret; } @@ -30,9 +31,10 @@ public ObjectResponse deleteByIdentifier(String identifierString) { public abstract void removeOrDeprecateNonUpdated(Long id, String loadDescription); public E findByIdentifierString(String id) { - if (id != null && id.startsWith("AGRKB:")) + if (id != null && id.startsWith("AGRKB:")) { return findByCurie(id); - + } + return findByAlternativeFields(List.of("modEntityId", "modInternalId"), id); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadConfig.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadConfig.java index d15d4d83c..3b8486736 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadConfig.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadConfig.java @@ -13,7 +13,7 @@ public class GenericOntologyLoadConfig { private HashSet altNameSpaces = new HashSet<>(); // must be set and will only load that Prefix of terms - private String loadOnlyIRIPrefix = null; + private String loadOnlyIRIPrefix; // do not load entities that have ChEBI equivalents private Boolean ignoreEntitiesWithChebiXref = false; diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadHelper.java index 0df29b911..f4ecd55e5 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/GenericOntologyLoadHelper.java @@ -44,7 +44,7 @@ public class GenericOntologyLoadHelper implements OWLObj private OWLOntology ontology; private GenericOntologyLoadConfig config; - private String defaultNamespace = null; + private String defaultNamespace; private Class clazz; private HashMap allNodes = new HashMap<>(); @@ -109,7 +109,7 @@ public Map load(InputStream inStream) throws Exception { Log.info("Finished Traversing Object Properties: " + allNodes.size()); return allNodes; } - + OWLClass root = manager.getOWLDataFactory().getOWLThing(); Log.info("Traversing Ontology"); @@ -237,7 +237,9 @@ private boolean isNodeInOntology(OWLClass currentTreeNode, T currentTerm, HashSe boolean condition5 = !config.getIgnoreEntitiesWithChebiXref(); boolean condition6 = !hasChebiXref(currentTerm); + //CHECKSTYLE:OFF: UnnecessaryParentheses return ((condition1 && condition2 && !condition3) || (condition3 && condition4)) && (condition5 || condition6); + //CHECKSTYLE:ON: UnnecessaryParentheses } public void printDepthMessage(int depth, String message) { @@ -250,16 +252,19 @@ public void printDepthMessage(int depth, String message) { } public String getIRIShortForm(OWLAnnotationValue owlAnnotationValue) { - if (owlAnnotationValue.isIRI()) + if (owlAnnotationValue.isIRI()) { return ((IRI) owlAnnotationValue).getShortForm(); + } return ""; } public String getString(OWLAnnotationValue owlAnnotationValue) { - if (owlAnnotationValue.isLiteral()) + if (owlAnnotationValue.isLiteral()) { return ((OWLLiteral) owlAnnotationValue).getLiteral(); - if (owlAnnotationValue.isIRI()) + } + if (owlAnnotationValue.isIRI()) { return ((IRI) owlAnnotationValue).getIRIString(); + } return ""; } @@ -284,7 +289,7 @@ public T getOntologyTerm(OWLClass node) throws Exception { return term; } - + private T parseAnnotation(OWLAnnotation annotation, OWLClass node, T term, String key) { if (key.equals("id")) { term.setCurie(getString(annotation.getValue())); @@ -300,8 +305,9 @@ private T parseAnnotation(OWLAnnotation annotation, OWLClass node, T term, Strin // System.out.println(inkey); if (inkey.equals("hasDbXref")) { // System.out.println("Adding: " + an.getValue().toString()); - if (term.getDefinitionUrls() == null) + if (term.getDefinitionUrls() == null) { term.setDefinitionUrls(new ArrayList<>()); + } term.getDefinitionUrls().add(getString(an.getValue())); } }); @@ -314,33 +320,37 @@ private T parseAnnotation(OWLAnnotation annotation, OWLClass node, T term, Strin } else if (key.equals("hasOBONamespace")) { term.setNamespace(getString(annotation.getValue())); } else if (key.equals("hasExactSynonym") || key.equals("hasRelatedSynonym")) { - if (term.getSynonyms() == null) + if (term.getSynonyms() == null) { term.setSynonyms(new ArrayList<>()); + } Synonym synonym = new Synonym(); synonym.setName(getString(annotation.getValue())); term.getSynonyms().add(synonym); } else if (key.equals("hasAlternativeId")) { - if (term.getSecondaryIdentifiers() == null) + if (term.getSecondaryIdentifiers() == null) { term.setSecondaryIdentifiers(new ArrayList<>()); + } term.getSecondaryIdentifiers().add(getString(annotation.getValue())); } else if (key.equals("hasDbXref") || key.equals("database_cross_reference")) { - if (term.getCrossReferences() == null) + if (term.getCrossReferences() == null) { term.setCrossReferences(new ArrayList<>()); + } CrossReference ref = new CrossReference(); ref.setReferencedCurie(getString(annotation.getValue())); ref.setDisplayName(getString(annotation.getValue())); term.getCrossReferences().add(ref); } else if (key.equals("inSubset")) { - if (term.getSubsets() == null) + if (term.getSubsets() == null) { term.setSubsets(new ArrayList<>()); + } term.getSubsets().add(getIRIShortForm(annotation.getValue())); } else { // log.info(key + " -> " + getString(annotation.getValue())); } - + return term; } - + public T traverseProperties(OWLObjectProperty currentTreeProperty, int depth) throws Exception { T currentTerm = null; @@ -349,18 +359,19 @@ public T traverseProperties(OWLObjectProperty currentTreeProperty, int depth) th currentTerm = getOntologyTermFromProperty(currentTreeProperty); boolean isPropertyInOntology = isPropertyInOntology(currentTreeProperty); - + if (isPropertyInOntology && currentTerm.getCurie() != null) { if (!allNodes.containsKey(currentTerm.getCurie())) { allNodes.put(currentTerm.getCurie(), currentTerm); - } else { + } else { currentTerm = allNodes.get(currentTerm.getCurie()); } } - if (traversedNodes.contains(currentTerm.getCurie())) + if (traversedNodes.contains(currentTerm.getCurie())) { return currentTerm; - + } + traversedNodes.add(currentTerm.getCurie()); if (isPropertyInOntology) { @@ -375,8 +386,9 @@ public T traverseProperties(OWLObjectProperty currentTreeProperty, int depth) th try { T childTerm = traverseProperties(childTermPropertyExpression.getNamedProperty(), depth + 1); - if (childTerm != null && currentTerm.getCurie() != null && isPropertyInOntology) - childTerm.addIsaParent(currentTerm); + if (childTerm != null && currentTerm.getCurie() != null && isPropertyInOntology) { + childTerm.addIsaParent(currentTerm); + } } catch (Exception e) { e.printStackTrace(); } @@ -386,22 +398,22 @@ public T traverseProperties(OWLObjectProperty currentTreeProperty, int depth) th return currentTerm; } - + public T getOntologyTermFromProperty(OWLObjectProperty property) throws Exception { T term = clazz.getDeclaredConstructor().newInstance(); term.setObsolete(false); term.setCurie(property.getIRI().getFragment().replaceFirst("_", ":")); - + EntitySearcher.getAnnotationObjects(property, ontology).forEach(annotation -> { String key = annotation.getProperty().getIRI().getShortForm(); parseAnnotation(annotation, null, term, key); }); - + return term; } - + private void traverseToRootProperty(OWLObjectProperty currentTreeProperty, int depth, HashSet ancestors) throws Exception { List parents = reasoner.getSuperObjectProperties(currentTreeProperty, true).entities().collect(Collectors.toList()); @@ -418,19 +430,21 @@ private void traverseToRootProperty(OWLObjectProperty currentTreeProperty, int d existingNode = currentTerm; } - if (!ancestors.contains(existingNode)) + if (!ancestors.contains(existingNode)) { ancestors.add(existingNode); + } } for (OWLObjectPropertyExpression parent : parents) { traverseToRootProperty(parent.getNamedProperty(), depth + 1, ancestors); } } - + private boolean isPropertyInOntology(OWLObjectProperty property) { - if (config.getLoadOnlyIRIPrefix() == null) + if (config.getLoadOnlyIRIPrefix() == null) { return true; - + } + return property.getIRI().getFragment().startsWith(config.getLoadOnlyIRIPrefix() + "_"); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdGeneratorHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdGeneratorHelper.java index 651738340..750ea1cc1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdGeneratorHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdGeneratorHelper.java @@ -26,7 +26,7 @@ public boolean add(String s) { } return false; } - + public void addList(List list) { if (CollectionUtils.isNotEmpty(list)) { Collections.sort(list); @@ -35,12 +35,12 @@ public void addList(List list) { } } } - + public void addSubmittedObjectList(List list) { if (CollectionUtils.isNotEmpty(list)) { List submittedIdentifiers = list.stream().map(SubmittedObject::getSubmittedIdentifier).collect(Collectors.toList()); addList(submittedIdentifiers); - } + } } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationRetrievalHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationRetrievalHelper.java index 25477f42b..bf57068c1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationRetrievalHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationRetrievalHelper.java @@ -7,14 +7,16 @@ public abstract class AnnotationRetrievalHelper { public static E getCurrentAnnotation(E annotation, SearchResponse annotationList) { - if (annotationList == null || CollectionUtils.isEmpty(annotationList.getResults())) + if (annotationList == null || CollectionUtils.isEmpty(annotationList.getResults())) { return annotation; - + } + for (E annotationInList : annotationList.getResults()) { - if (!annotationInList.getObsolete()) + if (!annotationInList.getObsolete()) { return annotationInList; + } } - + return annotationList.getResults().get(0); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java index 55d5da82c..78483f545 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java @@ -30,33 +30,40 @@ public abstract class AnnotationUniqueIdHelper { public static String getConditionRelationUniqueId(ConditionRelation relation) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); - if (relation.getConditionRelationType() != null) + if (relation.getConditionRelationType() != null) { uniqueId.add(relation.getConditionRelationType().getName()); + } uniqueId.add(relation.getHandle()); - if (relation.getSingleReference() != null) + if (relation.getSingleReference() != null) { uniqueId.add(relation.getSingleReference().getCurie()); - if (CollectionUtils.isNotEmpty(relation.getConditions())) + } + if (CollectionUtils.isNotEmpty(relation.getConditions())) { relation.getConditions().forEach(experimentalCondition -> uniqueId.add(getExperimentalConditionUniqueId(experimentalCondition))); + } return uniqueId.getUniqueId(); } public static String getConditionRelationUniqueId(ConditionRelationDTO dto, String refCurie) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); - if (dto.getConditionRelationTypeName() != null) + if (dto.getConditionRelationTypeName() != null) { uniqueId.add(dto.getConditionRelationTypeName()); + } uniqueId.add(dto.getHandle()); - if (refCurie != null) + if (refCurie != null) { uniqueId.add(refCurie); - if (CollectionUtils.isNotEmpty(dto.getConditionDtos())) + } + if (CollectionUtils.isNotEmpty(dto.getConditionDtos())) { dto.getConditionDtos().forEach(experimentalCondition -> uniqueId.add(getExperimentalConditionUniqueId(experimentalCondition))); + } return uniqueId.getUniqueId(); } public static String getConditionRelationUniqueId(ConditionRelationFmsDTO dto, String relationType) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(relationType); - if (CollectionUtils.isNotEmpty(dto.getConditions())) + if (CollectionUtils.isNotEmpty(dto.getConditions())) { dto.getConditions().forEach(experimentalCondition -> uniqueId.add(getExperimentalConditionUniqueId(experimentalCondition))); + } return uniqueId.getUniqueId(); } @@ -77,8 +84,9 @@ public static String getDiseaseAnnotationUniqueId(DiseaseAnnotationDTO annotatio uniqueId.addList(annotationDTO.getConditionRelationDtos().stream().map(conditionDTO -> { UniqueIdGeneratorHelper gen = new UniqueIdGeneratorHelper(); gen.add(conditionDTO.getConditionRelationTypeName()); - if (CollectionUtils.isNotEmpty(conditionDTO.getConditionDtos())) + if (CollectionUtils.isNotEmpty(conditionDTO.getConditionDtos())) { gen.add(conditionDTO.getConditionDtos().stream().map(AnnotationUniqueIdHelper::getExperimentalConditionUniqueId).collect(Collectors.joining(DELIMITER))); + } return gen.getUniqueId(); }).collect(Collectors.toList())); } @@ -91,16 +99,21 @@ public static String getDiseaseAnnotationUniqueId(DiseaseAnnotationDTO annotatio public static String getDiseaseAnnotationUniqueId(DiseaseAnnotation annotation) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(annotation.getSubjectIdentifier()); - if (annotation.getRelation() != null) + if (annotation.getRelation() != null) { uniqueId.add(annotation.getRelation().getName()); - if (annotation.getNegated() != null) + } + if (annotation.getNegated() != null) { uniqueId.add(annotation.getNegated().toString()); - if (annotation.getDiseaseAnnotationObject() != null) + } + if (annotation.getDiseaseAnnotationObject() != null) { uniqueId.add(annotation.getDiseaseAnnotationObject().getCurie()); - if (annotation.getSingleReference()!= null) + } + if (annotation.getSingleReference() != null) { uniqueId.add(annotation.getSingleReference().getCurie()); - if (CollectionUtils.isNotEmpty(annotation.getEvidenceCodes())) + } + if (CollectionUtils.isNotEmpty(annotation.getEvidenceCodes())) { uniqueId.addList(annotation.getEvidenceCodes().stream().map(ECOTerm::getCurie).collect(Collectors.toList())); + } uniqueId.addSubmittedObjectList(annotation.getWith()); if (CollectionUtils.isNotEmpty(annotation.getConditionRelations())) { uniqueId.addList(annotation.getConditionRelations().stream().map(condition -> { @@ -110,33 +123,39 @@ public static String getDiseaseAnnotationUniqueId(DiseaseAnnotation annotation) return gen.getUniqueId(); }).collect(Collectors.toList())); } - if (CollectionUtils.isNotEmpty(annotation.getDiseaseQualifiers())) + if (CollectionUtils.isNotEmpty(annotation.getDiseaseQualifiers())) { uniqueId.addList(annotation.getDiseaseQualifiers().stream().map(VocabularyTerm::getName).collect(Collectors.toList())); - if (annotation.getDiseaseGeneticModifierRelation() != null) + } + if (annotation.getDiseaseGeneticModifierRelation() != null) { uniqueId.add(annotation.getDiseaseGeneticModifierRelation().getName()); + } uniqueId.addSubmittedObjectList(annotation.getDiseaseGeneticModifiers()); return uniqueId.getUniqueId(); } - + public static String getPhenotypeAnnotationUniqueId(PhenotypeFmsDTO annotationFmsDTO, String subjectIdentifier, String refCurie) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(subjectIdentifier); uniqueId.add("has_phenotype"); uniqueId.add(annotationFmsDTO.getPhenotypeStatement()); - if (CollectionUtils.isNotEmpty(annotationFmsDTO.getPhenotypeTermIdentifiers())) + if (CollectionUtils.isNotEmpty(annotationFmsDTO.getPhenotypeTermIdentifiers())) { uniqueId.addList(annotationFmsDTO.getPhenotypeTermIdentifiers().stream().map(PhenotypeTermIdentifierFmsDTO::getTermId).collect(Collectors.toList())); + } uniqueId.add(refCurie); if (CollectionUtils.isNotEmpty(annotationFmsDTO.getConditionRelations())) { List crIds = new ArrayList<>(); for (ConditionRelationFmsDTO crFmsDto : annotationFmsDTO.getConditionRelations()) { UniqueIdGeneratorHelper gen = new UniqueIdGeneratorHelper(); ConditionRelationFmsEnum fmsCr = null; - if (StringUtils.isNotBlank(crFmsDto.getConditionRelationType())) + if (StringUtils.isNotBlank(crFmsDto.getConditionRelationType())) { fmsCr = ConditionRelationFmsEnum.findByName(crFmsDto.getConditionRelationType()); - if (fmsCr != null) + } + if (fmsCr != null) { gen.add(fmsCr.agrRelation); - if (CollectionUtils.isNotEmpty(crFmsDto.getConditions())) + } + if (CollectionUtils.isNotEmpty(crFmsDto.getConditions())) { gen.add(crFmsDto.getConditions().stream().map(AnnotationUniqueIdHelper::getExperimentalConditionUniqueId).collect(Collectors.joining(DELIMITER))); + } crIds.add(gen.getUniqueId()); } uniqueId.addAll(crIds); @@ -148,13 +167,16 @@ public static String getPhenotypeAnnotationUniqueId(PhenotypeFmsDTO annotationFm public static String getPhenotypeAnnotationUniqueId(PhenotypeAnnotation annotation) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(annotation.getSubjectIdentifier()); - if (annotation.getRelation() != null) + if (annotation.getRelation() != null) { uniqueId.add(annotation.getRelation().getName()); - if (annotation.getPhenotypeAnnotationObject() != null) + } + if (annotation.getPhenotypeAnnotationObject() != null) { uniqueId.add(annotation.getPhenotypeAnnotationObject()); + } uniqueId.add(annotation.getRelation().getName()); - if (annotation.getSingleReference()!= null) + if (annotation.getSingleReference() != null) { uniqueId.add(annotation.getSingleReference().getCurie()); + } if (CollectionUtils.isNotEmpty(annotation.getConditionRelations())) { uniqueId.addList(annotation.getConditionRelations().stream().map(condition -> { UniqueIdGeneratorHelper gen = new UniqueIdGeneratorHelper(); @@ -168,18 +190,24 @@ public static String getPhenotypeAnnotationUniqueId(PhenotypeAnnotation annotati public static String getExperimentalConditionUniqueId(ExperimentalCondition cond) { UniqueIdGeneratorHelper help = new UniqueIdGeneratorHelper(); - if (cond.getConditionClass() != null) + if (cond.getConditionClass() != null) { help.add(cond.getConditionClass().getCurie()); - if (cond.getConditionId() != null) + } + if (cond.getConditionId() != null) { help.add(cond.getConditionId().getCurie()); - if (cond.getConditionAnatomy() != null) + } + if (cond.getConditionAnatomy() != null) { help.add(cond.getConditionAnatomy().getCurie()); - if (cond.getConditionChemical() != null) + } + if (cond.getConditionChemical() != null) { help.add(cond.getConditionChemical().getCurie()); - if (cond.getConditionGeneOntology() != null) + } + if (cond.getConditionGeneOntology() != null) { help.add(cond.getConditionGeneOntology().getCurie()); - if (cond.getConditionTaxon() != null) + } + if (cond.getConditionTaxon() != null) { help.add(cond.getConditionTaxon().getCurie()); + } help.add(cond.getConditionQuantity()); help.add(cond.getConditionFreeText()); return help.getUniqueId(); @@ -240,4 +268,4 @@ public String getEvidenceCurie(List codes, String reference) { } return uniqueId.getUniqueId(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/DiseaseAnnotationUniqueIdUpdateHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/DiseaseAnnotationUniqueIdUpdateHelper.java index 8308bf6ce..4296caf57 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/DiseaseAnnotationUniqueIdUpdateHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/DiseaseAnnotationUniqueIdUpdateHelper.java @@ -12,12 +12,11 @@ @RequestScoped public class DiseaseAnnotationUniqueIdUpdateHelper { - @Inject - DiseaseAnnotationDAO diseaseAnnotationDAO; - + @Inject DiseaseAnnotationDAO diseaseAnnotationDAO; + public void updateDiseaseAnnotationUniqueIds() { ProcessDisplayHelper pdh = new ProcessDisplayHelper(); - + SearchResponse response = diseaseAnnotationDAO.findAllIds(); pdh.startProcess("DiseaseAnnotation uniqueId update", response.getTotalResults()); for (Long daId : response.getResults()) { @@ -30,11 +29,12 @@ public void updateDiseaseAnnotationUniqueIds() { @Transactional public void updateDiseaseAnnotationUniqueId(Long id) { DiseaseAnnotation annotation = diseaseAnnotationDAO.find(id); - if (annotation == null) + if (annotation == null) { return; - + } + annotation.setUniqueId(AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(annotation)); diseaseAnnotationDAO.merge(annotation); } - + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/ExperimentalConditionSummary.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/ExperimentalConditionSummary.java index 259f74505..520d0d33f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/ExperimentalConditionSummary.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/ExperimentalConditionSummary.java @@ -23,45 +23,47 @@ @RequestScoped public class ExperimentalConditionSummary { - @Inject - ZecoTermService zecoTermService; - @Inject - ExperimentalConditionOntologyTermService expCondTermService; - @Inject - AnatomicalTermService anatomicalTermService; - @Inject - GoTermService goTermService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - ChemicalTermService chemicalTermService; + @Inject ZecoTermService zecoTermService; + @Inject ExperimentalConditionOntologyTermService expCondTermService; + @Inject AnatomicalTermService anatomicalTermService; + @Inject GoTermService goTermService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject ChemicalTermService chemicalTermService; public static String getConditionSummary(ExperimentalCondition condition) { UniqueIdGeneratorHelper conditionSummary = new UniqueIdGeneratorHelper(); - if (condition.getConditionClass() != null) + if (condition.getConditionClass() != null) { conditionSummary.add(condition.getConditionClass().getName()); + } - if (condition.getConditionId() != null) + if (condition.getConditionId() != null) { conditionSummary.add(condition.getConditionId().getName()); + } - if (condition.getConditionAnatomy() != null) + if (condition.getConditionAnatomy() != null) { conditionSummary.add(condition.getConditionAnatomy().getName()); + } - if (condition.getConditionGeneOntology() != null) + if (condition.getConditionGeneOntology() != null) { conditionSummary.add(condition.getConditionGeneOntology().getName()); + } - if (condition.getConditionChemical() != null) + if (condition.getConditionChemical() != null) { conditionSummary.add(condition.getConditionChemical().getName()); + } - if (condition.getConditionTaxon() != null) + if (condition.getConditionTaxon() != null) { conditionSummary.add(condition.getConditionTaxon().getName()); + } - if (condition.getConditionQuantity() != null) + if (condition.getConditionQuantity() != null) { conditionSummary.add(condition.getConditionQuantity()); + } - if (StringUtils.isNotBlank(condition.getConditionFreeText())) + if (StringUtils.isNotBlank(condition.getConditionFreeText())) { conditionSummary.add(condition.getConditionFreeText()); + } return conditionSummary.getSummary(); } @@ -99,11 +101,13 @@ public String getConditionSummary(ExperimentalConditionDTO conditionDto) { conditionSummary.add(conditionTaxon.getName()); } - if (StringUtils.isNotBlank(conditionDto.getConditionQuantity())) + if (StringUtils.isNotBlank(conditionDto.getConditionQuantity())) { conditionSummary.add(conditionDto.getConditionQuantity()); + } - if (StringUtils.isNotBlank(conditionDto.getConditionFreeText())) + if (StringUtils.isNotBlank(conditionDto.getConditionFreeText())) { conditionSummary.add(conditionDto.getConditionFreeText()); + } return conditionSummary.getSummary(); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/constructs/ConstructUniqueIdHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/constructs/ConstructUniqueIdHelper.java index 9583b092b..0ed349fbd 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/constructs/ConstructUniqueIdHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/constructs/ConstructUniqueIdHelper.java @@ -17,10 +17,12 @@ public abstract class ConstructUniqueIdHelper { public static String getConstructUniqueId(ConstructDTO constructDTO) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); - if (constructDTO.getConstructSymbolDto() != null) + if (constructDTO.getConstructSymbolDto() != null) { uniqueId.add(constructDTO.getConstructSymbolDto().getFormatText()); - if (constructDTO.getConstructFullNameDto() != null) + } + if (constructDTO.getConstructFullNameDto() != null) { uniqueId.add(constructDTO.getConstructFullNameDto().getFormatText()); + } if (CollectionUtils.isNotEmpty(constructDTO.getConstructComponentDtos())) { List componentIds = new ArrayList<>(); @@ -30,17 +32,19 @@ public static String getConstructUniqueId(ConstructDTO constructDTO) { Collections.sort(componentIds); uniqueId.addAll(componentIds); } - + return uniqueId.getUniqueId(); } public static String getConstructUniqueId(Construct construct) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); - if (construct.getConstructSymbol() != null) + if (construct.getConstructSymbol() != null) { uniqueId.add(construct.getConstructSymbol().getFormatText()); - if (construct.getConstructFullName() != null) + } + if (construct.getConstructFullName() != null) { uniqueId.add(construct.getConstructFullName().getFormatText()); - + } + if (CollectionUtils.isNotEmpty(construct.getConstructComponents())) { List componentIds = new ArrayList<>(); for (ConstructComponentSlotAnnotation component : construct.getConstructComponents()) { @@ -49,26 +53,27 @@ public static String getConstructUniqueId(Construct construct) { Collections.sort(componentIds); uniqueId.addAll(componentIds); } - + return uniqueId.getUniqueId(); } - + private static String getConstructComponentUniqueId(ConstructComponentSlotAnnotationDTO dto) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(dto.getComponentSymbol()); uniqueId.add(dto.getTaxonCurie()); uniqueId.add(dto.getTaxonText()); - + return uniqueId.getUniqueId(); } - + private static String getConstructComponentUniqueId(ConstructComponentSlotAnnotation component) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(component.getComponentSymbol()); - if (component.getTaxon() != null) + if (component.getTaxon() != null) { uniqueId.add(component.getTaxon().getCurie()); + } uniqueId.add(component.getTaxonText()); - + return uniqueId.getUniqueId(); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionAnnotationsHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionAnnotationsHelper.java index 82c9e5eec..d7b347746 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionAnnotationsHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionAnnotationsHelper.java @@ -15,41 +15,46 @@ @RequestScoped public class InteractionAnnotationsHelper { - + private static final Pattern WB_PHENO_TERM = Pattern.compile("wormbase:\"(WBPhenotype:\\d+)\""); private static final Pattern NON_WB_ANNOT = Pattern.compile("(.*?)\\((.*?)\\)"); - + @Inject WbPhenotypeTermService wbPhenotypeTermService; - + public List extractPhenotypeStatements(List annotations) { - if (CollectionUtils.isEmpty(annotations)) + if (CollectionUtils.isEmpty(annotations)) { return null; - + } + List statements = new ArrayList<>(); for (String annotation : annotations) { String statement = extractPhenotypeStatement(annotation); - if (statement != null) + if (statement != null) { statements.add(statement); + } } - - if (CollectionUtils.isEmpty(statements)) + + if (CollectionUtils.isEmpty(statements)) { return null; - + } + return statements; } - + private String extractPhenotypeStatement(String annotation) { if (annotation.startsWith("wormbase:")) { Matcher wbMatcher = WB_PHENO_TERM.matcher(annotation); - if (!wbMatcher.find()) + if (!wbMatcher.find()) { return null; + } String wbPhenotypeTermCurie = wbMatcher.group(1); WBPhenotypeTerm wbPhenotypeTerm = wbPhenotypeTermService.findByCurieOrSecondaryId(wbPhenotypeTermCurie); - if (wbPhenotypeTerm == null) + if (wbPhenotypeTerm == null) { return null; + } return wbPhenotypeTerm.getName(); } - + List statementParts = new ArrayList<>(); String[] annotationParts = annotation.split(";"); for (String annotationPart : annotationParts) { @@ -67,18 +72,18 @@ private String extractPhenotypeStatement(String annotation) { statementParts.add("undetermined extend of rescue"); break; default: - Log.error("Unrecognised annotation type " + annotationPart); + Log.error("Unrecognised annotation type " + annotationPart); } - } - else { + } else { statementParts.add(nonWbMatcher.group(2)); } } } - - if (CollectionUtils.isEmpty(statementParts)) + + if (CollectionUtils.isEmpty(statementParts)) { return null; - + } + return String.join(", ", statementParts); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionCrossReferenceHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionCrossReferenceHelper.java index ae3cd0ad3..27b32147d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionCrossReferenceHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionCrossReferenceHelper.java @@ -15,48 +15,55 @@ @RequestScoped public class InteractionCrossReferenceHelper { - + @Inject ResourceDescriptorPageService rdpService; - + public List createAllianceXrefs(PsiMiTabDTO dto) { List xrefs = new ArrayList<>(); List xrefStrings = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(dto.getInteractionIds())) + if (CollectionUtils.isNotEmpty(dto.getInteractionIds())) { xrefStrings.addAll(dto.getInteractionIds()); - if (CollectionUtils.isNotEmpty(dto.getInteractionXrefs())) + } + if (CollectionUtils.isNotEmpty(dto.getInteractionXrefs())) { xrefStrings.addAll(dto.getInteractionXrefs()); + } - if (CollectionUtils.isEmpty(xrefStrings)) + if (CollectionUtils.isEmpty(xrefStrings)) { return null; - + } + for (String xrefString : xrefStrings) { String xrefCurie = PsiMiTabPrefixEnum.getAllianceIdentifier(xrefString); if (xrefCurie != null) { CrossReference xref = createAllianceXref(xrefCurie); - if (xref != null) + if (xref != null) { xrefs.add(xref); + } } } - - if (CollectionUtils.isEmpty(xrefs)) + + if (CollectionUtils.isEmpty(xrefs)) { return null; - + } + return xrefs; } - + private CrossReference createAllianceXref(String curie) { String[] curieParts = curie.split(":"); - if (curieParts.length != 2) + if (curieParts.length != 2) { return null; + } ResourceDescriptorPage rdp = rdpService.getPageForResourceDescriptor(curieParts[0], "gene/interactions"); - if (rdp == null) + if (rdp == null) { return null; - + } + CrossReference xref = new CrossReference(); xref.setDisplayName(curie); xref.setReferencedCurie(curie); xref.setResourceDescriptorPage(rdp); - + return xref; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionStringHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionStringHelper.java index 5d9c3b487..3fe816c2e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionStringHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/interactions/InteractionStringHelper.java @@ -14,7 +14,7 @@ import org.apache.commons.lang3.StringUtils; public abstract class InteractionStringHelper { - + private static final Pattern PSI_MI_FORMAT = Pattern.compile("^[^:]+:\"([^\"]*)\""); private static final Pattern WB_VAR_ANNOTATION = Pattern.compile("wormbase:(WBVar\\d+)\\D*"); private static final Pattern PSI_MI_FORMAT_TAXON = Pattern.compile("^taxid:(\\d+)"); @@ -22,34 +22,40 @@ public abstract class InteractionStringHelper { public static String getGeneMolecularInteractionUniqueId(PsiMiTabDTO dto, Gene interactorA, Gene interactorB, String interactionId, List references) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(getGeneInteractionUniqueId(dto, interactorA, interactorB, interactionId, references, VocabularyConstants.GENE_MOLECULAR_INTERACTION_RELATION_TERM)); - if (dto.getInteractionDetectionMethods() != null) + if (dto.getInteractionDetectionMethods() != null) { uniqueId.addList(dto.getInteractionDetectionMethods().stream().map(dm -> extractCurieFromPsiMiFormat(dm)).collect(Collectors.toList())); + } return uniqueId.getUniqueId(); } - + public static String getGeneGeneticInteractionUniqueId(PsiMiTabDTO dto, Gene interactorA, Gene interactorB, String interactionId, List references, List phenotypesOrTraits) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(getGeneInteractionUniqueId(dto, interactorA, interactorB, interactionId, references, VocabularyConstants.GENE_GENETIC_INTERACTION_RELATION_TERM)); - if (dto.getSourceDatabaseIds() != null) + if (dto.getSourceDatabaseIds() != null) { uniqueId.addList(dto.getSourceDatabaseIds().stream().map(sd -> extractCurieFromPsiMiFormat(sd)).collect(Collectors.toList())); + } uniqueId.add(extractWBVarCurieFromAnnotations(dto.getInteractorAAnnotationString())); uniqueId.add(extractWBVarCurieFromAnnotations(dto.getInteractorBAnnotationString())); uniqueId.addList(phenotypesOrTraits); return uniqueId.getUniqueId(); } - + public static String getGeneInteractionUniqueId(PsiMiTabDTO dto, Gene interactorA, Gene interactorB, String interactionId, List references, String relation) { UniqueIdGeneratorHelper uniqueId = new UniqueIdGeneratorHelper(); uniqueId.add(interactionId); - if (interactorA != null) + if (interactorA != null) { uniqueId.add(interactorA.getIdentifier()); + } uniqueId.add(relation); - if (interactorB != null) + if (interactorB != null) { uniqueId.add(interactorB.getIdentifier()); - if (references != null) + } + if (references != null) { uniqueId.addList(references.stream().map(Reference::getCurie).collect(Collectors.toList())); - if (dto.getInteractionTypes() != null) + } + if (dto.getInteractionTypes() != null) { uniqueId.addList(dto.getInteractionTypes().stream().map(it -> extractCurieFromPsiMiFormat(it)).collect(Collectors.toList())); + } uniqueId.add(extractCurieFromPsiMiFormat(dto.getExperimentalRoleA())); uniqueId.add(extractCurieFromPsiMiFormat(dto.getExperimentalRoleB())); uniqueId.add(extractCurieFromPsiMiFormat(dto.getInteractorAType())); @@ -58,49 +64,58 @@ public static String getGeneInteractionUniqueId(PsiMiTabDTO dto, Gene interactor } public static String extractCurieFromPsiMiFormat(String psiMiString) { - // For extracting curies from PSI-MI fields of format :""() - if (StringUtils.isBlank(psiMiString)) + // For extracting curies from PSI-MI fields of format + // :""() + if (StringUtils.isBlank(psiMiString)) { return null; - + } + Matcher matcher = PSI_MI_FORMAT.matcher(psiMiString); - - if (!matcher.find()) + + if (!matcher.find()) { return null; - + } + return matcher.group(1); } - + public static String getAllianceTaxonCurie(String psiMiTaxonString) { // For retrieving Alliance taxon curie from PSI-MI taxon fields - if (StringUtils.isBlank(psiMiTaxonString)) + if (StringUtils.isBlank(psiMiTaxonString)) { return null; - + } + Matcher matcher = PSI_MI_FORMAT_TAXON.matcher(psiMiTaxonString); - - if (!matcher.find()) + + if (!matcher.find()) { return null; - + } + return "NCBITaxon:" + matcher.group(1); } - + public static String extractWBVarCurieFromAnnotations(String annotationsString) { - if (StringUtils.isBlank(annotationsString)) + if (StringUtils.isBlank(annotationsString)) { return null; - + } + Matcher matcher = WB_VAR_ANNOTATION.matcher(annotationsString); - - if (!matcher.find()) + + if (!matcher.find()) { return null; - + } + return "WB:" + matcher.group(1); } - + public static String getAggregationDatabaseMITermCurie(PsiMiTabDTO dto) { - if (CollectionUtils.isEmpty(dto.getSourceDatabaseIds())) + if (CollectionUtils.isEmpty(dto.getSourceDatabaseIds())) { return null; + } String sourceDatabaseCurie = extractCurieFromPsiMiFormat(dto.getSourceDatabaseIds().get(0)); - if (sourceDatabaseCurie == null) + if (sourceDatabaseCurie == null) { return null; + } if (sourceDatabaseCurie.equals("MI:0478") || sourceDatabaseCurie.equals("MI:0487") || sourceDatabaseCurie.equals("MI:0463")) { return sourceDatabaseCurie; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java index 0fc877821..aa272f31e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java @@ -11,7 +11,10 @@ import org.apache.commons.lang.StringUtils; public class NoteIdentityHelper { - + private NoteIdentityHelper() { + // Hidden from view, as it is a utility class + } + public static String noteIdentity(Note note) { String identity = StringUtils.isBlank(note.getFreeText()) ? "" : note.getFreeText(); if (CollectionUtils.isNotEmpty(note.getReferences())) { @@ -19,16 +22,19 @@ public static String noteIdentity(Note note) { Collections.sort(evidenceCuries); identity = identity + "|" + StringUtils.join(evidenceCuries, ":"); } - if (note.getNoteType() != null) + if (note.getNoteType() != null) { identity = identity + "|" + note.getNoteType().getName(); - if (note.getInternal() != null) + } + if (note.getInternal() != null) { identity = identity + "|" + note.getInternal().toString(); - if (note.getObsolete() != null) + } + if (note.getObsolete() != null) { identity = identity + "|" + note.getObsolete().toString(); - + } + return identity; } - + public static String noteDtoIdentity(NoteDTO note) { String identity = StringUtils.isBlank(note.getFreeText()) ? "" : note.getFreeText(); List evidenceCuries = note.getEvidenceCuries(); @@ -36,13 +42,16 @@ public static String noteDtoIdentity(NoteDTO note) { Collections.sort(evidenceCuries); identity = identity + "|" + StringUtils.join(evidenceCuries, ":"); } - if (note.getNoteTypeName() != null) + if (note.getNoteTypeName() != null) { identity = identity + "|" + note.getNoteTypeName(); - if (note.getInternal() != null) + } + if (note.getInternal() != null) { identity = identity + "|" + note.getInternal().toString(); - if (note.getObsolete() != null) + } + if (note.getObsolete() != null) { identity = identity + "|" + note.getObsolete().toString(); - + } + return identity; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/references/ReferenceSynchronisationHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/references/ReferenceSynchronisationHelper.java index 8eda83cfc..679f197a7 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/references/ReferenceSynchronisationHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/references/ReferenceSynchronisationHelper.java @@ -25,14 +25,10 @@ @RequestScoped public class ReferenceSynchronisationHelper { - @Inject - ReferenceDAO referenceDAO; - @Inject - ReferenceService referenceService; - @Inject - LiteratureReferenceDAO literatureReferenceDAO; - @Inject - CrossReferenceDAO crossReferenceDAO; + @Inject ReferenceDAO referenceDAO; + @Inject ReferenceService referenceService; + @Inject LiteratureReferenceDAO literatureReferenceDAO; + @Inject CrossReferenceDAO crossReferenceDAO; public Reference retrieveFromLiteratureService(String curie) { @@ -40,8 +36,9 @@ public Reference retrieveFromLiteratureService(String curie) { if (litRef != null) { Reference ref = referenceService.findByCurie(curie); - if (ref == null) + if (ref == null) { ref = new Reference(); + } ref = copyLiteratureReferenceFields(litRef, ref); return ref; @@ -66,16 +63,17 @@ protected LiteratureReference fetchLiteratureServiceReference(String curie) { Pagination pagination = new Pagination(0, 50); SearchResponse response = literatureReferenceDAO.searchByParams(pagination, params); - if (response != null && response.getTotalResults() != null && response.getTotalResults() == 1) + if (response != null && response.getTotalResults() != null && response.getTotalResults() == 1) { return response.getSingleResult(); - + } + return null; } public void synchroniseReferences() { ProcessDisplayHelper pdh = new ProcessDisplayHelper(); - + SearchResponse response = referenceDAO.findAllIds(); pdh.startProcess("Reference Sync", response.getTotalResults()); for (Long refId : response.getResults()) { @@ -86,13 +84,13 @@ public void synchroniseReferences() { } protected Reference copyLiteratureReferenceFields(LiteratureReference litRef, Reference ref) { - + ref.setCurie(litRef.getCurie()); ref.setObsolete(false); List xrefs = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(litRef.getCross_references())) { - for (LiteratureCrossReference litXref : litRef.getCross_references()) { + if (CollectionUtils.isNotEmpty(litRef.getCrossReferences())) { + for (LiteratureCrossReference litXref : litRef.getCrossReferences()) { SearchResponse xrefResponse = crossReferenceDAO.findByField("referencedCurie", litXref.getCurie()); CrossReference xref; if (xrefResponse == null || xrefResponse.getSingleResult() == null) { @@ -108,8 +106,9 @@ protected Reference copyLiteratureReferenceFields(LiteratureReference litRef, Re xrefs.add(xref); } } - if (CollectionUtils.isNotEmpty(xrefs)) + if (CollectionUtils.isNotEmpty(xrefs)) { ref.setCrossReferences(xrefs); + } ref.setShortCitation(litRef.citationShort); @@ -120,9 +119,9 @@ protected Reference copyLiteratureReferenceFields(LiteratureReference litRef, Re public ObjectResponse synchroniseReference(Long id) { Reference ref = referenceDAO.find(id); ObjectResponse response = new ObjectResponse<>(); - if (ref == null) + if (ref == null) { return response; - + } LiteratureReference litRef = fetchLiteratureServiceReference(ref.getCurie()); if (litRef == null) { @@ -130,7 +129,7 @@ public ObjectResponse synchroniseReference(Long id) { } else { ref = copyLiteratureReferenceFields(litRef, ref); } - + response.setEntity(referenceDAO.persist(ref)); return response; diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/slotAnnotations/SlotAnnotationIdentityHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/slotAnnotations/SlotAnnotationIdentityHelper.java index 3d2f6c319..25336b843 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/slotAnnotations/SlotAnnotationIdentityHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/slotAnnotations/SlotAnnotationIdentityHelper.java @@ -38,9 +38,9 @@ @RequestScoped public class SlotAnnotationIdentityHelper { - + @Inject ReferenceService refService; - + public static String alleleMutationTypeIdentity(AlleleMutationTypeSlotAnnotation annotation) { String identity = ""; if (CollectionUtils.isNotEmpty(annotation.getMutationTypes())) { @@ -50,7 +50,7 @@ public static String alleleMutationTypeIdentity(AlleleMutationTypeSlotAnnotation } return identity + "|" + slotAnnotationIdentity(annotation); } - + public String alleleMutationTypeDtoIdentity(AlleleMutationTypeSlotAnnotationDTO dto) { String identity = ""; List mutationTypeCuries = dto.getMutationTypeCuries(); @@ -58,34 +58,34 @@ public String alleleMutationTypeDtoIdentity(AlleleMutationTypeSlotAnnotationDTO Collections.sort(mutationTypeCuries); identity = StringUtils.join(mutationTypeCuries, ":"); } - + return identity + "|" + slotAnnotationDtoIdentity(dto); } - + public static String alleleGermlineTransmissionStatusIdentity(AlleleGermlineTransmissionStatusSlotAnnotation annotation) { String gts = annotation.getGermlineTransmissionStatus() == null ? "" : annotation.getGermlineTransmissionStatus().getName(); - + return StringUtils.join(List.of(gts, slotAnnotationIdentity(annotation)), "|"); } - + public String alleleGermlineTransmissionStatusDtoIdentity(AlleleGermlineTransmissionStatusSlotAnnotationDTO dto) { String gts = StringUtils.isBlank(dto.getGermlineTransmissionStatusName()) ? "" : dto.getGermlineTransmissionStatusName(); - + return StringUtils.join(List.of(gts, slotAnnotationDtoIdentity(dto)), "|"); } - + public static String alleleNomenclatureEventIdentity(AlleleNomenclatureEventSlotAnnotation annotation) { String ne = annotation.getNomenclatureEvent() == null ? "" : annotation.getNomenclatureEvent().getName(); - + return StringUtils.join(List.of(ne, slotAnnotationIdentity(annotation)), "|"); } - + public String alleleNomenclatureEventDtoIdentity(AlleleNomenclatureEventSlotAnnotationDTO dto) { String ne = StringUtils.isBlank(dto.getNomenclatureEventName()) ? "" : dto.getNomenclatureEventName(); - + return StringUtils.join(List.of(ne, slotAnnotationDtoIdentity(dto)), "|"); } - + public static String alleleFunctionalImpactIdentity(AlleleFunctionalImpactSlotAnnotation annotation) { String functionalImpactNameString = ""; if (CollectionUtils.isNotEmpty(annotation.getFunctionalImpacts())) { @@ -98,7 +98,7 @@ public static String alleleFunctionalImpactIdentity(AlleleFunctionalImpactSlotAn return StringUtils.join(List.of(functionalImpactNameString, phenotypeTerm, phenotypeStatement, slotAnnotationIdentity(annotation)), "|"); } - + public String alleleFunctionalImpactDtoIdentity(AlleleFunctionalImpactSlotAnnotationDTO dto) { String functionalImpactNameString = ""; List functionalImpactNames = dto.getFunctionalImpactNames(); @@ -111,7 +111,7 @@ public String alleleFunctionalImpactDtoIdentity(AlleleFunctionalImpactSlotAnnota return StringUtils.join(List.of(functionalImpactNameString, phenotypeTerm, phenotypeStatement, slotAnnotationDtoIdentity(dto)), "|"); } - + public static String alleleInheritanceModeIdentity(AlleleInheritanceModeSlotAnnotation annotation) { String inheritanceMode = annotation.getInheritanceMode() == null ? "" : annotation.getInheritanceMode().getName(); String phenotypeTerm = annotation.getPhenotypeTerm() == null ? "" : annotation.getPhenotypeTerm().getCurie(); @@ -119,7 +119,7 @@ public static String alleleInheritanceModeIdentity(AlleleInheritanceModeSlotAnno return StringUtils.join(List.of(inheritanceMode, phenotypeTerm, phenotypeStatement, slotAnnotationIdentity(annotation)), "|"); } - + public String alleleInheritanceModeDtoIdentity(AlleleInheritanceModeSlotAnnotationDTO dto) { String inheritanceMode = StringUtils.isBlank(dto.getInheritanceModeName()) ? "" : dto.getInheritanceModeName(); String phenotypeTerm = StringUtils.isBlank(dto.getPhenotypeTermCurie()) ? "" : dto.getPhenotypeTermCurie(); @@ -127,76 +127,78 @@ public String alleleInheritanceModeDtoIdentity(AlleleInheritanceModeSlotAnnotati return StringUtils.join(List.of(inheritanceMode, phenotypeTerm, phenotypeStatement, slotAnnotationDtoIdentity(dto)), "|"); } - + public static String constructComponentIdentity(ConstructComponentSlotAnnotation annotation) { String componentSymbol = StringUtils.isBlank(annotation.getComponentSymbol()) ? "" : annotation.getComponentSymbol(); String taxon = annotation.getTaxon() == null ? "" : annotation.getTaxon().getCurie(); String taxonText = StringUtils.isBlank(annotation.getTaxonText()) ? "" : annotation.getTaxonText(); String notesIdentity = notesIdentity(annotation.getRelatedNotes()); - + return StringUtils.join(List.of(componentSymbol, taxon, taxonText, notesIdentity), "|"); } - + public String constructComponentDtoIdentity(ConstructComponentSlotAnnotationDTO dto) { String componentSymbol = StringUtils.isBlank(dto.getComponentSymbol()) ? "" : dto.getComponentSymbol(); String taxon = StringUtils.isBlank(dto.getTaxonCurie()) ? "" : dto.getTaxonCurie(); String taxonText = StringUtils.isBlank(dto.getTaxonText()) ? "" : dto.getTaxonText(); String notesIdentity = noteDtosIdentity(dto.getNoteDtos()); - + return StringUtils.join(List.of(componentSymbol, taxon, taxonText, notesIdentity), "|"); } - + public static String nameSlotAnnotationIdentity(NameSlotAnnotation annotation) { String displayText = StringUtils.isBlank(annotation.getDisplayText()) ? "" : annotation.getDisplayText(); String formatText = StringUtils.isBlank(annotation.getFormatText()) ? "" : annotation.getFormatText(); - + return StringUtils.join(List.of(displayText, formatText, slotAnnotationIdentity(annotation)), "|"); } public String nameSlotAnnotationDtoIdentity(NameSlotAnnotationDTO dto) { String displayText = StringUtils.isBlank(dto.getDisplayText()) ? "" : dto.getDisplayText(); String formatText = StringUtils.isBlank(dto.getFormatText()) ? "" : dto.getFormatText(); - + return StringUtils.join(List.of(displayText, formatText, slotAnnotationDtoIdentity(dto)), "|"); } - + public static String secondaryIdIdentity(SecondaryIdSlotAnnotation annotation) { String secondaryId = StringUtils.isBlank(annotation.getSecondaryId()) ? "" : annotation.getSecondaryId(); - + return StringUtils.join(List.of(secondaryId, slotAnnotationIdentity(annotation)), "|"); } - + public String secondaryIdDtoIdentity(SecondaryIdSlotAnnotationDTO dto) { String secondaryId = StringUtils.isBlank(dto.getSecondaryId()) ? "" : dto.getSecondaryId(); - + return StringUtils.join(List.of(secondaryId, slotAnnotationDtoIdentity(dto)), "|"); } - + private static String slotAnnotationIdentity(SlotAnnotation annotation) { return evidenceIdentity(annotation.getEvidence()); } - + private String slotAnnotationDtoIdentity(SlotAnnotationDTO dto) { List evidenceCuries = dto.getEvidenceCuries(); return evidenceIngestIdentity(evidenceCuries); } - + private static String evidenceIdentity(List evidence) { String identity = ""; - if (CollectionUtils.isEmpty(evidence)) + if (CollectionUtils.isEmpty(evidence)) { return identity; - + } + List evidenceCuries = evidence.stream().map(InformationContentEntity::getCurie).collect(Collectors.toList()); Collections.sort(evidenceCuries); identity = StringUtils.join(evidenceCuries, ":"); - + return identity; } - + public static String notesIdentity(List notes) { - if (CollectionUtils.isEmpty(notes)) + if (CollectionUtils.isEmpty(notes)) { return ""; - + } + List noteIdentities = new ArrayList<>(); for (Note note : notes) { String freeText = StringUtils.isBlank(note.getFreeText()) ? "" : note.getFreeText(); @@ -206,14 +208,15 @@ public static String notesIdentity(List notes) { noteIdentities.add(noteIdentity); } Collections.sort(noteIdentities); - + return StringUtils.join(noteIdentities, "|"); } - + public String noteDtosIdentity(List dtos) { - if (CollectionUtils.isEmpty(dtos)) + if (CollectionUtils.isEmpty(dtos)) { return ""; - + } + List noteIdentities = new ArrayList<>(); for (NoteDTO dto : dtos) { String freeText = StringUtils.isBlank(dto.getFreeText()) ? "" : dto.getFreeText(); @@ -223,35 +226,39 @@ public String noteDtosIdentity(List dtos) { noteIdentities.add(noteIdentity); } Collections.sort(noteIdentities); - + return StringUtils.join(noteIdentities, "|"); } - + private static String referencesIdentity(List references) { String identity = ""; - if (CollectionUtils.isEmpty(references)) + if (CollectionUtils.isEmpty(references)) { return identity; - + } + List referenceCuries = references.stream().map(InformationContentEntity::getCurie).collect(Collectors.toList()); Collections.sort(referenceCuries); identity = StringUtils.join(referenceCuries, ":"); - + return identity; } - + private String evidenceIngestIdentity(List evidenceCuries) { - if (CollectionUtils.isEmpty(evidenceCuries)) + if (CollectionUtils.isEmpty(evidenceCuries)) { return ""; - + } + List agrEvidenceCuries = new ArrayList<>(); for (String curie : evidenceCuries) { Reference ref = refService.retrieveFromDbOrLiteratureService(curie); - if (ref != null) + if (ref != null) { agrEvidenceCuries.add(ref.getCurie()); + } } - - if (CollectionUtils.isEmpty(agrEvidenceCuries)) + + if (CollectionUtils.isEmpty(agrEvidenceCuries)) { return ""; + } Collections.sort(agrEvidenceCuries); return StringUtils.join(agrEvidenceCuries, ":"); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java index 04be00bd0..9cae02f33 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java @@ -16,12 +16,10 @@ @RequestScoped public class BulkFMSLoadService extends BaseEntityCrudService { - @Inject - BulkFMSLoadDAO bulkFMSLoadDAO; - - @Inject - Event pendingJobEvents; - + @Inject BulkFMSLoadDAO bulkFMSLoadDAO; + + @Inject Event pendingJobEvents; + @Override @PostConstruct protected void init() { @@ -30,17 +28,17 @@ protected void init() { public ObjectResponse restartLoad(Long id) { ObjectResponse resp = updateLoad(id); - if(resp != null) { + if (resp != null) { pendingJobEvents.fire(new PendingBulkLoadJobEvent(id)); return resp; } return null; } - + @Transactional protected ObjectResponse updateLoad(Long id) { BulkFMSLoad load = bulkFMSLoadDAO.find(id); - if(load != null && load.getBulkloadStatus().isNotRunning()) { + if (load != null && load.getBulkloadStatus().isNotRunning()) { load.setBulkloadStatus(JobStatus.FORCED_PENDING); return new ObjectResponse(load); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileExceptionService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileExceptionService.java index 997ed1c97..b1a620edf 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileExceptionService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileExceptionService.java @@ -11,8 +11,7 @@ @RequestScoped public class BulkLoadFileExceptionService extends BaseEntityCrudService { - @Inject - BulkLoadFileExceptionDAO bulkLoadFileExceptionDAO; + @Inject BulkLoadFileExceptionDAO bulkLoadFileExceptionDAO; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java index 63d35ed4f..04e33b673 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java @@ -31,14 +31,14 @@ protected void init() { public Response download(Long id) { JsonArray jsonArray = new JsonArray(); BulkLoadFileHistory bulkLoadFileHistory = bulkLoadFileHistoryDAO.find(id); - for(BulkLoadFileException exception : bulkLoadFileHistory.getExceptions()){ + for (BulkLoadFileException exception : bulkLoadFileHistory.getExceptions()) { JsonObject object = new JsonObject(); object.put("message", exception.getException().getMessage()); JsonObject data = new JsonObject(exception.getException().getJsonObject()); object.put("jsonObject", data); jsonArray.add(object); } - + // TODO Pulling the history grabs all the exceptions causing the server to crash // TODO May need to revisit this // HashMap params = new HashMap<>(); @@ -64,9 +64,9 @@ public Response download(Long id) { // // BulkLoadFileHistory bulkLoadFileHistory = bulkLoadFileHistoryDAO.find(id); // response.header("Content-Disposition", "attachment; filename=\"" + id + "_file_exceptions.json\""); - + Response.ResponseBuilder response = Response.ok(jsonArray.toString()); - response.header("Content-Disposition", "attachment; filename=\"" + bulkLoadFileHistory.getBulkLoadFile().getBulkLoad().getName().replace( " ", "_") + "_exceptions.json\""); + response.header("Content-Disposition", "attachment; filename=\"" + bulkLoadFileHistory.getBulkLoadFile().getBulkLoad().getName().replace(" ", "_") + "_exceptions.json\""); response.type(MediaType.APPLICATION_OCTET_STREAM); return response.build(); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java index 25fac6e15..503d85c3e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java @@ -16,35 +16,33 @@ @RequestScoped public class BulkLoadFileService extends BaseEntityCrudService { - @Inject - BulkLoadFileDAO bulkLoadFileDAO; + @Inject BulkLoadFileDAO bulkLoadFileDAO; + + @Inject Event pendingFileJobEvents; - @Inject - Event pendingFileJobEvents; - @Override @PostConstruct protected void init() { setSQLDao(bulkLoadFileDAO); } - + public ObjectResponse restartLoad(Long id) { ObjectResponse resp = updateLoad(id); - if(resp != null) { + if (resp != null) { pendingFileJobEvents.fire(new PendingBulkLoadFileJobEvent(id)); return resp; } return null; } - + @Transactional protected ObjectResponse updateLoad(Long id) { BulkLoadFile load = bulkLoadFileDAO.find(id); - if(load != null && load.getBulkloadStatus().isNotRunning()) { + if (load != null && load.getBulkloadStatus().isNotRunning()) { load.setBulkloadStatus(JobStatus.FORCED_PENDING); return new ObjectResponse(load); } return null; } - + } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadGroupService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadGroupService.java index 627c0944d..b3ed01176 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadGroupService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadGroupService.java @@ -11,8 +11,7 @@ @RequestScoped public class BulkLoadGroupService extends BaseEntityCrudService { - @Inject - BulkLoadGroupDAO bulkLoadGroupDAO; + @Inject BulkLoadGroupDAO bulkLoadGroupDAO; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java index 331ae046b..ea7a58fde 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java @@ -16,12 +16,10 @@ @RequestScoped public class BulkManualLoadService extends BaseEntityCrudService { - @Inject - BulkManualLoadDAO bulkManualLoadDAO; - - @Inject - Event pendingJobEvents; - + @Inject BulkManualLoadDAO bulkManualLoadDAO; + + @Inject Event pendingJobEvents; + @Override @PostConstruct protected void init() { @@ -30,17 +28,17 @@ protected void init() { public ObjectResponse restartLoad(Long id) { ObjectResponse resp = updateLoad(id); - if(resp != null) { + if (resp != null) { pendingJobEvents.fire(new PendingBulkLoadJobEvent(id)); return resp; } return null; } - + @Transactional protected ObjectResponse updateLoad(Long id) { BulkManualLoad load = bulkManualLoadDAO.find(id); - if(load != null && load.getBulkloadStatus().isNotRunning()) { + if (load != null && load.getBulkloadStatus().isNotRunning()) { load.setBulkloadStatus(JobStatus.FORCED_PENDING); return new ObjectResponse(load); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java index c7e03189d..d86c89e38 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java @@ -17,12 +17,10 @@ @RequestScoped public class BulkURLLoadService extends BaseEntityCrudService { - @Inject - BulkURLLoadDAO bulkURLLoadDAO; - - @Inject - Event pendingJobEvents; - + @Inject BulkURLLoadDAO bulkURLLoadDAO; + + @Inject Event pendingJobEvents; + @Override @PostConstruct protected void init() { @@ -32,19 +30,19 @@ protected void init() { public ObjectResponse restartLoad(Long id) { Log.info("restartLoad: " + id); ObjectResponse resp = updateLoad(id); - if(resp != null) { + if (resp != null) { Log.info("Firing Load Pending Event: " + id); pendingJobEvents.fire(new PendingBulkLoadJobEvent(id)); return resp; } return null; } - + @Transactional protected ObjectResponse updateLoad(Long id) { Log.info("updateLoad: " + id); BulkURLLoad load = bulkURLLoadDAO.find(id); - if(load != null && load.getBulkloadStatus().isNotRunning()) { + if (load != null && load.getBulkloadStatus().isNotRunning()) { load.setBulkloadStatus(JobStatus.FORCED_PENDING); return new ObjectResponse(load); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/mati/MaTIService.java b/src/main/java/org/alliancegenome/curation_api/services/mati/MaTIService.java index a9c31b17a..dfd26ccc5 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/mati/MaTIService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/mati/MaTIService.java @@ -18,32 +18,32 @@ public class MaTIService { @ConfigProperty(name = "okta.client.id") - String client_id; + String clientId; @ConfigProperty(name = "okta.client.secret") - String client_secret; + String clientSecret; @ConfigProperty(name = "okta.url") - String okta_url; + String oktaUrl; @ConfigProperty(name = "okta.scopes") - String okta_scopes; + String oktaScopes; @ConfigProperty(name = "mati.url") - String mati_url; + String matiUrl; private String fetchOktaToken() throws IOException { - OktaTokenInterface oktaAPI = RestProxyFactory.createProxy(OktaTokenInterface.class, okta_url); - String authorization = "Basic " + Base64.getEncoder().encodeToString((client_id + ":" + client_secret).getBytes()); - OktaToken oktaToken = oktaAPI.getClientCredentialsAccessToken(authorization, "client_credentials", okta_scopes); - return oktaToken.getAccess_token(); + OktaTokenInterface oktaAPI = RestProxyFactory.createProxy(OktaTokenInterface.class, oktaUrl); + String authorization = "Basic " + Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes()); + OktaToken oktaToken = oktaAPI.getClientCredentialsAccessToken(authorization, "client_credentials", oktaScopes); + return oktaToken.getAccessToken(); } public Identifier mintIdentifier(String subdomain) throws IOException { String token = fetchOktaToken(); String authorization = "Bearer: " + token; Identifier identifier = RestAssured.given().contentType(ContentType.JSON).header("Accept", "application/json").header("Authorization", authorization).header("subdomain", subdomain).when() - .put(mati_url + "/api/identifier").then().extract().body().as(Identifier.class); + .put(matiUrl + "/api/identifier").then().extract().body().as(Identifier.class); return identifier; } @@ -51,7 +51,7 @@ public IdentifiersRange mintIdentifierRange(String subdomain, String howMany) th String token = fetchOktaToken(); String authorization = "Bearer: " + token; IdentifiersRange range = RestAssured.given().contentType(ContentType.JSON).header("Accept", "application/json").header("Authorization", authorization).header("subdomain", subdomain) - .header("value", howMany).when().post(mati_url + "/api/identifier").then().extract().body().as(IdentifiersRange.class); + .header("value", howMany).when().post(matiUrl + "/api/identifier").then().extract().body().as(IdentifiersRange.class); return range; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ontology/EcoTermService.java b/src/main/java/org/alliancegenome/curation_api/services/ontology/EcoTermService.java index 6100e684b..a34e49b00 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ontology/EcoTermService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ontology/EcoTermService.java @@ -19,10 +19,8 @@ @RequestScoped public class EcoTermService extends BaseOntologyTermService { - @Inject - EcoTermDAO ecoTermDAO; - @Inject - VocabularyDAO vocabularyDAO; + @Inject EcoTermDAO ecoTermDAO; + @Inject VocabularyDAO vocabularyDAO; @Override @PostConstruct @@ -36,7 +34,7 @@ public void updateAbbreviations() { SearchResponse res = vocabularyDAO.findByField("vocabularyLabel", OntologyConstants.ECO_TERM_ABBREVIATION_VOCABULARY); if (res != null && res.getTotalResults() == 1) { List ecoVocabularyTerms = res.getResults().get(0).getMemberTerms(); - ecoVocabularyTerms.forEach((ecoVocabularyTerm) -> { + ecoVocabularyTerms.forEach(ecoVocabularyTerm -> { ECOTerm ecoTerm = findByCurie(ecoVocabularyTerm.getName()); if (ecoTerm != null) { ecoTerm.setAbbreviation(ecoVocabularyTerm.getAbbreviation()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/ontology/NcbiTaxonTermService.java b/src/main/java/org/alliancegenome/curation_api/services/ontology/NcbiTaxonTermService.java index d68a99085..6ca8f7868 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ontology/NcbiTaxonTermService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ontology/NcbiTaxonTermService.java @@ -21,28 +21,27 @@ @RequestScoped public class NcbiTaxonTermService extends BaseOntologyTermService { - @Inject - NcbiTaxonTermDAO ncbiTaxonTermDAO; + @Inject NcbiTaxonTermDAO ncbiTaxonTermDAO; - Date taxonRequest = null; + Date taxonRequest; HashMap taxonCacheMap = new HashMap<>(); - + @Override @PostConstruct protected void init() { setSQLDao(ncbiTaxonTermDAO); } - private final int MAX_ATTEMPTS = 5; - + private static final int MAX_ATTEMPTS = 5; + private NCBIRESTInterface api = RestProxyFactory.createProxy(NCBIRESTInterface.class, "https://eutils.ncbi.nlm.nih.gov"); - + @Override public ObjectResponse getByCurie(String taxonCurie) { NCBITaxonTerm term = null; - - if(taxonRequest != null) { - if(taxonCacheMap.containsKey(taxonCurie)) { + + if (taxonRequest != null) { + if (taxonCacheMap.containsKey(taxonCurie)) { term = taxonCacheMap.get(taxonCurie); } else { Log.debug("Term not cached, caching term: (" + taxonCurie + ")"); @@ -58,8 +57,7 @@ public ObjectResponse getByCurie(String taxonCurie) { response.setEntity(term); return response; } - - + public NCBITaxonTerm getTaxonFromDB(String taxonCurie) { NCBITaxonTerm taxon = findByCurie(taxonCurie); if (taxon == null) { @@ -70,9 +68,9 @@ public NCBITaxonTerm getTaxonFromDB(String taxonCurie) { } return taxon; } - + public NCBITaxonTerm downloadAndSave(String taxonCurie) { - + Pattern taxonIdPattern = Pattern.compile("^NCBITaxon:(\\d+)$"); Matcher taxonIdMatcher = taxonIdPattern.matcher(taxonCurie); if (!taxonIdMatcher.find()) { @@ -94,8 +92,9 @@ public NCBITaxonTerm downloadAndSave(String taxonCurie) { } } - if (taxonMap == null || taxonMap.get("error") != null) + if (taxonMap == null || taxonMap.get("error") != null) { return null; + } String name = (String) taxonMap.get("scientificname"); NCBITaxonTerm taxon = new NCBITaxonTerm(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyCuratedService.java b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyCuratedService.java index e69392631..321c617c5 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyCuratedService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyCuratedService.java @@ -11,8 +11,7 @@ @RequestScoped public class GeneToGeneOrthologyCuratedService extends BaseEntityCrudService { - @Inject - GeneToGeneOrthologyCuratedDAO geneToGeneOrthologyCuratedDAO; + @Inject GeneToGeneOrthologyCuratedDAO geneToGeneOrthologyCuratedDAO; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java index 2d8046d24..577df2123 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java @@ -24,11 +24,9 @@ @RequestScoped public class GeneToGeneOrthologyGeneratedService extends BaseEntityCrudService implements BaseUpsertServiceInterface { - @Inject - GeneToGeneOrthologyGeneratedDAO geneToGeneOrthologyGeneratedDAO; - @Inject - OrthologyFmsDTOValidator orthologyFmsDtoValidator; - + @Inject GeneToGeneOrthologyGeneratedDAO geneToGeneOrthologyGeneratedDAO; + @Inject OrthologyFmsDTOValidator orthologyFmsDtoValidator; + @Override @PostConstruct protected void init() { @@ -36,11 +34,11 @@ protected void init() { } public GeneToGeneOrthologyGenerated upsert(OrthologyFmsDTO orthoPair, BackendBulkDataProvider backendBulkDataProvider) throws ObjectUpdateException { - return orthologyFmsDtoValidator.validateOrthologyFmsDTO(orthoPair); + return orthologyFmsDtoValidator.validateOrthologyFmsDTO(orthoPair); } public List getAllOrthologyPairsBySubjectGeneDataProvider(String dataProvider) { - switch(dataProvider) { + switch (dataProvider) { case "XBXL": return geneToGeneOrthologyGeneratedDAO.findAllOrthologyPairsBySubjectGeneDataProviderAndTaxon("XB", "NCBITaxon:8355"); case "XBXT": diff --git a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyService.java b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyService.java index 4c4b28e94..f0f0f880d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyService.java @@ -15,10 +15,8 @@ @RequestScoped public class GeneToGeneOrthologyService extends BaseEntityCrudService { - @Inject - GeneToGeneOrthologyDAO geneToGeneOrthologyDAO; - @Inject - PersonService personService; + @Inject GeneToGeneOrthologyDAO geneToGeneOrthologyDAO; + @Inject PersonService personService; @Override @PostConstruct @@ -29,13 +27,15 @@ protected void init() { @Transactional public GeneToGeneOrthology deprecateOrthologyPair(Long orthId, String loadDescription) { GeneToGeneOrthology orthoPair = geneToGeneOrthologyDAO.find(orthId); - - if (orthoPair == null) + + if (orthoPair == null) { return null; - - if (orthoPair.getObsolete()) + } + + if (orthoPair.getObsolete()) { return orthoPair; - + } + orthoPair.setObsolete(true); orthoPair.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); orthoPair.setDateUpdated(OffsetDateTime.now()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationService.java index 66bc8f888..512daf417 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleDatabaseStatusSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleDatabaseStatusSlotAnnotationDAO alleleDatabaseStatusDAO; - @Inject - AlleleDatabaseStatusSlotAnnotationValidator alleleDatabaseStatusValidator; + @Inject AlleleDatabaseStatusSlotAnnotationDAO alleleDatabaseStatusDAO; + @Inject AlleleDatabaseStatusSlotAnnotationValidator alleleDatabaseStatusValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleDatabaseStatusSlotAnnotation uiEntity) { AlleleDatabaseStatusSlotAnnotation dbEntity = alleleDatabaseStatusValidator.validateAlleleDatabaseStatusSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleDatabaseStatusDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationService.java index 595ac3705..73f9ddd45 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleFullNameSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleFullNameSlotAnnotationDAO alleleFullNameDAO; - @Inject - AlleleFullNameSlotAnnotationValidator alleleFullNameValidator; + @Inject AlleleFullNameSlotAnnotationDAO alleleFullNameDAO; + @Inject AlleleFullNameSlotAnnotationValidator alleleFullNameValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleFullNameSlotAnnotation uiEntity) { AlleleFullNameSlotAnnotation dbEntity = alleleFullNameValidator.validateAlleleFullNameSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleFullNameDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationService.java index 2c8f74750..48390f8bc 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleFunctionalImpactSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleFunctionalImpactSlotAnnotationDAO alleleFunctionalImpactDAO; - @Inject - AlleleFunctionalImpactSlotAnnotationValidator alleleFunctionalImpactValidator; + @Inject AlleleFunctionalImpactSlotAnnotationDAO alleleFunctionalImpactDAO; + @Inject AlleleFunctionalImpactSlotAnnotationValidator alleleFunctionalImpactValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleFunctionalImpactSlotAnnotation uiEntity) { AlleleFunctionalImpactSlotAnnotation dbEntity = alleleFunctionalImpactValidator.validateAlleleFunctionalImpactSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleFunctionalImpactDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationService.java index f219adaac..ed25bb107 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleGermlineTransmissionStatusSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleGermlineTransmissionStatusSlotAnnotationDAO alleleGermlineTransmissionStatusDAO; - @Inject - AlleleGermlineTransmissionStatusSlotAnnotationValidator alleleGermlineTransmissionStatusValidator; + @Inject AlleleGermlineTransmissionStatusSlotAnnotationDAO alleleGermlineTransmissionStatusDAO; + @Inject AlleleGermlineTransmissionStatusSlotAnnotationValidator alleleGermlineTransmissionStatusValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleGermlineTransmissionStatusSlotAnnotation uiEntity) { AlleleGermlineTransmissionStatusSlotAnnotation dbEntity = alleleGermlineTransmissionStatusValidator.validateAlleleGermlineTransmissionStatusSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleGermlineTransmissionStatusDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationService.java index 7a0349d75..7c9e501df 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleInheritanceModeSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleInheritanceModeSlotAnnotationDAO alleleInheritanceModeDAO; - @Inject - AlleleInheritanceModeSlotAnnotationValidator alleleInheritanceModeValidator; + @Inject AlleleInheritanceModeSlotAnnotationDAO alleleInheritanceModeDAO; + @Inject AlleleInheritanceModeSlotAnnotationValidator alleleInheritanceModeValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleInheritanceModeSlotAnnotation uiEntity) { AlleleInheritanceModeSlotAnnotation dbEntity = alleleInheritanceModeValidator.validateAlleleInheritanceModeSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleInheritanceModeDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationService.java index 0338bfed4..288106ce1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleMutationTypeSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleMutationTypeSlotAnnotationDAO alleleMutationTypeDAO; - @Inject - AlleleMutationTypeSlotAnnotationValidator alleleMutationTypeValidator; + @Inject AlleleMutationTypeSlotAnnotationDAO alleleMutationTypeDAO; + @Inject AlleleMutationTypeSlotAnnotationValidator alleleMutationTypeValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleMutationTypeSlotAnnotation uiEntity) { AlleleMutationTypeSlotAnnotation dbEntity = alleleMutationTypeValidator.validateAlleleMutationTypeSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleMutationTypeDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationService.java index 121215c8b..c3906a0b0 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleNomenclatureEventSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleNomenclatureEventSlotAnnotationDAO alleleNomenclatureEventDAO; - @Inject - AlleleNomenclatureEventSlotAnnotationValidator alleleNomenclatureEventValidator; + @Inject AlleleNomenclatureEventSlotAnnotationDAO alleleNomenclatureEventDAO; + @Inject AlleleNomenclatureEventSlotAnnotationValidator alleleNomenclatureEventValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleNomenclatureEventSlotAnnotation uiEntity) { AlleleNomenclatureEventSlotAnnotation dbEntity = alleleNomenclatureEventValidator.validateAlleleNomenclatureEventSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleNomenclatureEventDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationService.java index 85359cd57..05e24744e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleSecondaryIdSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleSecondaryIdSlotAnnotationDAO alleleSecondaryIdDAO; - @Inject - AlleleSecondaryIdSlotAnnotationValidator alleleSecondaryIdValidator; + @Inject AlleleSecondaryIdSlotAnnotationDAO alleleSecondaryIdDAO; + @Inject AlleleSecondaryIdSlotAnnotationValidator alleleSecondaryIdValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleSecondaryIdSlotAnnotation uiEntity) { AlleleSecondaryIdSlotAnnotation dbEntity = alleleSecondaryIdValidator.validateAlleleSecondaryIdSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleSecondaryIdDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationService.java index f098cfe48..955e00200 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleSymbolSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleSymbolSlotAnnotationDAO alleleSymbolDAO; - @Inject - AlleleSymbolSlotAnnotationValidator alleleSymbolValidator; + @Inject AlleleSymbolSlotAnnotationDAO alleleSymbolDAO; + @Inject AlleleSymbolSlotAnnotationValidator alleleSymbolValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleSymbolSlotAnnotation uiEntity) { AlleleSymbolSlotAnnotation dbEntity = alleleSymbolValidator.validateAlleleSymbolSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleSymbolDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationService.java index daea90f20..d489cab6c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class AlleleSynonymSlotAnnotationService extends BaseEntityCrudService { - @Inject - AlleleSynonymSlotAnnotationDAO alleleSynonymDAO; - @Inject - AlleleSynonymSlotAnnotationValidator alleleSynonymValidator; + @Inject AlleleSynonymSlotAnnotationDAO alleleSynonymDAO; + @Inject AlleleSynonymSlotAnnotationValidator alleleSynonymValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(AlleleSynonymSlotAnnotation uiEntity) { AlleleSynonymSlotAnnotation dbEntity = alleleSynonymValidator.validateAlleleSynonymSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(alleleSynonymDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationService.java index edd4a2587..09b371410 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class ConstructComponentSlotAnnotationService extends BaseEntityCrudService { - @Inject - ConstructComponentSlotAnnotationDAO constructComponentDAO; - @Inject - ConstructComponentSlotAnnotationValidator constructComponentValidator; + @Inject ConstructComponentSlotAnnotationDAO constructComponentDAO; + @Inject ConstructComponentSlotAnnotationValidator constructComponentValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(ConstructComponentSlotAnnotation uiEntity) { ConstructComponentSlotAnnotation dbEntity = constructComponentValidator.validateConstructComponentSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(constructComponentDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationService.java index 98a633727..343e84984 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class ConstructFullNameSlotAnnotationService extends BaseEntityCrudService { - @Inject - ConstructFullNameSlotAnnotationDAO constructFullNameDAO; - @Inject - ConstructFullNameSlotAnnotationValidator constructFullNameValidator; + @Inject ConstructFullNameSlotAnnotationDAO constructFullNameDAO; + @Inject ConstructFullNameSlotAnnotationValidator constructFullNameValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(ConstructFullNameSlotAnnotation uiEntity) { ConstructFullNameSlotAnnotation dbEntity = constructFullNameValidator.validateConstructFullNameSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(constructFullNameDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationService.java index 66b87d6f6..c89f3ceb9 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class ConstructSymbolSlotAnnotationService extends BaseEntityCrudService { - @Inject - ConstructSymbolSlotAnnotationDAO constructSymbolDAO; - @Inject - ConstructSymbolSlotAnnotationValidator constructSymbolValidator; + @Inject ConstructSymbolSlotAnnotationDAO constructSymbolDAO; + @Inject ConstructSymbolSlotAnnotationValidator constructSymbolValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(ConstructSymbolSlotAnnotation uiEntity) { ConstructSymbolSlotAnnotation dbEntity = constructSymbolValidator.validateConstructSymbolSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(constructSymbolDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationService.java index 5c7272381..334e51eb7 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class ConstructSynonymSlotAnnotationService extends BaseEntityCrudService { - @Inject - ConstructSynonymSlotAnnotationDAO constructSynonymDAO; - @Inject - ConstructSynonymSlotAnnotationValidator constructSynonymValidator; + @Inject ConstructSynonymSlotAnnotationDAO constructSynonymDAO; + @Inject ConstructSynonymSlotAnnotationValidator constructSynonymValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(ConstructSynonymSlotAnnotation uiEntity) { ConstructSynonymSlotAnnotation dbEntity = constructSynonymValidator.validateConstructSynonymSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(constructSynonymDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationService.java index 52b79d818..2fb4560db 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class GeneFullNameSlotAnnotationService extends BaseEntityCrudService { - @Inject - GeneFullNameSlotAnnotationDAO geneFullNameDAO; - @Inject - GeneFullNameSlotAnnotationValidator geneFullNameValidator; + @Inject GeneFullNameSlotAnnotationDAO geneFullNameDAO; + @Inject GeneFullNameSlotAnnotationValidator geneFullNameValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(GeneFullNameSlotAnnotation uiEntity) { GeneFullNameSlotAnnotation dbEntity = geneFullNameValidator.validateGeneFullNameSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(geneFullNameDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationService.java index 567b3804a..48c0b446a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class GeneSecondaryIdSlotAnnotationService extends BaseEntityCrudService { - @Inject - GeneSecondaryIdSlotAnnotationDAO geneSecondaryIdDAO; - @Inject - GeneSecondaryIdSlotAnnotationValidator geneSecondaryIdValidator; + @Inject GeneSecondaryIdSlotAnnotationDAO geneSecondaryIdDAO; + @Inject GeneSecondaryIdSlotAnnotationValidator geneSecondaryIdValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(GeneSecondaryIdSlotAnnotation uiEntity) { GeneSecondaryIdSlotAnnotation dbEntity = geneSecondaryIdValidator.validateGeneSecondaryIdSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(geneSecondaryIdDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationService.java index 9bf1d80b4..b0be4a5b5 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class GeneSymbolSlotAnnotationService extends BaseEntityCrudService { - @Inject - GeneSymbolSlotAnnotationDAO geneSymbolDAO; - @Inject - GeneSymbolSlotAnnotationValidator geneSymbolValidator; + @Inject GeneSymbolSlotAnnotationDAO geneSymbolDAO; + @Inject GeneSymbolSlotAnnotationValidator geneSymbolValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(GeneSymbolSlotAnnotation uiEntity) { GeneSymbolSlotAnnotation dbEntity = geneSymbolValidator.validateGeneSymbolSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(geneSymbolDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationService.java index 67b703e7c..1a8e567e0 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class GeneSynonymSlotAnnotationService extends BaseEntityCrudService { - @Inject - GeneSynonymSlotAnnotationDAO geneSynonymDAO; - @Inject - GeneSynonymSlotAnnotationValidator geneSynonymValidator; + @Inject GeneSynonymSlotAnnotationDAO geneSynonymDAO; + @Inject GeneSynonymSlotAnnotationValidator geneSynonymValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(GeneSynonymSlotAnnotation uiEntity) { GeneSynonymSlotAnnotation dbEntity = geneSynonymValidator.validateGeneSynonymSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(geneSynonymDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationService.java index cfdec526e..ed6bb4d40 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationService.java @@ -14,10 +14,8 @@ @RequestScoped public class GeneSystematicNameSlotAnnotationService extends BaseEntityCrudService { - @Inject - GeneSystematicNameSlotAnnotationDAO geneSystematicNameDAO; - @Inject - GeneSystematicNameSlotAnnotationValidator geneSystematicNameValidator; + @Inject GeneSystematicNameSlotAnnotationDAO geneSystematicNameDAO; + @Inject GeneSystematicNameSlotAnnotationValidator geneSystematicNameValidator; @Override @PostConstruct @@ -28,8 +26,9 @@ protected void init() { @Transactional public ObjectResponse upsert(GeneSystematicNameSlotAnnotation uiEntity) { GeneSystematicNameSlotAnnotation dbEntity = geneSystematicNameValidator.validateGeneSystematicNameSlotAnnotation(uiEntity, true, true); - if (dbEntity == null) + if (dbEntity == null) { return null; + } return new ObjectResponse(geneSystematicNameDAO.persist(dbEntity)); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/AGMDiseaseAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/AGMDiseaseAnnotationValidator.java index b0e262ae4..cabafdbbd 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/AGMDiseaseAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/AGMDiseaseAnnotationValidator.java @@ -26,17 +26,13 @@ @RequestScoped public class AGMDiseaseAnnotationValidator extends DiseaseAnnotationValidator { - @Inject - AffectedGenomicModelDAO affectedGenomicModelDAO; + @Inject AffectedGenomicModelDAO affectedGenomicModelDAO; - @Inject - AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; + @Inject AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject VocabularyTermService vocabularyTermService; - @Inject - AlleleDAO alleleDAO; + @Inject AlleleDAO alleleDAO; private String errorMessage; @@ -107,8 +103,9 @@ private AffectedGenomicModel validateSubject(AGMDiseaseAnnotation uiEntity, AGMD } AffectedGenomicModel subjectEntity = null; - if (uiEntity.getDiseaseAnnotationSubject().getId() != null) + if (uiEntity.getDiseaseAnnotationSubject().getId() != null) { subjectEntity = affectedGenomicModelDAO.find(uiEntity.getDiseaseAnnotationSubject().getId()); + } if (subjectEntity == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -124,12 +121,14 @@ private AffectedGenomicModel validateSubject(AGMDiseaseAnnotation uiEntity, AGMD } private Gene validateInferredGene(AGMDiseaseAnnotation uiEntity, AGMDiseaseAnnotation dbEntity) { - if (uiEntity.getInferredGene() == null) + if (uiEntity.getInferredGene() == null) { return null; + } Gene inferredGene = null; - if (uiEntity.getInferredGene().getId() != null) + if (uiEntity.getInferredGene().getId() != null) { inferredGene = geneDAO.find(uiEntity.getInferredGene().getId()); + } if (inferredGene == null) { addMessageResponse("inferredGene", ValidationConstants.INVALID_MESSAGE); return null; @@ -144,17 +143,20 @@ private Gene validateInferredGene(AGMDiseaseAnnotation uiEntity, AGMDiseaseAnnot } private List validateAssertedGenes(AGMDiseaseAnnotation uiEntity, AGMDiseaseAnnotation dbEntity) { - if (CollectionUtils.isEmpty(uiEntity.getAssertedGenes())) + if (CollectionUtils.isEmpty(uiEntity.getAssertedGenes())) { return null; + } List assertedGenes = new ArrayList(); List previousIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getAssertedGenes())) + if (CollectionUtils.isNotEmpty(dbEntity.getAssertedGenes())) { previousIds = dbEntity.getAssertedGenes().stream().map(Gene::getId).collect(Collectors.toList()); + } for (Gene gene : uiEntity.getAssertedGenes()) { Gene assertedGene = null; - if (gene.getId() != null) + if (gene.getId() != null) { assertedGene = geneDAO.find(gene.getId()); + } if (assertedGene == null) { addMessageResponse("assertedGenes", ValidationConstants.INVALID_MESSAGE); return null; @@ -170,12 +172,14 @@ private List validateAssertedGenes(AGMDiseaseAnnotation uiEntity, AGMDisea } private Allele validateInferredAllele(AGMDiseaseAnnotation uiEntity, AGMDiseaseAnnotation dbEntity) { - if (uiEntity.getInferredAllele() == null) + if (uiEntity.getInferredAllele() == null) { return null; + } Allele inferredAllele = null; - if (uiEntity.getInferredAllele().getId() != null) + if (uiEntity.getInferredAllele().getId() != null) { inferredAllele = alleleDAO.find(uiEntity.getInferredAllele().getId()); + } if (inferredAllele == null) { addMessageResponse("inferredAllele", ValidationConstants.INVALID_MESSAGE); return null; @@ -190,12 +194,14 @@ private Allele validateInferredAllele(AGMDiseaseAnnotation uiEntity, AGMDiseaseA } private Allele validateAssertedAllele(AGMDiseaseAnnotation uiEntity, AGMDiseaseAnnotation dbEntity) { - if (uiEntity.getAssertedAllele() == null) + if (uiEntity.getAssertedAllele() == null) { return null; + } Allele assertedAllele = null; - if (uiEntity.getAssertedAllele().getId() != null) + if (uiEntity.getAssertedAllele().getId() != null) { assertedAllele = alleleDAO.find(uiEntity.getAssertedAllele().getId()); + } if (assertedAllele == null) { addMessageResponse("assertedAllele", ValidationConstants.INVALID_MESSAGE); return null; @@ -230,4 +236,4 @@ private VocabularyTerm validateDiseaseRelation(AGMDiseaseAnnotation uiEntity, AG return relation; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/AffectedGenomicModelValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/AffectedGenomicModelValidator.java index 393223cc5..9780a14fd 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/AffectedGenomicModelValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/AffectedGenomicModelValidator.java @@ -16,13 +16,10 @@ @RequestScoped public class AffectedGenomicModelValidator extends GenomicEntityValidator { - @Inject - AffectedGenomicModelDAO affectedGenomicModelDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - CrossReferenceDAO crossReferenceDAO; - + @Inject AffectedGenomicModelDAO affectedGenomicModelDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject CrossReferenceDAO crossReferenceDAO; + private String errorMessage; public AffectedGenomicModel validateAffectedGenomicModelUpdate(AffectedGenomicModel uiEntity) { @@ -40,27 +37,27 @@ public AffectedGenomicModel validateAffectedGenomicModelUpdate(AffectedGenomicMo addMessageResponse("id", ValidationConstants.INVALID_MESSAGE); throw new ApiErrorException(response); } - + dbEntity = (AffectedGenomicModel) validateAuditedObjectFields(uiEntity, dbEntity, false); - + return validateAffectedGenomicModel(uiEntity, dbEntity); } - + public AffectedGenomicModel validateAffectedGenomicModelCreate(AffectedGenomicModel uiEntity) { response = new ObjectResponse<>(uiEntity); errorMessage = "Could not create AGM"; AffectedGenomicModel dbEntity = new AffectedGenomicModel(); - + dbEntity = (AffectedGenomicModel) validateAuditedObjectFields(uiEntity, dbEntity, true); - + return validateAffectedGenomicModel(uiEntity, dbEntity); } - + private AffectedGenomicModel validateAffectedGenomicModel(AffectedGenomicModel uiEntity, AffectedGenomicModel dbEntity) { dbEntity = (AffectedGenomicModel) validateGenomicEntityFields(uiEntity, dbEntity); - + String name = handleStringField(uiEntity.getName()); dbEntity.setName(name); @@ -74,7 +71,7 @@ private AffectedGenomicModel validateAffectedGenomicModel(AffectedGenomicModel u return dbEntity; } - + public VocabularyTerm validateSubtype(AffectedGenomicModel uiEntity, AffectedGenomicModel dbEntity) { String field = "subtype"; if (uiEntity.getSubtype() == null) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleDiseaseAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleDiseaseAnnotationValidator.java index 6b32794b0..e11544431 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleDiseaseAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleDiseaseAnnotationValidator.java @@ -24,14 +24,11 @@ @RequestScoped public class AlleleDiseaseAnnotationValidator extends DiseaseAnnotationValidator { - @Inject - AlleleDAO alleleDAO; + @Inject AlleleDAO alleleDAO; - @Inject - AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; + @Inject AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject VocabularyTermService vocabularyTermService; private String errorMessage; @@ -96,8 +93,9 @@ private Allele validateSubject(AlleleDiseaseAnnotation uiEntity, AlleleDiseaseAn } Allele subjectEntity = null; - if (uiEntity.getDiseaseAnnotationSubject().getId() != null) + if (uiEntity.getDiseaseAnnotationSubject().getId() != null) { subjectEntity = alleleDAO.find(uiEntity.getDiseaseAnnotationSubject().getId()); + } if (subjectEntity == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -112,12 +110,14 @@ private Allele validateSubject(AlleleDiseaseAnnotation uiEntity, AlleleDiseaseAn } private Gene validateInferredGene(AlleleDiseaseAnnotation uiEntity, AlleleDiseaseAnnotation dbEntity) { - if (uiEntity.getInferredGene() == null) + if (uiEntity.getInferredGene() == null) { return null; + } Gene inferredGene = null; - if (uiEntity.getInferredGene().getId() != null) + if (uiEntity.getInferredGene().getId() != null) { inferredGene = geneDAO.find(uiEntity.getInferredGene().getId()); + } if (inferredGene == null) { addMessageResponse("inferredGene", ValidationConstants.INVALID_MESSAGE); return null; @@ -132,17 +132,20 @@ private Gene validateInferredGene(AlleleDiseaseAnnotation uiEntity, AlleleDiseas } private List validateAssertedGenes(AlleleDiseaseAnnotation uiEntity, AlleleDiseaseAnnotation dbEntity) { - if (CollectionUtils.isEmpty(uiEntity.getAssertedGenes())) + if (CollectionUtils.isEmpty(uiEntity.getAssertedGenes())) { return null; + } List assertedGenes = new ArrayList(); List previousIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getAssertedGenes())) + if (CollectionUtils.isNotEmpty(dbEntity.getAssertedGenes())) { previousIds = dbEntity.getAssertedGenes().stream().map(Gene::getId).collect(Collectors.toList()); + } for (Gene gene : uiEntity.getAssertedGenes()) { Gene assertedGene = null; - if (gene.getId() != null) + if (gene.getId() != null) { assertedGene = geneDAO.find(gene.getId()); + } if (assertedGene == null) { addMessageResponse("assertedGenes", ValidationConstants.INVALID_MESSAGE); return null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java index d792f7c31..974e40f44 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java @@ -52,38 +52,22 @@ @RequestScoped public class AlleleValidator extends GenomicEntityValidator { - @Inject - AlleleDAO alleleDAO; - @Inject - AlleleMutationTypeSlotAnnotationValidator alleleMutationTypeValidator; - @Inject - AlleleInheritanceModeSlotAnnotationValidator alleleInheritanceModeValidator; - @Inject - AlleleGermlineTransmissionStatusSlotAnnotationValidator alleleGermlineTransmissionStatusValidator; - @Inject - AlleleNomenclatureEventSlotAnnotationValidator alleleNomenclatureEventValidator; - @Inject - AlleleSymbolSlotAnnotationValidator alleleSymbolValidator; - @Inject - AlleleFullNameSlotAnnotationValidator alleleFullNameValidator; - @Inject - AlleleSynonymSlotAnnotationValidator alleleSynonymValidator; - @Inject - AlleleSecondaryIdSlotAnnotationValidator alleleSecondaryIdValidator; - @Inject - AlleleFunctionalImpactSlotAnnotationValidator alleleFunctionalImpactValidator; - @Inject - AlleleDatabaseStatusSlotAnnotationValidator alleleDatabaseStatusValidator; - @Inject - AlleleGeneAssociationValidator alleleGeneAssociationValidator; - @Inject - NoteValidator noteValidator; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - ReferenceValidator referenceValidator; - @Inject - CrossReferenceDAO crossReferenceDAO; + @Inject AlleleDAO alleleDAO; + @Inject AlleleMutationTypeSlotAnnotationValidator alleleMutationTypeValidator; + @Inject AlleleInheritanceModeSlotAnnotationValidator alleleInheritanceModeValidator; + @Inject AlleleGermlineTransmissionStatusSlotAnnotationValidator alleleGermlineTransmissionStatusValidator; + @Inject AlleleNomenclatureEventSlotAnnotationValidator alleleNomenclatureEventValidator; + @Inject AlleleSymbolSlotAnnotationValidator alleleSymbolValidator; + @Inject AlleleFullNameSlotAnnotationValidator alleleFullNameValidator; + @Inject AlleleSynonymSlotAnnotationValidator alleleSynonymValidator; + @Inject AlleleSecondaryIdSlotAnnotationValidator alleleSecondaryIdValidator; + @Inject AlleleFunctionalImpactSlotAnnotationValidator alleleFunctionalImpactValidator; + @Inject AlleleDatabaseStatusSlotAnnotationValidator alleleDatabaseStatusValidator; + @Inject AlleleGeneAssociationValidator alleleGeneAssociationValidator; + @Inject NoteValidator noteValidator; + @Inject VocabularyTermService vocabularyTermService; + @Inject ReferenceValidator referenceValidator; + @Inject CrossReferenceDAO crossReferenceDAO; private String errorMessage; @@ -136,13 +120,15 @@ public Allele validateAllele(Allele uiEntity, Allele dbEntity, Boolean updateAll } else { dbEntity.setIsExtinct(null); } - + List relatedNotes = validateRelatedNotes(uiEntity, dbEntity); - if (dbEntity.getRelatedNotes() != null) + if (dbEntity.getRelatedNotes() != null) { dbEntity.getRelatedNotes().clear(); + } if (relatedNotes != null) { - if (dbEntity.getRelatedNotes() == null) + if (dbEntity.getRelatedNotes() == null) { dbEntity.setRelatedNotes(new ArrayList<>()); + } dbEntity.getRelatedNotes().addAll(relatedNotes); } @@ -156,14 +142,14 @@ public Allele validateAllele(Allele uiEntity, Allele dbEntity, Boolean updateAll List functionalImpacts = validateAlleleFunctionalImpacts(uiEntity, dbEntity); List mutationTypes = validateAlleleMutationTypes(uiEntity, dbEntity); List nomenclatureEvents = validateAlleleNomenclatureEvents(uiEntity, dbEntity); - + List geneAssociations = null; if (updateAllAssociations) { // This should contain logic for all fields only returned in AlleleDetailView geneAssociations = validateAlleleGeneAssociations(uiEntity, dbEntity); } - + response.convertErrorMessagesToMap(); - + if (response.hasErrors()) { response.setErrorMessage(errorMessage); throw new ApiErrorException(response); @@ -171,84 +157,106 @@ public Allele validateAllele(Allele uiEntity, Allele dbEntity, Boolean updateAll dbEntity = alleleDAO.persist(dbEntity); - if (symbol != null) + if (symbol != null) { symbol.setSingleAllele(dbEntity); + } dbEntity.setAlleleSymbol(symbol); - - if (fullName != null) + + if (fullName != null) { fullName.setSingleAllele(dbEntity); + } dbEntity.setAlleleFullName(fullName); - - if (germlineTransmissionStatus != null) + + if (germlineTransmissionStatus != null) { germlineTransmissionStatus.setSingleAllele(dbEntity); + } dbEntity.setAlleleGermlineTransmissionStatus(germlineTransmissionStatus); - - if (databaseStatus != null) + + if (databaseStatus != null) { databaseStatus.setSingleAllele(dbEntity); + } dbEntity.setAlleleDatabaseStatus(databaseStatus); - - if (dbEntity.getAlleleSynonyms() != null) + + if (dbEntity.getAlleleSynonyms() != null) { dbEntity.getAlleleSynonyms().clear(); + } if (synonyms != null) { - if (dbEntity.getAlleleSynonyms() == null) + if (dbEntity.getAlleleSynonyms() == null) { dbEntity.setAlleleSynonyms(new ArrayList<>()); + } dbEntity.getAlleleSynonyms().addAll(synonyms); } - - if (dbEntity.getAlleleSecondaryIds() != null) + + if (dbEntity.getAlleleSecondaryIds() != null) { dbEntity.getAlleleSecondaryIds().clear(); + } if (secondaryIds != null) { - if (dbEntity.getAlleleSecondaryIds() == null) + if (dbEntity.getAlleleSecondaryIds() == null) { dbEntity.setAlleleSecondaryIds(new ArrayList<>()); + } dbEntity.getAlleleSecondaryIds().addAll(secondaryIds); } - - if (dbEntity.getAlleleInheritanceModes() != null) + + if (dbEntity.getAlleleInheritanceModes() != null) { dbEntity.getAlleleInheritanceModes().clear(); + } if (inheritanceModes != null) { - if (dbEntity.getAlleleInheritanceModes() == null) + if (dbEntity.getAlleleInheritanceModes() == null) { dbEntity.setAlleleInheritanceModes(new ArrayList<>()); - for (AlleleInheritanceModeSlotAnnotation im : inheritanceModes) + } + for (AlleleInheritanceModeSlotAnnotation im : inheritanceModes) { im.setSingleAllele(dbEntity); + } dbEntity.getAlleleInheritanceModes().addAll(inheritanceModes); } - - if (dbEntity.getAlleleFunctionalImpacts() != null) + + if (dbEntity.getAlleleFunctionalImpacts() != null) { dbEntity.getAlleleFunctionalImpacts().clear(); + } if (functionalImpacts != null) { - if (dbEntity.getAlleleFunctionalImpacts() == null) + if (dbEntity.getAlleleFunctionalImpacts() == null) { dbEntity.setAlleleFunctionalImpacts(new ArrayList<>()); - for (AlleleFunctionalImpactSlotAnnotation fi : functionalImpacts) - fi.setSingleAllele(dbEntity); + } + for (AlleleFunctionalImpactSlotAnnotation fi : functionalImpacts) { + fi.setSingleAllele(dbEntity); + } dbEntity.getAlleleFunctionalImpacts().addAll(functionalImpacts); } - - if (dbEntity.getAlleleMutationTypes() != null) + + if (dbEntity.getAlleleMutationTypes() != null) { dbEntity.getAlleleMutationTypes().clear(); + } if (mutationTypes != null) { - if (dbEntity.getAlleleMutationTypes() == null) + if (dbEntity.getAlleleMutationTypes() == null) { dbEntity.setAlleleMutationTypes(new ArrayList<>()); - for (AlleleMutationTypeSlotAnnotation mt : mutationTypes) + } + for (AlleleMutationTypeSlotAnnotation mt : mutationTypes) { mt.setSingleAllele(dbEntity); + } dbEntity.getAlleleMutationTypes().addAll(mutationTypes); } - - if (dbEntity.getAlleleNomenclatureEvents() != null) + + if (dbEntity.getAlleleNomenclatureEvents() != null) { dbEntity.getAlleleNomenclatureEvents().clear(); + } if (nomenclatureEvents != null) { - if (dbEntity.getAlleleNomenclatureEvents() == null) + if (dbEntity.getAlleleNomenclatureEvents() == null) { dbEntity.setAlleleNomenclatureEvents(new ArrayList<>()); - for (AlleleNomenclatureEventSlotAnnotation nm : nomenclatureEvents) + } + for (AlleleNomenclatureEventSlotAnnotation nm : nomenclatureEvents) { nm.setSingleAllele(dbEntity); + } dbEntity.getAlleleNomenclatureEvents().addAll(nomenclatureEvents); } - + if (updateAllAssociations) { // This should contain logic for all fields only returned in AlleleDetailView - if (dbEntity.getAlleleGeneAssociations() != null) + if (dbEntity.getAlleleGeneAssociations() != null) { dbEntity.getAlleleGeneAssociations().clear(); + } if (geneAssociations != null) { - if (dbEntity.getAlleleGeneAssociations() == null) + if (dbEntity.getAlleleGeneAssociations() == null) { dbEntity.setAlleleGeneAssociations(new ArrayList<>()); + } dbEntity.getAlleleGeneAssociations().addAll(geneAssociations); } } @@ -268,15 +276,16 @@ private ObjectResponse validateReference(Reference uiEntity, List validateReferences(Allele uiEntity, Allele dbEntity) { String field = "references"; - + List validatedReferences = new ArrayList(); List previousReferenceCuries = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getReferences())) + if (CollectionUtils.isNotEmpty(dbEntity.getReferences())) { previousReferenceCuries = dbEntity.getReferences().stream().map(Reference::getCurie).collect(Collectors.toList()); - + } + Boolean allValid = true; if (CollectionUtils.isNotEmpty(uiEntity.getReferences())) { for (int ix = 0; ix < uiEntity.getReferences().size(); ix++) { @@ -289,14 +298,15 @@ public List validateReferences(Allele uiEntity, Allele dbEntity) { } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedReferences)) + + if (CollectionUtils.isEmpty(validatedReferences)) { return null; + } return validatedReferences; } @@ -304,8 +314,9 @@ public List validateReferences(Allele uiEntity, Allele dbEntity) { private VocabularyTerm validateInCollection(Allele uiEntity, Allele dbEntity) { String field = "inCollection"; - if (uiEntity.getInCollection() == null) + if (uiEntity.getInCollection() == null) { return null; + } VocabularyTerm inCollection = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ALLELE_COLLECTION_VOCABULARY, uiEntity.getInCollection().getName()).getEntity(); if (inCollection == null) { @@ -335,7 +346,7 @@ public List validateRelatedNotes(Allele uiEntity, Allele dbEntity) { response.addErrorMessages(field, ix, noteResponse.getErrorMessages()); } else { note = noteResponse.getEntity(); - + String noteIdentity = NoteIdentityHelper.noteIdentity(note); if (validatedNoteIdentities.contains(noteIdentity)) { allValid = false; @@ -353,14 +364,14 @@ public List validateRelatedNotes(Allele uiEntity, Allele dbEntity) { convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedNotes)) + + if (CollectionUtils.isEmpty(validatedNotes)) { return null; + } return validatedNotes; } - private List validateAlleleMutationTypes(Allele uiEntity, Allele dbEntity) { String field = "alleleMutationTypes"; @@ -378,14 +389,15 @@ private List validateAlleleMutationTypes(Allel } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - if (CollectionUtils.isEmpty(validatedMutationTypes)) + if (CollectionUtils.isEmpty(validatedMutationTypes)) { return null; + } return validatedMutationTypes; } @@ -407,47 +419,50 @@ private List validateAlleleInheritanceModes } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - if (CollectionUtils.isEmpty(validatedInheritanceModes)) + if (CollectionUtils.isEmpty(validatedInheritanceModes)) { return null; + } return validatedInheritanceModes; } - + private AlleleGermlineTransmissionStatusSlotAnnotation validateAlleleGermlineTransmissionStatus(Allele uiEntity, Allele dbEntity) { - if (uiEntity.getAlleleGermlineTransmissionStatus() == null) + if (uiEntity.getAlleleGermlineTransmissionStatus() == null) { return null; - + } + String field = "alleleGermlineTransmissionStatus"; - + ObjectResponse agtsResponse = alleleGermlineTransmissionStatusValidator.validateAlleleGermlineTransmissionStatusSlotAnnotation(uiEntity.getAlleleGermlineTransmissionStatus()); if (agtsResponse.getEntity() == null) { addMessageResponse(field, agtsResponse.errorMessagesString()); response.addErrorMessages(field, agtsResponse.getErrorMessages()); return null; } - + return agtsResponse.getEntity(); } - + private AlleleDatabaseStatusSlotAnnotation validateAlleleDatabaseStatus(Allele uiEntity, Allele dbEntity) { - if (uiEntity.getAlleleDatabaseStatus() == null) + if (uiEntity.getAlleleDatabaseStatus() == null) { return null; - + } + String field = "alleleDatabaseStatus"; - + ObjectResponse adsResponse = alleleDatabaseStatusValidator.validateAlleleDatabaseStatusSlotAnnotation(uiEntity.getAlleleDatabaseStatus()); if (adsResponse.getEntity() == null) { addMessageResponse(field, adsResponse.errorMessagesString()); response.addErrorMessages(field, adsResponse.getErrorMessages()); return null; } - + return adsResponse.getEntity(); } @@ -468,8 +483,9 @@ private List validateAlleleNomenclatureEv } } - if (CollectionUtils.isEmpty(validatedNomenclatureEvents)) + if (CollectionUtils.isEmpty(validatedNomenclatureEvents)) { return null; + } return validatedNomenclatureEvents; } @@ -493,8 +509,9 @@ private AlleleSymbolSlotAnnotation validateAlleleSymbol(Allele uiEntity, Allele } private AlleleFullNameSlotAnnotation validateAlleleFullName(Allele uiEntity, Allele dbEntity) { - if (uiEntity.getAlleleFullName() == null) + if (uiEntity.getAlleleFullName() == null) { return null; + } String field = "alleleFullName"; @@ -514,7 +531,7 @@ private List validateAlleleSynonyms(Allele uiEntity List validatedSynonyms = new ArrayList(); Boolean allValid = true; if (CollectionUtils.isNotEmpty(uiEntity.getAlleleSynonyms())) { - for (int ix = 0; ix < uiEntity.getAlleleSynonyms().size(); ix++) { + for (int ix = 0; ix < uiEntity.getAlleleSynonyms().size(); ix++) { AlleleSynonymSlotAnnotation syn = uiEntity.getAlleleSynonyms().get(ix); ObjectResponse synResponse = alleleSynonymValidator.validateAlleleSynonymSlotAnnotation(syn); if (synResponse.getEntity() == null) { @@ -533,8 +550,9 @@ private List validateAlleleSynonyms(Allele uiEntity return null; } - if (CollectionUtils.isEmpty(validatedSynonyms)) + if (CollectionUtils.isEmpty(validatedSynonyms)) { return null; + } return validatedSynonyms; } @@ -558,14 +576,15 @@ private List validateAlleleSecondaryIds(Allele } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - if (CollectionUtils.isEmpty(validatedSecondaryIds)) + if (CollectionUtils.isEmpty(validatedSecondaryIds)) { return null; + } return validatedSecondaryIds; } @@ -593,8 +612,9 @@ private List validateAlleleFunctionalImpac return null; } - if (CollectionUtils.isEmpty(validatedFunctionalImpacts)) + if (CollectionUtils.isEmpty(validatedFunctionalImpacts)) { return null; + } return validatedFunctionalImpacts; } @@ -647,8 +667,8 @@ private List validateAlleleGeneAssociations(Allele uiEnti if (uiAssociations != null) { Set uiIDs = new HashSet<>(uiAssociations.stream().map(AlleleGeneAssociation::getId).filter(id -> id != null).collect(Collectors.toList())); idsToDelete.removeAll(uiIDs); - for(AlleleGeneAssociation ga: dbAssociations){ - if(idsToDelete.contains(ga.getId())){ + for (AlleleGeneAssociation ga : dbAssociations) { + if (idsToDelete.contains(ga.getId())) { Gene gene = ga.getAlleleGeneAssociationObject(); List geneAssociations = gene.getAlleleGeneAssociations(); geneAssociations.removeIf(geneAGA -> { @@ -658,14 +678,15 @@ private List validateAlleleGeneAssociations(Allele uiEnti } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - if (CollectionUtils.isEmpty(validatedGeneAssociations)) + if (CollectionUtils.isEmpty(validatedGeneAssociations)) { return null; + } return validatedGeneAssociations; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java index f1fe26223..d05b2bb6b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java @@ -30,51 +30,43 @@ public class AnnotationValidator extends AuditedObjectValidator { - @Inject - ReferenceValidator referenceValidator; - @Inject - NoteValidator noteValidator; - @Inject - NoteDAO noteDAO; - @Inject - ConditionRelationValidator conditionRelationValidator; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - AnnotationDAO annotationDAO; - @Inject - DataProviderService dataProviderService; - @Inject - DataProviderValidator dataProviderValidator; - - + @Inject ReferenceValidator referenceValidator; + @Inject NoteValidator noteValidator; + @Inject NoteDAO noteDAO; + @Inject ConditionRelationValidator conditionRelationValidator; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject AnnotationDAO annotationDAO; + @Inject DataProviderService dataProviderService; + @Inject DataProviderValidator dataProviderValidator; + public DataProvider validateDataProvider(Annotation uiEntity, Annotation dbEntity) { String field = "dataProvider"; - + if (uiEntity.getDataProvider() == null) { - if (dbEntity.getId() == null) + if (dbEntity.getId() == null) { uiEntity.setDataProvider(dataProviderService.createAffiliatedModDataProvider()); + } if (uiEntity.getDataProvider() == null) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - } + } DataProvider uiDataProvider = uiEntity.getDataProvider(); DataProvider dbDataProvider = dbEntity.getDataProvider(); - + ObjectResponse dpResponse = dataProviderValidator.validateDataProvider(uiDataProvider, dbDataProvider, false); if (dpResponse.hasErrors()) { addMessageResponse(field, dpResponse.errorMessagesString()); return null; } - + DataProvider validatedDataProvider = dpResponse.getEntity(); if (validatedDataProvider.getObsolete() && (dbDataProvider == null || !validatedDataProvider.getId().equals(dbDataProvider.getId()))) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } - + return validatedDataProvider; } @@ -93,7 +85,7 @@ public List validateRelatedNotes(Annotation uiEntity, Annotation dbEntity, response.addErrorMessages(field, ix, noteResponse.getErrorMessages()); } else { note = noteResponse.getEntity(); - + String noteIdentity = NoteIdentityHelper.noteIdentity(note); if (validatedNoteIdentities.contains(noteIdentity)) { allValid = false; @@ -126,24 +118,27 @@ public List validateRelatedNotes(Annotation uiEntity, Annotation dbEntity, return null; } - if (CollectionUtils.isEmpty(validatedNotes)) + if (CollectionUtils.isEmpty(validatedNotes)) { return null; + } return validatedNotes; } public List validateConditionRelations(Annotation uiEntity, Annotation dbEntity) { - if (CollectionUtils.isEmpty(uiEntity.getConditionRelations())) + if (CollectionUtils.isEmpty(uiEntity.getConditionRelations())) { return null; + } List validatedConditionRelations = new ArrayList<>(); List previousConditionRelationIds = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(dbEntity.getConditionRelations())) + if (CollectionUtils.isNotEmpty(dbEntity.getConditionRelations())) { previousConditionRelationIds = dbEntity.getConditionRelations().stream().map(ConditionRelation::getId).collect(Collectors.toList()); + } for (ConditionRelation conditionRelation : uiEntity.getConditionRelations()) { - if (uiEntity.getSingleReference() != null && !StringUtils.isBlank(uiEntity.getSingleReference().getCurie()) && conditionRelation.getSingleReference() != null - && !StringUtils.isBlank(conditionRelation.getSingleReference().getCurie()) && !conditionRelation.getSingleReference().getCurie().equals(uiEntity.getSingleReference().getCurie())) { + if (uiEntity.getSingleReference() != null && !StringUtils.isBlank(uiEntity.getSingleReference().getCurie()) && conditionRelation.getSingleReference() != null && !StringUtils.isBlank(conditionRelation.getSingleReference().getCurie()) + && !conditionRelation.getSingleReference().getCurie().equals(uiEntity.getSingleReference().getCurie())) { addMessageResponse("conditionRelations", "singleReference - " + ValidationConstants.INVALID_MESSAGE); } @@ -194,13 +189,14 @@ public Reference validateSingleReference(Annotation uiEntity, Annotation dbEntit public Annotation validateCommonAnnotationFields(Annotation uiEntity, Annotation dbEntity, String noteTypeSet) { Boolean newEntity = false; - if (dbEntity.getId() == null) + if (dbEntity.getId() == null) { newEntity = true; + } dbEntity = validateAuditedObjectFields(uiEntity, dbEntity, newEntity); String modEntityId = StringUtils.isNotBlank(uiEntity.getModEntityId()) ? uiEntity.getModEntityId() : null; dbEntity.setModEntityId(modEntityId); - + String modInternalId = StringUtils.isNotBlank(uiEntity.getModInternalId()) ? uiEntity.getModInternalId() : null; dbEntity.setModInternalId(modInternalId); @@ -214,11 +210,13 @@ public Annotation validateCommonAnnotationFields(Annotation uiEntity, Annotation dbEntity.setConditionRelations(conditionRelations); List relatedNotes = validateRelatedNotes(uiEntity, dbEntity, noteTypeSet); - if (dbEntity.getRelatedNotes() != null) + if (dbEntity.getRelatedNotes() != null) { dbEntity.getRelatedNotes().clear(); + } if (relatedNotes != null) { - if (dbEntity.getRelatedNotes() == null) + if (dbEntity.getRelatedNotes() == null) { dbEntity.setRelatedNotes(new ArrayList<>()); + } dbEntity.getRelatedNotes().addAll(relatedNotes); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/BiologicalEntityValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/BiologicalEntityValidator.java index 5fb44be44..a82a96c1b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/BiologicalEntityValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/BiologicalEntityValidator.java @@ -12,16 +12,15 @@ public class BiologicalEntityValidator extends SubmittedObjectValidator { - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - + @Inject NcbiTaxonTermService ncbiTaxonTermService; + public E validateBiologicalEntityFields(E uiEntity, E dbEntity) { - + dbEntity = validateSubmittedObjectFields(uiEntity, dbEntity); - + NCBITaxonTerm taxon = validateTaxon(uiEntity, dbEntity); dbEntity.setTaxon(taxon); - + return dbEntity; } @@ -39,13 +38,13 @@ public NCBITaxonTerm validateTaxon(E uiEntity, E dbEntity) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } - + if (taxon.getObsolete() && (dbEntity.getTaxon() == null || !taxon.getCurie().equals(dbEntity.getTaxon().getCurie()))) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } } - + return taxon; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/ConditionRelationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/ConditionRelationValidator.java index 2b2e17676..36896844e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/ConditionRelationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/ConditionRelationValidator.java @@ -30,20 +30,13 @@ @RequestScoped public class ConditionRelationValidator extends AuditedObjectValidator { - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - LiteratureReferenceDAO literatureReferenceDAO; - @Inject - ReferenceDAO referenceDAO; - @Inject - ExperimentalConditionDAO experimentalConditionDAO; - @Inject - ReferenceService referenceService; - @Inject - ReferenceValidator referenceValidator; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject LiteratureReferenceDAO literatureReferenceDAO; + @Inject ReferenceDAO referenceDAO; + @Inject ExperimentalConditionDAO experimentalConditionDAO; + @Inject ReferenceService referenceService; + @Inject ReferenceValidator referenceValidator; private String errorMessage; @@ -148,7 +141,7 @@ private String validateHandle(ConditionRelation uiEntity, ConditionRelation dbEn HashMap params = new HashMap<>(); params.put("handle", uiEntity.getHandle()); params.put("singleReference.curie", uiEntity.getSingleReference().getCurie()); - + SearchResponse response = conditionRelationDAO.findByParams(params); if (response.getTotalResults() > 0) { addMessageResponse("handle", "Handle / Pub combination already exists"); @@ -165,9 +158,10 @@ private String getUniqueKey(ConditionRelation relation) { private Reference validateSingleReference(ConditionRelation uiEntity, ConditionRelation dbEntity) { String field = "singleReference"; - if (uiEntity.getSingleReference() == null) + if (uiEntity.getSingleReference() == null) { return null; - + } + ObjectResponse singleRefResponse = referenceValidator.validateReference(uiEntity.getSingleReference()); if (singleRefResponse.getEntity() == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); @@ -217,7 +211,7 @@ public List validateConditions(ConditionRelation uiEntity addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } - if(condition.getId() == null){ + if (condition.getId() == null) { condition = conditionResponse.getSingleResult(); } conditions.add(condition); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/ConstructValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/ConstructValidator.java index 86005fe26..10ccb25b2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/ConstructValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/ConstructValidator.java @@ -30,21 +30,14 @@ @RequestScoped public class ConstructValidator extends ReagentValidator { - @Inject - ConstructDAO constructDAO; - @Inject - ConstructComponentSlotAnnotationValidator constructComponentValidator; - @Inject - ReferenceValidator referenceValidator; - @Inject - ConstructSymbolSlotAnnotationValidator constructSymbolValidator; - @Inject - ConstructFullNameSlotAnnotationValidator constructFullNameValidator; - @Inject - ConstructSynonymSlotAnnotationValidator constructSynonymValidator; - @Inject - ConstructGenomicEntityAssociationValidator constructGenomicEntityAssociationValidator; - + @Inject ConstructDAO constructDAO; + @Inject ConstructComponentSlotAnnotationValidator constructComponentValidator; + @Inject ReferenceValidator referenceValidator; + @Inject ConstructSymbolSlotAnnotationValidator constructSymbolValidator; + @Inject ConstructFullNameSlotAnnotationValidator constructFullNameValidator; + @Inject ConstructSynonymSlotAnnotationValidator constructSynonymValidator; + @Inject ConstructGenomicEntityAssociationValidator constructGenomicEntityAssociationValidator; + private String errorMessage; public Construct validateConstructUpdate(Construct uiEntity) { @@ -79,8 +72,9 @@ public Construct validateConstructCreate(Construct uiEntity) { public Construct validateConstruct(Construct uiEntity, Construct dbEntity) { List previousReferenceCuries = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getReferences())) + if (CollectionUtils.isNotEmpty(dbEntity.getReferences())) { previousReferenceCuries = dbEntity.getReferences().stream().map(Reference::getCurie).collect(Collectors.toList()); + } if (CollectionUtils.isNotEmpty(uiEntity.getReferences())) { List references = new ArrayList(); for (Reference uiReference : uiEntity.getReferences()) { @@ -93,63 +87,71 @@ public Construct validateConstruct(Construct uiEntity, Construct dbEntity) { } else { dbEntity.setReferences(null); } - + dbEntity = (Construct) validateCommonReagentFields(uiEntity, dbEntity); - + ConstructSymbolSlotAnnotation symbol = validateConstructSymbol(uiEntity, dbEntity); ConstructFullNameSlotAnnotation fullName = validateConstructFullName(uiEntity, dbEntity); List synonyms = validateConstructSynonyms(uiEntity, dbEntity); List components = validateConstructComponents(uiEntity, dbEntity); - + List geAssociations = validateConstructGenomicEntityAssociations(uiEntity, dbEntity); - + String uniqueId = validateUniqueId(uiEntity, dbEntity); dbEntity.setUniqueId(uniqueId); response.convertErrorMessagesToMap(); - + if (response.hasErrors()) { response.setErrorMessage(errorMessage); throw new ApiErrorException(response); } - + dbEntity = constructDAO.persist(dbEntity); - - if (symbol != null) + + if (symbol != null) { symbol.setSingleConstruct(dbEntity); + } dbEntity.setConstructSymbol(symbol); - if (fullName != null) + if (fullName != null) { fullName.setSingleConstruct(dbEntity); + } dbEntity.setConstructFullName(fullName); - if (dbEntity.getConstructSynonyms() != null) + if (dbEntity.getConstructSynonyms() != null) { dbEntity.getConstructSynonyms().clear(); + } if (synonyms != null) { - if (dbEntity.getConstructSynonyms() == null) + if (dbEntity.getConstructSynonyms() == null) { dbEntity.setConstructSynonyms(new ArrayList<>()); + } dbEntity.getConstructSynonyms().addAll(synonyms); } - - if (dbEntity.getConstructComponents() != null) + + if (dbEntity.getConstructComponents() != null) { dbEntity.getConstructComponents().clear(); + } if (components != null) { - if (dbEntity.getConstructComponents() == null) + if (dbEntity.getConstructComponents() == null) { dbEntity.setConstructComponents(new ArrayList<>()); + } dbEntity.getConstructComponents().addAll(components); } - - if (dbEntity.getConstructGenomicEntityAssociations() != null) + + if (dbEntity.getConstructGenomicEntityAssociations() != null) { dbEntity.getConstructGenomicEntityAssociations().clear(); + } if (geAssociations != null) { - if (dbEntity.getConstructGenomicEntityAssociations() == null) + if (dbEntity.getConstructGenomicEntityAssociations() == null) { dbEntity.setConstructGenomicEntityAssociations(new ArrayList<>()); + } dbEntity.getConstructGenomicEntityAssociations().addAll(geAssociations); } return dbEntity; } - + private Reference validateReference(Reference uiEntity, List previousCuries) { ObjectResponse singleRefResponse = referenceValidator.validateReference(uiEntity); if (singleRefResponse.getEntity() == null) { @@ -166,10 +168,11 @@ private Reference validateReference(Reference uiEntity, List previousCur } public String validateUniqueId(Construct uiEntity, Construct dbEntity) { - - if (dbEntity.getDataProvider() == null) + + if (dbEntity.getDataProvider() == null) { return null; - + } + String uniqueId = ConstructUniqueIdHelper.getConstructUniqueId(uiEntity); if (dbEntity.getUniqueId() == null || !uniqueId.equals(dbEntity.getUniqueId())) { @@ -182,7 +185,7 @@ public String validateUniqueId(Construct uiEntity, Construct dbEntity) { return uniqueId; } - + private ConstructSymbolSlotAnnotation validateConstructSymbol(Construct uiEntity, Construct dbEntity) { String field = "constructSymbol"; @@ -202,8 +205,9 @@ private ConstructSymbolSlotAnnotation validateConstructSymbol(Construct uiEntity } private ConstructFullNameSlotAnnotation validateConstructFullName(Construct uiEntity, Construct dbEntity) { - if (uiEntity.getConstructFullName() == null) + if (uiEntity.getConstructFullName() == null) { return null; + } String field = "constructFullName"; @@ -223,7 +227,7 @@ private List validateConstructSynonyms(Construct List validatedSynonyms = new ArrayList(); Boolean allValid = true; if (CollectionUtils.isNotEmpty(uiEntity.getConstructSynonyms())) { - for (int ix = 0; ix < uiEntity.getConstructSynonyms().size(); ix++) { + for (int ix = 0; ix < uiEntity.getConstructSynonyms().size(); ix++) { ConstructSynonymSlotAnnotation syn = uiEntity.getConstructSynonyms().get(ix); ObjectResponse synResponse = constructSynonymValidator.validateConstructSynonymSlotAnnotation(syn); if (synResponse.getEntity() == null) { @@ -242,19 +246,20 @@ private List validateConstructSynonyms(Construct return null; } - if (CollectionUtils.isEmpty(validatedSynonyms)) + if (CollectionUtils.isEmpty(validatedSynonyms)) { return null; + } return validatedSynonyms; } - + private List validateConstructComponents(Construct uiEntity, Construct dbEntity) { String field = "constructComponents"; List validatedComponents = new ArrayList(); Boolean allValid = true; if (CollectionUtils.isNotEmpty(uiEntity.getConstructComponents())) { - for (int ix = 0; ix < uiEntity.getConstructComponents().size(); ix++) { + for (int ix = 0; ix < uiEntity.getConstructComponents().size(); ix++) { ConstructComponentSlotAnnotation comp = uiEntity.getConstructComponents().get(ix); ObjectResponse synResponse = constructComponentValidator.validateConstructComponentSlotAnnotation(comp); if (synResponse.getEntity() == null) { @@ -273,12 +278,13 @@ private List validateConstructComponents(Const return null; } - if (CollectionUtils.isEmpty(validatedComponents)) + if (CollectionUtils.isEmpty(validatedComponents)) { return null; + } return validatedComponents; } - + private List validateConstructGenomicEntityAssociations(Construct uiEntity, Construct dbEntity) { String field = "constructGenomicEntityAssociations"; @@ -298,16 +304,17 @@ private List validateConstructGenomicEntityAs } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - if (CollectionUtils.isEmpty(validatedAssociations)) + if (CollectionUtils.isEmpty(validatedAssociations)) { return null; + } return validatedAssociations; } - + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/CrossReferenceValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/CrossReferenceValidator.java index ca9e7082e..08cb93622 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/CrossReferenceValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/CrossReferenceValidator.java @@ -14,8 +14,7 @@ @RequestScoped public class CrossReferenceValidator extends AuditedObjectValidator { - @Inject - CrossReferenceDAO crossReferenceDAO; + @Inject CrossReferenceDAO crossReferenceDAO; public ObjectResponse validateCrossReference(CrossReference uiEntity, Boolean throwError) { response = new ObjectResponse<>(uiEntity); @@ -23,28 +22,32 @@ public ObjectResponse validateCrossReference(CrossReference uiEn CrossReference dbEntity; - Boolean newEntity = true; + Boolean newEntity = true; if (uiEntity.getId() != null) { dbEntity = crossReferenceDAO.find(uiEntity.getId()); newEntity = false; } else { dbEntity = new CrossReference(); } - + dbEntity = (CrossReference) validateAuditedObjectFields(uiEntity, dbEntity, newEntity); - if (StringUtils.isEmpty(uiEntity.getReferencedCurie())) + if (StringUtils.isEmpty(uiEntity.getReferencedCurie())) { addMessageResponse("referencedCurie", ValidationConstants.REQUIRED_MESSAGE); + } dbEntity.setReferencedCurie(uiEntity.getReferencedCurie()); - if (StringUtils.isEmpty(uiEntity.getDisplayName())) - if (StringUtils.isEmpty(uiEntity.getReferencedCurie())) + if (StringUtils.isEmpty(uiEntity.getDisplayName())) { + if (StringUtils.isEmpty(uiEntity.getReferencedCurie())) { addMessageResponse("displayName", ValidationConstants.REQUIRED_MESSAGE); + } + } dbEntity.setDisplayName(uiEntity.getDisplayName()); - - if (uiEntity.getResourceDescriptorPage() != null) + + if (uiEntity.getResourceDescriptorPage() != null) { dbEntity.setResourceDescriptorPage(uiEntity.getResourceDescriptorPage()); - + } + if (response.hasErrors()) { if (throwError) { response.setErrorMessage(errorTitle); @@ -52,7 +55,7 @@ public ObjectResponse validateCrossReference(CrossReference uiEn } return response; } - + response.setEntity(crossReferenceDAO.persist(dbEntity)); return response; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java index a8c29a1df..597ec31c1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java @@ -18,37 +18,33 @@ @RequestScoped public class DataProviderValidator extends AuditedObjectValidator { - @Inject - DataProviderDAO dataProviderDAO; - @Inject - OrganizationService organizationService; - @Inject - CrossReferenceValidator crossReferenceValidator; - @Inject - CrossReferenceService crossReferenceService; - @Inject - CrossReferenceDAO crossReferenceDAO; - + @Inject DataProviderDAO dataProviderDAO; + @Inject OrganizationService organizationService; + @Inject CrossReferenceValidator crossReferenceValidator; + @Inject CrossReferenceService crossReferenceService; + @Inject CrossReferenceDAO crossReferenceDAO; + public ObjectResponse validateDataProvider(DataProvider uiEntity, DataProvider dbEntity, Boolean throwError) { response = new ObjectResponse<>(uiEntity); String errorTitle = "Could not create/update DataProvider: [" + uiEntity.getId() + "]"; - if (dbEntity == null) + if (dbEntity == null) { dbEntity = new DataProvider(); + } - Boolean newEntity = true; + Boolean newEntity = true; if (uiEntity.getId() != null) { dbEntity = dataProviderDAO.find(uiEntity.getId()); newEntity = false; } else { dbEntity = new DataProvider(); } - + dbEntity = (DataProvider) validateAuditedObjectFields(uiEntity, dbEntity, newEntity); Organization sourceOrganization = validateSourceOrganization(uiEntity, dbEntity); dbEntity.setSourceOrganization(sourceOrganization); - + String dbXrefUniqueId = null; String uiXrefUniqueId = null; Long dbXrefId = null; @@ -56,7 +52,7 @@ public ObjectResponse validateDataProvider(DataProvider uiEntity, dbXrefUniqueId = crossReferenceService.getCrossReferenceUniqueId(dbEntity.getCrossReference()); dbXrefId = dbEntity.getCrossReference().getId(); } - + if (uiEntity.getCrossReference() != null) { ObjectResponse xrefResponse = crossReferenceValidator.validateCrossReference(uiEntity.getCrossReference(), false); if (xrefResponse.hasErrors()) { @@ -72,7 +68,7 @@ public ObjectResponse validateDataProvider(DataProvider uiEntity, } else { dbEntity.setCrossReference(null); } - + if (response.hasErrors()) { if (throwError) { response.setErrorMessage(errorTitle); @@ -80,26 +76,28 @@ public ObjectResponse validateDataProvider(DataProvider uiEntity, } return response; } else { - if (dbXrefId != null && (uiXrefUniqueId == null || !dbXrefUniqueId.equals(uiXrefUniqueId))) + if (dbXrefId != null && (uiXrefUniqueId == null || !dbXrefUniqueId.equals(uiXrefUniqueId))) { crossReferenceDAO.remove(dbXrefId); - - if (dbEntity.getId() == null) + } + + if (dbEntity.getId() == null) { dbEntity = dataProviderDAO.persist(dbEntity); + } } - + response.setEntity(dbEntity); return response; } - + private Organization validateSourceOrganization(DataProvider uiEntity, DataProvider dbEntity) { String field = "sourceOrganization"; - + if (uiEntity.getSourceOrganization() == null) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - + Organization sourceOrganization = organizationService.getById(uiEntity.getSourceOrganization().getId()).getEntity(); if (sourceOrganization == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); @@ -110,7 +108,7 @@ private Organization validateSourceOrganization(DataProvider uiEntity, DataProvi addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } - + return sourceOrganization; } } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java index b3872b946..ee929311d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java @@ -32,22 +32,14 @@ public class DiseaseAnnotationValidator extends AnnotationValidator { - @Inject - EcoTermDAO ecoTermDAO; - @Inject - DoTermService doTermService; - @Inject - GeneDAO geneDAO; - @Inject - BiologicalEntityDAO biologicalEntityDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - DiseaseAnnotationDAO diseaseAnnotationDAO; - @Inject - DataProviderService dataProviderService; - @Inject - DataProviderValidator dataProviderValidator; + @Inject EcoTermDAO ecoTermDAO; + @Inject DoTermService doTermService; + @Inject GeneDAO geneDAO; + @Inject BiologicalEntityDAO biologicalEntityDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject DiseaseAnnotationDAO diseaseAnnotationDAO; + @Inject DataProviderService dataProviderService; + @Inject DataProviderValidator dataProviderValidator; public DOTerm validateObjectOntologyTerm(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { String field = "diseaseAnnotationObject"; @@ -55,7 +47,7 @@ public DOTerm validateObjectOntologyTerm(DiseaseAnnotation uiEntity, DiseaseAnno addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - + DOTerm diseaseTerm = null; if (StringUtils.isNotBlank(uiEntity.getDiseaseAnnotationObject().getCurie())) { diseaseTerm = doTermService.findByCurie(uiEntity.getDiseaseAnnotationObject().getCurie()); @@ -100,12 +92,14 @@ public List validateEvidenceCodes(DiseaseAnnotation uiEntity, DiseaseAn } List validEvidenceCodes = new ArrayList<>(); List previousIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getEvidenceCodes())) + if (CollectionUtils.isNotEmpty(dbEntity.getEvidenceCodes())) { previousIds = dbEntity.getEvidenceCodes().stream().map(ECOTerm::getId).collect(Collectors.toList()); + } for (ECOTerm ec : uiEntity.getEvidenceCodes()) { ECOTerm evidenceCode = null; - if (ec.getId() != null) + if (ec.getId() != null) { evidenceCode = ecoTermDAO.find(ec.getId()); + } if (evidenceCode == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -124,17 +118,20 @@ public List validateEvidenceCodes(DiseaseAnnotation uiEntity, DiseaseAn } public List validateWith(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { - if (CollectionUtils.isEmpty(uiEntity.getWith())) + if (CollectionUtils.isEmpty(uiEntity.getWith())) { return null; + } List validWithGenes = new ArrayList(); List previousIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getWith())) + if (CollectionUtils.isNotEmpty(dbEntity.getWith())) { previousIds = dbEntity.getWith().stream().map(Gene::getId).collect(Collectors.toList()); + } for (Gene wg : uiEntity.getWith()) { Gene withGene = null; - if (wg.getId() != null) + if (wg.getId() != null) { withGene = geneDAO.find(wg.getId()); + } if (withGene == null || withGene.getModEntityId() == null || !withGene.getModEntityId().startsWith("HGNC:")) { addMessageResponse("with", ValidationConstants.INVALID_MESSAGE); return null; @@ -148,35 +145,35 @@ public List validateWith(DiseaseAnnotation uiEntity, DiseaseAnnotation dbE return validWithGenes; } - public DataProvider validateSecondaryDataProvider(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { String field = "secondaryDataProvider"; - + if (uiEntity.getSecondaryDataProvider() == null) { if (dbEntity.getId() == null) { uiEntity.setSecondaryDataProvider(dataProviderService.createAllianceDataProvider()); - if (uiEntity.getSecondaryDataProvider() == null) + if (uiEntity.getSecondaryDataProvider() == null) { return null; + } } else { return null; } } - + DataProvider uiDataProvider = uiEntity.getSecondaryDataProvider(); DataProvider dbDataProvider = dbEntity.getSecondaryDataProvider(); - + ObjectResponse dpResponse = dataProviderValidator.validateDataProvider(uiDataProvider, dbDataProvider, false); if (dpResponse.hasErrors()) { addMessageResponse(field, dpResponse.errorMessagesString()); return null; } - + DataProvider validatedDataProvider = dpResponse.getEntity(); if (validatedDataProvider.getObsolete() && (dbDataProvider == null || !validatedDataProvider.getId().equals(dbDataProvider.getId()))) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } - + return validatedDataProvider; } @@ -192,12 +189,14 @@ public List validateDiseaseGeneticModifiers(DiseaseAnnotation List validModifiers = new ArrayList<>(); List previousIds = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(dbEntity.getDiseaseGeneticModifiers())) + if (CollectionUtils.isNotEmpty(dbEntity.getDiseaseGeneticModifiers())) { previousIds = dbEntity.getDiseaseGeneticModifiers().stream().map(BiologicalEntity::getId).collect(Collectors.toList()); + } for (BiologicalEntity modifier : uiEntity.getDiseaseGeneticModifiers()) { BiologicalEntity diseaseGeneticModifier = null; - if (modifier.getId() != null) + if (modifier.getId() != null) { diseaseGeneticModifier = biologicalEntityDAO.find(modifier.getId()); + } if (diseaseGeneticModifier == null) { addMessageResponse("diseaseGeneticModifiers", ValidationConstants.INVALID_MESSAGE); return null; @@ -282,10 +281,11 @@ public VocabularyTerm validateAnnotationType(DiseaseAnnotation uiEntity, Disease } public String validateUniqueId(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { - - if (dbEntity.getDataProvider() == null) + + if (dbEntity.getDataProvider() == null) { return null; - + } + String uniqueId = AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(uiEntity); if (dbEntity.getUniqueId() == null || !uniqueId.equals(dbEntity.getUniqueId())) { @@ -300,7 +300,7 @@ public String validateUniqueId(DiseaseAnnotation uiEntity, DiseaseAnnotation dbE } public DiseaseAnnotation validateCommonDiseaseAnnotationFields(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { - + DOTerm term = validateObjectOntologyTerm(uiEntity, dbEntity); dbEntity.setDiseaseAnnotationObject(term); @@ -331,7 +331,7 @@ public DiseaseAnnotation validateCommonDiseaseAnnotationFields(DiseaseAnnotation dbEntity.setDiseaseQualifiers(diseaseQualifiers); dbEntity = (DiseaseAnnotation) validateCommonAnnotationFields(uiEntity, dbEntity, VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET); - + String uniqueId = validateUniqueId(uiEntity, dbEntity); dbEntity.setUniqueId(uniqueId); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/ExperimentalConditionValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/ExperimentalConditionValidator.java index f204fd15e..e4ed7a78e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/ExperimentalConditionValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/ExperimentalConditionValidator.java @@ -31,20 +31,13 @@ @RequestScoped public class ExperimentalConditionValidator extends AuditedObjectValidator { - @Inject - ExperimentalConditionDAO experimentalConditionDAO; - @Inject - GoTermService goTermService; - @Inject - ZecoTermService zecoTermService; - @Inject - AnatomicalTermService anatomicalTermService; - @Inject - ChemicalTermService chemicalTermService; - @Inject - ExperimentalConditionOntologyTermService ecOntologyTermService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; + @Inject ExperimentalConditionDAO experimentalConditionDAO; + @Inject GoTermService goTermService; + @Inject ZecoTermService zecoTermService; + @Inject AnatomicalTermService anatomicalTermService; + @Inject ChemicalTermService chemicalTermService; + @Inject ExperimentalConditionOntologyTermService ecOntologyTermService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; private String errorMessage; @@ -143,8 +136,9 @@ public ZECOTerm validateConditionClass(ExperimentalCondition uiEntity, Experimen public ExperimentalConditionOntologyTerm validateConditionId(ExperimentalCondition uiEntity, ExperimentalCondition dbEntity) { String field = "conditionId"; - if (ObjectUtils.isEmpty(uiEntity.getConditionId())) + if (ObjectUtils.isEmpty(uiEntity.getConditionId())) { return null; + } ExperimentalConditionOntologyTerm ecOntologyTerm = null; if (StringUtils.isNotBlank(uiEntity.getConditionId().getCurie())) { ecOntologyTerm = ecOntologyTermService.findByCurie(uiEntity.getConditionId().getCurie()); @@ -161,8 +155,9 @@ public ExperimentalConditionOntologyTerm validateConditionId(ExperimentalConditi public GOTerm validateConditionGeneOntology(ExperimentalCondition uiEntity, ExperimentalCondition dbEntity) { String field = "conditionGeneOntology"; - if (ObjectUtils.isEmpty(uiEntity.getConditionGeneOntology())) + if (ObjectUtils.isEmpty(uiEntity.getConditionGeneOntology())) { return null; + } GOTerm goTerm = null; if (StringUtils.isNotBlank(uiEntity.getConditionGeneOntology().getCurie())) { goTerm = goTermService.findByCurie(uiEntity.getConditionGeneOntology().getCurie()); @@ -179,8 +174,9 @@ public GOTerm validateConditionGeneOntology(ExperimentalCondition uiEntity, Expe public AnatomicalTerm validateConditionAnatomy(ExperimentalCondition uiEntity, ExperimentalCondition dbEntity) { String field = "conditionAnatomy"; - if (ObjectUtils.isEmpty(uiEntity.getConditionAnatomy())) + if (ObjectUtils.isEmpty(uiEntity.getConditionAnatomy())) { return null; + } AnatomicalTerm anatomicalTerm = null; if (StringUtils.isNotBlank(uiEntity.getConditionAnatomy().getCurie())) { anatomicalTerm = anatomicalTermService.findByCurie(uiEntity.getConditionAnatomy().getCurie()); @@ -197,8 +193,9 @@ public AnatomicalTerm validateConditionAnatomy(ExperimentalCondition uiEntity, E public ChemicalTerm validateConditionChemical(ExperimentalCondition uiEntity, ExperimentalCondition dbEntity) { String field = "conditionChemical"; - if (ObjectUtils.isEmpty(uiEntity.getConditionChemical())) + if (ObjectUtils.isEmpty(uiEntity.getConditionChemical())) { return null; + } ChemicalTerm chemicalTerm = null; if (StringUtils.isNotBlank(uiEntity.getConditionChemical().getCurie())) { chemicalTerm = chemicalTermService.findByCurie(uiEntity.getConditionChemical().getCurie()); @@ -215,13 +212,15 @@ public ChemicalTerm validateConditionChemical(ExperimentalCondition uiEntity, Ex public NCBITaxonTerm validateConditionTaxon(ExperimentalCondition uiEntity, ExperimentalCondition dbEntity) { String field = "conditionTaxon"; - if (ObjectUtils.isEmpty(uiEntity.getConditionTaxon())) + if (ObjectUtils.isEmpty(uiEntity.getConditionTaxon())) { return null; + } NCBITaxonTerm taxonTerm = null; if (StringUtils.isNotBlank(uiEntity.getConditionTaxon().getCurie())) { taxonTerm = ncbiTaxonTermService.findByCurie(uiEntity.getConditionTaxon().getCurie()); - if (taxonTerm == null) + if (taxonTerm == null) { taxonTerm = ncbiTaxonTermService.downloadAndSave(uiEntity.getConditionTaxon().getCurie()); + } if (taxonTerm == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/GeneDiseaseAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/GeneDiseaseAnnotationValidator.java index 4c7e35ef3..6faebbe51 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/GeneDiseaseAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/GeneDiseaseAnnotationValidator.java @@ -20,14 +20,10 @@ @RequestScoped public class GeneDiseaseAnnotationValidator extends DiseaseAnnotationValidator { - @Inject - GeneDAO geneDAO; - @Inject - AffectedGenomicModelDAO agmDAO; - @Inject - GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject GeneDAO geneDAO; + @Inject AffectedGenomicModelDAO agmDAO; + @Inject GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; + @Inject VocabularyTermService vocabularyTermService; private String errorMessage; @@ -89,8 +85,9 @@ private Gene validateSubject(GeneDiseaseAnnotation uiEntity, GeneDiseaseAnnotati } Gene subjectEntity = null; - if (uiEntity.getDiseaseAnnotationSubject().getId() != null) + if (uiEntity.getDiseaseAnnotationSubject().getId() != null) { subjectEntity = geneDAO.find(uiEntity.getDiseaseAnnotationSubject().getId()); + } if (subjectEntity == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -129,12 +126,14 @@ private VocabularyTerm validateDiseaseRelation(GeneDiseaseAnnotation uiEntity, G private AffectedGenomicModel validateSgdStrainBackground(GeneDiseaseAnnotation uiEntity, GeneDiseaseAnnotation dbEntity) { String field = "sgdStrainBackground"; - if (ObjectUtils.isEmpty(uiEntity.getSgdStrainBackground())) + if (ObjectUtils.isEmpty(uiEntity.getSgdStrainBackground())) { return null; + } AffectedGenomicModel sgdStrainBackground = null; - if (uiEntity.getSgdStrainBackground().getId() != null) + if (uiEntity.getSgdStrainBackground().getId() != null) { sgdStrainBackground = agmDAO.find(uiEntity.getSgdStrainBackground().getId()); + } if (sgdStrainBackground == null || !sgdStrainBackground.getTaxon().getName().startsWith("Saccharomyces cerevisiae")) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java index 9f146c322..9752a3632 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java @@ -31,22 +31,14 @@ @RequestScoped public class GeneValidator extends GenomicEntityValidator { - @Inject - GeneDAO geneDAO; - @Inject - SoTermService soTermService; - @Inject - GeneSymbolSlotAnnotationValidator geneSymbolValidator; - @Inject - GeneFullNameSlotAnnotationValidator geneFullNameValidator; - @Inject - GeneSystematicNameSlotAnnotationValidator geneSystematicNameValidator; - @Inject - GeneSynonymSlotAnnotationValidator geneSynonymValidator; - @Inject - GeneSecondaryIdSlotAnnotationValidator geneSecondaryIdValidator; - @Inject - CrossReferenceDAO crossReferenceDAO; + @Inject GeneDAO geneDAO; + @Inject SoTermService soTermService; + @Inject GeneSymbolSlotAnnotationValidator geneSymbolValidator; + @Inject GeneFullNameSlotAnnotationValidator geneFullNameValidator; + @Inject GeneSystematicNameSlotAnnotationValidator geneSystematicNameValidator; + @Inject GeneSynonymSlotAnnotationValidator geneSynonymValidator; + @Inject GeneSecondaryIdSlotAnnotationValidator geneSecondaryIdValidator; + @Inject CrossReferenceDAO crossReferenceDAO; private String errorMessage; @@ -85,7 +77,7 @@ public Gene validateGeneCreate(Gene uiEntity) { private Gene validateGene(Gene uiEntity, Gene dbEntity) { dbEntity = (Gene) validateGenomicEntityFields(uiEntity, dbEntity); - + SOTerm geneType = validateGeneType(uiEntity, dbEntity); dbEntity.setGeneType(geneType); @@ -94,9 +86,9 @@ private Gene validateGene(Gene uiEntity, Gene dbEntity) { GeneSystematicNameSlotAnnotation systematicName = validateGeneSystematicName(uiEntity, dbEntity); List synonyms = validateGeneSynonyms(uiEntity, dbEntity); List secondaryIds = validateGeneSecondaryIds(uiEntity, dbEntity); - + response.convertErrorMessagesToMap(); - + if (response.hasErrors()) { response.setErrorMessage(errorMessage); throw new ApiErrorException(response); @@ -104,31 +96,38 @@ private Gene validateGene(Gene uiEntity, Gene dbEntity) { dbEntity = geneDAO.persist(dbEntity); - if (symbol != null) + if (symbol != null) { symbol.setSingleGene(dbEntity); + } dbEntity.setGeneSymbol(symbol); - if (fullName != null) + if (fullName != null) { fullName.setSingleGene(dbEntity); + } dbEntity.setGeneFullName(fullName); - if (systematicName != null) + if (systematicName != null) { systematicName.setSingleGene(dbEntity); + } dbEntity.setGeneSystematicName(systematicName); - if (dbEntity.getGeneSynonyms() != null) + if (dbEntity.getGeneSynonyms() != null) { dbEntity.getGeneSynonyms().clear(); + } if (synonyms != null) { - if (dbEntity.getGeneSynonyms() == null) + if (dbEntity.getGeneSynonyms() == null) { dbEntity.setGeneSynonyms(new ArrayList<>()); + } dbEntity.getGeneSynonyms().addAll(synonyms); } - if (dbEntity.getGeneSecondaryIds() != null) + if (dbEntity.getGeneSecondaryIds() != null) { dbEntity.getGeneSecondaryIds().clear(); + } if (secondaryIds != null) { - if (dbEntity.getGeneSecondaryIds() == null) + if (dbEntity.getGeneSecondaryIds() == null) { dbEntity.setGeneSecondaryIds(new ArrayList<>()); + } dbEntity.getGeneSecondaryIds().addAll(secondaryIds); } @@ -136,8 +135,9 @@ private Gene validateGene(Gene uiEntity, Gene dbEntity) { } private SOTerm validateGeneType(Gene uiEntity, Gene dbEntity) { - if (ObjectUtils.isEmpty(uiEntity.getGeneType())) + if (ObjectUtils.isEmpty(uiEntity.getGeneType())) { return null; + } SOTerm soTerm = null; if (StringUtils.isNotBlank(uiEntity.getGeneType().getCurie())) { @@ -172,8 +172,9 @@ private GeneSymbolSlotAnnotation validateGeneSymbol(Gene uiEntity, Gene dbEntity } private GeneFullNameSlotAnnotation validateGeneFullName(Gene uiEntity, Gene dbEntity) { - if (uiEntity.getGeneFullName() == null) + if (uiEntity.getGeneFullName() == null) { return null; + } String field = "geneFullName"; @@ -188,8 +189,9 @@ private GeneFullNameSlotAnnotation validateGeneFullName(Gene uiEntity, Gene dbEn } private GeneSystematicNameSlotAnnotation validateGeneSystematicName(Gene uiEntity, Gene dbEntity) { - if (uiEntity.getGeneSystematicName() == null) + if (uiEntity.getGeneSystematicName() == null) { return null; + } String field = "geneSystematicName"; @@ -209,7 +211,7 @@ private List validateGeneSynonyms(Gene uiEntity, Gene List validatedSynonyms = new ArrayList(); Boolean allValid = true; if (CollectionUtils.isNotEmpty(uiEntity.getGeneSynonyms())) { - for (int ix = 0; ix < uiEntity.getGeneSynonyms().size(); ix++) { + for (int ix = 0; ix < uiEntity.getGeneSynonyms().size(); ix++) { GeneSynonymSlotAnnotation syn = uiEntity.getGeneSynonyms().get(ix); ObjectResponse synResponse = geneSynonymValidator.validateGeneSynonymSlotAnnotation(syn); if (synResponse.getEntity() == null) { @@ -228,8 +230,9 @@ private List validateGeneSynonyms(Gene uiEntity, Gene return null; } - if (CollectionUtils.isEmpty(validatedSynonyms)) + if (CollectionUtils.isEmpty(validatedSynonyms)) { return null; + } return validatedSynonyms; } @@ -253,14 +256,15 @@ private List validateGeneSecondaryIds(Gene uiEnti } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - if (CollectionUtils.isEmpty(validatedSecondaryIds)) + if (CollectionUtils.isEmpty(validatedSecondaryIds)) { return null; + } return validatedSecondaryIds; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/GenomicEntityValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/GenomicEntityValidator.java index 4af5c3e5b..676b39a83 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/GenomicEntityValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/GenomicEntityValidator.java @@ -13,24 +13,24 @@ public class GenomicEntityValidator extends BiologicalEntityValidator { - @Inject - CrossReferenceValidator crossReferenceValidator; - @Inject - CrossReferenceService crossReferenceService; - + @Inject CrossReferenceValidator crossReferenceValidator; + @Inject CrossReferenceService crossReferenceService; + public E validateGenomicEntityFields(E uiEntity, E dbEntity) { dbEntity = validateBiologicalEntityFields(uiEntity, dbEntity); - + List xrefs = validateCrossReferences(uiEntity, dbEntity); - if (dbEntity.getCrossReferences() != null) + if (dbEntity.getCrossReferences() != null) { dbEntity.getCrossReferences().clear(); + } if (xrefs != null) { - if (dbEntity.getCrossReferences() == null) + if (dbEntity.getCrossReferences() == null) { dbEntity.setCrossReferences(new ArrayList<>()); + } dbEntity.getCrossReferences().addAll(xrefs); } - + return dbEntity; } @@ -51,14 +51,15 @@ public List validateCrossReferences(E uiEntity, E dbEntity) { } } } - + if (!allValid) { convertMapToErrorMessages(field); return null; } - if (CollectionUtils.isEmpty(validatedXrefs)) + if (CollectionUtils.isEmpty(validatedXrefs)) { return null; + } return validatedXrefs; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/MoleculeValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/MoleculeValidator.java index 534476a41..8148b352e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/MoleculeValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/MoleculeValidator.java @@ -13,49 +13,48 @@ @RequestScoped public class MoleculeValidator extends CurieObjectValidator { - @Inject - MoleculeDAO moleculeDAO; + @Inject MoleculeDAO moleculeDAO; private String errorMessage; - + public Molecule validateMoleculeUpdate(Molecule uiEntity) { response = new ObjectResponse<>(uiEntity); errorMessage = "Could not update Molecule: [" + uiEntity.getCurie() + "]"; - - Long id = uiEntity.getId(); + + Long id = uiEntity.getId(); if (id == null) { addMessageResponse("No Molecule ID provided"); throw new ApiErrorException(response); } - + Molecule dbEntity = moleculeDAO.find(id); if (dbEntity == null) { addMessageResponse("id", ValidationConstants.INVALID_MESSAGE); throw new ApiErrorException(response); } - + dbEntity = (Molecule) validateAuditedObjectFields(uiEntity, dbEntity, false); - + return validateMolecule(uiEntity, dbEntity); } - + public Molecule validateMoleculeCreate(Molecule uiEntity) { response = new ObjectResponse<>(uiEntity); errorMessage = "Could not create Molecule"; - + Molecule dbEntity = new Molecule(); - + dbEntity = (Molecule) validateAuditedObjectFields(uiEntity, dbEntity, true); return validateMolecule(uiEntity, dbEntity); } - + public Molecule validateMolecule(Molecule uiEntity, Molecule dbEntity) { response = new ObjectResponse<>(uiEntity); String curie = validateCurie(uiEntity); dbEntity.setCurie(curie); - + dbEntity.setInchi(handleStringField(uiEntity.getInchi())); dbEntity.setInchiKey(handleStringField(uiEntity.getInchiKey())); dbEntity.setIupac(handleStringField(uiEntity.getIupac())); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java index 56afad20c..08502d969 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java @@ -24,14 +24,10 @@ @RequestScoped public class NoteValidator extends AuditedObjectValidator { - @Inject - NoteDAO noteDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - ReferenceService referenceService; - @Inject - ReferenceValidator referenceValidator; + @Inject NoteDAO noteDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject ReferenceService referenceService; + @Inject ReferenceValidator referenceValidator; public ObjectResponse validateNote(Note uiEntity, String noteVocabularySetName) { Note note = validateNote(uiEntity, noteVocabularySetName, false); @@ -66,8 +62,9 @@ public Note validateNote(Note uiEntity, String noteVocabularySetName, Boolean th dbEntity.setFreeText(freeText); List previousReferenceCuries = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getReferences())) + if (CollectionUtils.isNotEmpty(dbEntity.getReferences())) { previousReferenceCuries = dbEntity.getReferences().stream().map(Reference::getCurie).collect(Collectors.toList()); + } if (CollectionUtils.isNotEmpty(uiEntity.getReferences())) { List references = new ArrayList(); for (Reference uiReference : uiEntity.getReferences()) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/PersonValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/PersonValidator.java index d47823093..4a13590e4 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/PersonValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/PersonValidator.java @@ -15,8 +15,7 @@ @RequestScoped public class PersonValidator extends AuditedObjectValidator { - @Inject - PersonDAO personDAO; + @Inject PersonDAO personDAO; public Person validatePerson(Person uiEntity) { response = new ObjectResponse<>(uiEntity); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/ReagentValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/ReagentValidator.java index 841aa3e54..3c8d327af 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/ReagentValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/ReagentValidator.java @@ -16,62 +16,61 @@ public class ReagentValidator extends SubmittedObjectValidator { - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - DataProviderService dataProviderService; - @Inject - DataProviderValidator dataProviderValidator; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject DataProviderService dataProviderService; + @Inject DataProviderValidator dataProviderValidator; public Reagent validateCommonReagentFields(Reagent uiEntity, Reagent dbEntity) { - + Boolean newEntity = false; - if (dbEntity.getId() == null) + if (dbEntity.getId() == null) { newEntity = true; + } dbEntity = (Reagent) validateAuditedObjectFields(uiEntity, dbEntity, newEntity); - + String modEntityId = StringUtils.isNotBlank(uiEntity.getModEntityId()) ? uiEntity.getModEntityId() : null; dbEntity.setModEntityId(modEntityId); - + String modInternalId = validateModInternalId(uiEntity); dbEntity.setModInternalId(modInternalId); - + List secondaryIds = CollectionUtils.isNotEmpty(uiEntity.getSecondaryIdentifiers()) ? uiEntity.getSecondaryIdentifiers() : null; dbEntity.setSecondaryIdentifiers(secondaryIds); - + DataProvider dataProvider = validateDataProvider(uiEntity, dbEntity); dbEntity.setDataProvider(dataProvider); - + return dbEntity; } - + public DataProvider validateDataProvider(Reagent uiEntity, Reagent dbEntity) { String field = "dataProvider"; - + if (uiEntity.getDataProvider() == null) { - if (dbEntity.getId() == null) + if (dbEntity.getId() == null) { uiEntity.setDataProvider(dataProviderService.createAffiliatedModDataProvider()); + } if (uiEntity.getDataProvider() == null) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - } + } DataProvider uiDataProvider = uiEntity.getDataProvider(); DataProvider dbDataProvider = dbEntity.getDataProvider(); - + ObjectResponse dpResponse = dataProviderValidator.validateDataProvider(uiDataProvider, dbDataProvider, false); if (dpResponse.hasErrors()) { addMessageResponse(field, dpResponse.errorMessagesString()); return null; } - + DataProvider validatedDataProvider = dpResponse.getEntity(); if (validatedDataProvider.getObsolete() && (dbDataProvider == null || !validatedDataProvider.getId().equals(dbDataProvider.getId()))) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } - + return validatedDataProvider; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/ReferenceValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/ReferenceValidator.java index 442fb81d9..7e4530c7f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/ReferenceValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/ReferenceValidator.java @@ -15,13 +15,10 @@ @RequestScoped public class ReferenceValidator extends AuditedObjectValidator { - @Inject - ReferenceService referenceService; - @Inject - ReferenceDAO referenceDAO; + @Inject ReferenceService referenceService; + @Inject ReferenceDAO referenceDAO; - @Inject - PersonService personService; + @Inject PersonService personService; public ObjectResponse validateReference(Reference uiEntity) { Reference reference = validateReference(uiEntity, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/VariantValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/VariantValidator.java index 1b6c26932..7068154ef 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/VariantValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/VariantValidator.java @@ -30,16 +30,11 @@ @RequestScoped public class VariantValidator extends GenomicEntityValidator { - @Inject - VariantDAO variantDAO; - @Inject - NoteValidator noteValidator; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - CrossReferenceDAO crossReferenceDAO; - @Inject - SoTermService soTermService; + @Inject VariantDAO variantDAO; + @Inject NoteValidator noteValidator; + @Inject VocabularyTermService vocabularyTermService; + @Inject CrossReferenceDAO crossReferenceDAO; + @Inject SoTermService soTermService; private String errorMessage; @@ -67,7 +62,7 @@ public Variant validateVariantUpdate(Variant uiEntity) { public Variant validateVariantCreate(Variant uiEntity) { response = new ObjectResponse<>(); errorMessage = "Could not create Variant"; - + Variant dbEntity = new Variant(); dbEntity = (Variant) validateAuditedObjectFields(uiEntity, dbEntity, true); @@ -78,22 +73,24 @@ public Variant validateVariantCreate(Variant uiEntity) { public Variant validateVariant(Variant uiEntity, Variant dbEntity) { dbEntity = (Variant) validateGenomicEntityFields(uiEntity, dbEntity); - + SOTerm variantType = validateVariantType(uiEntity, dbEntity); dbEntity.setVariantType(variantType); VocabularyTerm variantStatus = validateVariantStatus(uiEntity, dbEntity); dbEntity.setVariantStatus(variantStatus); - + SOTerm sourceGeneralConsequence = validateSourceGeneralConsequence(uiEntity, dbEntity); dbEntity.setSourceGeneralConsequence(sourceGeneralConsequence); - + List relatedNotes = validateRelatedNotes(uiEntity, dbEntity); - if (dbEntity.getRelatedNotes() != null) + if (dbEntity.getRelatedNotes() != null) { dbEntity.getRelatedNotes().clear(); + } if (relatedNotes != null) { - if (dbEntity.getRelatedNotes() == null) + if (dbEntity.getRelatedNotes() == null) { dbEntity.setRelatedNotes(new ArrayList<>()); + } dbEntity.getRelatedNotes().addAll(relatedNotes); } @@ -106,7 +103,7 @@ public Variant validateVariant(Variant uiEntity, Variant dbEntity) { return dbEntity; } - + public SOTerm validateVariantType(Variant uiEntity, Variant dbEntity) { String field = "variantType"; if (ObjectUtils.isEmpty(uiEntity.getVariantType())) { @@ -130,8 +127,9 @@ public SOTerm validateVariantType(Variant uiEntity, Variant dbEntity) { private VocabularyTerm validateVariantStatus(Variant uiEntity, Variant dbEntity) { String field = "variantStatus"; - if (uiEntity.getVariantStatus() == null) + if (uiEntity.getVariantStatus() == null) { return null; + } VocabularyTerm variantStatus = vocabularyTermService.getTermInVocabulary(VocabularyConstants.VARIANT_STATUS_VOCABULARY, uiEntity.getVariantStatus().getName()).getEntity(); if (variantStatus == null) { @@ -145,12 +143,13 @@ private VocabularyTerm validateVariantStatus(Variant uiEntity, Variant dbEntity) } return variantStatus; } - + public SOTerm validateSourceGeneralConsequence(Variant uiEntity, Variant dbEntity) { String field = "sourceGeneralConsequence"; - if (ObjectUtils.isEmpty(uiEntity.getSourceGeneralConsequence())) + if (ObjectUtils.isEmpty(uiEntity.getSourceGeneralConsequence())) { return null; - + } + SOTerm sourceGeneralConsequence = null; if (StringUtils.isNotBlank(uiEntity.getSourceGeneralConsequence().getCurie())) { sourceGeneralConsequence = soTermService.findByCurie(uiEntity.getSourceGeneralConsequence().getCurie()); @@ -180,7 +179,7 @@ public List validateRelatedNotes(Variant uiEntity, Variant dbEntity) { response.addErrorMessages(field, ix, noteResponse.getErrorMessages()); } else { note = noteResponse.getEntity(); - + String noteIdentity = NoteIdentityHelper.noteIdentity(note); if (validatedNoteIdentities.contains(noteIdentity)) { allValid = false; @@ -199,8 +198,9 @@ public List validateRelatedNotes(Variant uiEntity, Variant dbEntity) { return null; } - if (CollectionUtils.isEmpty(validatedNotes)) + if (CollectionUtils.isEmpty(validatedNotes)) { return null; + } return validatedNotes; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermSetValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermSetValidator.java index 8498ec579..eee7f38c2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermSetValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermSetValidator.java @@ -23,10 +23,8 @@ @RequestScoped public class VocabularyTermSetValidator extends AuditedObjectValidator { - @Inject - VocabularyTermSetDAO vocabularyTermSetDAO; - @Inject - VocabularyDAO vocabularyDAO; + @Inject VocabularyTermSetDAO vocabularyTermSetDAO; + @Inject VocabularyDAO vocabularyDAO; private String errorMessage; @@ -68,7 +66,7 @@ private VocabularyTermSet validateVocabularyTermSet(VocabularyTermSet uiEntity, String label = validateVocabularyLabel(uiEntity, dbEntity); dbEntity.setVocabularyLabel(label); - + Vocabulary vocabularyTermSetVocabulary = validateVocabularyTermSetVocabulary(uiEntity, dbEntity); dbEntity.setVocabularyTermSetVocabulary(vocabularyTermSetVocabulary); @@ -105,8 +103,7 @@ public String validateVocabularyLabel(VocabularyTermSet uiEntity, VocabularyTerm addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - if (StringUtils.isNotBlank(dbEntity.getVocabularyLabel()) && - !StringUtils.equals(uiEntity.getVocabularyLabel(), dbEntity.getVocabularyLabel())) { + if (StringUtils.isNotBlank(dbEntity.getVocabularyLabel()) && !StringUtils.equals(uiEntity.getVocabularyLabel(), dbEntity.getVocabularyLabel())) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } @@ -142,15 +139,18 @@ private Vocabulary validateVocabularyTermSetVocabulary(VocabularyTermSet uiEntit private List validateMemberTerms(VocabularyTermSet uiEntity, VocabularyTermSet dbEntity) { String field = "memberTerms"; - if (dbEntity.getVocabularyTermSetVocabulary() == null) + if (dbEntity.getVocabularyTermSetVocabulary() == null) { return null; + } - if (CollectionUtils.isEmpty(uiEntity.getMemberTerms())) + if (CollectionUtils.isEmpty(uiEntity.getMemberTerms())) { return null; + } List previousIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getMemberTerms())) + if (CollectionUtils.isNotEmpty(dbEntity.getMemberTerms())) { dbEntity.getMemberTerms().stream().map(VocabularyTerm::getId).collect(Collectors.toList()); + } for (VocabularyTerm memberTerm : uiEntity.getMemberTerms()) { if (!memberTerm.getVocabulary().getId().equals(dbEntity.getVocabularyTermSetVocabulary().getId())) { @@ -166,15 +166,18 @@ private List validateMemberTerms(VocabularyTermSet uiEntity, Voc return uiEntity.getMemberTerms(); } - + private Boolean isUniqueValue(String uiEntityValue, String field, Long uiEntityId) { SearchResponse response = vocabularyTermSetDAO.findByField(field, uiEntityValue); - if (response == null || response.getSingleResult() == null) + if (response == null || response.getSingleResult() == null) { return true; - if (uiEntityId == null) + } + if (uiEntityId == null) { return false; - if (uiEntityId.equals(response.getSingleResult().getId())) + } + if (uiEntityId.equals(response.getSingleResult().getId())) { return true; + } return false; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermValidator.java index 6548644f6..672f2c579 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyTermValidator.java @@ -18,10 +18,8 @@ @RequestScoped public class VocabularyTermValidator extends AuditedObjectValidator { - @Inject - VocabularyTermService vocabularyTermService; - @Inject - VocabularyDAO vocabularyDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject VocabularyDAO vocabularyDAO; private String errorMessage; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyValidator.java index e6b12a934..46fdf3fc4 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/VocabularyValidator.java @@ -16,8 +16,7 @@ @RequestScoped public class VocabularyValidator extends AuditedObjectValidator { - @Inject - VocabularyDAO vocabularyDAO; + @Inject VocabularyDAO vocabularyDAO; private String errorMessage; @@ -56,7 +55,7 @@ public Vocabulary validateVocabulary(Vocabulary uiEntity, Vocabulary dbEntity) { String name = validateName(uiEntity); dbEntity.setName(name); - + String label = validateVocabularyLabel(uiEntity, dbEntity); dbEntity.setVocabularyLabel(label); @@ -96,8 +95,7 @@ public String validateVocabularyLabel(Vocabulary uiEntity, Vocabulary dbEntity) addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - if (StringUtils.isNotBlank(dbEntity.getVocabularyLabel()) && - !StringUtils.equals(uiEntity.getVocabularyLabel(), dbEntity.getVocabularyLabel())) { + if (StringUtils.isNotBlank(dbEntity.getVocabularyLabel()) && !StringUtils.equals(uiEntity.getVocabularyLabel(), dbEntity.getVocabularyLabel())) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } @@ -108,15 +106,18 @@ public String validateVocabularyLabel(Vocabulary uiEntity, Vocabulary dbEntity) return uiEntity.getVocabularyLabel(); } - + private Boolean isUniqueValue(String uiEntityValue, String field, Long uiEntityId) { SearchResponse response = vocabularyDAO.findByField(field, uiEntityValue); - if (response == null || response.getSingleResult() == null) + if (response == null || response.getSingleResult() == null) { return true; - if (uiEntityId == null) + } + if (uiEntityId == null) { return false; - if (uiEntityId.equals(response.getSingleResult().getId())) + } + if (uiEntityId.equals(response.getSingleResult().getId())) { return true; + } return false; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java index 153dabc72..d11e18932 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java @@ -13,15 +13,15 @@ import jakarta.inject.Inject; public class EvidenceAssociationValidator extends AuditedObjectValidator { - - @Inject - InformationContentEntityService informationContentEntityService; - + + @Inject InformationContentEntityService informationContentEntityService; + public List validateEvidence(E uiEntity, E dbEntity) { String field = "evidence"; - if (CollectionUtils.isEmpty(uiEntity.getEvidence())) + if (CollectionUtils.isEmpty(uiEntity.getEvidence())) { return null; - + } + List validatedEntities = new ArrayList<>(); for (InformationContentEntity evidenceEntity : uiEntity.getEvidence()) { evidenceEntity = informationContentEntityService.retrieveFromDbOrLiteratureService(evidenceEntity.getCurie()); @@ -41,8 +41,9 @@ public List validateEvidence(E uiEntity, E dbEntity) { public E validateEvidenceAssociationFields(E uiEntity, E dbEntity) { Boolean newEntity = false; - if (dbEntity.getId() == null) + if (dbEntity.getId() == null) { newEntity = true; + } dbEntity = validateAuditedObjectFields(uiEntity, dbEntity, newEntity); List evidence = validateEvidence(uiEntity, dbEntity); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java index d083e9bd9..fa73871b2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java @@ -19,15 +19,12 @@ @RequestScoped public class AlleleGeneAssociationValidator extends AlleleGenomicEntityAssociationValidator { - @Inject - GeneDAO geneDAO; - @Inject - AlleleGeneAssociationDAO alleleGeneAssociationDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject GeneDAO geneDAO; + @Inject AlleleGeneAssociationDAO alleleGeneAssociationDAO; + @Inject VocabularyTermService vocabularyTermService; private String errorMessage; - + public ObjectResponse validateAlleleGeneAssociation(AlleleGeneAssociation uiEntity) { AlleleGeneAssociation geneAssociation = validateAlleleGeneAssociation(uiEntity, false, false); response.setEntity(geneAssociation); @@ -49,14 +46,14 @@ public AlleleGeneAssociation validateAlleleGeneAssociation(AlleleGeneAssociation } else { dbEntity = new AlleleGeneAssociation(); } - + dbEntity = (AlleleGeneAssociation) validateAlleleGenomicEntityAssociationFields(uiEntity, dbEntity); if (validateAllele) { Allele subject = validateSubject(uiEntity, dbEntity); dbEntity.setAlleleAssociationSubject(subject); } - + Gene object = validateObject(uiEntity, dbEntity); dbEntity.setAlleleGeneAssociationObject(object); @@ -74,7 +71,7 @@ public AlleleGeneAssociation validateAlleleGeneAssociation(AlleleGeneAssociation return dbEntity; } - + private Allele validateSubject(AlleleGeneAssociation uiEntity, AlleleGeneAssociation dbEntity) { String field = "alleleAssociationSubject"; if (ObjectUtils.isEmpty(uiEntity.getAlleleAssociationSubject())) { @@ -83,8 +80,9 @@ private Allele validateSubject(AlleleGeneAssociation uiEntity, AlleleGeneAssocia } Allele subjectEntity = null; - if (uiEntity.getAlleleAssociationSubject().getId() != null) + if (uiEntity.getAlleleAssociationSubject().getId() != null) { subjectEntity = alleleDAO.find(uiEntity.getAlleleAssociationSubject().getId()); + } if (subjectEntity == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -107,17 +105,17 @@ private Gene validateObject(AlleleGeneAssociation uiEntity, AlleleGeneAssociatio } Gene objectEntity = null; - if (uiEntity.getAlleleGeneAssociationObject().getId() != null) + if (uiEntity.getAlleleGeneAssociationObject().getId() != null) { objectEntity = geneDAO.find(uiEntity.getAlleleGeneAssociationObject().getId()); + } if (objectEntity == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; - } - else { + } else { // fix for SCRUM-3738 - if (objectEntity.getGeneSymbol() != null){ - if(objectEntity.getGeneSymbol().getEvidence() != null) { - objectEntity.getGeneSymbol().getEvidence().size(); + if (objectEntity.getGeneSymbol() != null) { + if (objectEntity.getGeneSymbol().getEvidence() != null) { + objectEntity.getGeneSymbol().getEvidence().size(); } } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java index 087888fd3..3cb44df82 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java @@ -18,23 +18,21 @@ public class AlleleGenomicEntityAssociationValidator extends EvidenceAssociationValidator { - @Inject - NoteValidator noteValidator; - @Inject - NoteDAO noteDAO; - @Inject - EcoTermDAO ecoTermDAO; - @Inject - AlleleDAO alleleDAO; - + @Inject NoteValidator noteValidator; + @Inject NoteDAO noteDAO; + @Inject EcoTermDAO ecoTermDAO; + @Inject AlleleDAO alleleDAO; + public ECOTerm validateEvidenceCode(E uiEntity, E dbEntity) { String field = "evidenceCode"; - if (ObjectUtils.isEmpty(uiEntity.getEvidenceCode())) + if (ObjectUtils.isEmpty(uiEntity.getEvidenceCode())) { return null; - + } + ECOTerm evidenceCode = null; - if (uiEntity.getEvidenceCode().getId() != null) + if (uiEntity.getEvidenceCode().getId() != null) { evidenceCode = ecoTermDAO.find(uiEntity.getEvidenceCode().getId()); + } if (evidenceCode == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -47,16 +45,17 @@ public ECOTerm validateEvidenceCode(E uiEntity, E dbEntity) { addMessageResponse(field, ValidationConstants.UNSUPPORTED_MESSAGE); return null; } - + return evidenceCode; } - + public Note validateRelatedNote(E uiEntity, E dbEntity) { String field = "relatedNote"; - if (uiEntity.getRelatedNote() == null) + if (uiEntity.getRelatedNote() == null) { return null; - + } + ObjectResponse noteResponse = noteValidator.validateNote(uiEntity.getRelatedNote(), VocabularyConstants.ALLELE_GENOMIC_ENTITY_ASSOCIATION_NOTE_TYPES_VOCABULARY_TERM_SET); if (noteResponse.getEntity() == null) { addMessageResponse(field, noteResponse.errorMessagesString()); @@ -66,7 +65,7 @@ public Note validateRelatedNote(E uiEntity, E dbEntity) { } public E validateAlleleGenomicEntityAssociationFields(E uiEntity, E dbEntity) { - + dbEntity = validateEvidenceAssociationFields(uiEntity, dbEntity); ECOTerm evidenceCode = validateEvidenceCode(uiEntity, dbEntity); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java index ceb4a2172..0ad32dd88 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java @@ -32,16 +32,11 @@ @RequestScoped public class ConstructGenomicEntityAssociationValidator extends EvidenceAssociationValidator { - @Inject - ConstructDAO constructDAO; - @Inject - GenomicEntityDAO genomicEntityDAO; - @Inject - ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - NoteValidator noteValidator; + @Inject ConstructDAO constructDAO; + @Inject GenomicEntityDAO genomicEntityDAO; + @Inject ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject NoteValidator noteValidator; private String errorMessage; @@ -50,7 +45,7 @@ public ObjectResponse validateConstructGenomi response.setEntity(geAssociation); return response; } - + public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociation(ConstructGenomicEntityAssociation uiEntity, Boolean throwError, Boolean validateConstruct) { response = new ObjectResponse<>(uiEntity); errorMessage = "Could not create/update Construct GenomicEntity Association: [" + uiEntity.getId() + "]"; @@ -66,26 +61,28 @@ public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociati } else { dbEntity = new ConstructGenomicEntityAssociation(); } - + dbEntity = (ConstructGenomicEntityAssociation) validateEvidenceAssociationFields(uiEntity, dbEntity); if (validateConstruct) { Construct subject = validateSubjectReagent(uiEntity, dbEntity); dbEntity.setConstructAssociationSubject(subject); } - + GenomicEntity object = validateObject(uiEntity, dbEntity); dbEntity.setConstructGenomicEntityAssociationObject(object); VocabularyTerm relation = validateRelation(uiEntity, dbEntity); dbEntity.setRelation(relation); - + List relatedNotes = validateRelatedNotes(uiEntity, dbEntity); - if (dbEntity.getRelatedNotes() != null) + if (dbEntity.getRelatedNotes() != null) { dbEntity.getRelatedNotes().clear(); + } if (relatedNotes != null) { - if (dbEntity.getRelatedNotes() == null) + if (dbEntity.getRelatedNotes() == null) { dbEntity.setRelatedNotes(new ArrayList<>()); + } dbEntity.getRelatedNotes().addAll(relatedNotes); } @@ -100,7 +97,7 @@ public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociati return dbEntity; } - + private Construct validateSubjectReagent(ConstructGenomicEntityAssociation uiEntity, ConstructGenomicEntityAssociation dbEntity) { String field = "constructAssociationSubject"; if (ObjectUtils.isEmpty(uiEntity.getConstructAssociationSubject())) { @@ -109,8 +106,9 @@ private Construct validateSubjectReagent(ConstructGenomicEntityAssociation uiEnt } Construct subjectEntity = null; - if (uiEntity.getConstructAssociationSubject().getId() != null) + if (uiEntity.getConstructAssociationSubject().getId() != null) { subjectEntity = constructDAO.find(uiEntity.getConstructAssociationSubject().getId()); + } if (subjectEntity == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -133,8 +131,9 @@ private GenomicEntity validateObject(ConstructGenomicEntityAssociation uiEntity, } GenomicEntity objectEntity = null; - if (uiEntity.getConstructGenomicEntityAssociationObject().getId() != null) + if (uiEntity.getConstructGenomicEntityAssociationObject().getId() != null) { objectEntity = genomicEntityDAO.find(uiEntity.getConstructGenomicEntityAssociationObject().getId()); + } if (objectEntity == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; @@ -170,7 +169,7 @@ private VocabularyTerm validateRelation(ConstructGenomicEntityAssociation uiEnti return relation; } - + public List validateRelatedNotes(ConstructGenomicEntityAssociation uiEntity, ConstructGenomicEntityAssociation dbEntity) { String field = "relatedNotes"; @@ -186,7 +185,7 @@ public List validateRelatedNotes(ConstructGenomicEntityAssociation uiEntit response.addErrorMessages(field, ix, noteResponse.getErrorMessages()); } else { note = noteResponse.getEntity(); - + String noteIdentity = NoteIdentityHelper.noteIdentity(note); if (validatedNoteIdentities.contains(noteIdentity)) { allValid = false; @@ -205,8 +204,9 @@ public List validateRelatedNotes(ConstructGenomicEntityAssociation uiEntit return null; } - if (CollectionUtils.isEmpty(validatedNotes)) + if (CollectionUtils.isEmpty(validatedNotes)) { return null; + } return validatedNotes; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/base/AuditedObjectValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/base/AuditedObjectValidator.java index 18b28abb0..a20a97f83 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/base/AuditedObjectValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/base/AuditedObjectValidator.java @@ -17,19 +17,18 @@ public class AuditedObjectValidator { @Inject - @AuthenticatedUser - protected Person authenticatedPerson; + @AuthenticatedUser protected Person authenticatedPerson; - @Inject - PersonService personService; + @Inject PersonService personService; public ObjectResponse response; public E validateAuditedObjectFields(E uiEntity, E dbEntity, Boolean newEntity) { Boolean defaultInternal = false; - if (uiEntity instanceof Note) + if (uiEntity instanceof Note) { defaultInternal = true; - + } + Boolean internal = uiEntity.getInternal() == null ? defaultInternal : uiEntity.getInternal(); dbEntity.setInternal(internal); @@ -83,7 +82,7 @@ public void addMessageResponse(String message) { public void addMessageResponse(String fieldName, String message) { response.addErrorMessage(fieldName, message); } - + public void convertMapToErrorMessages(String fieldName) { response.convertMapToErrorMessages(fieldName); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/base/SubmittedObjectValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/base/SubmittedObjectValidator.java index 494740ad2..821e4e67c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/base/SubmittedObjectValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/base/SubmittedObjectValidator.java @@ -14,23 +14,23 @@ public class SubmittedObjectValidator extends Audited @Inject DataProviderService dataProviderService; @Inject DataProviderValidator dataProviderValidator; - + public E validateSubmittedObjectFields(E uiEntity, E dbEntity) { String curie = handleStringField(uiEntity.getCurie()); dbEntity.setCurie(curie); - + String modEntityId = handleStringField(uiEntity.getModEntityId()); dbEntity.setModEntityId(modEntityId); - + String modInternalId = validateModInternalId(uiEntity); dbEntity.setModInternalId(modInternalId); - + DataProvider dataProvider = validateDataProvider(uiEntity, dbEntity); dbEntity.setDataProvider(dataProvider); - + return dbEntity; } - + public String validateCurie(E uiEntity) { String curie = handleStringField(uiEntity.getCurie()); if (curie != null && !curie.startsWith("AGRKB:")) { @@ -39,12 +39,13 @@ public String validateCurie(E uiEntity) { } return curie; } - + public String validateModInternalId(E uiEntity) { String modInternalId = uiEntity.getModInternalId(); if (StringUtils.isBlank(modInternalId)) { - if (StringUtils.isBlank(uiEntity.getModEntityId())) + if (StringUtils.isBlank(uiEntity.getModEntityId())) { addMessageResponse("modInternalId", ValidationConstants.REQUIRED_UNLESS_OTHER_FIELD_POPULATED_MESSAGE + "modEntityId"); + } return null; } return modInternalId; @@ -53,29 +54,30 @@ public String validateModInternalId(E uiEntity) { public DataProvider validateDataProvider(E uiEntity, E dbEntity) { String field = "dataProvider"; if (uiEntity.getDataProvider() == null) { - if (dbEntity.getDataProvider() == null) + if (dbEntity.getDataProvider() == null) { uiEntity.setDataProvider(dataProviderService.createAffiliatedModDataProvider()); + } if (uiEntity.getDataProvider() == null) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } } - + DataProvider uiDataProvider = uiEntity.getDataProvider(); DataProvider dbDataProvider = dbEntity.getDataProvider(); - + ObjectResponse dpResponse = dataProviderValidator.validateDataProvider(uiDataProvider, dbDataProvider, false); if (dpResponse.hasErrors()) { addMessageResponse(field, dpResponse.errorMessagesString()); return null; } - + DataProvider validatedDataProvider = dpResponse.getEntity(); if (validatedDataProvider.getObsolete() && (dbDataProvider == null || !validatedDataProvider.getId().equals(dbDataProvider.getId()))) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } - + return validatedDataProvider; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java index ed1320ad2..875022490 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java @@ -33,16 +33,11 @@ @RequestScoped public class AGMDiseaseAnnotationDTOValidator extends DiseaseAnnotationDTOValidator { - @Inject - AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - AffectedGenomicModelService agmService; - @Inject - GeneService geneService; - @Inject - AlleleService alleleService; + @Inject AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject AffectedGenomicModelService agmService; + @Inject GeneService geneService; + @Inject AlleleService alleleService; public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException, ObjectValidationException { @@ -66,7 +61,7 @@ public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotation String annotationId; String identifyingField; String uniqueId = AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(dto, dto.getAgmIdentifier(), refCurie); - + if (StringUtils.isNotBlank(dto.getModEntityId())) { annotationId = dto.getModEntityId(); annotation.setModEntityId(annotationId); @@ -84,9 +79,10 @@ public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotation annotation = AnnotationRetrievalHelper.getCurrentAnnotation(annotation, annotationList); annotation.setUniqueId(uniqueId); annotation.setDiseaseAnnotationSubject(agm); - - if (dataProvider != null && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) && !agm.getTaxon().getCurie().equals(dataProvider.canonicalTaxonCurie) || - !dataProvider.sourceOrganization.equals(agm.getDataProvider().getSourceOrganization().getAbbreviation())) { + + if (dataProvider != null + && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) + && (!agm.getTaxon().getCurie().equals(dataProvider.canonicalTaxonCurie) || !dataProvider.sourceOrganization.equals(agm.getDataProvider().getSourceOrganization().getAbbreviation()))) { adaResponse.addErrorMessage("agm_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAgmIdentifier() + ") for " + dataProvider.name() + " load"); } } @@ -99,8 +95,9 @@ public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotation if (StringUtils.isNotEmpty(dto.getDiseaseRelationName())) { VocabularyTerm diseaseRelation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.AGM_DISEASE_RELATION_VOCABULARY_TERM_SET, dto.getDiseaseRelationName()).getEntity(); - if (diseaseRelation == null) + if (diseaseRelation == null) { adaResponse.addErrorMessage("disease_relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getDiseaseRelationName() + ")"); + } annotation.setRelation(diseaseRelation); } else { adaResponse.addErrorMessage("disease_relation_name", ValidationConstants.REQUIRED_MESSAGE); @@ -108,8 +105,9 @@ public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotation if (StringUtils.isNotBlank(dto.getInferredGeneIdentifier())) { Gene inferredGene = geneService.findByIdentifierString(dto.getInferredGeneIdentifier()); - if (inferredGene == null) + if (inferredGene == null) { adaResponse.addErrorMessage("inferred_gene_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getInferredGeneIdentifier() + ")"); + } annotation.setInferredGene(inferredGene); } else { annotation.setInferredGene(null); @@ -132,8 +130,9 @@ public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotation if (StringUtils.isNotBlank(dto.getInferredAlleleIdentifier())) { Allele inferredAllele = alleleService.findByIdentifierString(dto.getInferredAlleleIdentifier()); - if (inferredAllele == null) + if (inferredAllele == null) { adaResponse.addErrorMessage("inferred_allele_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getInferredAlleleIdentifier() + ")"); + } annotation.setInferredAllele(inferredAllele); } else { annotation.setInferredAllele(null); @@ -141,16 +140,18 @@ public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotation if (StringUtils.isNotBlank(dto.getAssertedAlleleIdentifier())) { Allele assertedAllele = alleleService.findByIdentifierString(dto.getAssertedAlleleIdentifier()); - if (assertedAllele == null) + if (assertedAllele == null) { adaResponse.addErrorMessage("asserted_allele_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAssertedAlleleIdentifier() + ")"); + } annotation.setAssertedAllele(assertedAllele); } else { annotation.setAssertedAllele(null); } - if (adaResponse.hasErrors()) + if (adaResponse.hasErrors()) { throw new ObjectValidationException(dto, adaResponse.errorMessagesString()); - + } + return annotation; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java index 801f99be1..7be172abf 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java @@ -20,47 +20,48 @@ @RequestScoped public class AffectedGenomicModelDTOValidator extends BaseDTOValidator { - @Inject - AffectedGenomicModelDAO affectedGenomicModelDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AffectedGenomicModelDAO affectedGenomicModelDAO; + @Inject VocabularyTermService vocabularyTermService; private ObjectResponse agmResponse = new ObjectResponse(); public AffectedGenomicModel validateAffectedGenomicModelDTO(AffectedGenomicModelDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { - + AffectedGenomicModel agm = null; if (StringUtils.isNotBlank(dto.getModEntityId())) { SearchResponse response = affectedGenomicModelDAO.findByField("modEntityId", dto.getModEntityId()); - if (response != null && response.getSingleResult() != null) + if (response != null && response.getSingleResult() != null) { agm = response.getSingleResult(); + } } else { agmResponse.addErrorMessage("modEntityId", ValidationConstants.REQUIRED_MESSAGE); } - if (agm == null) + if (agm == null) { agm = new AffectedGenomicModel(); + } agm.setModEntityId(dto.getModEntityId()); agm.setModInternalId(handleStringField(dto.getModInternalId())); agm.setName(handleStringField(dto.getName())); - + ObjectResponse geResponse = validateGenomicEntityDTO(agm, dto, dataProvider); agmResponse.addErrorMessages(geResponse.getErrorMessages()); agm = geResponse.getEntity(); - + VocabularyTerm subtype = null; if (StringUtils.isBlank(dto.getSubtypeName())) { agmResponse.addErrorMessage("subtype_name", ValidationConstants.REQUIRED_MESSAGE); - + } else { subtype = vocabularyTermService.getTermInVocabulary(VocabularyConstants.AGM_SUBTYPE_VOCABULARY, dto.getSubtypeName()).getEntity(); - if (subtype == null) + if (subtype == null) { agmResponse.addErrorMessage("subtype_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getSubtypeName() + ")"); + } } agm.setSubtype(subtype); - + agmResponse.convertErrorMessagesToMap(); if (agmResponse.hasErrors()) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java index d1ad81623..b4c5a1d55 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java @@ -59,57 +59,43 @@ @RequestScoped public class AlleleDTOValidator extends BaseDTOValidator { - @Inject - AlleleDAO alleleDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - ReferenceDAO referenceDAO; - @Inject - ReferenceService referenceService; - @Inject - AlleleMutationTypeSlotAnnotationDTOValidator alleleMutationTypeDtoValidator; - @Inject - AlleleInheritanceModeSlotAnnotationDTOValidator alleleInheritanceModeDtoValidator; - @Inject - AlleleGermlineTransmissionStatusSlotAnnotationDTOValidator alleleGermlineTransmissionStatusDtoValidator; - @Inject - AlleleNomenclatureEventSlotAnnotationDTOValidator alleleNomenclatureEventDtoValidator; - @Inject - AlleleSymbolSlotAnnotationDTOValidator alleleSymbolDtoValidator; - @Inject - AlleleFullNameSlotAnnotationDTOValidator alleleFullNameDtoValidator; - @Inject - AlleleSynonymSlotAnnotationDTOValidator alleleSynonymDtoValidator; - @Inject - AlleleSecondaryIdSlotAnnotationDTOValidator alleleSecondaryIdDtoValidator; - @Inject - AlleleDatabaseStatusSlotAnnotationDTOValidator alleleDatabaseStatusDtoValidator; - @Inject - SlotAnnotationIdentityHelper identityHelper; - @Inject - AlleleFunctionalImpactSlotAnnotationDTOValidator alleleFunctionalImpactDtoValidator; - @Inject - NoteDTOValidator noteDtoValidator; + @Inject AlleleDAO alleleDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject ReferenceDAO referenceDAO; + @Inject ReferenceService referenceService; + @Inject AlleleMutationTypeSlotAnnotationDTOValidator alleleMutationTypeDtoValidator; + @Inject AlleleInheritanceModeSlotAnnotationDTOValidator alleleInheritanceModeDtoValidator; + @Inject AlleleGermlineTransmissionStatusSlotAnnotationDTOValidator alleleGermlineTransmissionStatusDtoValidator; + @Inject AlleleNomenclatureEventSlotAnnotationDTOValidator alleleNomenclatureEventDtoValidator; + @Inject AlleleSymbolSlotAnnotationDTOValidator alleleSymbolDtoValidator; + @Inject AlleleFullNameSlotAnnotationDTOValidator alleleFullNameDtoValidator; + @Inject AlleleSynonymSlotAnnotationDTOValidator alleleSynonymDtoValidator; + @Inject AlleleSecondaryIdSlotAnnotationDTOValidator alleleSecondaryIdDtoValidator; + @Inject AlleleDatabaseStatusSlotAnnotationDTOValidator alleleDatabaseStatusDtoValidator; + @Inject SlotAnnotationIdentityHelper identityHelper; + @Inject AlleleFunctionalImpactSlotAnnotationDTOValidator alleleFunctionalImpactDtoValidator; + @Inject NoteDTOValidator noteDtoValidator; private ObjectResponse alleleResponse; - + @Transactional public Allele validateAlleleDTO(AlleleDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { - + alleleResponse = new ObjectResponse<>(); - + Allele allele = null; if (StringUtils.isNotBlank(dto.getModEntityId())) { SearchResponse response = alleleDAO.findByField("modEntityId", dto.getModEntityId()); - if (response != null && response.getSingleResult() != null) + if (response != null && response.getSingleResult() != null) { allele = response.getSingleResult(); + } } else { alleleResponse.addErrorMessage("modEntityId", ValidationConstants.REQUIRED_MESSAGE); } - if (allele == null) + if (allele == null) { allele = new Allele(); + } allele.setModEntityId(dto.getModEntityId()); allele.setModInternalId(handleStringField(dto.getModInternalId())); @@ -144,91 +130,105 @@ public Allele validateAlleleDTO(AlleleDTO dto, BackendBulkDataProvider dataProvi } else { allele.setReferences(null); } - + List relatedNotes = validateRelatedNotes(allele, dto); if (relatedNotes != null) { - if (allele.getRelatedNotes() == null) + if (allele.getRelatedNotes() == null) { allele.setRelatedNotes(new ArrayList<>()); + } allele.getRelatedNotes().addAll(relatedNotes); } List mutationTypes = validateAlleleMutationTypes(allele, dto); - if (allele.getAlleleMutationTypes() != null) + if (allele.getAlleleMutationTypes() != null) { allele.getAlleleMutationTypes().clear(); + } if (mutationTypes != null) { - if (allele.getAlleleMutationTypes() == null) + if (allele.getAlleleMutationTypes() == null) { allele.setAlleleMutationTypes(new ArrayList<>()); + } allele.getAlleleMutationTypes().addAll(mutationTypes); } - + List inheritanceModes = validateAlleleInheritanceModes(allele, dto); - if (allele.getAlleleInheritanceModes() != null) + if (allele.getAlleleInheritanceModes() != null) { allele.getAlleleInheritanceModes().clear(); + } if (inheritanceModes != null) { - if (allele.getAlleleInheritanceModes() == null) + if (allele.getAlleleInheritanceModes() == null) { allele.setAlleleInheritanceModes(new ArrayList<>()); + } allele.getAlleleInheritanceModes().addAll(inheritanceModes); } - + AlleleGermlineTransmissionStatusSlotAnnotation germlineTransmissionStatus = validateAlleleGermlineTransmissionStatus(allele, dto); allele.setAlleleGermlineTransmissionStatus(germlineTransmissionStatus); - + AlleleDatabaseStatusSlotAnnotation databaseStatus = validateAlleleDatabaseStatus(allele, dto); allele.setAlleleDatabaseStatus(databaseStatus); - + List nomenclatureEvents = validateAlleleNomenclatureEvents(allele, dto); - if (allele.getAlleleNomenclatureEvents() != null) + if (allele.getAlleleNomenclatureEvents() != null) { allele.getAlleleNomenclatureEvents().clear(); + } if (nomenclatureEvents != null) { - if (allele.getAlleleNomenclatureEvents() == null) + if (allele.getAlleleNomenclatureEvents() == null) { allele.setAlleleNomenclatureEvents(new ArrayList<>()); + } allele.getAlleleNomenclatureEvents().addAll(nomenclatureEvents); } - + AlleleSymbolSlotAnnotation symbol = validateAlleleSymbol(allele, dto); allele.setAlleleSymbol(symbol); - + AlleleFullNameSlotAnnotation fullName = validateAlleleFullName(allele, dto); allele.setAlleleFullName(fullName); - + List synonyms = validateAlleleSynonyms(allele, dto); - if (allele.getAlleleSynonyms() != null) + if (allele.getAlleleSynonyms() != null) { allele.getAlleleSynonyms().clear(); + } if (synonyms != null) { - if (allele.getAlleleSynonyms() == null) + if (allele.getAlleleSynonyms() == null) { allele.setAlleleSynonyms(new ArrayList<>()); + } allele.getAlleleSynonyms().addAll(synonyms); } - + List secondaryIds = validateAlleleSecondaryIds(allele, dto); - if (allele.getAlleleSecondaryIds() != null) + if (allele.getAlleleSecondaryIds() != null) { allele.getAlleleSecondaryIds().clear(); + } if (secondaryIds != null) { - if (allele.getAlleleSecondaryIds() == null) + if (allele.getAlleleSecondaryIds() == null) { allele.setAlleleSecondaryIds(new ArrayList<>()); + } allele.getAlleleSecondaryIds().addAll(secondaryIds); } - + List functionalImpacts = validateAlleleFunctionalImpacts(allele, dto); - if (allele.getAlleleFunctionalImpacts() != null) + if (allele.getAlleleFunctionalImpacts() != null) { allele.getAlleleFunctionalImpacts().clear(); + } if (functionalImpacts != null) { - if (allele.getAlleleFunctionalImpacts() == null) + if (allele.getAlleleFunctionalImpacts() == null) { allele.setAlleleFunctionalImpacts(new ArrayList<>()); + } allele.getAlleleFunctionalImpacts().addAll(functionalImpacts); } alleleResponse.convertErrorMessagesToMap(); - - if (alleleResponse.hasErrors()) + + if (alleleResponse.hasErrors()) { throw new ObjectValidationException(dto, alleleResponse.errorMessagesString()); - + } + return alleleDAO.persist(allele); } - + private List validateAlleleMutationTypes(Allele allele, AlleleDTO dto) { String field = "allele_mutation_type_dtos"; - + Map existingMutationTypes = new HashMap<>(); if (CollectionUtils.isNotEmpty(allele.getAlleleMutationTypes())) { for (AlleleMutationTypeSlotAnnotation existingMutationType : allele.getAlleleMutationTypes()) { @@ -253,21 +253,22 @@ private List validateAlleleMutationTypes(Allel } } } - + if (!allValid) { alleleResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedMutationTypes)) + + if (CollectionUtils.isEmpty(validatedMutationTypes)) { return null; + } return validatedMutationTypes; } - + private List validateAlleleInheritanceModes(Allele allele, AlleleDTO dto) { String field = "allele_inheritance_mode_dtos"; - + Map existingInheritanceModes = new HashMap<>(); if (CollectionUtils.isNotEmpty(allele.getAlleleInheritanceModes())) { for (AlleleInheritanceModeSlotAnnotation existingInheritanceMode : allele.getAlleleInheritanceModes()) { @@ -292,59 +293,62 @@ private List validateAlleleInheritanceModes } } } - + if (!allValid) { alleleResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedInheritanceModes)) + + if (CollectionUtils.isEmpty(validatedInheritanceModes)) { return null; + } return validatedInheritanceModes; } - + private AlleleGermlineTransmissionStatusSlotAnnotation validateAlleleGermlineTransmissionStatus(Allele allele, AlleleDTO dto) { - if (dto.getAlleleGermlineTransmissionStatusDto() == null) + if (dto.getAlleleGermlineTransmissionStatusDto() == null) { return null; - + } + String field = "allele_germline_transmission_status_dto"; - + ObjectResponse agtsResponse = alleleGermlineTransmissionStatusDtoValidator.validateAlleleGermlineTransmissionStatusSlotAnnotationDTO(allele.getAlleleGermlineTransmissionStatus(), dto.getAlleleGermlineTransmissionStatusDto()); if (agtsResponse.hasErrors()) { alleleResponse.addErrorMessage(field, agtsResponse.errorMessagesString()); alleleResponse.addErrorMessages(field, agtsResponse.getErrorMessages()); return null; } - + AlleleGermlineTransmissionStatusSlotAnnotation agts = agtsResponse.getEntity(); agts.setSingleAllele(allele); - + return agts; } - + private AlleleDatabaseStatusSlotAnnotation validateAlleleDatabaseStatus(Allele allele, AlleleDTO dto) { - if (dto.getAlleleDatabaseStatusDto() == null) + if (dto.getAlleleDatabaseStatusDto() == null) { return null; - + } + String field = "allele_database_status_dto"; - + ObjectResponse adsResponse = alleleDatabaseStatusDtoValidator.validateAlleleDatabaseStatusSlotAnnotationDTO(allele.getAlleleDatabaseStatus(), dto.getAlleleDatabaseStatusDto()); if (adsResponse.hasErrors()) { alleleResponse.addErrorMessage(field, adsResponse.errorMessagesString()); alleleResponse.addErrorMessages(field, adsResponse.getErrorMessages()); return null; } - + AlleleDatabaseStatusSlotAnnotation ads = adsResponse.getEntity(); ads.setSingleAllele(allele); - + return ads; } private List validateAlleleNomenclatureEvents(Allele allele, AlleleDTO dto) { String field = "allele_nomenclature_event_dtos"; - + Map existingNomenclatureEvents = new HashMap<>(); if (CollectionUtils.isNotEmpty(allele.getAlleleNomenclatureEvents())) { for (AlleleNomenclatureEventSlotAnnotation existingNomenclatureEvent : allele.getAlleleNomenclatureEvents()) { @@ -369,14 +373,15 @@ private List validateAlleleNomenclatureEv } } } - + if (!allValid) { alleleResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedNomenclatureEvents)) + + if (CollectionUtils.isEmpty(validatedNomenclatureEvents)) { return null; + } return validatedNomenclatureEvents; } @@ -398,13 +403,14 @@ private AlleleSymbolSlotAnnotation validateAlleleSymbol(Allele allele, AlleleDTO AlleleSymbolSlotAnnotation symbol = symbolResponse.getEntity(); symbol.setSingleAllele(allele); - + return symbol; } private AlleleFullNameSlotAnnotation validateAlleleFullName(Allele allele, AlleleDTO dto) { - if (dto.getAlleleFullNameDto() == null) + if (dto.getAlleleFullNameDto() == null) { return null; + } String field = "allele_full_name_dto"; @@ -417,13 +423,13 @@ private AlleleFullNameSlotAnnotation validateAlleleFullName(Allele allele, Allel AlleleFullNameSlotAnnotation fullName = nameResponse.getEntity(); fullName.setSingleAllele(allele); - + return fullName; } private List validateAlleleSynonyms(Allele allele, AlleleDTO dto) { String field = "allele_synonym_dtos"; - + Map existingSynonyms = new HashMap<>(); if (CollectionUtils.isNotEmpty(allele.getAlleleSynonyms())) { for (AlleleSynonymSlotAnnotation existingSynonym : allele.getAlleleSynonyms()) { @@ -448,21 +454,22 @@ private List validateAlleleSynonyms(Allele allele, } } } - + if (!allValid) { alleleResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedSynonyms)) + + if (CollectionUtils.isEmpty(validatedSynonyms)) { return null; + } return validatedSynonyms; } private List validateAlleleSecondaryIds(Allele allele, AlleleDTO dto) { String field = "allele_secondary_id_dtos"; - + Map existingSecondaryIds = new HashMap<>(); if (CollectionUtils.isNotEmpty(allele.getAlleleSecondaryIds())) { for (AlleleSecondaryIdSlotAnnotation existingSecondaryId : allele.getAlleleSecondaryIds()) { @@ -487,21 +494,22 @@ private List validateAlleleSecondaryIds(Allele } } } - + if (!allValid) { alleleResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedSecondaryIds)) + + if (CollectionUtils.isEmpty(validatedSecondaryIds)) { return null; + } return validatedSecondaryIds; } private List validateAlleleFunctionalImpacts(Allele allele, AlleleDTO dto) { String field = "allele_functional_impact_dtos"; - + Map existingFunctionalImpacts = new HashMap<>(); if (CollectionUtils.isNotEmpty(allele.getAlleleFunctionalImpacts())) { for (AlleleFunctionalImpactSlotAnnotation existingFunctionalImpact : allele.getAlleleFunctionalImpacts()) { @@ -526,24 +534,26 @@ private List validateAlleleFunctionalImpac } } } - + if (!allValid) { alleleResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedFunctionalImpacts)) + + if (CollectionUtils.isEmpty(validatedFunctionalImpacts)) { return null; + } return validatedFunctionalImpacts; } - + private List validateRelatedNotes(Allele allele, AlleleDTO dto) { String field = "relatedNotes"; - - if (allele.getRelatedNotes() != null) + + if (allele.getRelatedNotes() != null) { allele.getRelatedNotes().clear(); - + } + List validatedNotes = new ArrayList(); List noteIdentities = new ArrayList(); Boolean allValid = true; @@ -562,15 +572,16 @@ private List validateRelatedNotes(Allele allele, AlleleDTO dto) { } } } - + if (!allValid) { alleleResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedNotes)) + + if (CollectionUtils.isEmpty(validatedNotes)) { return null; - + } + return validatedNotes; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java index 50ee73fec..69c1ad33f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java @@ -30,14 +30,10 @@ @RequestScoped public class AlleleDiseaseAnnotationDTOValidator extends DiseaseAnnotationDTOValidator { - @Inject - AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; - @Inject - AlleleService alleleService; - @Inject - GeneService geneService; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AlleleDiseaseAnnotationDAO alleleDiseaseAnnotationDAO; + @Inject AlleleService alleleService; + @Inject GeneService geneService; + @Inject VocabularyTermService vocabularyTermService; public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { AlleleDiseaseAnnotation annotation = new AlleleDiseaseAnnotation(); @@ -60,7 +56,7 @@ public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseA String annotationId; String identifyingField; String uniqueId = AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(dto, dto.getAlleleIdentifier(), refCurie); - + if (StringUtils.isNotBlank(dto.getModEntityId())) { annotationId = dto.getModEntityId(); annotation.setModEntityId(annotationId); @@ -78,9 +74,10 @@ public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseA annotation = AnnotationRetrievalHelper.getCurrentAnnotation(annotation, annotationList); annotation.setUniqueId(uniqueId); annotation.setDiseaseAnnotationSubject(allele); - - if (dataProvider != null && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) && !allele.getTaxon().getCurie().equals(dataProvider.canonicalTaxonCurie) || - !dataProvider.sourceOrganization.equals(allele.getDataProvider().getSourceOrganization().getAbbreviation())) { + + if (dataProvider != null + && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) + && (!allele.getTaxon().getCurie().equals(dataProvider.canonicalTaxonCurie) || !dataProvider.sourceOrganization.equals(allele.getDataProvider().getSourceOrganization().getAbbreviation()))) { adaResponse.addErrorMessage("allele_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAlleleIdentifier() + ") for " + dataProvider.name() + " load"); } } @@ -93,8 +90,9 @@ public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseA if (StringUtils.isNotEmpty(dto.getDiseaseRelationName())) { VocabularyTerm diseaseRelation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ALLELE_DISEASE_RELATION_VOCABULARY_TERM_SET, dto.getDiseaseRelationName()).getEntity(); - if (diseaseRelation == null) + if (diseaseRelation == null) { adaResponse.addErrorMessage("disease_relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getDiseaseRelationName() + ")"); + } annotation.setRelation(diseaseRelation); } else { adaResponse.addErrorMessage("disease_relation_name", ValidationConstants.REQUIRED_MESSAGE); @@ -102,8 +100,9 @@ public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseA if (StringUtils.isNotBlank(dto.getInferredGeneIdentifier())) { Gene inferredGene = geneService.findByIdentifierString(dto.getInferredGeneIdentifier()); - if (inferredGene == null) + if (inferredGene == null) { adaResponse.addErrorMessage("inferred_gene_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getInferredGeneIdentifier() + ")"); + } annotation.setInferredGene(inferredGene); } else { annotation.setInferredGene(null); @@ -124,9 +123,10 @@ public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseA annotation.setAssertedGenes(null); } - if (adaResponse.hasErrors()) + if (adaResponse.hasErrors()) { throw new ObjectValidationException(dto, adaResponse.errorMessagesString()); - + } + return annotation; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java index f69d876fa..6f7026b73 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java @@ -30,22 +30,14 @@ @RequestScoped public class AnnotationDTOValidator extends BaseDTOValidator { - @Inject - ReferenceService referenceService; - @Inject - NoteDAO noteDAO; - @Inject - AnnotationDAO annotationDAO; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - ConditionRelationDTOValidator conditionRelationDtoValidator; - @Inject - NoteDTOValidator noteDtoValidator; - @Inject - DataProviderDTOValidator dataProviderDtoValidator; - @Inject - DataProviderDAO dataProviderDAO; + @Inject ReferenceService referenceService; + @Inject NoteDAO noteDAO; + @Inject AnnotationDAO annotationDAO; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject ConditionRelationDTOValidator conditionRelationDtoValidator; + @Inject NoteDTOValidator noteDtoValidator; + @Inject DataProviderDTOValidator dataProviderDtoValidator; + @Inject DataProviderDAO dataProviderDAO; public ObjectResponse validateAnnotationDTO(E annotation, D dto, String noteTypeSet) { ObjectResponse annotResponse = validateAuditedObjectDTO(annotation, dto); @@ -53,7 +45,7 @@ public ObjectResponse validat annotation.setModEntityId(handleStringField(dto.getModEntityId())); annotation.setModInternalId(handleStringField(dto.getModInternalId())); - + if (dto.getDataProviderDto() == null) { annotResponse.addErrorMessage("data_provider_dto", ValidationConstants.REQUIRED_MESSAGE); } else { @@ -64,10 +56,11 @@ public ObjectResponse validat annotation.setDataProvider(dataProviderDAO.persist(dpResponse.getEntity())); } } - - if (annotation.getRelatedNotes() != null) + + if (annotation.getRelatedNotes() != null) { annotation.getRelatedNotes().clear(); - + } + List validatedNotes = new ArrayList(); List noteIdentities = new ArrayList(); Boolean allNotesValid = true; @@ -96,11 +89,13 @@ public ObjectResponse validat } } } - if (!allNotesValid) + if (!allNotesValid) { annotResponse.convertMapToErrorMessages("relatedNotes"); + } if (CollectionUtils.isNotEmpty(validatedNotes) && allNotesValid) { - if (annotation.getRelatedNotes() == null) + if (annotation.getRelatedNotes() == null) { annotation.setRelatedNotes(new ArrayList<>()); + } annotation.getRelatedNotes().addAll(validatedNotes); } @@ -125,7 +120,7 @@ public ObjectResponse validat } annotResponse.setEntity(annotation); - + return annotResponse; } @@ -137,8 +132,9 @@ public ObjectResponse validat aResponse.addErrorMessage("reference_curie", ValidationConstants.REQUIRED_MESSAGE); } else { reference = referenceService.retrieveFromDbOrLiteratureService(dto.getReferenceCurie()); - if (reference == null) + if (reference == null) { aResponse.addErrorMessage("reference_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getReferenceCurie() + ")"); + } } annotation.setSingleReference(reference); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConditionRelationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConditionRelationDTOValidator.java index 94c405084..5210efadc 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConditionRelationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConditionRelationDTOValidator.java @@ -29,18 +29,12 @@ @RequestScoped public class ConditionRelationDTOValidator extends BaseDTOValidator { - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - ExperimentalConditionDTOValidator experimentalConditionDtoValidator; - @Inject - ExperimentalConditionDAO experimentalConditionDAO; - @Inject - ReferenceDAO referenceDAO; - @Inject - ReferenceService referenceService; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject ExperimentalConditionDTOValidator experimentalConditionDtoValidator; + @Inject ExperimentalConditionDAO experimentalConditionDAO; + @Inject ReferenceDAO referenceDAO; + @Inject ReferenceService referenceService; public ObjectResponse validateConditionRelationDTO(ConditionRelationDTO dto) { ObjectResponse crResponse = new ObjectResponse(); @@ -50,8 +44,9 @@ public ObjectResponse validateConditionRelationDTO(ConditionR Reference reference = null; if (StringUtils.isNotBlank(dto.getReferenceCurie())) { reference = referenceService.retrieveFromDbOrLiteratureService(dto.getReferenceCurie()); - if (reference == null) + if (reference == null) { crResponse.addErrorMessage("reference_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getReferenceCurie() + ")"); + } } String refCurie = reference == null ? null : reference.getCurie(); @@ -75,8 +70,9 @@ public ObjectResponse validateConditionRelationDTO(ConditionR crResponse.addErrorMessage("condition_relation_type_name", ValidationConstants.REQUIRED_MESSAGE); } else { VocabularyTerm conditionRelationTypeTerm = vocabularyTermService.getTermInVocabulary(VocabularyConstants.CONDITION_RELATION_TYPE_VOCABULARY, relationType).getEntity(); - if (conditionRelationTypeTerm == null) + if (conditionRelationTypeTerm == null) { crResponse.addErrorMessage("condition_relation_type_name", ValidationConstants.INVALID_MESSAGE + " (" + relationType + ")"); + } relation.setConditionRelationType(conditionRelationTypeTerm); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java index 00da4b08f..667802e52 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java @@ -36,31 +36,25 @@ @RequestScoped public class ConstructDTOValidator extends ReagentDTOValidator { - @Inject - ConstructSymbolSlotAnnotationDTOValidator constructSymbolDtoValidator; - @Inject - ConstructFullNameSlotAnnotationDTOValidator constructFullNameDtoValidator; - @Inject - ConstructSynonymSlotAnnotationDTOValidator constructSynonymDtoValidator; - @Inject - ConstructDAO constructDAO; - @Inject - ConstructComponentSlotAnnotationDTOValidator constructComponentDtoValidator; - @Inject - SlotAnnotationIdentityHelper identityHelper; + @Inject ConstructSymbolSlotAnnotationDTOValidator constructSymbolDtoValidator; + @Inject ConstructFullNameSlotAnnotationDTOValidator constructFullNameDtoValidator; + @Inject ConstructSynonymSlotAnnotationDTOValidator constructSynonymDtoValidator; + @Inject ConstructDAO constructDAO; + @Inject ConstructComponentSlotAnnotationDTOValidator constructComponentDtoValidator; + @Inject SlotAnnotationIdentityHelper identityHelper; private ObjectResponse constructResponse; - + @Transactional public Construct validateConstructDTO(ConstructDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { constructResponse = new ObjectResponse(); - + Construct construct = new Construct(); String constructId; String identifyingField; String uniqueId = ConstructUniqueIdHelper.getConstructUniqueId(dto); - + if (StringUtils.isNotBlank(dto.getModEntityId())) { constructId = dto.getModEntityId(); construct.setModEntityId(constructId); @@ -79,7 +73,7 @@ public Construct validateConstructDTO(ConstructDTO dto, BackendBulkDataProvider construct = constructList.getResults().get(0); } construct.setUniqueId(uniqueId); - + ObjectResponse reagentResponse = validateReagentDTO(construct, dto); constructResponse.addErrorMessages(reagentResponse.getErrorMessages()); construct = reagentResponse.getEntity(); @@ -98,39 +92,44 @@ public Construct validateConstructDTO(ConstructDTO dto, BackendBulkDataProvider } else { construct.setReferences(null); } - + ConstructSymbolSlotAnnotation symbol = validateConstructSymbol(construct, dto); construct.setConstructSymbol(symbol); - + ConstructFullNameSlotAnnotation fullName = validateConstructFullName(construct, dto); construct.setConstructFullName(fullName); - + List synonyms = validateConstructSynonyms(construct, dto); - if (construct.getConstructSynonyms() != null) + if (construct.getConstructSynonyms() != null) { construct.getConstructSynonyms().clear(); + } if (synonyms != null) { - if (construct.getConstructSynonyms() == null) + if (construct.getConstructSynonyms() == null) { construct.setConstructSynonyms(new ArrayList<>()); + } construct.getConstructSynonyms().addAll(synonyms); } - + List components = validateConstructComponents(construct, dto); - if (construct.getConstructComponents() != null) + if (construct.getConstructComponents() != null) { construct.getConstructComponents().clear(); + } if (components != null) { - if (construct.getConstructComponents() == null) + if (construct.getConstructComponents() == null) { construct.setConstructComponents(new ArrayList<>()); + } construct.getConstructComponents().addAll(components); } - + constructResponse.convertErrorMessagesToMap(); - if (constructResponse.hasErrors()) + if (constructResponse.hasErrors()) { throw new ObjectValidationException(dto, constructResponse.errorMessagesString()); + } return constructDAO.persist(construct); } - + private ConstructSymbolSlotAnnotation validateConstructSymbol(Construct construct, ConstructDTO dto) { String field = "construct_symbol_dto"; @@ -148,13 +147,14 @@ private ConstructSymbolSlotAnnotation validateConstructSymbol(Construct construc ConstructSymbolSlotAnnotation symbol = symbolResponse.getEntity(); symbol.setSingleConstruct(construct); - + return symbol; } private ConstructFullNameSlotAnnotation validateConstructFullName(Construct construct, ConstructDTO dto) { - if (dto.getConstructFullNameDto() == null) + if (dto.getConstructFullNameDto() == null) { return null; + } String field = "construct_full_name_dto"; @@ -167,13 +167,13 @@ private ConstructFullNameSlotAnnotation validateConstructFullName(Construct cons ConstructFullNameSlotAnnotation fullName = nameResponse.getEntity(); fullName.setSingleConstruct(construct); - + return fullName; } private List validateConstructSynonyms(Construct construct, ConstructDTO dto) { String field = "construct_synonym_dtos"; - + Map existingSynonyms = new HashMap<>(); if (CollectionUtils.isNotEmpty(construct.getConstructSynonyms())) { for (ConstructSynonymSlotAnnotation existingSynonym : construct.getConstructSynonyms()) { @@ -198,21 +198,22 @@ private List validateConstructSynonyms(Construct } } } - + if (!allValid) { constructResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedSynonyms)) + + if (CollectionUtils.isEmpty(validatedSynonyms)) { return null; + } return validatedSynonyms; } - + private List validateConstructComponents(Construct construct, ConstructDTO dto) { String field = "construct_component_dtos"; - + Map existingComponents = new HashMap<>(); if (CollectionUtils.isNotEmpty(construct.getConstructComponents())) { for (ConstructComponentSlotAnnotation existingComponent : construct.getConstructComponents()) { @@ -237,14 +238,15 @@ private List validateConstructComponents(Const } } } - + if (!allValid) { constructResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedComponents)) + + if (CollectionUtils.isEmpty(validatedComponents)) { return null; + } return validatedComponents; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/CrossReferenceDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/CrossReferenceDTOValidator.java index 99027c03c..4503f5bf3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/CrossReferenceDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/CrossReferenceDTOValidator.java @@ -17,21 +17,20 @@ @RequestScoped public class CrossReferenceDTOValidator extends BaseDTOValidator { - @Inject - ResourceDescriptorService resourceDescriptorService; - @Inject - ResourceDescriptorPageService resourceDescriptorPageService; + @Inject ResourceDescriptorService resourceDescriptorService; + @Inject ResourceDescriptorPageService resourceDescriptorPageService; public ObjectResponse validateCrossReferenceDTO(CrossReferenceDTO dto, CrossReference xref) { - if (xref == null) + if (xref == null) { xref = new CrossReference(); + } ObjectResponse crResponse = validateAuditedObjectDTO(xref, dto); xref = crResponse.getEntity(); if (StringUtils.isBlank(dto.getPrefix())) { - crResponse.addErrorMessage("prefix", ValidationConstants.REQUIRED_MESSAGE); + crResponse.addErrorMessage("prefix", ValidationConstants.REQUIRED_MESSAGE); } else { ObjectResponse rdResponse = resourceDescriptorService.getByPrefixOrSynonym(dto.getPrefix()); if (rdResponse == null || rdResponse.getEntity() == null) { @@ -40,13 +39,12 @@ public ObjectResponse validateCrossReferenceDTO(CrossReferenceDT } if (StringUtils.isBlank(dto.getReferencedCurie())) { - crResponse.addErrorMessage("reference_curie", ValidationConstants.REQUIRED_MESSAGE); + crResponse.addErrorMessage("reference_curie", ValidationConstants.REQUIRED_MESSAGE); } xref.setReferencedCurie(dto.getReferencedCurie()); - if (StringUtils.isBlank(dto.getDisplayName())) { - crResponse.addErrorMessage("display_name", ValidationConstants.REQUIRED_MESSAGE); + crResponse.addErrorMessage("display_name", ValidationConstants.REQUIRED_MESSAGE); } xref.setDisplayName(dto.getDisplayName()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DataProviderDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DataProviderDTOValidator.java index ed840907a..9b761ff72 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DataProviderDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DataProviderDTOValidator.java @@ -18,19 +18,16 @@ @RequestScoped public class DataProviderDTOValidator extends BaseDTOValidator { - @Inject - OrganizationService organizationService; - @Inject - ResourceDescriptorPageDAO resourceDescriptorPageDAO; - @Inject - CrossReferenceService crossReferenceService; - @Inject - CrossReferenceDTOValidator crossReferenceDtoValidator; - + @Inject OrganizationService organizationService; + @Inject ResourceDescriptorPageDAO resourceDescriptorPageDAO; + @Inject CrossReferenceService crossReferenceService; + @Inject CrossReferenceDTOValidator crossReferenceDtoValidator; + public ObjectResponse validateDataProviderDTO(DataProviderDTO dto, DataProvider dbEntity) { - if (dbEntity == null) + if (dbEntity == null) { dbEntity = new DataProvider(); - + } + ObjectResponse dpResponse = validateAuditedObjectDTO(dbEntity, dto); dbEntity = dpResponse.getEntity(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java index 7369dce66..522038733 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java @@ -31,22 +31,14 @@ @RequestScoped public class DiseaseAnnotationDTOValidator extends AnnotationDTOValidator { - @Inject - DoTermService doTermService; - @Inject - EcoTermService ecoTermService; - @Inject - ReferenceService referenceService; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - GeneService geneService; - @Inject - BiologicalEntityService biologicalEntityService; - @Inject - DataProviderDTOValidator dataProviderDtoValidator; - @Inject - DataProviderDAO dataProviderDAO; + @Inject DoTermService doTermService; + @Inject EcoTermService ecoTermService; + @Inject ReferenceService referenceService; + @Inject VocabularyTermService vocabularyTermService; + @Inject GeneService geneService; + @Inject BiologicalEntityService biologicalEntityService; + @Inject DataProviderDTOValidator dataProviderDtoValidator; + @Inject DataProviderDAO dataProviderDAO; public ObjectResponse validateDiseaseAnnotationDTO(E annotation, D dto) { ObjectResponse daResponse = validateAnnotationDTO(annotation, dto, VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET); @@ -56,8 +48,9 @@ public ObjectRespo daResponse.addErrorMessage("do_term_curie", ValidationConstants.REQUIRED_MESSAGE); } else { DOTerm disease = doTermService.findByCurieOrSecondaryId(dto.getDoTermCurie()); - if (disease == null) + if (disease == null) { daResponse.addErrorMessage("do_term_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getDoTermCurie() + ")"); + } annotation.setDiseaseAnnotationObject(disease); } @@ -135,10 +128,10 @@ public ObjectRespo } else if (StringUtils.isBlank(dto.getDiseaseGeneticModifierRelationName())) { daResponse.addErrorMessage("disease_genetic_modifier_identifiers", ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "disease_genetic_modifier_relation_name"); } else { - VocabularyTerm diseaseGeneticModifierRelation = vocabularyTermService.getTermInVocabulary(VocabularyConstants.DISEASE_GENETIC_MODIFIER_RELATION_VOCABULARY, - dto.getDiseaseGeneticModifierRelationName()).getEntity(); - if (diseaseGeneticModifierRelation == null) + VocabularyTerm diseaseGeneticModifierRelation = vocabularyTermService.getTermInVocabulary(VocabularyConstants.DISEASE_GENETIC_MODIFIER_RELATION_VOCABULARY, dto.getDiseaseGeneticModifierRelationName()).getEntity(); + if (diseaseGeneticModifierRelation == null) { daResponse.addErrorMessage("disease_genetic_modifier_relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getDiseaseGeneticModifierRelationName() + ")"); + } List diseaseGeneticModifiers = new ArrayList<>(); for (String modifierIdentifier : dto.getDiseaseGeneticModifierIdentifiers()) { BiologicalEntity diseaseGeneticModifier = biologicalEntityService.findByIdentifierString(modifierIdentifier); @@ -159,21 +152,23 @@ public ObjectRespo VocabularyTerm annotationType = null; if (StringUtils.isNotBlank(dto.getAnnotationTypeName())) { annotationType = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ANNOTATION_TYPE_VOCABULARY, dto.getAnnotationTypeName()).getEntity(); - if (annotationType == null) + if (annotationType == null) { daResponse.addErrorMessage("annotation_type_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAnnotationTypeName() + ")"); + } } annotation.setAnnotationType(annotationType); VocabularyTerm geneticSex = null; if (StringUtils.isNotBlank(dto.getGeneticSexName())) { geneticSex = vocabularyTermService.getTermInVocabulary(VocabularyConstants.GENETIC_SEX_VOCABULARY, dto.getGeneticSexName()).getEntity(); - if (geneticSex == null) + if (geneticSex == null) { daResponse.addErrorMessage("genetic_sex_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGeneticSexName() + ")"); + } } annotation.setGeneticSex(geneticSex); daResponse.setEntity(annotation); - + return daResponse; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ExperimentalConditionDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ExperimentalConditionDTOValidator.java index bbba8a1b5..c095a2e69 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ExperimentalConditionDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ExperimentalConditionDTOValidator.java @@ -30,22 +30,14 @@ @RequestScoped public class ExperimentalConditionDTOValidator extends BaseDTOValidator { - @Inject - ExperimentalConditionDAO experimentalConditionDAO; - @Inject - ZecoTermService zecoTermService; - @Inject - ChemicalTermService chemicalTermService; - @Inject - AnatomicalTermService anatomicalTermService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - GoTermService goTermService; - @Inject - ExperimentalConditionOntologyTermService experimentalConditionOntologyTermService; - @Inject - ExperimentalConditionSummary experimentalConditionSummary; + @Inject ExperimentalConditionDAO experimentalConditionDAO; + @Inject ZecoTermService zecoTermService; + @Inject ChemicalTermService chemicalTermService; + @Inject AnatomicalTermService anatomicalTermService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject GoTermService goTermService; + @Inject ExperimentalConditionOntologyTermService experimentalConditionOntologyTermService; + @Inject ExperimentalConditionSummary experimentalConditionSummary; public ObjectResponse validateExperimentalConditionDTO(ExperimentalConditionDTO dto) { ObjectResponse ecResponse = new ObjectResponse(); @@ -68,23 +60,26 @@ public ObjectResponse validateExperimentalConditionDTO(Ex ChemicalTerm conditionChemical = null; if (StringUtils.isNotBlank(dto.getConditionChemicalCurie())) { conditionChemical = chemicalTermService.findByCurieOrSecondaryId(dto.getConditionChemicalCurie()); - if (conditionChemical == null) + if (conditionChemical == null) { ecResponse.addErrorMessage("condition_chemical_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionChemicalCurie() + ")"); + } } experimentalCondition.setConditionChemical(conditionChemical); ExperimentalConditionOntologyTerm conditionId = null; if (StringUtils.isNotBlank(dto.getConditionIdCurie())) { conditionId = experimentalConditionOntologyTermService.findByCurieOrSecondaryId(dto.getConditionIdCurie()); - if (conditionId == null) + if (conditionId == null) { ecResponse.addErrorMessage("condition_id_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionIdCurie() + ")"); + } } experimentalCondition.setConditionId(conditionId); if (StringUtils.isNotBlank(dto.getConditionClassCurie())) { ZECOTerm term = zecoTermService.findByCurieOrSecondaryId(dto.getConditionClassCurie()); - if (term == null || term.getSubsets().isEmpty() || !term.getSubsets().contains(OntologyConstants.ZECO_AGR_SLIM_SUBSET)) + if (term == null || term.getSubsets().isEmpty() || !term.getSubsets().contains(OntologyConstants.ZECO_AGR_SLIM_SUBSET)) { ecResponse.addErrorMessage("condition_class_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionClassCurie() + ")"); + } experimentalCondition.setConditionClass(term); } else { ecResponse.addErrorMessage("condition_class_curie", ValidationConstants.REQUIRED_MESSAGE); @@ -93,35 +88,40 @@ public ObjectResponse validateExperimentalConditionDTO(Ex AnatomicalTerm conditionAnatomy = null; if (StringUtils.isNotBlank(dto.getConditionAnatomyCurie())) { conditionAnatomy = anatomicalTermService.findByCurieOrSecondaryId(dto.getConditionAnatomyCurie()); - if (conditionAnatomy == null) + if (conditionAnatomy == null) { ecResponse.addErrorMessage("condition_anatomy_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionAnatomyCurie() + ")"); + } } experimentalCondition.setConditionAnatomy(conditionAnatomy); NCBITaxonTerm conditionTaxon = null; if (StringUtils.isNotBlank(dto.getConditionTaxonCurie())) { conditionTaxon = ncbiTaxonTermService.getTaxonFromDB(dto.getConditionTaxonCurie()); - if (conditionTaxon == null) + if (conditionTaxon == null) { ecResponse.addErrorMessage("condition_taxon_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionTaxonCurie() + ")"); + } } experimentalCondition.setConditionTaxon(conditionTaxon); GOTerm conditionGeneOntology = null; if (StringUtils.isNotBlank(dto.getConditionGeneOntologyCurie())) { conditionGeneOntology = goTermService.findByCurieOrSecondaryId(dto.getConditionGeneOntologyCurie()); - if (conditionGeneOntology == null) + if (conditionGeneOntology == null) { ecResponse.addErrorMessage("condition_gene_ontology_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionGeneOntologyCurie() + ")"); + } } experimentalCondition.setConditionGeneOntology(conditionGeneOntology); String conditionQuantity = null; - if (StringUtils.isNotBlank(dto.getConditionQuantity())) + if (StringUtils.isNotBlank(dto.getConditionQuantity())) { conditionQuantity = dto.getConditionQuantity(); + } experimentalCondition.setConditionQuantity(conditionQuantity); String conditionFreeText = null; - if (StringUtils.isNotBlank(dto.getConditionFreeText())) + if (StringUtils.isNotBlank(dto.getConditionFreeText())) { conditionFreeText = dto.getConditionFreeText(); + } experimentalCondition.setConditionFreeText(conditionFreeText); if (!ecResponse.hasErrors()) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java index 26c85d1f4..a61ab55ce 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java @@ -37,20 +37,13 @@ @RequestScoped public class GeneDTOValidator extends BaseDTOValidator { - @Inject - GeneDAO geneDAO; - @Inject - GeneSymbolSlotAnnotationDTOValidator geneSymbolDtoValidator; - @Inject - GeneFullNameSlotAnnotationDTOValidator geneFullNameDtoValidator; - @Inject - GeneSystematicNameSlotAnnotationDTOValidator geneSystematicNameDtoValidator; - @Inject - GeneSynonymSlotAnnotationDTOValidator geneSynonymDtoValidator; - @Inject - GeneSecondaryIdSlotAnnotationDTOValidator geneSecondaryIdDtoValidator; - @Inject - SlotAnnotationIdentityHelper identityHelper; + @Inject GeneDAO geneDAO; + @Inject GeneSymbolSlotAnnotationDTOValidator geneSymbolDtoValidator; + @Inject GeneFullNameSlotAnnotationDTOValidator geneFullNameDtoValidator; + @Inject GeneSystematicNameSlotAnnotationDTOValidator geneSystematicNameDtoValidator; + @Inject GeneSynonymSlotAnnotationDTOValidator geneSynonymDtoValidator; + @Inject GeneSecondaryIdSlotAnnotationDTOValidator geneSecondaryIdDtoValidator; + @Inject SlotAnnotationIdentityHelper identityHelper; private ObjectResponse geneResponse; @@ -58,18 +51,20 @@ public class GeneDTOValidator extends BaseDTOValidator { public Gene validateGeneDTO(GeneDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { geneResponse = new ObjectResponse(); - + Gene gene = null; if (StringUtils.isNotBlank(dto.getModEntityId())) { SearchResponse response = geneDAO.findByField("modEntityId", dto.getModEntityId()); - if (response != null && response.getSingleResult() != null) + if (response != null && response.getSingleResult() != null) { gene = response.getSingleResult(); + } } else { geneResponse.addErrorMessage("modEntityId", ValidationConstants.REQUIRED_MESSAGE); } - if (gene == null) + if (gene == null) { gene = new Gene(); + } gene.setModEntityId(dto.getModEntityId()); gene.setModInternalId(handleStringField(dto.getModInternalId())); @@ -80,39 +75,44 @@ public Gene validateGeneDTO(GeneDTO dto, BackendBulkDataProvider dataProvider) t GeneSymbolSlotAnnotation symbol = validateGeneSymbol(gene, dto); gene.setGeneSymbol(symbol); - + GeneFullNameSlotAnnotation fullName = validateGeneFullName(gene, dto); gene.setGeneFullName(fullName); - + GeneSystematicNameSlotAnnotation systematicName = validateGeneSystematicName(gene, dto); gene.setGeneSystematicName(systematicName); - + List synonyms = validateGeneSynonyms(gene, dto); - if (gene.getGeneSynonyms() != null) + if (gene.getGeneSynonyms() != null) { gene.getGeneSynonyms().clear(); + } if (synonyms != null) { - if (gene.getGeneSynonyms() == null) + if (gene.getGeneSynonyms() == null) { gene.setGeneSynonyms(new ArrayList<>()); + } gene.getGeneSynonyms().addAll(synonyms); } - + List secondaryIds = validateGeneSecondaryIds(gene, dto); - if (gene.getGeneSecondaryIds() != null) + if (gene.getGeneSecondaryIds() != null) { gene.getGeneSecondaryIds().clear(); + } if (secondaryIds != null) { - if (gene.getGeneSecondaryIds() == null) + if (gene.getGeneSecondaryIds() == null) { gene.setGeneSecondaryIds(new ArrayList<>()); + } gene.getGeneSecondaryIds().addAll(secondaryIds); } - + geneResponse.convertErrorMessagesToMap(); - - if (geneResponse.hasErrors()) + + if (geneResponse.hasErrors()) { throw new ObjectValidationException(dto, geneResponse.errorMessagesString()); + } return geneDAO.persist(gene); } - + private GeneSymbolSlotAnnotation validateGeneSymbol(Gene gene, GeneDTO dto) { String field = "gene_symbol_dto"; @@ -130,13 +130,14 @@ private GeneSymbolSlotAnnotation validateGeneSymbol(Gene gene, GeneDTO dto) { GeneSymbolSlotAnnotation symbol = symbolResponse.getEntity(); symbol.setSingleGene(gene); - + return symbol; } private GeneFullNameSlotAnnotation validateGeneFullName(Gene gene, GeneDTO dto) { - if (dto.getGeneFullNameDto() == null) + if (dto.getGeneFullNameDto() == null) { return null; + } String field = "gene_full_name_dto"; @@ -149,13 +150,14 @@ private GeneFullNameSlotAnnotation validateGeneFullName(Gene gene, GeneDTO dto) GeneFullNameSlotAnnotation fullName = nameResponse.getEntity(); fullName.setSingleGene(gene); - + return fullName; } private GeneSystematicNameSlotAnnotation validateGeneSystematicName(Gene gene, GeneDTO dto) { - if (dto.getGeneSystematicNameDto() == null) + if (dto.getGeneSystematicNameDto() == null) { return null; + } String field = "gene_systematic_name_dto"; @@ -168,13 +170,13 @@ private GeneSystematicNameSlotAnnotation validateGeneSystematicName(Gene gene, G GeneSystematicNameSlotAnnotation systematicName = nameResponse.getEntity(); systematicName.setSingleGene(gene); - + return systematicName; } - + private List validateGeneSynonyms(Gene gene, GeneDTO dto) { String field = "gene_synonym_dtos"; - + Map existingSynonyms = new HashMap<>(); if (CollectionUtils.isNotEmpty(gene.getGeneSynonyms())) { for (GeneSynonymSlotAnnotation existingSynonym : gene.getGeneSynonyms()) { @@ -199,21 +201,22 @@ private List validateGeneSynonyms(Gene gene, GeneDTO } } } - + if (!allValid) { geneResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedSynonyms)) + + if (CollectionUtils.isEmpty(validatedSynonyms)) { return null; + } return validatedSynonyms; } private List validateGeneSecondaryIds(Gene gene, GeneDTO dto) { String field = "gene_secondary_id_dtos"; - + Map existingSecondaryIds = new HashMap<>(); if (CollectionUtils.isNotEmpty(gene.getGeneSecondaryIds())) { for (GeneSecondaryIdSlotAnnotation existingSecondaryId : gene.getGeneSecondaryIds()) { @@ -238,14 +241,15 @@ private List validateGeneSecondaryIds(Gene gene, } } } - + if (!allValid) { geneResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedSecondaryIds)) + + if (CollectionUtils.isEmpty(validatedSecondaryIds)) { return null; + } return validatedSecondaryIds; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java index d11a0c4ec..0b54f7f96 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java @@ -27,16 +27,11 @@ @RequestScoped public class GeneDiseaseAnnotationDTOValidator extends DiseaseAnnotationDTOValidator { - @Inject - GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; - @Inject - AffectedGenomicModelService affectedGenomicModelService; - @Inject - NoteDAO noteDAO; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject GeneDiseaseAnnotationDAO geneDiseaseAnnotationDAO; + @Inject AffectedGenomicModelService affectedGenomicModelService; + @Inject NoteDAO noteDAO; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject VocabularyTermService vocabularyTermService; public GeneDiseaseAnnotation validateGeneDiseaseAnnotationDTO(GeneDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { GeneDiseaseAnnotation annotation = new GeneDiseaseAnnotation(); @@ -59,7 +54,7 @@ public GeneDiseaseAnnotation validateGeneDiseaseAnnotationDTO(GeneDiseaseAnnotat String annotationId; String identifyingField; String uniqueId = AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(dto, dto.getGeneIdentifier(), refCurie); - + if (StringUtils.isNotBlank(dto.getModEntityId())) { annotationId = dto.getModEntityId(); annotation.setModEntityId(annotationId); @@ -77,9 +72,9 @@ public GeneDiseaseAnnotation validateGeneDiseaseAnnotationDTO(GeneDiseaseAnnotat annotation = AnnotationRetrievalHelper.getCurrentAnnotation(annotation, annotationList); annotation.setUniqueId(uniqueId); annotation.setDiseaseAnnotationSubject(gene); - - if (dataProvider != null && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) && !gene.getTaxon().getCurie().equals(dataProvider.canonicalTaxonCurie) || - !dataProvider.sourceOrganization.equals(gene.getDataProvider().getSourceOrganization().getAbbreviation())) { + + if (dataProvider != null && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) && !gene.getTaxon().getCurie().equals(dataProvider.canonicalTaxonCurie) + || !dataProvider.sourceOrganization.equals(gene.getDataProvider().getSourceOrganization().getAbbreviation())) { gdaResponse.addErrorMessage("gene_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGeneIdentifier() + ") for " + dataProvider.name() + " load"); } } @@ -102,16 +97,18 @@ public GeneDiseaseAnnotation validateGeneDiseaseAnnotationDTO(GeneDiseaseAnnotat if (StringUtils.isNotEmpty(dto.getDiseaseRelationName())) { VocabularyTerm diseaseRelation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.GENE_DISEASE_RELATION_VOCABULARY_TERM_SET, dto.getDiseaseRelationName()).getEntity(); - if (diseaseRelation == null) + if (diseaseRelation == null) { gdaResponse.addErrorMessage("disease_relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getDiseaseRelationName() + ")"); + } annotation.setRelation(diseaseRelation); } else { gdaResponse.addErrorMessage("disease_relation_name", ValidationConstants.REQUIRED_MESSAGE); } - - if (gdaResponse.hasErrors()) + + if (gdaResponse.hasErrors()) { throw new ObjectValidationException(dto, gdaResponse.errorMessagesString()); - + } + return annotation; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java index 2a7a710d0..cf0b68c86 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java @@ -23,14 +23,10 @@ @RequestScoped public class NoteDTOValidator extends BaseDTOValidator { - @Inject - ReferenceDAO referenceDAO; - @Inject - ReferenceService referenceService; - @Inject - PersonService personService; - @Inject - VocabularyTermService vocabularyTermService; + @Inject ReferenceDAO referenceDAO; + @Inject ReferenceService referenceService; + @Inject PersonService personService; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateNoteDTO(NoteDTO dto, String noteTypeVocabularyTermSet) { Note note = new Note(); @@ -38,16 +34,18 @@ public ObjectResponse validateNoteDTO(NoteDTO dto, String noteTypeVocabula note = noteResponse.getEntity(); - if (StringUtils.isBlank(dto.getFreeText())) + if (StringUtils.isBlank(dto.getFreeText())) { noteResponse.addErrorMessage("freeText", ValidationConstants.REQUIRED_MESSAGE); + } note.setFreeText(dto.getFreeText()); if (StringUtils.isBlank(dto.getNoteTypeName())) { noteResponse.addErrorMessage("note_type_name", ValidationConstants.REQUIRED_MESSAGE); } else { VocabularyTerm noteType = vocabularyTermService.getTermInVocabularyTermSet(noteTypeVocabularyTermSet, dto.getNoteTypeName()).getEntity(); - if (noteType == null) + if (noteType == null) { noteResponse.addErrorMessage("note_type_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getNoteTypeName() + ")"); + } note.setNoteType(noteType); } @@ -65,9 +63,10 @@ public ObjectResponse validateNoteDTO(NoteDTO dto, String noteTypeVocabula } else { note.setReferences(null); } - - if (note.getInternal() == null) + + if (note.getInternal() == null) { note.setInternal(true); + } noteResponse.setEntity(note); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ReagentDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ReagentDTOValidator.java index bf4441293..9a96ec225 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ReagentDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ReagentDTOValidator.java @@ -13,10 +13,8 @@ @RequestScoped public class ReagentDTOValidator extends AnnotationDTOValidator { - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - DataProviderDTOValidator dataProviderDtoValidator; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject DataProviderDTOValidator dataProviderDtoValidator; public ObjectResponse validateReagentDTO(E reagent, D dto) { ObjectResponse reagentResponse = validateAuditedObjectDTO(reagent, dto); @@ -24,9 +22,9 @@ public ObjectResponse validateReage reagent.setModEntityId(handleStringField(dto.getModEntityId())); reagent.setModInternalId(handleStringField(dto.getModInternalId())); - + reagent.setSecondaryIdentifiers(handleStringListField(dto.getSecondaryIdentifiers())); - + if (dto.getDataProviderDto() == null) { reagentResponse.addErrorMessage("data_provider_dto", ValidationConstants.REQUIRED_MESSAGE); } else { @@ -39,7 +37,7 @@ public ObjectResponse validateReage } reagentResponse.setEntity(reagent); - + return reagentResponse; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java index 4ce2aec2a..1ff2de6d3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java @@ -24,17 +24,14 @@ @RequestScoped public class ResourceDescriptorDTOValidator extends BaseDTOValidator { - - @Inject - ResourceDescriptorDAO resourceDescriptorDAO; - @Inject - ResourceDescriptorPageDAO resourceDescriptorPageDAO; - @Inject - ResourceDescriptorPageDTOValidator resourceDescriptorPageDtoValidator; + + @Inject ResourceDescriptorDAO resourceDescriptorDAO; + @Inject ResourceDescriptorPageDAO resourceDescriptorPageDAO; + @Inject ResourceDescriptorPageDTOValidator resourceDescriptorPageDtoValidator; public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dto) throws ObjectValidationException { ObjectResponse rdResponse = new ObjectResponse(); - + ResourceDescriptor rd = null; if (StringUtils.isBlank(dto.getDbPrefix())) { rdResponse.addErrorMessage("db_prefix", ValidationConstants.REQUIRED_MESSAGE); @@ -47,24 +44,24 @@ public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dt rd = rdSearchResponse.getSingleResult(); } } - - if (StringUtils.isBlank(dto.getName())) + if (StringUtils.isBlank(dto.getName())) { rdResponse.addErrorMessage("name", ValidationConstants.REQUIRED_MESSAGE); + } rd.setName(dto.getName()); - if (CollectionUtils.isNotEmpty(dto.getAliases())) { rd.setSynonyms(dto.getAliases()); } else { rd.setSynonyms(null); } - + String idPattern = null; - if (StringUtils.isNotBlank(dto.getGidPattern())) + if (StringUtils.isNotBlank(dto.getGidPattern())) { idPattern = StringEscapeUtils.escapeJava(dto.getGidPattern()); + } rd.setIdPattern(idPattern); - + String idExample = null; if (StringUtils.isNotBlank(dto.getExampleGid())) { idExample = dto.getExampleGid(); @@ -72,9 +69,9 @@ public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dt idExample = dto.getExampleId(); } rd.setIdExample(idExample); - + List rdPages = new ArrayList<>(); - + String defaultUrlTemplate = null; ResourceDescriptorPageDTO defaultPageDTO = null; if (StringUtils.isNotBlank(dto.getDefaultUrl())) { @@ -83,15 +80,17 @@ public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dt defaultPageDTO.setName("default"); defaultPageDTO.setUrl(defaultUrlTemplate); ObjectResponse defaultRdPageResponse = resourceDescriptorPageDtoValidator.validateResourceDescriptorPageDTO(defaultPageDTO, dto.getDbPrefix()); - if (defaultRdPageResponse.hasErrors()) + if (defaultRdPageResponse.hasErrors()) { rdResponse.addErrorMessage("default_url_template", "Error during default page construction: " + defaultRdPageResponse.errorMessagesString()); + } rdPages.add(defaultRdPageResponse.getEntity()); } rd.setDefaultUrlTemplate(defaultUrlTemplate); - + List previousPageIds = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(rd.getResourcePages())) + if (CollectionUtils.isNotEmpty(rd.getResourcePages())) { previousPageIds = rd.getResourcePages().stream().map(ResourceDescriptorPage::getId).collect(Collectors.toList()); + } if (CollectionUtils.isNotEmpty(dto.getPages())) { for (ResourceDescriptorPageDTO rdPageDTO : dto.getPages()) { ObjectResponse rdPageResponse = resourceDescriptorPageDtoValidator.validateResourceDescriptorPageDTO(rdPageDTO, dto.getDbPrefix()); @@ -104,7 +103,7 @@ public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dt } else { rd.setResourcePages(null); } - + rdResponse.setEntity(rd); if (rdResponse.hasErrors()) { @@ -125,11 +124,12 @@ public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dt // Remove unused ResourceDescriptorPage objects if (CollectionUtils.isNotEmpty(previousPageIds)) { for (Long previousPageId : previousPageIds) { - if (!newPageIds.contains(previousPageId)) + if (!newPageIds.contains(previousPageId)) { resourceDescriptorPageDAO.remove(previousPageId); + } } } - + return rd; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorPageDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorPageDTOValidator.java index 119b751a6..0ad3cc62d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorPageDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorPageDTOValidator.java @@ -14,32 +14,34 @@ @RequestScoped public class ResourceDescriptorPageDTOValidator extends BaseDTOValidator { - @Inject - ResourceDescriptorPageService resourceDescriptorPageService; - + @Inject ResourceDescriptorPageService resourceDescriptorPageService; + public ObjectResponse validateResourceDescriptorPageDTO(ResourceDescriptorPageDTO dto, String resourceDescriptorPrefix) { ResourceDescriptorPage rdPage = null; - + ObjectResponse rdPageResponse = new ObjectResponse(); if (StringUtils.isBlank(dto.getName())) { rdPageResponse.addErrorMessage("name", ValidationConstants.REQUIRED_MESSAGE); } else { rdPage = resourceDescriptorPageService.getPageForResourceDescriptor(resourceDescriptorPrefix, dto.getName()); - if (rdPage == null) + if (rdPage == null) { rdPage = new ResourceDescriptorPage(); + } rdPage.setName(dto.getName()); } - - if (StringUtils.isBlank(dto.getUrl())) + + if (StringUtils.isBlank(dto.getUrl())) { rdPageResponse.addErrorMessage("url", ValidationConstants.REQUIRED_MESSAGE); + } rdPage.setUrlTemplate(dto.getUrl()); - + String pageDescription = null; - if (StringUtils.isNotBlank(dto.getDescription())) + if (StringUtils.isNotBlank(dto.getDescription())) { pageDescription = dto.getDescription(); + } rdPage.setPageDescription(pageDescription); - + rdPageResponse.setEntity(rdPage); return rdPageResponse; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java index 0d1e05afc..73df6c086 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java @@ -30,43 +30,42 @@ @RequestScoped public class VariantDTOValidator extends BaseDTOValidator { - @Inject - VariantDAO variantDAO; - @Inject - NoteDAO noteDAO; - @Inject - NoteDTOValidator noteDtoValidator; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - SoTermService soTermService; + @Inject VariantDAO variantDAO; + @Inject NoteDAO noteDAO; + @Inject NoteDTOValidator noteDtoValidator; + @Inject VocabularyTermService vocabularyTermService; + @Inject SoTermService soTermService; private ObjectResponse variantResponse; - + @Transactional public Variant validateVariantDTO(VariantDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { variantResponse = new ObjectResponse(); - + Variant variant = null; if (StringUtils.isNotBlank(dto.getModEntityId())) { SearchResponse response = variantDAO.findByField("modEntityId", dto.getModEntityId()); - if (response != null && response.getSingleResult() != null) + if (response != null && response.getSingleResult() != null) { variant = response.getSingleResult(); + } } if (variant == null) { if (StringUtils.isBlank(dto.getModInternalId())) { - if (StringUtils.isBlank(dto.getModEntityId())) + if (StringUtils.isBlank(dto.getModEntityId())) { variantResponse.addErrorMessage("modInternalId", ValidationConstants.REQUIRED_UNLESS_OTHER_FIELD_POPULATED_MESSAGE + "modEntityId"); + } } else { SearchResponse response = variantDAO.findByField("modInternalId", dto.getModInternalId()); - if (response != null && response.getSingleResult() != null) + if (response != null && response.getSingleResult() != null) { variant = response.getSingleResult(); + } } } - if (variant == null) + if (variant == null) { variant = new Variant(); + } variant.setModEntityId(dto.getModEntityId()); variant.setModInternalId(dto.getModInternalId()); @@ -75,14 +74,15 @@ public Variant validateVariantDTO(VariantDTO dto, BackendBulkDataProvider dataPr variantResponse.addErrorMessages(geResponse.getErrorMessages()); variant = geResponse.getEntity(); - + SOTerm variantType = null; if (StringUtils.isBlank(dto.getVariantTypeCurie())) { variantResponse.addErrorMessage("variant_type_curie", ValidationConstants.REQUIRED_MESSAGE); } else { variantType = soTermService.findByCurieOrSecondaryId(dto.getVariantTypeCurie()); - if (variantType == null) + if (variantType == null) { variantResponse.addErrorMessage("variant_type_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getVariantTypeCurie() + ")"); + } } variant.setVariantType(variantType); @@ -94,38 +94,42 @@ public Variant validateVariantDTO(VariantDTO dto, BackendBulkDataProvider dataPr } } variant.setVariantStatus(variantStatus); - + SOTerm sourceGeneralConsequence = null; if (!StringUtils.isBlank(dto.getSourceGeneralConsequenceCurie())) { sourceGeneralConsequence = soTermService.findByCurieOrSecondaryId(dto.getSourceGeneralConsequenceCurie()); - if (sourceGeneralConsequence == null) + if (sourceGeneralConsequence == null) { variantResponse.addErrorMessage("source_general_consequence_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getSourceGeneralConsequenceCurie() + ")"); + } } variant.setSourceGeneralConsequence(sourceGeneralConsequence); List relatedNotes = validateRelatedNotes(variant, dto); if (relatedNotes != null) { - if (variant.getRelatedNotes() == null) + if (variant.getRelatedNotes() == null) { variant.setRelatedNotes(new ArrayList<>()); + } variant.getRelatedNotes().addAll(relatedNotes); } - + variantResponse.convertErrorMessagesToMap(); - if (variantResponse.hasErrors()) + if (variantResponse.hasErrors()) { throw new ObjectValidationException(dto, variantResponse.errorMessagesString()); - + } + variant = variantDAO.persist(variant); return variant; } - + private List validateRelatedNotes(Variant variant, VariantDTO dto) { String field = "relatedNotes"; - - if (variant.getRelatedNotes() != null) + + if (variant.getRelatedNotes() != null) { variant.getRelatedNotes().clear(); - + } + List validatedNotes = new ArrayList(); List noteIdentities = new ArrayList(); Boolean allValid = true; @@ -144,15 +148,16 @@ private List validateRelatedNotes(Variant variant, VariantDTO dto) { } } } - + if (!allValid) { variantResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedNotes)) + + if (CollectionUtils.isEmpty(validatedNotes)) { return null; - + } + return validatedNotes; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java index b48d113a7..4441063db 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java @@ -18,9 +18,7 @@ @RequestScoped public class EvidenceAssociationDTOValidator extends BaseDTOValidator { - @Inject - InformationContentEntityService informationContentEntityService; - + @Inject InformationContentEntityService informationContentEntityService; public ObjectResponse validateEvidenceAssociationDTO(E association, D dto) { ObjectResponse assocResponse = validateAuditedObjectDTO(association, dto); @@ -42,7 +40,7 @@ public ObjectR } assocResponse.setEntity(association); - + return assocResponse; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java index 172bc2595..032533ded 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java @@ -26,18 +26,14 @@ @RequestScoped public class AlleleGeneAssociationDTOValidator extends AlleleGenomicEntityAssociationDTOValidator { - @Inject - AlleleGeneAssociationDAO alleleGeneAssociationDAO; - @Inject - AlleleService alleleService; - @Inject - GeneService geneService; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AlleleGeneAssociationDAO alleleGeneAssociationDAO; + @Inject AlleleService alleleService; + @Inject GeneService geneService; + @Inject VocabularyTermService vocabularyTermService; public AlleleGeneAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ObjectValidationException { ObjectResponse agaResponse = new ObjectResponse(); - + Allele subject = null; if (StringUtils.isBlank(dto.getAlleleIdentifier())) { agaResponse.addErrorMessage("allele_identifier", ValidationConstants.REQUIRED_MESSAGE); @@ -49,7 +45,7 @@ public AlleleGeneAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociat agaResponse.addErrorMessage("allele_identifier", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load (" + dto.getAlleleIdentifier() + ")"); } } - + Gene object = null; if (StringUtils.isBlank(dto.getGeneIdentifier())) { agaResponse.addErrorMessage("gene_identifier", ValidationConstants.REQUIRED_MESSAGE); @@ -61,43 +57,46 @@ public AlleleGeneAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociat agaResponse.addErrorMessage("gene_identifier", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load (" + dto.getGeneIdentifier() + ")"); } } - + AlleleGeneAssociation association = null; if (subject != null && object != null && StringUtils.isNotBlank(dto.getRelationName())) { HashMap params = new HashMap<>(); params.put("alleleAssociationSubject.id", subject.getId()); params.put("relation.name", dto.getRelationName()); params.put("alleleGeneAssociationObject.id", object.getId()); - + SearchResponse searchResponse = alleleGeneAssociationDAO.findByParams(params); if (searchResponse != null && searchResponse.getResults().size() == 1) { association = searchResponse.getSingleResult(); } } - if (association == null) + if (association == null) { association = new AlleleGeneAssociation(); - + } + association.setAlleleAssociationSubject(subject); association.setAlleleGeneAssociationObject(object); - + ObjectResponse ageaResponse = validateAlleleGenomicEntityAssociationDTO(association, dto); agaResponse.addErrorMessages(ageaResponse.getErrorMessages()); association = (AlleleGeneAssociation) ageaResponse.getEntity(); if (StringUtils.isNotEmpty(dto.getRelationName())) { VocabularyTerm relation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ALLELE_GENE_RELATION_VOCABULARY_TERM_SET, dto.getRelationName()).getEntity(); - if (relation == null) + if (relation == null) { agaResponse.addErrorMessage("relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getRelationName() + ")"); + } association.setRelation(relation); } else { agaResponse.addErrorMessage("relation_name", ValidationConstants.REQUIRED_MESSAGE); } - - if (agaResponse.hasErrors()) + + if (agaResponse.hasErrors()) { throw new ObjectValidationException(dto, agaResponse.errorMessagesString()); - + } + association = alleleGeneAssociationDAO.persist(association); - - return association; + + return association; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java index 1793d46ab..ac01f03cd 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java @@ -19,10 +19,8 @@ @RequestScoped public class AlleleGenomicEntityAssociationDTOValidator extends EvidenceAssociationDTOValidator { - @Inject - NoteDTOValidator noteDtoValidator; - @Inject - EcoTermService ecoTermService; + @Inject NoteDTOValidator noteDtoValidator; + @Inject EcoTermService ecoTermService; public ObjectResponse validateAlleleGenomicEntityAssociationDTO(E association, D dto) { ObjectResponse assocResponse = validateEvidenceAssociationDTO(association, dto); @@ -40,7 +38,7 @@ public noteResponse = noteDtoValidator.validateNoteDTO(dto.getNoteDto(), VocabularyConstants.ALLELE_GENOMIC_ENTITY_ASSOCIATION_NOTE_TYPES_VOCABULARY_TERM_SET); if (noteResponse.hasErrors()) { @@ -51,9 +49,9 @@ public assocResponse; - + public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociationDTO(ConstructGenomicEntityAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ObjectValidationException { - + assocResponse = new ObjectResponse(); - + Construct construct = null; if (StringUtils.isNotBlank(dto.getConstructIdentifier())) { ObjectResponse constructResponse = constructService.getByIdentifier(dto.getConstructIdentifier()); @@ -56,74 +51,81 @@ public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociati assocResponse.addErrorMessage("construct_identifier", ValidationConstants.INVALID_MESSAGE); } else { construct = constructResponse.getEntity(); - if (beDataProvider != null && !construct.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) + if (beDataProvider != null && !construct.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) { assocResponse.addErrorMessage("construct_identifier", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load"); + } } } else { assocResponse.addErrorMessage("construct_identifier", ValidationConstants.REQUIRED_MESSAGE); } - + GenomicEntity genomicEntity = null; if (StringUtils.isBlank(dto.getGenomicEntityIdentifier())) { assocResponse.addErrorMessage("genomic_entity_identifier", ValidationConstants.REQUIRED_MESSAGE); } else { genomicEntity = genomicEntityService.findByIdentifierString(dto.getGenomicEntityIdentifier()); - if (genomicEntity == null) + if (genomicEntity == null) { assocResponse.addErrorMessage("genomic_entity_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGenomicEntityIdentifier() + ")"); + } } - + ConstructGenomicEntityAssociation association = null; if (construct != null && StringUtils.isNotBlank(dto.getGenomicEntityRelationName()) && genomicEntity != null) { HashMap params = new HashMap<>(); params.put("constructAssociationSubject.id", construct.getId()); params.put("relation.name", dto.getGenomicEntityRelationName()); params.put("constructGenomicEntityAssociationObject.id", genomicEntity.getId()); - + SearchResponse searchResponse = constructGenomicEntityAssociationDAO.findByParams(params); if (searchResponse != null && searchResponse.getResults().size() == 1) { association = searchResponse.getSingleResult(); } } - if (association == null) + if (association == null) { association = new ConstructGenomicEntityAssociation(); - + } + association.setConstructAssociationSubject(construct); association.setConstructGenomicEntityAssociationObject(genomicEntity); - + ObjectResponse eviResponse = validateEvidenceAssociationDTO(association, dto); assocResponse.addErrorMessages(eviResponse.getErrorMessages()); association = eviResponse.getEntity(); - + if (StringUtils.isNotEmpty(dto.getGenomicEntityRelationName())) { VocabularyTerm relation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, dto.getGenomicEntityRelationName()).getEntity(); - if (relation == null) + if (relation == null) { assocResponse.addErrorMessage("genomic_entity_relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGenomicEntityRelationName() + ")"); + } association.setRelation(relation); } else { assocResponse.addErrorMessage("genomic_entity_relation_name", ValidationConstants.REQUIRED_MESSAGE); } - + List relatedNotes = validateRelatedNotes(association, dto); if (relatedNotes != null) { - if (association.getRelatedNotes() == null) + if (association.getRelatedNotes() == null) { association.setRelatedNotes(new ArrayList<>()); + } association.getRelatedNotes().addAll(relatedNotes); } - - if (assocResponse.hasErrors()) + + if (assocResponse.hasErrors()) { throw new ObjectValidationException(dto, assocResponse.errorMessagesString()); + } association = constructGenomicEntityAssociationDAO.persist(association); - + return association; } - + private List validateRelatedNotes(ConstructGenomicEntityAssociation association, ConstructGenomicEntityAssociationDTO dto) { String field = "relatedNotes"; - - if (association.getRelatedNotes() != null) + + if (association.getRelatedNotes() != null) { association.getRelatedNotes().clear(); - + } + List validatedNotes = new ArrayList(); List noteIdentities = new ArrayList(); Boolean allValid = true; @@ -142,15 +144,16 @@ private List validateRelatedNotes(ConstructGenomicEntityAssociation associ } } } - + if (!allValid) { assocResponse.convertMapToErrorMessages(field); return null; } - - if (CollectionUtils.isEmpty(validatedNotes)) + + if (CollectionUtils.isEmpty(validatedNotes)) { return null; - + } + return validatedNotes; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/base/BaseDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/base/BaseDTOValidator.java index d9476b1cd..1651b1ae6 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/base/BaseDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/base/BaseDTOValidator.java @@ -40,46 +40,38 @@ @RequestScoped public class BaseDTOValidator { - @Inject - PersonService personService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - DataProviderService dataProviderService; - @Inject - DataProviderDTOValidator dataProviderDtoValidator; - @Inject - DataProviderDAO dataProviderDAO; - @Inject - CrossReferenceDTOValidator crossReferenceDtoValidator; - @Inject - CrossReferenceService crossReferenceService; - @Inject - MiTermService miTermService; - + @Inject PersonService personService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject DataProviderService dataProviderService; + @Inject DataProviderDTOValidator dataProviderDtoValidator; + @Inject DataProviderDAO dataProviderDAO; + @Inject CrossReferenceDTOValidator crossReferenceDtoValidator; + @Inject CrossReferenceService crossReferenceService; + @Inject MiTermService miTermService; + protected HashMap miCurieCache = new HashMap<>(); protected HashMap miTermCache = new HashMap<>(); - + protected String getCurieFromCache(String psiMiFormat) { - if(miCurieCache.containsKey(psiMiFormat)) { + if (miCurieCache.containsKey(psiMiFormat)) { return miCurieCache.get(psiMiFormat); } else { String curie = InteractionStringHelper.extractCurieFromPsiMiFormat(psiMiFormat); - if(curie != null) { + if (curie != null) { miCurieCache.put(psiMiFormat, curie); return curie; } } return null; } - + protected MITerm getTermFromCache(String curie) { - if(miTermCache.containsKey(curie)) { + if (miTermCache.containsKey(curie)) { return miTermCache.get(curie); } else { - if(curie != null) { + if (curie != null) { MITerm miTerm = miTermService.findByCurie(curie); - if(miTerm != null) { + if (miTerm != null) { miTermCache.put(curie, miTerm); return miTerm; } @@ -93,23 +85,27 @@ public ObjectResponse v ObjectResponse response = new ObjectResponse(); Person createdBy = null; - if (StringUtils.isNotBlank(dto.getCreatedByCurie())) + if (StringUtils.isNotBlank(dto.getCreatedByCurie())) { createdBy = personService.fetchByUniqueIdOrCreate(dto.getCreatedByCurie()); + } entity.setCreatedBy(createdBy); Person updatedBy = null; - if (StringUtils.isNotBlank(dto.getUpdatedByCurie())) + if (StringUtils.isNotBlank(dto.getUpdatedByCurie())) { updatedBy = personService.fetchByUniqueIdOrCreate(dto.getUpdatedByCurie()); + } entity.setUpdatedBy(updatedBy); - Boolean internal = dto instanceof NoteDTO ? true : false; - if (dto.getInternal() != null) + Boolean internal = dto instanceof NoteDTO; + if (dto.getInternal() != null) { internal = dto.getInternal(); + } entity.setInternal(internal); Boolean obsolete = false; - if (dto.getObsolete() != null) + if (dto.getObsolete() != null) { obsolete = dto.getObsolete(); + } entity.setObsolete(obsolete); OffsetDateTime dateUpdated = null; @@ -152,13 +148,12 @@ public ObjectRespons if (taxonResponse.getEntity() == null) { beResponse.addErrorMessage("taxon_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getTaxonCurie() + ")"); } - if (beDataProvider != null && (beDataProvider.name().equals("RGD") || beDataProvider.name().equals("HUMAN")) && - !taxonResponse.getEntity().getCurie().equals(beDataProvider.canonicalTaxonCurie)) { + if (beDataProvider != null && (beDataProvider.name().equals("RGD") || beDataProvider.name().equals("HUMAN")) && !taxonResponse.getEntity().getCurie().equals(beDataProvider.canonicalTaxonCurie)) { beResponse.addErrorMessage("taxon_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getTaxonCurie() + ") for " + beDataProvider.name() + " load"); } entity.setTaxon(taxonResponse.getEntity()); } - + if (dto.getDataProviderDto() == null) { beResponse.addErrorMessage("data_provider_dto", ValidationConstants.REQUIRED_MESSAGE); } else { @@ -167,13 +162,12 @@ public ObjectRespons beResponse.addErrorMessage("data_provider_dto", dpResponse.errorMessagesString()); } else { if (beDataProvider != null && !dpResponse.getEntity().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) { - beResponse.addErrorMessage("data_provider_dto - source_organization_dto - abbreviation", ValidationConstants.INVALID_MESSAGE + - " (" + dpResponse.getEntity().getSourceOrganization().getAbbreviation() + ") for " + beDataProvider.name() + " load"); + beResponse.addErrorMessage("data_provider_dto - source_organization_dto - abbreviation", ValidationConstants.INVALID_MESSAGE + " (" + dpResponse.getEntity().getSourceOrganization().getAbbreviation() + ") for " + beDataProvider.name() + " load"); } entity.setDataProvider(dataProviderDAO.persist(dpResponse.getEntity())); } } - + beResponse.setEntity(entity); return beResponse; @@ -186,7 +180,7 @@ public ObjectResponse v ObjectResponse beResponse = validateBiologicalEntityDTO(entity, dto, dataProvider); geResponse.addErrorMessages(beResponse.getErrorMessages()); entity = beResponse.getEntity(); - + List validatedXrefs = new ArrayList<>(); if (CollectionUtils.isNotEmpty(dto.getCrossReferenceDtos())) { for (CrossReferenceDTO xrefDto : dto.getCrossReferenceDtos()) { @@ -199,14 +193,16 @@ public ObjectResponse v } } } - + List xrefs = crossReferenceService.getUpdatedXrefList(validatedXrefs, entity.getCrossReferences()); - - if (entity.getCrossReferences() != null) + + if (entity.getCrossReferences() != null) { entity.getCrossReferences().clear(); + } if (xrefs != null) { - if (entity.getCrossReferences() == null) + if (entity.getCrossReferences() == null) { entity.setCrossReferences(new ArrayList<>()); + } entity.getCrossReferences().addAll(xrefs); } @@ -214,18 +210,20 @@ public ObjectResponse v return geResponse; } - + public String handleStringField(String string) { - if (StringUtils.isNotBlank(string)) + if (StringUtils.isNotBlank(string)) { return string; - + } + return null; } - + public List handleStringListField(List list) { - if (CollectionUtils.isEmpty(list)) + if (CollectionUtils.isEmpty(list)) { return null; - + } + return list; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java index 0cb431145..5a94987b9 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java @@ -28,62 +28,61 @@ @RequestScoped public class AGMPhenotypeAnnotationFmsDTOValidator extends PhenotypeAnnotationFmsDTOValidator { - @Inject - AGMPhenotypeAnnotationDAO agmPhenotypeAnnotationDAO; - @Inject - GenomicEntityService genomicEntityService; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; - + @Inject AGMPhenotypeAnnotationDAO agmPhenotypeAnnotationDAO; + @Inject GenomicEntityService genomicEntityService; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; + public AGMPhenotypeAnnotation validatePrimaryAnnotation(AffectedGenomicModel subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { ObjectResponse apaResponse = new ObjectResponse(); AGMPhenotypeAnnotation annotation = new AGMPhenotypeAnnotation(); - + ObjectResponse refResponse = validateReference(dto); apaResponse.addErrorMessages(refResponse.getErrorMessages()); - + Reference reference = refResponse.getEntity(); String refString = reference == null ? null : reference.getCurie(); - + String uniqueId = AnnotationUniqueIdHelper.getPhenotypeAnnotationUniqueId(dto, subject.getIdentifier(), refString); SearchResponse annotationSearch = agmPhenotypeAnnotationDAO.findByField("uniqueId", uniqueId); - if (annotationSearch != null && annotationSearch.getSingleResult() != null) + if (annotationSearch != null && annotationSearch.getSingleResult() != null) { annotation = annotationSearch.getSingleResult(); + } annotation.setUniqueId(uniqueId); annotation.setSingleReference(reference); annotation.setPhenotypeAnnotationSubject(subject); - + // Reset implied/asserted fields as secondary annotations loaded separately annotation.setAssertedAllele(null); annotation.setAssertedGenes(null); annotation.setInferredAllele(null); annotation.setInferredGene(null); - + ObjectResponse paResponse = validatePhenotypeAnnotation(annotation, dto, dataProvider); apaResponse.addErrorMessages(paResponse.getErrorMessages()); annotation = paResponse.getEntity(); - - if (apaResponse.hasErrors()) + + if (apaResponse.hasErrors()) { throw new ObjectValidationException(dto, apaResponse.errorMessagesString()); - + } + return annotation; } public AGMPhenotypeAnnotation validateInferredOrAssertedEntities(AffectedGenomicModel primaryAnnotationSubject, PhenotypeFmsDTO dto, List idsAdded, BackendBulkDataProvider dataProvider) throws ObjectValidationException { ObjectResponse apaResponse = new ObjectResponse(); - + ObjectResponse refResponse = validateReference(dto); apaResponse.addErrorMessages(refResponse.getErrorMessages()); - + Reference reference = refResponse.getEntity(); String refString = reference == null ? null : reference.getCurie(); - + String primaryAnnotationUniqueId = AnnotationUniqueIdHelper.getPhenotypeAnnotationUniqueId(dto, primaryAnnotationSubject.getIdentifier(), refString); AGMPhenotypeAnnotation primaryAnnotation = null; - + SearchResponse annotationSearch = agmPhenotypeAnnotationDAO.findByField("uniqueId", primaryAnnotationUniqueId); if (annotationSearch == null || annotationSearch.getSingleResult() == null) { PhenotypeFmsDTO inferredPrimaryDTO = createPrimaryAnnotationDTO(dto, primaryAnnotationSubject.getIdentifier()); @@ -98,7 +97,7 @@ public AGMPhenotypeAnnotation validateInferredOrAssertedEntities(AffectedGenomic } else { primaryAnnotation = annotationSearch.getSingleResult(); } - + if (StringUtils.isBlank(dto.getObjectId())) { apaResponse.addErrorMessage("objectId", ValidationConstants.REQUIRED_MESSAGE); } else { @@ -110,13 +109,14 @@ public AGMPhenotypeAnnotation validateInferredOrAssertedEntities(AffectedGenomic primaryAnnotation.setInferredGene((Gene) inferredOrAssertedEntity); } else if (dataProvider.hasAssertedGenePhenotypeAnnotations) { List assertedGenes = primaryAnnotation.getAssertedGenes(); - if (assertedGenes == null) + if (assertedGenes == null) { assertedGenes = new ArrayList<>(); + } assertedGenes.add((Gene) inferredOrAssertedEntity); primaryAnnotation.setAssertedGenes(assertedGenes); } else { apaResponse.addErrorMessage("objectId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getObjectId() + ")"); - } + } } else if (inferredOrAssertedEntity instanceof Allele) { if (dataProvider.hasInferredAllelePhenotypeAnnotations) { primaryAnnotation.setInferredAllele((Allele) inferredOrAssertedEntity); @@ -129,23 +129,24 @@ public AGMPhenotypeAnnotation validateInferredOrAssertedEntities(AffectedGenomic apaResponse.addErrorMessage("objectId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getObjectId() + ")"); } } - - if (apaResponse.hasErrors()) + + if (apaResponse.hasErrors()) { throw new ObjectValidationException(dto, apaResponse.errorMessagesString()); - + } + return primaryAnnotation; } - + private PhenotypeFmsDTO createPrimaryAnnotationDTO(PhenotypeFmsDTO dto, String primarySubjectId) { PhenotypeFmsDTO primaryAnnotationDTO = new PhenotypeFmsDTO(); - + primaryAnnotationDTO.setObjectId(primarySubjectId); primaryAnnotationDTO.setPhenotypeStatement(dto.getPhenotypeStatement()); primaryAnnotationDTO.setPhenotypeTermIdentifiers(dto.getPhenotypeTermIdentifiers()); primaryAnnotationDTO.setEvidence(dto.getEvidence()); primaryAnnotationDTO.setDateAssigned(dto.getDateAssigned()); primaryAnnotationDTO.setConditionRelations(dto.getConditionRelations()); - + return primaryAnnotationDTO; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java index cd239c294..f9496b228 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java @@ -26,61 +26,60 @@ @RequestScoped public class AllelePhenotypeAnnotationFmsDTOValidator extends PhenotypeAnnotationFmsDTOValidator { - - @Inject - AllelePhenotypeAnnotationDAO allelePhenotypeAnnotationDAO; - @Inject - GenomicEntityService genomicEntityService; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; - + + @Inject AllelePhenotypeAnnotationDAO allelePhenotypeAnnotationDAO; + @Inject GenomicEntityService genomicEntityService; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; + public AllelePhenotypeAnnotation validatePrimaryAnnotation(Allele subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { ObjectResponse apaResponse = new ObjectResponse(); AllelePhenotypeAnnotation annotation = new AllelePhenotypeAnnotation(); - + ObjectResponse refResponse = validateReference(dto); apaResponse.addErrorMessages(refResponse.getErrorMessages()); - + Reference reference = refResponse.getEntity(); String refString = reference == null ? null : reference.getCurie(); - + String uniqueId = AnnotationUniqueIdHelper.getPhenotypeAnnotationUniqueId(dto, subject.getIdentifier(), refString); SearchResponse annotationSearch = allelePhenotypeAnnotationDAO.findByField("uniqueId", uniqueId); - if (annotationSearch != null && annotationSearch.getSingleResult() != null) + if (annotationSearch != null && annotationSearch.getSingleResult() != null) { annotation = annotationSearch.getSingleResult(); + } annotation.setUniqueId(uniqueId); annotation.setSingleReference(reference); annotation.setPhenotypeAnnotationSubject(subject); - + // Reset implied/asserted fields as secondary annotations loaded separately annotation.setAssertedGenes(null); annotation.setInferredGene(null); - + ObjectResponse paResponse = validatePhenotypeAnnotation(annotation, dto, dataProvider); apaResponse.addErrorMessages(paResponse.getErrorMessages()); annotation = paResponse.getEntity(); - - if (apaResponse.hasErrors()) + + if (apaResponse.hasErrors()) { throw new ObjectValidationException(dto, apaResponse.errorMessagesString()); - + } + return annotation; } public AllelePhenotypeAnnotation validateInferredOrAssertedEntities(Allele primaryAnnotationSubject, PhenotypeFmsDTO dto, List idsAdded, BackendBulkDataProvider dataProvider) throws ObjectValidationException { ObjectResponse apaResponse = new ObjectResponse(); - + ObjectResponse refResponse = validateReference(dto); apaResponse.addErrorMessages(refResponse.getErrorMessages()); - + Reference reference = refResponse.getEntity(); String refString = reference == null ? null : reference.getCurie(); - + String primaryAnnotationUniqueId = AnnotationUniqueIdHelper.getPhenotypeAnnotationUniqueId(dto, primaryAnnotationSubject.getIdentifier(), refString); AllelePhenotypeAnnotation primaryAnnotation = null; - + SearchResponse annotationSearch = allelePhenotypeAnnotationDAO.findByField("uniqueId", primaryAnnotationUniqueId); if (annotationSearch == null || annotationSearch.getSingleResult() == null) { PhenotypeFmsDTO inferredPrimaryDTO = createPrimaryAnnotationDTO(dto, primaryAnnotationSubject.getIdentifier()); @@ -95,7 +94,7 @@ public AllelePhenotypeAnnotation validateInferredOrAssertedEntities(Allele prima } else { primaryAnnotation = annotationSearch.getSingleResult(); } - + if (StringUtils.isBlank(dto.getObjectId())) { apaResponse.addErrorMessage("objectId", ValidationConstants.REQUIRED_MESSAGE); } else { @@ -107,34 +106,36 @@ public AllelePhenotypeAnnotation validateInferredOrAssertedEntities(Allele prima primaryAnnotation.setInferredGene((Gene) inferredOrAssertedEntity); } else if (dataProvider.hasAssertedGenePhenotypeAnnotations) { List assertedGenes = primaryAnnotation.getAssertedGenes(); - if (assertedGenes == null) + if (assertedGenes == null) { assertedGenes = new ArrayList<>(); + } assertedGenes.add((Gene) inferredOrAssertedEntity); primaryAnnotation.setAssertedGenes(assertedGenes); } else { apaResponse.addErrorMessage("objectId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getObjectId() + ")"); - } + } } else { apaResponse.addErrorMessage("objectId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getObjectId() + ")"); } } - - if (apaResponse.hasErrors()) + + if (apaResponse.hasErrors()) { throw new ObjectValidationException(dto, apaResponse.errorMessagesString()); - + } + return primaryAnnotation; } - + private PhenotypeFmsDTO createPrimaryAnnotationDTO(PhenotypeFmsDTO dto, String primarySubjectId) { PhenotypeFmsDTO primaryAnnotationDTO = new PhenotypeFmsDTO(); - + primaryAnnotationDTO.setObjectId(primarySubjectId); primaryAnnotationDTO.setPhenotypeStatement(dto.getPhenotypeStatement()); primaryAnnotationDTO.setPhenotypeTermIdentifiers(dto.getPhenotypeTermIdentifiers()); primaryAnnotationDTO.setEvidence(dto.getEvidence()); primaryAnnotationDTO.setDateAssigned(dto.getDateAssigned()); primaryAnnotationDTO.setConditionRelations(dto.getConditionRelations()); - + return primaryAnnotationDTO; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ConditionRelationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ConditionRelationFmsDTOValidator.java index 7cb574270..633b445a3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ConditionRelationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ConditionRelationFmsDTOValidator.java @@ -25,28 +25,25 @@ @RequestScoped public class ConditionRelationFmsDTOValidator { - - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - ExperimentalConditionDAO experimentalConditionDAO; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - ExperimentalConditionFmsDTOValidator experimentalConditionFmsDtoValidator; - public ObjectResponse validateConditionRelationFmsDTO (ConditionRelationFmsDTO dto) { + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject ExperimentalConditionDAO experimentalConditionDAO; + @Inject VocabularyTermService vocabularyTermService; + @Inject ExperimentalConditionFmsDTOValidator experimentalConditionFmsDtoValidator; + + public ObjectResponse validateConditionRelationFmsDTO(ConditionRelationFmsDTO dto) { ObjectResponse crResponse = new ObjectResponse<>(); - + ConditionRelation relation; ConditionRelationFmsEnum fmsConditionRelation = null; - + if (StringUtils.isBlank(dto.getConditionRelationType())) { crResponse.addErrorMessage("conditionRelationType", ValidationConstants.REQUIRED_MESSAGE); } else { fmsConditionRelation = ConditionRelationFmsEnum.findByName(dto.getConditionRelationType()); - if (fmsConditionRelation == null) + if (fmsConditionRelation == null) { crResponse.addErrorMessage("conditionRelationType", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionRelationType() + ")"); + } } String relationTypeString = fmsConditionRelation == null ? null : fmsConditionRelation.agrRelation; @@ -59,14 +56,15 @@ public ObjectResponse validateConditionRelationFmsDTO (Condit } else { relation = searchResponseRel.getSingleResult(); } - + if (relationTypeString != null) { VocabularyTerm conditionRelationTypeTerm = vocabularyTermService.getTermInVocabulary(VocabularyConstants.CONDITION_RELATION_TYPE_VOCABULARY, relationTypeString).getEntity(); - if (conditionRelationTypeTerm == null) + if (conditionRelationTypeTerm == null) { crResponse.addErrorMessage("conditionRelationType", ValidationConstants.INVALID_MESSAGE + " (" + relationTypeString + ")"); + } relation.setConditionRelationType(conditionRelationTypeTerm); } - + List conditions = new ArrayList<>(); if (CollectionUtils.isEmpty(dto.getConditions())) { crResponse.addErrorMessage("conditions", ValidationConstants.REQUIRED_MESSAGE); @@ -81,9 +79,9 @@ public ObjectResponse validateConditionRelationFmsDTO (Condit } } relation.setConditions(conditions); - + crResponse.setEntity(relation); - + return crResponse; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ExperimentalConditionFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ExperimentalConditionFmsDTOValidator.java index 10e7a0227..20022836f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ExperimentalConditionFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ExperimentalConditionFmsDTOValidator.java @@ -28,25 +28,18 @@ @RequestScoped public class ExperimentalConditionFmsDTOValidator { - - @Inject - ExperimentalConditionDAO experimentalConditionDAO; - @Inject - ZecoTermService zecoTermService; - @Inject - ChemicalTermService chemicalTermService; - @Inject - AnatomicalTermService anatomicalTermService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - GoTermService goTermService; - @Inject - ExperimentalConditionOntologyTermService experimentalConditionOntologyTermService; - - public ObjectResponse validateExperimentalConditionFmsDTO (ExperimentalConditionFmsDTO dto) { + + @Inject ExperimentalConditionDAO experimentalConditionDAO; + @Inject ZecoTermService zecoTermService; + @Inject ChemicalTermService chemicalTermService; + @Inject AnatomicalTermService anatomicalTermService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject GoTermService goTermService; + @Inject ExperimentalConditionOntologyTermService experimentalConditionOntologyTermService; + + public ObjectResponse validateExperimentalConditionFmsDTO(ExperimentalConditionFmsDTO dto) { ObjectResponse ecResponse = new ObjectResponse<>(); - + String uniqueId = AnnotationUniqueIdHelper.getExperimentalConditionUniqueId(dto); ExperimentalCondition experimentalCondition; @@ -61,16 +54,18 @@ public ObjectResponse validateExperimentalConditionFmsDTO ChemicalTerm conditionChemical = null; if (StringUtils.isNotBlank(dto.getChemicalOntologyId())) { conditionChemical = chemicalTermService.findByCurieOrSecondaryId(dto.getChemicalOntologyId()); - if (conditionChemical == null) + if (conditionChemical == null) { ecResponse.addErrorMessage("chemicalOntologyId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getChemicalOntologyId() + ")"); + } } experimentalCondition.setConditionChemical(conditionChemical); ExperimentalConditionOntologyTerm conditionId = null; if (StringUtils.isNotBlank(dto.getConditionId())) { conditionId = experimentalConditionOntologyTermService.findByCurieOrSecondaryId(dto.getConditionId()); - if (conditionId == null) + if (conditionId == null) { ecResponse.addErrorMessage("conditionId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionId() + ")"); + } } experimentalCondition.setConditionId(conditionId); @@ -78,8 +73,8 @@ public ObjectResponse validateExperimentalConditionFmsDTO ZECOTerm term = zecoTermService.findByCurieOrSecondaryId(dto.getConditionClassId()); if (term == null) { ecResponse.addErrorMessage("conditionClassId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionClassId() + ") not found"); - } else if(term.getSubsets().isEmpty() || !term.getSubsets().contains(OntologyConstants.ZECO_AGR_SLIM_SUBSET)) { - ecResponse.addErrorMessage("conditionClassId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionClassId() + " not part of " + OntologyConstants.ZECO_AGR_SLIM_SUBSET + " subset)"); + } else if (term.getSubsets().isEmpty() || !term.getSubsets().contains(OntologyConstants.ZECO_AGR_SLIM_SUBSET)) { + ecResponse.addErrorMessage("conditionClassId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConditionClassId() + " not part of " + OntologyConstants.ZECO_AGR_SLIM_SUBSET + " subset)"); } else { experimentalCondition.setConditionClass(term); } @@ -90,30 +85,34 @@ public ObjectResponse validateExperimentalConditionFmsDTO AnatomicalTerm conditionAnatomy = null; if (StringUtils.isNotBlank(dto.getAnatomicalOntologyId())) { conditionAnatomy = anatomicalTermService.findByCurieOrSecondaryId(dto.getAnatomicalOntologyId()); - if (conditionAnatomy == null) + if (conditionAnatomy == null) { ecResponse.addErrorMessage("anatomicalOntologyId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAnatomicalOntologyId() + ")"); + } } experimentalCondition.setConditionAnatomy(conditionAnatomy); NCBITaxonTerm conditionTaxon = null; if (StringUtils.isNotBlank(dto.getNcbiTaxonId())) { conditionTaxon = ncbiTaxonTermService.getTaxonFromDB(dto.getNcbiTaxonId()); - if (conditionTaxon == null) + if (conditionTaxon == null) { ecResponse.addErrorMessage("NCBITaxonId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getNcbiTaxonId() + ")"); + } } experimentalCondition.setConditionTaxon(conditionTaxon); GOTerm conditionGeneOntology = null; if (StringUtils.isNotBlank(dto.getGeneOntologyId())) { conditionGeneOntology = goTermService.findByCurieOrSecondaryId(dto.getGeneOntologyId()); - if (conditionGeneOntology == null) + if (conditionGeneOntology == null) { ecResponse.addErrorMessage("geneOntologyId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGeneOntologyId() + ")"); + } } experimentalCondition.setConditionGeneOntology(conditionGeneOntology); String conditionQuantity = null; - if (StringUtils.isNotBlank(dto.getConditionQuantity())) + if (StringUtils.isNotBlank(dto.getConditionQuantity())) { conditionQuantity = dto.getConditionQuantity(); + } experimentalCondition.setConditionQuantity(conditionQuantity); if (StringUtils.isNotBlank(dto.getConditionStatement())) { @@ -123,7 +122,7 @@ public ObjectResponse validateExperimentalConditionFmsDTO } ecResponse.setEntity(experimentalCondition); - + return ecResponse; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java index 9b0f274c4..066ec65dc 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java @@ -26,96 +26,100 @@ @RequestScoped public class GeneGeneticInteractionFmsDTOValidator extends GeneInteractionFmsDTOValidator { - @Inject - GeneGeneticInteractionService geneGeneticInteractionService; - @Inject - AlleleService alleleService; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - InteractionAnnotationsHelper interactionAnnotationsHelper; - + @Inject GeneGeneticInteractionService geneGeneticInteractionService; + @Inject AlleleService alleleService; + @Inject VocabularyTermService vocabularyTermService; + @Inject InteractionAnnotationsHelper interactionAnnotationsHelper; + private ObjectResponse ggiResponse; - + public GeneGeneticInteraction validateGeneGeneticInteractionFmsDTO(PsiMiTabDTO dto) throws ObjectValidationException { GeneGeneticInteraction interaction = null; ggiResponse = new ObjectResponse(); - + ObjectResponse> refResponse = validateReferences(dto); ggiResponse.addErrorMessages(refResponse.getErrorMessages()); - + String interactionId = null; - if (CollectionUtils.isNotEmpty(dto.getInteractionIds())) + if (CollectionUtils.isNotEmpty(dto.getInteractionIds())) { interactionId = PsiMiTabPrefixEnum.getAllianceIdentifier(dto.getInteractionIds().get(0)); - + } + Gene interactorA = null; if (StringUtils.isBlank(dto.getInteractorAIdentifier())) { ggiResponse.addErrorMessage("interactorAIdentifier", ValidationConstants.REQUIRED_MESSAGE); } else { ObjectResponse interactorAResponse = findAllianceGene(dto.getInteractorAIdentifier(), dto.getInteractorATaxonId()); - if (interactorAResponse.hasErrors()) + if (interactorAResponse.hasErrors()) { ggiResponse.addErrorMessage("interactorAIdentifier", interactorAResponse.errorMessagesString()); + } interactorA = interactorAResponse.getEntity(); } - + Gene interactorB = null; if (StringUtils.isBlank(dto.getInteractorBIdentifier())) { ggiResponse.addErrorMessage("interactorBIdentifier", ValidationConstants.REQUIRED_MESSAGE); } else { ObjectResponse interactorBResponse = findAllianceGene(dto.getInteractorBIdentifier(), dto.getInteractorBTaxonId()); - if (interactorBResponse.hasErrors()) + if (interactorBResponse.hasErrors()) { ggiResponse.addErrorMessage("interactorBIdentifier", interactorBResponse.errorMessagesString()); + } interactorB = interactorBResponse.getEntity(); } - + List references = refResponse.getEntity(); - + List phenotypesOrTraits = interactionAnnotationsHelper.extractPhenotypeStatements(dto.getInteractionAnnotations()); - + String uniqueId = InteractionStringHelper.getGeneGeneticInteractionUniqueId(dto, interactorA, interactorB, interactionId, references, phenotypesOrTraits); - + String searchValue = interactionId == null ? uniqueId : interactionId; ObjectResponse interactionResponse = geneGeneticInteractionService.getByIdentifier(searchValue); - if (interactionResponse != null) + if (interactionResponse != null) { interaction = interactionResponse.getEntity(); - if (interaction == null) + } + if (interaction == null) { interaction = new GeneGeneticInteraction(); - + } + interaction.setUniqueId(uniqueId); interaction.setGeneAssociationSubject(interactorA); interaction.setGeneGeneAssociationObject(interactorB); interaction.setInteractionId(interactionId); interaction.setPhenotypesOrTraits(handleStringListField(phenotypesOrTraits)); - + ObjectResponse giResponse = validateGeneInteraction(interaction, dto, references); ggiResponse.addErrorMessages(giResponse.getErrorMessages()); interaction = giResponse.getEntity(); - + interaction.setRelation(vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.GENE_GENETIC_INTERACTION_RELATION_VOCABULARY_TERM_SET, VocabularyConstants.GENE_GENETIC_INTERACTION_RELATION_TERM).getEntity()); - + Allele interactorAGeneticPerturbation = validatePerturbation("interactorAAnnotationString", dto.getInteractorAAnnotationString()); interaction.setInteractorAGeneticPerturbation(interactorAGeneticPerturbation); - + Allele interactorBGeneticPerturbation = validatePerturbation("interactorBAnnotationString", dto.getInteractorBAnnotationString()); interaction.setInteractorBGeneticPerturbation(interactorBGeneticPerturbation); - - if (ggiResponse.hasErrors()) + + if (ggiResponse.hasErrors()) { throw new ObjectValidationException(dto, ggiResponse.getErrorMessages().values()); + } return interaction; } - - private Allele validatePerturbation (String fieldName, String dtoField) { + + private Allele validatePerturbation(String fieldName, String dtoField) { Allele geneticPerturbation = null; String geneticPerturbationCurie = InteractionStringHelper.extractWBVarCurieFromAnnotations(dtoField); - if (geneticPerturbationCurie == null) + if (geneticPerturbationCurie == null) { return null; - + } + geneticPerturbation = alleleService.findByIdentifierString(geneticPerturbationCurie); - if (geneticPerturbation == null) + if (geneticPerturbation == null) { ggiResponse.addErrorMessage(fieldName, ValidationConstants.INVALID_MESSAGE + " (" + geneticPerturbationCurie + ")"); + } return geneticPerturbation; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneInteractionFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneInteractionFmsDTOValidator.java index ba6b04da1..0c822e422 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneInteractionFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneInteractionFmsDTOValidator.java @@ -37,21 +37,16 @@ @RequestScoped public class GeneInteractionFmsDTOValidator extends BaseDTOValidator { - @Inject - ReferenceService referenceService; - @Inject - GeneService geneService; - @Inject - CrossReferenceDAO crossReferenceDAO; - @Inject - InteractionCrossReferenceHelper interactionXrefHelper; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - + @Inject ReferenceService referenceService; + @Inject GeneService geneService; + @Inject CrossReferenceDAO crossReferenceDAO; + @Inject InteractionCrossReferenceHelper interactionXrefHelper; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + public ObjectResponse validateGeneInteraction(E interaction, PsiMiTabDTO dto, List references) { ObjectResponse giResponse = new ObjectResponse(); - + if (CollectionUtils.isNotEmpty(references)) { List evidence = new ArrayList<>(); evidence.addAll(references); @@ -59,7 +54,7 @@ public ObjectResponse validateGeneInteraction(E i } else { interaction.setEvidence(null); } - + // Taxon strings are needed for xref check but don't need to be stored if (StringUtils.isBlank(dto.getInteractorATaxonId())) { giResponse.addErrorMessage("interactorATaxonId", ValidationConstants.REQUIRED_MESSAGE); @@ -67,7 +62,7 @@ public ObjectResponse validateGeneInteraction(E i if (StringUtils.isBlank(dto.getInteractorBTaxonId())) { giResponse.addErrorMessage("interactorBTaxonId", ValidationConstants.REQUIRED_MESSAGE); } - + MITerm interactorARole = null; if (StringUtils.isNotBlank(dto.getExperimentalRoleA())) { interactorARole = getTermFromCache(getCurieFromCache(dto.getExperimentalRoleA())); @@ -76,7 +71,7 @@ public ObjectResponse validateGeneInteraction(E i } } interaction.setInteractorARole(interactorARole); - + MITerm interactorBRole = null; if (StringUtils.isNotBlank(dto.getExperimentalRoleB())) { interactorBRole = getTermFromCache(getCurieFromCache(dto.getExperimentalRoleB())); @@ -85,7 +80,7 @@ public ObjectResponse validateGeneInteraction(E i } } interaction.setInteractorBRole(interactorBRole); - + MITerm interactorAType = null; if (StringUtils.isNotBlank(dto.getInteractorAType())) { interactorAType = getTermFromCache(getCurieFromCache(dto.getInteractorAType())); @@ -96,7 +91,7 @@ public ObjectResponse validateGeneInteraction(E i giResponse.addErrorMessage("interactorAType", ValidationConstants.REQUIRED_MESSAGE); } interaction.setInteractorAType(interactorAType); - + MITerm interactorBType = null; if (StringUtils.isNotBlank(dto.getInteractorBType())) { interactorBType = getTermFromCache(getCurieFromCache(dto.getInteractorBType())); @@ -107,14 +102,14 @@ public ObjectResponse validateGeneInteraction(E i giResponse.addErrorMessage("interactorBType", ValidationConstants.REQUIRED_MESSAGE); } interaction.setInteractorBType(interactorBType); - + MITerm interactionType = null; if (CollectionUtils.isNotEmpty(dto.getInteractionTypes())) { for (String interactionTypeString : dto.getInteractionTypes()) { String interactionTypeCurie = getCurieFromCache(interactionTypeString); if (interactionTypeCurie != null) { interactionType = getTermFromCache(interactionTypeCurie); - if(interactionType == null) { + if (interactionType == null) { giResponse.addErrorMessage("interactionTypes", ValidationConstants.INVALID_MESSAGE + " (" + interactionTypeString + ")"); } break; @@ -125,7 +120,7 @@ public ObjectResponse validateGeneInteraction(E i giResponse.addErrorMessage("interactionType", ValidationConstants.REQUIRED_MESSAGE); } interaction.setInteractionType(interactionType); - + MITerm interactionSource = null; if (CollectionUtils.isNotEmpty(dto.getSourceDatabaseIds())) { for (String interactionSourceString : dto.getSourceDatabaseIds()) { @@ -143,30 +138,32 @@ public ObjectResponse validateGeneInteraction(E i giResponse.addErrorMessage("sourceDatabaseIds", ValidationConstants.REQUIRED_MESSAGE); } interaction.setInteractionSource(interactionSource); - + List xrefs = updateInteractionXrefs(interaction.getCrossReferences(), dto); - if (interaction.getCrossReferences() != null) + if (interaction.getCrossReferences() != null) { interaction.getCrossReferences().clear(); + } if (CollectionUtils.isNotEmpty(xrefs)) { - if (interaction.getCrossReferences() == null) + if (interaction.getCrossReferences() == null) { interaction.setCrossReferences(new ArrayList<>()); + } interaction.getCrossReferences().addAll(xrefs); } - + OffsetDateTime dateCreated = processPsiMiTabDateFormat(dto.getCreationDate()); OffsetDateTime dateUpdated = processPsiMiTabDateFormat(dto.getUpdateDate()); interaction.setDateCreated(dateCreated); interaction.setDateUpdated(dateUpdated); - + interaction.setObsolete(false); interaction.setInternal(false); - + giResponse.setEntity(interaction); return giResponse; } - + protected ObjectResponse findAllianceGene(String psiMiTabIdentifier, String psiMiTabTaxonCurie) { ObjectResponse response = new ObjectResponse<>(); String[] psiMiTabIdParts = psiMiTabIdentifier.split(":"); @@ -174,13 +171,13 @@ protected ObjectResponse findAllianceGene(String psiMiTabIdentifier, Strin response.addErrorMessage("curie", ValidationConstants.INVALID_MESSAGE + " (expecting , got " + psiMiTabIdentifier + ")"); return response; } - + PsiMiTabPrefixEnum prefix = PsiMiTabPrefixEnum.findByPsiMiTabPrefix(psiMiTabIdParts[0]); if (prefix == null) { response.addErrorMessage("curie", ValidationConstants.INVALID_MESSAGE + " (cannot convert prefix " + psiMiTabIdParts[0] + " to Alliance format)"); return response; } - + Gene allianceGene = null; String convertedCurie = prefix.alliancePrefix + ":" + psiMiTabIdParts[1]; if (prefix.isModPrefix) { @@ -196,7 +193,7 @@ protected ObjectResponse findAllianceGene(String psiMiTabIdentifier, Strin response.addErrorMessage("taxon", ValidationConstants.INVALID_MESSAGE + " (" + taxonCurie + " not found)"); return response; } - + SearchResponse searchResponse = geneService.findByField("crossReferences.referencedCurie", convertedCurie); if (searchResponse != null) { // Need to check that returned gene belongs to MOD corresponding to taxon @@ -209,22 +206,24 @@ protected ObjectResponse findAllianceGene(String psiMiTabIdentifier, Strin } } } - if (allianceGene == null) + if (allianceGene == null) { response.addErrorMessage("curie", ValidationConstants.INVALID_MESSAGE + " (" + convertedCurie + " not found)"); + } response.setEntity(allianceGene); - + return response; } - + protected ObjectResponse> validateReferences(PsiMiTabDTO dto) { ObjectResponse> refResponse = new ObjectResponse<>(); List validatedReferences = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(dto.getPublicationIds())) { + if (CollectionUtils.isNotEmpty(dto.getPublicationIds())) { for (String publicationId : dto.getPublicationIds()) { Reference reference = null; String alliancePubXrefCurie = PsiMiTabPrefixEnum.getAllianceIdentifier(publicationId); - if (alliancePubXrefCurie != null) + if (alliancePubXrefCurie != null) { reference = referenceService.retrieveFromDbOrLiteratureService(alliancePubXrefCurie); + } if (reference == null) { refResponse.addErrorMessage("publicationIds", ValidationConstants.INVALID_MESSAGE + " (" + publicationId + ")"); return refResponse; @@ -232,21 +231,23 @@ protected ObjectResponse> validateReferences(PsiMiTabDTO dto) { validatedReferences.add(reference); } } - if (CollectionUtils.isNotEmpty(validatedReferences)) + if (CollectionUtils.isNotEmpty(validatedReferences)) { refResponse.setEntity(validatedReferences); - + } + return refResponse; } - + private List updateInteractionXrefs(List existingXrefs, PsiMiTabDTO dto) { List newXrefs = interactionXrefHelper.createAllianceXrefs(dto); - if (CollectionUtils.isEmpty(newXrefs)) + if (CollectionUtils.isEmpty(newXrefs)) { return null; - if (CollectionUtils.isEmpty(existingXrefs)) + } + if (CollectionUtils.isEmpty(existingXrefs)) { return newXrefs; - - Map existingXrefMap = existingXrefs.stream() - .collect(Collectors.toMap(CrossReference::getReferencedCurie, Function.identity())); + } + + Map existingXrefMap = existingXrefs.stream().collect(Collectors.toMap(CrossReference::getReferencedCurie, Function.identity())); List updatedXrefs = new ArrayList<>(); for (CrossReference newXref : newXrefs) { if (existingXrefMap.containsKey(newXref.getReferencedCurie())) { @@ -255,13 +256,14 @@ private List updateInteractionXrefs(List existin updatedXrefs.add(crossReferenceDAO.persist(newXref)); } } - + return updatedXrefs; } - + private OffsetDateTime processPsiMiTabDateFormat(String dateString) { - if (StringUtils.isBlank(dateString)) + if (StringUtils.isBlank(dateString)) { return null; + } DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME; dateString = dateString.replace("/", "-"); return OffsetDateTime.parse(dateString + "T00:00:00+00:00", dtf); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java index 398132eaf..f9dd46b46 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java @@ -25,83 +25,86 @@ @RequestScoped public class GeneMolecularInteractionFmsDTOValidator extends GeneInteractionFmsDTOValidator { - @Inject - GeneMolecularInteractionService geneMolecularInteractionService; - @Inject - GenomicEntityService genomicEntityService; - @Inject - VocabularyTermService vocabularyTermService; - + @Inject GeneMolecularInteractionService geneMolecularInteractionService; + @Inject GenomicEntityService genomicEntityService; + @Inject VocabularyTermService vocabularyTermService; + private ObjectResponse gmiResponse; public GeneMolecularInteraction validateGeneMolecularInteractionFmsDTO(PsiMiTabDTO dto) throws ObjectValidationException { GeneMolecularInteraction interaction = null; gmiResponse = new ObjectResponse(); - + ObjectResponse> refResponse = validateReferences(dto); gmiResponse.addErrorMessages(refResponse.getErrorMessages()); - + String interactionId = null; - if (CollectionUtils.isNotEmpty(dto.getInteractionIds())) + if (CollectionUtils.isNotEmpty(dto.getInteractionIds())) { interactionId = PsiMiTabPrefixEnum.getAllianceIdentifier(dto.getInteractionIds().get(0)); - + } + Gene interactorA = null; if (StringUtils.isBlank(dto.getInteractorAIdentifier())) { gmiResponse.addErrorMessage("interactorAIdentifier", ValidationConstants.REQUIRED_MESSAGE); } else { ObjectResponse interactorAResponse = findAllianceGene(dto.getInteractorAIdentifier(), dto.getInteractorATaxonId()); - if (interactorAResponse.hasErrors()) + if (interactorAResponse.hasErrors()) { gmiResponse.addErrorMessage("interactorAIdentifier", interactorAResponse.errorMessagesString()); + } interactorA = interactorAResponse.getEntity(); } - + Gene interactorB = null; if (StringUtils.isBlank(dto.getInteractorBIdentifier())) { gmiResponse.addErrorMessage("interactorBIdentifier", ValidationConstants.REQUIRED_MESSAGE); } else { ObjectResponse interactorBResponse = findAllianceGene(dto.getInteractorBIdentifier(), dto.getInteractorBTaxonId()); - if (interactorBResponse.hasErrors()) + if (interactorBResponse.hasErrors()) { gmiResponse.addErrorMessage("interactorBIdentifier", interactorBResponse.errorMessagesString()); + } interactorB = interactorBResponse.getEntity(); } - + List references = refResponse.getEntity(); - + String uniqueId = InteractionStringHelper.getGeneMolecularInteractionUniqueId(dto, interactorA, interactorB, interactionId, references); - + String searchValue = interactionId == null ? uniqueId : interactionId; ObjectResponse interactionResponse = geneMolecularInteractionService.getByIdentifier(searchValue); - if (interactionResponse != null) + if (interactionResponse != null) { interaction = interactionResponse.getEntity(); - if (interaction == null) + } + if (interaction == null) { interaction = new GeneMolecularInteraction(); - + } + interaction.setUniqueId(uniqueId); interaction.setGeneAssociationSubject(interactorA); interaction.setGeneGeneAssociationObject(interactorB); interaction.setInteractionId(interactionId); - + ObjectResponse giResponse = validateGeneInteraction(interaction, dto, references); gmiResponse.addErrorMessages(giResponse.getErrorMessages()); interaction = giResponse.getEntity(); - + interaction.setRelation(vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.GENE_MOLECULAR_INTERACTION_RELATION_VOCABULARY_TERM_SET, VocabularyConstants.GENE_MOLECULAR_INTERACTION_RELATION_TERM).getEntity()); - + MITerm detectionMethod = null; if (CollectionUtils.isNotEmpty(dto.getInteractionDetectionMethods())) { for (String detectionMethodString : dto.getInteractionDetectionMethods()) { String detectionMethodCurie = getCurieFromCache(detectionMethodString); if (detectionMethodCurie != null) { detectionMethod = getTermFromCache(detectionMethodCurie); - if (detectionMethod == null) + if (detectionMethod == null) { gmiResponse.addErrorMessage("interactionDetectionMethods", ValidationConstants.INVALID_MESSAGE + " (" + detectionMethodCurie + ")"); + } break; } } } interaction.setDetectionMethod(detectionMethod); - + MITerm aggregationDatabase = null; String aggregationDatabaseCurie = InteractionStringHelper.getAggregationDatabaseMITermCurie(dto); if (aggregationDatabaseCurie != null) { @@ -110,11 +113,12 @@ public GeneMolecularInteraction validateGeneMolecularInteractionFmsDTO(PsiMiTabD gmiResponse.addErrorMessage("aggregationDatabase (inferred from sourceDatabaseIds)", ValidationConstants.INVALID_MESSAGE + " (" + aggregationDatabaseCurie + ")"); } } - interaction.setAggregationDatabase(aggregationDatabase); - - if (gmiResponse.hasErrors()) + interaction.setAggregationDatabase(aggregationDatabase); + + if (gmiResponse.hasErrors()) { throw new ObjectValidationException(dto, gmiResponse.getErrorMessages().values()); - + } + return interaction; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java index b62b67a50..cc782f83a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java @@ -19,41 +19,39 @@ @RequestScoped public class GenePhenotypeAnnotationFmsDTOValidator extends PhenotypeAnnotationFmsDTOValidator { - @Inject - GenePhenotypeAnnotationDAO genePhenotypeAnnotationDAO; - @Inject - GenomicEntityService genomicEntityService; - @Inject - PhenotypeAnnotationService phenotypeAnnotationService; - + @Inject GenePhenotypeAnnotationDAO genePhenotypeAnnotationDAO; + @Inject GenomicEntityService genomicEntityService; + @Inject PhenotypeAnnotationService phenotypeAnnotationService; + public GenePhenotypeAnnotation validatePrimaryAnnotation(Gene subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { ObjectResponse apaResponse = new ObjectResponse(); GenePhenotypeAnnotation annotation = new GenePhenotypeAnnotation(); - + ObjectResponse refResponse = validateReference(dto); apaResponse.addErrorMessages(refResponse.getErrorMessages()); - + Reference reference = refResponse.getEntity(); String refString = reference == null ? null : reference.getCurie(); - + String uniqueId = AnnotationUniqueIdHelper.getPhenotypeAnnotationUniqueId(dto, subject.getIdentifier(), refString); SearchResponse annotationSearch = genePhenotypeAnnotationDAO.findByField("uniqueId", uniqueId); - if (annotationSearch != null && annotationSearch.getSingleResult() != null) + if (annotationSearch != null && annotationSearch.getSingleResult() != null) { annotation = annotationSearch.getSingleResult(); + } annotation.setUniqueId(uniqueId); annotation.setSingleReference(reference); annotation.setPhenotypeAnnotationSubject(subject); - - + ObjectResponse paResponse = validatePhenotypeAnnotation(annotation, dto, dataProvider); apaResponse.addErrorMessages(paResponse.getErrorMessages()); annotation = paResponse.getEntity(); - - if (apaResponse.hasErrors()) + + if (apaResponse.hasErrors()) { throw new ObjectValidationException(dto, apaResponse.errorMessagesString()); - + } + return annotation; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java index abdf6a790..7b254a960 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java @@ -30,14 +30,10 @@ @RequestScoped public class OrthologyFmsDTOValidator { - @Inject - GeneToGeneOrthologyGeneratedDAO generatedOrthologyDAO; - @Inject - GeneService geneService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - VocabularyTermService vocabularyTermService; + @Inject GeneToGeneOrthologyGeneratedDAO generatedOrthologyDAO; + @Inject GeneService geneService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject VocabularyTermService vocabularyTermService; @Transactional public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) throws ObjectValidationException { @@ -46,7 +42,7 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) String subjectGeneIdentifier = null; String objectGeneIdentifier = null; - + GeneToGeneOrthologyGenerated orthoPair = null; if (StringUtils.isBlank(dto.getGene1())) { @@ -59,7 +55,7 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) } else { objectGeneIdentifier = convertToModCurie(dto.getGene2(), dto.getGene2Species()); } - + Gene subjectGene = null; if (StringUtils.isNotBlank(dto.getGene1())) { subjectGene = geneService.findByIdentifierString(subjectGeneIdentifier); @@ -79,7 +75,7 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) } } } - + Gene objectGene = null; if (StringUtils.isNotBlank(dto.getGene2())) { objectGene = geneService.findByIdentifierString(objectGeneIdentifier); @@ -99,20 +95,22 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) } } } - + if (subjectGene != null && objectGene != null) { Map params = new HashMap<>(); params.put("subjectGene.id", subjectGene.getId()); params.put("objectGene.id", objectGene.getId()); SearchResponse searchResponse = generatedOrthologyDAO.findByParams(params); - if (searchResponse != null && searchResponse.getSingleResult() != null) + if (searchResponse != null && searchResponse.getSingleResult() != null) { orthoPair = searchResponse.getSingleResult(); + } } - if (orthoPair == null) + if (orthoPair == null) { orthoPair = new GeneToGeneOrthologyGenerated(); + } - orthoPair.setSubjectGene(subjectGene); + orthoPair.setSubjectGene(subjectGene); orthoPair.setObjectGene(objectGene); VocabularyTerm isBestScore = null; @@ -120,8 +118,9 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) orthologyResponse.addErrorMessage("isBestScore", ValidationConstants.REQUIRED_MESSAGE); } else { isBestScore = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ORTHOLOGY_BEST_SCORE_VOCABULARY, dto.getIsBestScore()).getEntity(); - if (isBestScore == null) + if (isBestScore == null) { orthologyResponse.addErrorMessage("isBestScore", ValidationConstants.INVALID_MESSAGE + " (" + dto.getIsBestScore() + ")"); + } } orthoPair.setIsBestScore(isBestScore); @@ -130,8 +129,9 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) orthologyResponse.addErrorMessage("isBestRevScore", ValidationConstants.REQUIRED_MESSAGE); } else { isBestScoreReverse = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ORTHOLOGY_BEST_REVERSE_SCORE_VOCABULARY_TERM_SET, dto.getIsBestRevScore()).getEntity(); - if (isBestScoreReverse == null) + if (isBestScoreReverse == null) { orthologyResponse.addErrorMessage("isBestRevScore", ValidationConstants.INVALID_MESSAGE + " (" + dto.getIsBestRevScore() + ")"); + } } orthoPair.setIsBestScoreReverse(isBestScoreReverse); @@ -182,21 +182,23 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) orthologyResponse.addErrorMessage("confidence", ValidationConstants.REQUIRED_MESSAGE); } else { confidence = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ORTHOLOGY_CONFIDENCE_VOCABULARY, dto.getConfidence()).getEntity(); - if (confidence == null) + if (confidence == null) { orthologyResponse.addErrorMessage("confidence", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConfidence() + ")"); + } } orthoPair.setConfidence(confidence); orthoPair.setModerateFilter(dto.getModerateFilter()); - + orthoPair.setStrictFilter(dto.getStrictFilter()); - + orthoPair.setObsolete(false); orthoPair.setInternal(false); - if (orthologyResponse.hasErrors()) + if (orthologyResponse.hasErrors()) { throw new ObjectValidationException(dto, orthologyResponse.errorMessagesString()); - + } + return generatedOrthologyDAO.persist(orthoPair); } @@ -204,14 +206,16 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) private boolean sameGenus(NCBITaxonTerm taxon, NCBITaxonTerm geneTaxon) { if (StringUtils.equals(taxon.getCurie(), "NCBITaxon:8355") || StringUtils.equals(taxon.getCurie(), "NCBITaxon:8364")) { // Must be same species for Xenopus as cleanup uses taxon curie - if (StringUtils.equals(taxon.getCurie(), geneTaxon.getCurie())) + if (StringUtils.equals(taxon.getCurie(), geneTaxon.getCurie())) { return true; + } return false; } String genus = taxon.getName().substring(0, taxon.getName().indexOf(" ")); String geneGenus = geneTaxon.getName().substring(0, geneTaxon.getName().indexOf(" ")); - if (StringUtils.equals(genus, geneGenus)) + if (StringUtils.equals(genus, geneGenus)) { return true; + } return false; } @@ -219,10 +223,11 @@ private String convertToModCurie(String curie, Integer taxonId) { curie = curie.replaceFirst("^DRSC:", ""); if (curie.indexOf(":") == -1) { String prefix = BackendBulkDataProvider.getCuriePrefixFromTaxonId(taxonId); - if (prefix != null) + if (prefix != null) { curie = prefix + curie; + } } - + return curie; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java index 51ce1e567..048e8b36c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java @@ -17,12 +17,9 @@ @RequestScoped public class ParalogyFmsDTOValidator { - @Inject - GeneToGeneParalogyDAO genetoGeneParalogyDAO; - @Inject - GeneService geneService; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; + @Inject GeneToGeneParalogyDAO genetoGeneParalogyDAO; + @Inject GeneService geneService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; @Transactional public GeneToGeneParalogy validateParalogyFmsDTO(ParalogyFmsDTO dto) throws ObjectValidationException { @@ -80,25 +77,27 @@ private String convertToModCurie(String curie, Integer taxonId) { curie = curie.replaceFirst("^DRSC:", ""); if (curie.indexOf(":") == -1) { String prefix = BackendBulkDataProvider.getCuriePrefixFromTaxonId(taxonId); - if (prefix != null) + if (prefix != null) { curie = prefix + curie; + } } return curie; } private boolean sameGenus(NCBITaxonTerm taxon, NCBITaxonTerm geneTaxon) { - if (StringUtils.equals(taxon.getCurie(), "NCBITaxon:8355") - || StringUtils.equals(taxon.getCurie(), "NCBITaxon:8364")) { + if (StringUtils.equals(taxon.getCurie(), "NCBITaxon:8355") || StringUtils.equals(taxon.getCurie(), "NCBITaxon:8364")) { // Must be same species for Xenopus as cleanup uses taxon curie - if (StringUtils.equals(taxon.getCurie(), geneTaxon.getCurie())) + if (StringUtils.equals(taxon.getCurie(), geneTaxon.getCurie())) { return true; + } return false; } String genus = taxon.getName().substring(0, taxon.getName().indexOf(" ")); String geneGenus = geneTaxon.getName().substring(0, geneTaxon.getName().indexOf(" ")); - if (StringUtils.equals(genus, geneGenus)) + if (StringUtils.equals(genus, geneGenus)) { return true; + } return false; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java index 2338aabbb..3fd8b71b2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java @@ -36,44 +36,38 @@ @RequestScoped public class PhenotypeAnnotationFmsDTOValidator { - @Inject - ReferenceService referenceService; - @Inject - PhenotypeTermService phenotypeTermService; - @Inject - ConditionRelationFmsDTOValidator conditionRelationFmsDtoValidator; - @Inject - ConditionRelationDAO conditionRelationDAO; - @Inject - DataProviderService dataProviderService; - @Inject - VocabularyTermService vocabularyTermService; - @Inject - ResourceDescriptorPageService resourceDescriptorPageService; - + @Inject ReferenceService referenceService; + @Inject PhenotypeTermService phenotypeTermService; + @Inject ConditionRelationFmsDTOValidator conditionRelationFmsDtoValidator; + @Inject ConditionRelationDAO conditionRelationDAO; + @Inject DataProviderService dataProviderService; + @Inject VocabularyTermService vocabularyTermService; + @Inject ResourceDescriptorPageService resourceDescriptorPageService; + public ObjectResponse validatePhenotypeAnnotation(E annotation, PhenotypeFmsDTO dto, BackendBulkDataProvider beDataProvider) { ObjectResponse paResponse = new ObjectResponse(); - + if (StringUtils.isBlank(dto.getPhenotypeStatement())) { paResponse.addErrorMessage("phenotypeStatement", ValidationConstants.REQUIRED_MESSAGE); } - annotation.setPhenotypeAnnotationObject(dto.getPhenotypeStatement()); - + annotation.setPhenotypeAnnotationObject(dto.getPhenotypeStatement()); + if (CollectionUtils.isNotEmpty(dto.getPhenotypeTermIdentifiers())) { List phenotypeTerms = new ArrayList<>(); for (PhenotypeTermIdentifierFmsDTO phenotypeTermIdentifier : dto.getPhenotypeTermIdentifiers()) { if (StringUtils.isNotBlank(phenotypeTermIdentifier.getTermId())) { PhenotypeTerm phenotypeTerm = phenotypeTermService.findByCurieOrSecondaryId(phenotypeTermIdentifier.getTermId()); - if (phenotypeTerm != null) + if (phenotypeTerm != null) { phenotypeTerms.add(phenotypeTerm); + } } } - annotation.setPhenotypeTerms(phenotypeTerms); + annotation.setPhenotypeTerms(phenotypeTerms); } else { annotation.setPhenotypeTerms(null); } - + if (CollectionUtils.isNotEmpty(dto.getConditionRelations())) { List relations = new ArrayList<>(); for (ConditionRelationFmsDTO conditionRelationFmsDTO : dto.getConditionRelations()) { @@ -88,22 +82,23 @@ public ObjectResponse validatePhenotypeAnnota } else { annotation.setConditionRelations(null); } - + annotation.setDataProvider(dataProviderService.createOrganizationDataProvider(beDataProvider.sourceOrganization)); annotation.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.PHENOTYPE_RELATION_VOCABULARY, "has_phenotype").getEntity()); - + CrossReference evidenceXref = null; if (dto.getEvidence() != null && dto.getEvidence().getPublicationId() != null) { if (annotation.getCrossReference() != null && Objects.equals(annotation.getCrossReference().getDisplayName(), dto.getEvidence().getPublicationId())) { evidenceXref = annotation.getCrossReference(); } else { evidenceXref = createXrefFromPublicationId(dto.getEvidence().getPublicationId()); - if (evidenceXref == null) + if (evidenceXref == null) { paResponse.addErrorMessage("evidence - publicationId", ValidationConstants.INVALID_MESSAGE + " for generating cross reference (" + dto.getEvidence().getPublicationId() + ")"); + } } } annotation.setCrossReference(evidenceXref); - + OffsetDateTime creationDate = null; if (StringUtils.isNotBlank(dto.getDateAssigned())) { try { @@ -115,20 +110,20 @@ public ObjectResponse validatePhenotypeAnnota paResponse.addErrorMessage("dateAssigned", ValidationConstants.REQUIRED_MESSAGE); } annotation.setDateCreated(creationDate); - + annotation.setObsolete(false); annotation.setInternal(false); - + paResponse.setEntity(annotation); return paResponse; } - + public ObjectResponse validateReference(PhenotypeFmsDTO dto) { ObjectResponse refResponse = new ObjectResponse<>(); Reference reference = null; - + if (ObjectUtils.isEmpty(dto.getEvidence())) { refResponse.addErrorMessage("evidence", ValidationConstants.REQUIRED_MESSAGE); } else { @@ -136,32 +131,35 @@ public ObjectResponse validateReference(PhenotypeFmsDTO dto) { refResponse.addErrorMessage("evidence - publicationId", ValidationConstants.REQUIRED_MESSAGE); } else { String refCurie = dto.getEvidence().getPublicationId(); - if (refCurie.startsWith("OMIM:") || refCurie.startsWith("MIM:") || refCurie.startsWith("ORPHA:")) + if (refCurie.startsWith("OMIM:") || refCurie.startsWith("MIM:") || refCurie.startsWith("ORPHA:")) { refCurie = ReferenceConstants.RGD_OMIM_ORPHANET_REFERENCE; + } reference = referenceService.retrieveFromDbOrLiteratureService(refCurie); - if (reference == null) + if (reference == null) { refResponse.addErrorMessage("evidence - publicationId", ValidationConstants.INVALID_MESSAGE); + } } } - + refResponse.setEntity(reference); return refResponse; } - + private CrossReference createXrefFromPublicationId(String curie) { CrossReference xref = new CrossReference(); - + xref.setReferencedCurie(curie); xref.setDisplayName(curie); - + String[] curieParts = curie.split(":"); String prefix = curieParts[0]; - + ResourceDescriptorPage page = resourceDescriptorPageService.getPageForResourceDescriptor(prefix, "default"); - if (page == null) + if (page == null) { return null; + } xref.setResourceDescriptorPage(page); - + return xref; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/NameSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/NameSlotAnnotationDTOValidator.java index fc8622aba..8c044a36e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/NameSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/NameSlotAnnotationDTOValidator.java @@ -15,8 +15,7 @@ @RequestScoped public class NameSlotAnnotationDTOValidator extends SlotAnnotationDTOValidator { - @Inject - VocabularyTermService vocabularyTermService; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateNameSlotAnnotationDTO(E annotation, NameSlotAnnotationDTO dto, String nameTypeVocabularyOrSet) { ObjectResponse nsaResponse = validateSlotAnnotationDTO(annotation, dto); @@ -33,7 +32,7 @@ public ObjectResponse validateNameSlotAnnotati } else { annotation.setFormatText(dto.getFormatText()); } - + if (StringUtils.isNotEmpty(dto.getNameTypeName())) { VocabularyTerm nameType; if (nameTypeVocabularyOrSet.equals(VocabularyConstants.NAME_TYPE_VOCABULARY)) { @@ -41,8 +40,9 @@ public ObjectResponse validateNameSlotAnnotati } else { nameType = vocabularyTermService.getTermInVocabularyTermSet(nameTypeVocabularyOrSet, dto.getNameTypeName()).getEntity(); } - if (nameType == null) + if (nameType == null) { nsaResponse.addErrorMessage("name_type_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getNameTypeName() + ")"); + } annotation.setNameType(nameType); } else { nsaResponse.addErrorMessage("name_type_name", ValidationConstants.REQUIRED_MESSAGE); @@ -56,8 +56,9 @@ public ObjectResponse validateNameSlotAnnotati if (StringUtils.isNotBlank(dto.getSynonymScopeName())) { VocabularyTerm synonymScope = vocabularyTermService.getTermInVocabulary(VocabularyConstants.SYNONYM_SCOPE_VOCABULARY, dto.getSynonymScopeName()).getEntity(); - if (synonymScope == null) + if (synonymScope == null) { nsaResponse.addErrorMessage("synonym_scope", ValidationConstants.INVALID_MESSAGE + " (" + dto.getSynonymScopeName() + ")"); + } annotation.setSynonymScope(synonymScope); } else { annotation.setSynonymScope(null); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/SlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/SlotAnnotationDTOValidator.java index 8ee81c331..438d8ec30 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/SlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/SlotAnnotationDTOValidator.java @@ -18,13 +18,12 @@ @RequestScoped public class SlotAnnotationDTOValidator extends BaseDTOValidator { - @Inject - InformationContentEntityService informationContentEntityService; + @Inject InformationContentEntityService informationContentEntityService; public ObjectResponse validateSlotAnnotationDTO(E annotation, D dto) { ObjectResponse saResponse = validateAuditedObjectDTO(annotation, dto); annotation = saResponse.getEntity(); - + List evidence = new ArrayList<>(); if (CollectionUtils.isNotEmpty(dto.getEvidenceCuries())) { for (String evidenceCurie : dto.getEvidenceCuries()) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationDTOValidator.java index 46a509a4b..fe24dab03 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationDTOValidator.java @@ -16,25 +16,26 @@ @RequestScoped public class AlleleDatabaseStatusSlotAnnotationDTOValidator extends SlotAnnotationDTOValidator { - @Inject - VocabularyTermService vocabularyTermService; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleDatabaseStatusSlotAnnotationDTO(AlleleDatabaseStatusSlotAnnotation annotation, AlleleDatabaseStatusSlotAnnotationDTO dto) { ObjectResponse adsResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new AlleleDatabaseStatusSlotAnnotation(); + } VocabularyTerm databaseStatus = null; if (StringUtils.isBlank(dto.getDatabaseStatusName())) { adsResponse.addErrorMessage("database_status_name", ValidationConstants.REQUIRED_MESSAGE); } else { databaseStatus = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ALLELE_DATABASE_STATUS_VOCABULARY, dto.getDatabaseStatusName()).getEntity(); - if (databaseStatus == null) + if (databaseStatus == null) { adsResponse.addErrorMessage("database_status_name", ValidationConstants.INVALID_MESSAGE); + } } annotation.setDatabaseStatus(databaseStatus); - + ObjectResponse saResponse = validateSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); adsResponse.addErrorMessages(saResponse.getErrorMessages()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationDTOValidator.java index 6bd5f3ff4..dd82d02b5 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class AlleleFullNameSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateAlleleFullNameSlotAnnotationDTO(AlleleFullNameSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new AlleleFullNameSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.FULL_NAME_TYPE_TERM_SET); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDTOValidator.java index d6f8f4c12..1d1a71a38 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationDTOValidator.java @@ -22,16 +22,15 @@ @RequestScoped public class AlleleFunctionalImpactSlotAnnotationDTOValidator extends SlotAnnotationDTOValidator { - @Inject - VocabularyTermService vocabularyTermService; - @Inject - PhenotypeTermService phenotypeTermService; + @Inject VocabularyTermService vocabularyTermService; + @Inject PhenotypeTermService phenotypeTermService; public ObjectResponse validateAlleleFunctionalImpactSlotAnnotationDTO(AlleleFunctionalImpactSlotAnnotation annotation, AlleleFunctionalImpactSlotAnnotationDTO dto) { ObjectResponse afisaResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new AlleleFunctionalImpactSlotAnnotation(); + } if (CollectionUtils.isEmpty(dto.getFunctionalImpactNames())) { afisaResponse.addErrorMessage("functional_impact_names", ValidationConstants.REQUIRED_MESSAGE); @@ -42,23 +41,24 @@ public ObjectResponse validateAlleleFuncti if (functionalImpact == null) { afisaResponse.addErrorMessage("functional_impact_names", ValidationConstants.INVALID_MESSAGE); break; - } + } functionalImpacts.add(functionalImpact); } annotation.setFunctionalImpacts(functionalImpacts); } - + PhenotypeTerm phenotypeTerm = null; if (StringUtils.isNotBlank(dto.getPhenotypeTermCurie())) { phenotypeTerm = phenotypeTermService.findByCurieOrSecondaryId(dto.getPhenotypeTermCurie()); - if (phenotypeTerm == null) + if (phenotypeTerm == null) { afisaResponse.addErrorMessage("phenotype_term_curie", ValidationConstants.INVALID_MESSAGE); + } } annotation.setPhenotypeTerm(phenotypeTerm); - + String phenotypeStatement = StringUtils.isBlank(dto.getPhenotypeStatement()) ? null : dto.getPhenotypeStatement(); annotation.setPhenotypeStatement(phenotypeStatement); - + ObjectResponse saResponse = validateSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); afisaResponse.addErrorMessages(saResponse.getErrorMessages()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationDTOValidator.java index 3a56e97b1..266e90250 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationDTOValidator.java @@ -16,14 +16,14 @@ @RequestScoped public class AlleleGermlineTransmissionStatusSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { - @Inject - VocabularyTermService vocabularyTermService; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleGermlineTransmissionStatusSlotAnnotationDTO(AlleleGermlineTransmissionStatusSlotAnnotation annotation, AlleleGermlineTransmissionStatusSlotAnnotationDTO dto) { ObjectResponse agtsResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new AlleleGermlineTransmissionStatusSlotAnnotation(); + } ObjectResponse saResponse = validateSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); @@ -31,8 +31,9 @@ public ObjectResponse validateAl if (StringUtils.isNotEmpty(dto.getGermlineTransmissionStatusName())) { VocabularyTerm gts = vocabularyTermService.getTermInVocabulary(VocabularyConstants.GERMLINE_TRANSMISSION_STATUS_VOCABULARY, dto.getGermlineTransmissionStatusName()).getEntity(); - if (gts == null) + if (gts == null) { agtsResponse.addErrorMessage("germline_transmission_status_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGermlineTransmissionStatusName() + ")"); + } annotation.setGermlineTransmissionStatus(gts); } else { agtsResponse.addErrorMessage("germline_transmission_status_name", ValidationConstants.REQUIRED_MESSAGE); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationDTOValidator.java index bc846a67a..3e9de24e1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationDTOValidator.java @@ -18,38 +18,39 @@ @RequestScoped public class AlleleInheritanceModeSlotAnnotationDTOValidator extends SlotAnnotationDTOValidator { - @Inject - VocabularyTermService vocabularyTermService; - @Inject - PhenotypeTermService phenotypeTermService; + @Inject VocabularyTermService vocabularyTermService; + @Inject PhenotypeTermService phenotypeTermService; public ObjectResponse validateAlleleInheritanceModeSlotAnnotationDTO(AlleleInheritanceModeSlotAnnotation annotation, AlleleInheritanceModeSlotAnnotationDTO dto) { ObjectResponse aisaResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new AlleleInheritanceModeSlotAnnotation(); + } VocabularyTerm inheritanceMode = null; if (StringUtils.isBlank(dto.getInheritanceModeName())) { aisaResponse.addErrorMessage("inheritance_mode_name", ValidationConstants.REQUIRED_MESSAGE); } else { inheritanceMode = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ALLELE_INHERITANCE_MODE_VOCABULARY, dto.getInheritanceModeName()).getEntity(); - if (inheritanceMode == null) + if (inheritanceMode == null) { aisaResponse.addErrorMessage("inheritance_mode_name", ValidationConstants.INVALID_MESSAGE); + } } annotation.setInheritanceMode(inheritanceMode); - + PhenotypeTerm phenotypeTerm = null; if (StringUtils.isNotBlank(dto.getPhenotypeTermCurie())) { phenotypeTerm = phenotypeTermService.findByCurieOrSecondaryId(dto.getPhenotypeTermCurie()); - if (phenotypeTerm == null) + if (phenotypeTerm == null) { aisaResponse.addErrorMessage("phenotype_term_curie", ValidationConstants.INVALID_MESSAGE); + } } annotation.setPhenotypeTerm(phenotypeTerm); - + String phenotypeStatement = StringUtils.isBlank(dto.getPhenotypeStatement()) ? null : dto.getPhenotypeStatement(); annotation.setPhenotypeStatement(phenotypeStatement); - + ObjectResponse saResponse = validateSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); aisaResponse.addErrorMessages(saResponse.getErrorMessages()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationDTOValidator.java index 790b2db93..f4dcc1749 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationDTOValidator.java @@ -18,14 +18,14 @@ @RequestScoped public class AlleleMutationTypeSlotAnnotationDTOValidator extends SlotAnnotationDTOValidator { - @Inject - SoTermService soTermService; + @Inject SoTermService soTermService; public ObjectResponse validateAlleleMutationTypeSlotAnnotationDTO(AlleleMutationTypeSlotAnnotation annotation, AlleleMutationTypeSlotAnnotationDTO dto) { ObjectResponse amsaResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new AlleleMutationTypeSlotAnnotation(); + } if (CollectionUtils.isEmpty(dto.getMutationTypeCuries())) { amsaResponse.addErrorMessage("mutation_type_curies", ValidationConstants.REQUIRED_MESSAGE); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationDTOValidator.java index f9823c48f..a1429eb5a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationDTOValidator.java @@ -16,25 +16,26 @@ @RequestScoped public class AlleleNomenclatureEventSlotAnnotationDTOValidator extends SlotAnnotationDTOValidator { - @Inject - VocabularyTermService vocabularyTermService; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleNomenclatureEventSlotAnnotationDTO(AlleleNomenclatureEventSlotAnnotation annotation, AlleleNomenclatureEventSlotAnnotationDTO dto) { ObjectResponse adsResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new AlleleNomenclatureEventSlotAnnotation(); + } VocabularyTerm nomenclatureEvent = null; if (StringUtils.isBlank(dto.getNomenclatureEventName())) { adsResponse.addErrorMessage("nomenclature_event_name", ValidationConstants.REQUIRED_MESSAGE); } else { nomenclatureEvent = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ALLELE_NOMENCLATURE_EVENT_VOCABULARY, dto.getNomenclatureEventName()).getEntity(); - if (nomenclatureEvent == null) + if (nomenclatureEvent == null) { adsResponse.addErrorMessage("nomenclature_event_name", ValidationConstants.INVALID_MESSAGE); + } } annotation.setNomenclatureEvent(nomenclatureEvent); - + ObjectResponse saResponse = validateSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); adsResponse.addErrorMessages(saResponse.getErrorMessages()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationDTOValidator.java index 9456441b6..8d9057f27 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationDTOValidator.java @@ -13,8 +13,9 @@ public class AlleleSecondaryIdSlotAnnotationDTOValidator extends SecondaryIdSlot public ObjectResponse validateAlleleSecondaryIdSlotAnnotationDTO(AlleleSecondaryIdSlotAnnotation annotation, SecondaryIdSlotAnnotationDTO dto) { ObjectResponse asidResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new AlleleSecondaryIdSlotAnnotation(); + } ObjectResponse saResponse = validateSecondaryIdSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); @@ -24,4 +25,4 @@ public ObjectResponse validateAlleleSecondaryId return asidResponse; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationDTOValidator.java index e9965585d..2be49a211 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class AlleleSymbolSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateAlleleSymbolSlotAnnotationDTO(AlleleSymbolSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new AlleleSymbolSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.SYMBOL_NAME_TYPE_TERM_SET); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationDTOValidator.java index ed8e5ead9..3849e1841 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class AlleleSynonymSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateAlleleSynonymSlotAnnotationDTO(AlleleSynonymSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new AlleleSynonymSlotAnnotation(); + } - return validateNameSlotAnnotationDTO(annotation, dto,VocabularyConstants.NAME_TYPE_VOCABULARY); + return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.NAME_TYPE_VOCABULARY); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java index cfd313456..19a919e6a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java @@ -30,42 +30,39 @@ @RequestScoped public class ConstructComponentSlotAnnotationDTOValidator extends SlotAnnotationDTOValidator { - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - ConstructComponentSlotAnnotationDAO constructComponentDAO; - @Inject - NoteDTOValidator noteDtoValidator; - @Inject - NoteDAO noteDAO; - @Inject - VocabularyTermService vocabularyTermService; - + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject ConstructComponentSlotAnnotationDAO constructComponentDAO; + @Inject NoteDTOValidator noteDtoValidator; + @Inject NoteDAO noteDAO; + @Inject VocabularyTermService vocabularyTermService; + public ObjectResponse validateConstructComponentSlotAnnotationDTO(ConstructComponentSlotAnnotation annotation, ConstructComponentSlotAnnotationDTO dto) { ObjectResponse ccsaResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new ConstructComponentSlotAnnotation(); - + } + ObjectResponse saResponse = validateSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); ccsaResponse.addErrorMessages(saResponse.getErrorMessages()); if (StringUtils.isAllBlank(dto.getComponentSymbol())) { - ccsaResponse.addErrorMessage("component_symbol", ValidationConstants.REQUIRED_MESSAGE);; + ccsaResponse.addErrorMessage("component_symbol", ValidationConstants.REQUIRED_MESSAGE); } else { annotation.setComponentSymbol(dto.getComponentSymbol()); } - + if (StringUtils.isNotEmpty(dto.getRelationName())) { VocabularyTerm diseaseRelation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, dto.getRelationName()).getEntity(); - if (diseaseRelation == null) + if (diseaseRelation == null) { ccsaResponse.addErrorMessage("relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getRelationName() + ")"); + } annotation.setRelation(diseaseRelation); } else { ccsaResponse.addErrorMessage("relation_name", ValidationConstants.REQUIRED_MESSAGE); } - + if (StringUtils.isNotBlank(dto.getTaxonCurie())) { ObjectResponse taxonResponse = ncbiTaxonTermService.getByCurie(dto.getTaxonCurie()); if (taxonResponse.getEntity() == null) { @@ -75,13 +72,13 @@ public ObjectResponse validateConstructCompone } else { annotation.setTaxon(null); } - + if (StringUtils.isNotBlank(dto.getTaxonText())) { annotation.setTaxonText(dto.getTaxonText()); } else { annotation.setTaxonText(null); } - + if (CollectionUtils.isNotEmpty(annotation.getRelatedNotes())) { annotation.getRelatedNotes().forEach(note -> { constructComponentDAO.deleteAttachedNote(note.getId()); @@ -106,7 +103,7 @@ public ObjectResponse validateConstructCompone } else { annotation.setRelatedNotes(null); } - + ccsaResponse.setEntity(annotation); return ccsaResponse; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationDTOValidator.java index 71822e8c2..fb00fee8f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class ConstructFullNameSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateConstructFullNameSlotAnnotationDTO(ConstructFullNameSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new ConstructFullNameSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.FULL_NAME_TYPE_TERM_SET); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationDTOValidator.java index b0eb4c4f8..719c77a51 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class ConstructSymbolSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateConstructSymbolSlotAnnotationDTO(ConstructSymbolSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new ConstructSymbolSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.SYMBOL_NAME_TYPE_TERM_SET); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationDTOValidator.java index 0a0be0595..eccafcd73 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class ConstructSynonymSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateConstructSynonymSlotAnnotationDTO(ConstructSynonymSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new ConstructSynonymSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.NAME_TYPE_VOCABULARY); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationDTOValidator.java index f8d6561d2..7da4bb83a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class GeneFullNameSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateGeneFullNameSlotAnnotationDTO(GeneFullNameSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new GeneFullNameSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.FULL_NAME_TYPE_TERM_SET); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationDTOValidator.java index 2d69d1855..7d49c6961 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationDTOValidator.java @@ -13,8 +13,9 @@ public class GeneSecondaryIdSlotAnnotationDTOValidator extends SecondaryIdSlotAn public ObjectResponse validateGeneSecondaryIdSlotAnnotationDTO(GeneSecondaryIdSlotAnnotation annotation, SecondaryIdSlotAnnotationDTO dto) { ObjectResponse gsidResponse = new ObjectResponse(); - if (annotation == null) + if (annotation == null) { annotation = new GeneSecondaryIdSlotAnnotation(); + } ObjectResponse saResponse = validateSecondaryIdSlotAnnotationDTO(annotation, dto); annotation = saResponse.getEntity(); @@ -24,4 +25,4 @@ public ObjectResponse validateGeneSecondaryIdSlot return gsidResponse; } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationDTOValidator.java index 355b70c14..9b40694cc 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class GeneSymbolSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateGeneSymbolSlotAnnotationDTO(GeneSymbolSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new GeneSymbolSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.SYMBOL_NAME_TYPE_TERM_SET); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationDTOValidator.java index 25ed0d56b..1478f7696 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class GeneSynonymSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateGeneSynonymSlotAnnotationDTO(GeneSynonymSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new GeneSynonymSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.NAME_TYPE_VOCABULARY); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationDTOValidator.java index 54578576e..b749842ce 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationDTOValidator.java @@ -12,9 +12,10 @@ public class GeneSystematicNameSlotAnnotationDTOValidator extends NameSlotAnnotationDTOValidator { public ObjectResponse validateGeneSystematicNameSlotAnnotationDTO(GeneSystematicNameSlotAnnotation annotation, NameSlotAnnotationDTO dto) { - if (annotation == null) + if (annotation == null) { annotation = new GeneSystematicNameSlotAnnotation(); + } return validateNameSlotAnnotationDTO(annotation, dto, VocabularyConstants.SYSTEMATIC_NAME_TYPE_TERM_SET); } -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/NameSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/NameSlotAnnotationValidator.java index 3f44b82a4..a99a46866 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/NameSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/NameSlotAnnotationValidator.java @@ -11,8 +11,7 @@ public class NameSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - VocabularyTermService vocabularyTermService; + @Inject VocabularyTermService vocabularyTermService; public E validateNameSlotAnnotationFields(E uiEntity, E dbEntity, Boolean newEntity) { @@ -46,8 +45,9 @@ public E validateNameSlotAnnotationFields(E uiEntity, E dbEntity, Boolean newEnt private VocabularyTerm validateSynonymScope(E uiEntity, E dbEntity) { String field = "synonymScope"; - if (uiEntity.getSynonymScope() == null) + if (uiEntity.getSynonymScope() == null) { return null; + } VocabularyTerm synonymScope = vocabularyTermService.getTermInVocabulary(VocabularyConstants.SYNONYM_SCOPE_VOCABULARY, uiEntity.getSynonymScope().getName()).getEntity(); if (synonymScope == null) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/SlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/SlotAnnotationValidator.java index c87aadaa3..d2f5b6721 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/SlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/SlotAnnotationValidator.java @@ -21,14 +21,10 @@ public class SlotAnnotationValidator extends AuditedObjectValidator { - @Inject - InformationContentEntityService informationContentEntityService; - @Inject - AlleleDAO alleleDAO; - @Inject - ConstructDAO constructDAO; - @Inject - GeneDAO geneDAO; + @Inject InformationContentEntityService informationContentEntityService; + @Inject AlleleDAO alleleDAO; + @Inject ConstructDAO constructDAO; + @Inject GeneDAO geneDAO; public E validateSlotAnnotationFields(E uiEntity, E dbEntity, Boolean newObject) { dbEntity = validateAuditedObjectFields(uiEntity, dbEntity, newObject); @@ -42,8 +38,9 @@ public E validateSlotAnnotationFields(E uiEntity, E dbEntity, Boolean newObject) public List validateEvidence(E uiEntity, E dbEntity) { String field = "evidence"; - if (CollectionUtils.isEmpty(uiEntity.getEvidence())) + if (CollectionUtils.isEmpty(uiEntity.getEvidence())) { return null; + } List validatedEntities = new ArrayList<>(); for (InformationContentEntity evidenceEntity : uiEntity.getEvidence()) { @@ -68,37 +65,39 @@ public Allele validateSingleAllele(Allele uiAllele, Allele dbAllele) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - + Allele allele = null; - if (uiAllele.getId() != null) + if (uiAllele.getId() != null) { allele = alleleDAO.find(uiAllele.getId()); + } if (allele == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } - if (allele.getObsolete() && (dbAllele != null && !dbAllele.getObsolete())) { + if (allele.getObsolete() && dbAllele != null && !dbAllele.getObsolete()) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } return allele; } - + public Construct validateSingleConstruct(Construct uiConstruct, Construct dbConstruct) { String field = "singleConstruct"; if (ObjectUtils.isEmpty(uiConstruct)) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - + Construct construct = null; - if (uiConstruct.getId() != null) + if (uiConstruct.getId() != null) { construct = constructDAO.find(uiConstruct.getId()); + } if (construct == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } - if (construct.getObsolete() && (dbConstruct != null && !dbConstruct.getObsolete())) { + if (construct.getObsolete() && dbConstruct != null && !dbConstruct.getObsolete()) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } @@ -112,15 +111,16 @@ public Gene validateSingleGene(Gene uiGene, Gene dbGene) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - + Gene gene = null; - if (uiGene.getId() != null) + if (uiGene.getId() != null) { gene = geneDAO.find(uiGene.getId()); + } if (gene == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } - if (gene.getObsolete() && (dbGene != null && !dbGene.getObsolete())) { + if (gene.getObsolete() && dbGene != null && !dbGene.getObsolete()) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationValidator.java index 2fc864c66..c0a8dd026 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotationValidator.java @@ -17,10 +17,8 @@ @RequestScoped public class AlleleDatabaseStatusSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - AlleleDatabaseStatusSlotAnnotationDAO alleleDatabaseStatusDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AlleleDatabaseStatusSlotAnnotationDAO alleleDatabaseStatusDAO; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleDatabaseStatusSlotAnnotation(AlleleDatabaseStatusSlotAnnotation uiEntity) { AlleleDatabaseStatusSlotAnnotation mutationType = validateAlleleDatabaseStatusSlotAnnotation(uiEntity, false, false); @@ -57,7 +55,7 @@ public AlleleDatabaseStatusSlotAnnotation validateAlleleDatabaseStatusSlotAnnota VocabularyTerm databaseStatus = validateDatabaseStatus(uiEntity, dbEntity); dbEntity.setDatabaseStatus(databaseStatus); - + if (response.hasErrors()) { if (throwError) { response.setErrorMessage(errorTitle); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationValidator.java index 7bc67d15f..50114458b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class AlleleFullNameSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - AlleleFullNameSlotAnnotationDAO alleleFullNameDAO; - @Inject - AlleleDAO alleleDAO; + @Inject AlleleFullNameSlotAnnotationDAO alleleFullNameDAO; + @Inject AlleleDAO alleleDAO; public ObjectResponse validateAlleleFullNameSlotAnnotation(AlleleFullNameSlotAnnotation uiEntity) { AlleleFullNameSlotAnnotation fullName = validateAlleleFullNameSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationValidator.java index 6241a01e4..df35ef180 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotationValidator.java @@ -25,12 +25,9 @@ @RequestScoped public class AlleleFunctionalImpactSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - AlleleFunctionalImpactSlotAnnotationDAO alleleFunctionalImpactDAO; - @Inject - PhenotypeTermService phenotypeTermService; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AlleleFunctionalImpactSlotAnnotationDAO alleleFunctionalImpactDAO; + @Inject PhenotypeTermService phenotypeTermService; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleFunctionalImpactSlotAnnotation(AlleleFunctionalImpactSlotAnnotation uiEntity) { AlleleFunctionalImpactSlotAnnotation mutationType = validateAlleleFunctionalImpactSlotAnnotation(uiEntity, false, false); @@ -67,10 +64,10 @@ public AlleleFunctionalImpactSlotAnnotation validateAlleleFunctionalImpactSlotAn List functionalImpacts = validateFunctionalImpacts(uiEntity, dbEntity); dbEntity.setFunctionalImpacts(functionalImpacts); - + PhenotypeTerm phenotypeTerm = validatePhenotypeTerm(uiEntity, dbEntity); dbEntity.setPhenotypeTerm(phenotypeTerm); - + String phenotypeStatement = handleStringField(uiEntity.getPhenotypeStatement()); dbEntity.setPhenotypeStatement(phenotypeStatement); @@ -112,9 +109,10 @@ private List validateFunctionalImpacts(AlleleFunctionalImpactSlo public PhenotypeTerm validatePhenotypeTerm(AlleleFunctionalImpactSlotAnnotation uiEntity, AlleleFunctionalImpactSlotAnnotation dbEntity) { String field = "phenotypeTerm"; - if (ObjectUtils.isEmpty(uiEntity.getPhenotypeTerm())) + if (ObjectUtils.isEmpty(uiEntity.getPhenotypeTerm())) { return null; - + } + PhenotypeTerm phenotypeTerm = null; if (StringUtils.isNotBlank(uiEntity.getPhenotypeTerm().getCurie())) { phenotypeTerm = phenotypeTermService.findByCurie(uiEntity.getPhenotypeTerm().getCurie()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationValidator.java index 28b8fcc11..72c0185e7 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotationValidator.java @@ -18,12 +18,9 @@ @RequestScoped public class AlleleGermlineTransmissionStatusSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - AlleleGermlineTransmissionStatusSlotAnnotationDAO alleleGermlineTransmissionStatusDAO; - @Inject - AlleleDAO alleleDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AlleleGermlineTransmissionStatusSlotAnnotationDAO alleleGermlineTransmissionStatusDAO; + @Inject AlleleDAO alleleDAO; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleGermlineTransmissionStatusSlotAnnotation(AlleleGermlineTransmissionStatusSlotAnnotation uiEntity) { AlleleGermlineTransmissionStatusSlotAnnotation germlineTransmissionStatus = validateAlleleGermlineTransmissionStatusSlotAnnotation(uiEntity, false, false); @@ -71,7 +68,7 @@ public AlleleGermlineTransmissionStatusSlotAnnotation validateAlleleGermlineTran return dbEntity; } - + private VocabularyTerm validateGermlineTransmissionStatus(AlleleGermlineTransmissionStatusSlotAnnotation uiEntity, AlleleGermlineTransmissionStatusSlotAnnotation dbEntity) { String field = "germlineTransmissionStatus"; if (uiEntity.getGermlineTransmissionStatus() == null) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationValidator.java index 654ade21b..d095625fb 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotationValidator.java @@ -21,12 +21,9 @@ @RequestScoped public class AlleleInheritanceModeSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - AlleleInheritanceModeSlotAnnotationDAO alleleInheritanceModeDAO; - @Inject - PhenotypeTermService phenotypeTermService; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AlleleInheritanceModeSlotAnnotationDAO alleleInheritanceModeDAO; + @Inject PhenotypeTermService phenotypeTermService; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleInheritanceModeSlotAnnotation(AlleleInheritanceModeSlotAnnotation uiEntity) { AlleleInheritanceModeSlotAnnotation mutationType = validateAlleleInheritanceModeSlotAnnotation(uiEntity, false, false); @@ -63,10 +60,10 @@ public AlleleInheritanceModeSlotAnnotation validateAlleleInheritanceModeSlotAnno VocabularyTerm inheritanceMode = validateInheritanceMode(uiEntity, dbEntity); dbEntity.setInheritanceMode(inheritanceMode); - + PhenotypeTerm phenotypeTerm = validatePhenotypeTerm(uiEntity, dbEntity); dbEntity.setPhenotypeTerm(phenotypeTerm); - + String phenotypeStatement = handleStringField(uiEntity.getPhenotypeStatement()); dbEntity.setPhenotypeStatement(phenotypeStatement); @@ -105,9 +102,10 @@ private VocabularyTerm validateInheritanceMode(AlleleInheritanceModeSlotAnnotati public PhenotypeTerm validatePhenotypeTerm(AlleleInheritanceModeSlotAnnotation uiEntity, AlleleInheritanceModeSlotAnnotation dbEntity) { String field = "phenotypeTerm"; - if (ObjectUtils.isEmpty(uiEntity.getPhenotypeTerm())) + if (ObjectUtils.isEmpty(uiEntity.getPhenotypeTerm())) { return null; - + } + PhenotypeTerm phenotypeTerm = null; if (StringUtils.isNotBlank(uiEntity.getPhenotypeTerm().getCurie())) { phenotypeTerm = phenotypeTermService.findByCurie(uiEntity.getPhenotypeTerm().getCurie()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationValidator.java index 6c62852f1..2967c0ad8 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotationValidator.java @@ -21,10 +21,8 @@ @RequestScoped public class AlleleMutationTypeSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - AlleleMutationTypeSlotAnnotationDAO alleleMutationTypeDAO; - @Inject - SoTermDAO soTermDAO; + @Inject AlleleMutationTypeSlotAnnotationDAO alleleMutationTypeDAO; + @Inject SoTermDAO soTermDAO; public ObjectResponse validateAlleleMutationTypeSlotAnnotation(AlleleMutationTypeSlotAnnotation uiEntity) { AlleleMutationTypeSlotAnnotation mutationType = validateAlleleMutationTypeSlotAnnotation(uiEntity, false, false); @@ -82,12 +80,14 @@ private List validateMutationTypes(AlleleMutationTypeSlotAnnotation uiEn } List validMutationTypes = new ArrayList<>(); List previousIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getMutationTypes())) + if (CollectionUtils.isNotEmpty(dbEntity.getMutationTypes())) { previousIds = dbEntity.getMutationTypes().stream().map(SOTerm::getId).collect(Collectors.toList()); + } for (SOTerm mt : uiEntity.getMutationTypes()) { SOTerm mutationType = null; - if (mt.getId() != null) + if (mt.getId() != null) { mutationType = soTermDAO.find(mt.getId()); + } if (mutationType == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationValidator.java index d3a14bb0e..5da4854a9 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotationValidator.java @@ -17,10 +17,8 @@ @RequestScoped public class AlleleNomenclatureEventSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - AlleleNomenclatureEventSlotAnnotationDAO alleleNomenclatureEventDAO; - @Inject - VocabularyTermService vocabularyTermService; + @Inject AlleleNomenclatureEventSlotAnnotationDAO alleleNomenclatureEventDAO; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateAlleleNomenclatureEventSlotAnnotation(AlleleNomenclatureEventSlotAnnotation uiEntity) { AlleleNomenclatureEventSlotAnnotation nomenclatureEvent = validateAlleleNomenclatureEventSlotAnnotation(uiEntity, false, false); @@ -57,7 +55,7 @@ public AlleleNomenclatureEventSlotAnnotation validateAlleleNomenclatureEventSlot VocabularyTerm nomenclatureEvent = validateNomenclatureEvent(uiEntity, dbEntity); dbEntity.setNomenclatureEvent(nomenclatureEvent); - + if (response.hasErrors()) { if (throwError) { response.setErrorMessage(errorTitle); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationValidator.java index 30bf2ff4f..798dd7489 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotationValidator.java @@ -13,8 +13,7 @@ @RequestScoped public class AlleleSecondaryIdSlotAnnotationValidator extends SecondaryIdSlotAnnotationValidator { - @Inject - AlleleSecondaryIdSlotAnnotationDAO alleleSecondaryIdDAO; + @Inject AlleleSecondaryIdSlotAnnotationDAO alleleSecondaryIdDAO; public ObjectResponse validateAlleleSecondaryIdSlotAnnotation(AlleleSecondaryIdSlotAnnotation uiEntity) { AlleleSecondaryIdSlotAnnotation secondaryId = validateAlleleSecondaryIdSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationValidator.java index f2ff30842..4f0c835d7 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class AlleleSymbolSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - AlleleSymbolSlotAnnotationDAO alleleSymbolDAO; - @Inject - AlleleDAO alleleDAO; + @Inject AlleleSymbolSlotAnnotationDAO alleleSymbolDAO; + @Inject AlleleDAO alleleDAO; public ObjectResponse validateAlleleSymbolSlotAnnotation(AlleleSymbolSlotAnnotation uiEntity) { AlleleSymbolSlotAnnotation symbol = validateAlleleSymbolSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationValidator.java index b5e375b9a..1335ac6ce 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class AlleleSynonymSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - AlleleSynonymSlotAnnotationDAO alleleSynonymDAO; - @Inject - AlleleDAO alleleDAO; + @Inject AlleleSynonymSlotAnnotationDAO alleleSynonymDAO; + @Inject AlleleDAO alleleDAO; public ObjectResponse validateAlleleSynonymSlotAnnotation(AlleleSynonymSlotAnnotation uiEntity) { AlleleSynonymSlotAnnotation synonym = validateAlleleSynonymSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java index 86c9c3c4f..7d2abaa0c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java @@ -32,17 +32,11 @@ @RequestScoped public class ConstructComponentSlotAnnotationValidator extends SlotAnnotationValidator { - @Inject - ConstructComponentSlotAnnotationDAO constructComponentDAO; - @Inject - NcbiTaxonTermService ncbiTaxonTermService; - @Inject - NoteValidator noteValidator; - @Inject - NoteDAO noteDAO; - @Inject - VocabularyTermService vocabularyTermService; - + @Inject ConstructComponentSlotAnnotationDAO constructComponentDAO; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject NoteValidator noteValidator; + @Inject NoteDAO noteDAO; + @Inject VocabularyTermService vocabularyTermService; public ObjectResponse validateConstructComponentSlotAnnotation(ConstructComponentSlotAnnotation uiEntity) { ConstructComponentSlotAnnotation component = validateConstructComponentSlotAnnotation(uiEntity, false, false); @@ -76,22 +70,22 @@ public ConstructComponentSlotAnnotation validateConstructComponentSlotAnnotation Construct singleConstruct = validateSingleConstruct(uiEntity.getSingleConstruct(), dbEntity.getSingleConstruct()); dbEntity.setSingleConstruct(singleConstruct); } - + String componentSymbol = validateComponentSymbol(uiEntity); dbEntity.setComponentSymbol(componentSymbol); - + VocabularyTerm relation = validateRelation(uiEntity, dbEntity); dbEntity.setRelation(relation); - + NCBITaxonTerm taxon = validateTaxon(uiEntity, dbEntity); dbEntity.setTaxon(taxon); - + if (StringUtils.isNotBlank(uiEntity.getTaxonText())) { dbEntity.setTaxonText(uiEntity.getTaxonText()); } else { dbEntity.setTaxonText(null); } - + List relatedNotes = validateRelatedNotes(uiEntity, dbEntity); dbEntity.setRelatedNotes(relatedNotes); @@ -106,17 +100,17 @@ public ConstructComponentSlotAnnotation validateConstructComponentSlotAnnotation return dbEntity; } - + public String validateComponentSymbol(ConstructComponentSlotAnnotation uiEntity) { String field = "componentSymbol"; if (StringUtils.isBlank(uiEntity.getComponentSymbol())) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); return null; } - + return uiEntity.getComponentSymbol(); } - + private VocabularyTerm validateRelation(ConstructComponentSlotAnnotation uiEntity, ConstructComponentSlotAnnotation dbEntity) { String field = "relation"; if (uiEntity.getRelation() == null) { @@ -138,26 +132,27 @@ private VocabularyTerm validateRelation(ConstructComponentSlotAnnotation uiEntit return relation; } - + public NCBITaxonTerm validateTaxon(ConstructComponentSlotAnnotation uiEntity, ConstructComponentSlotAnnotation dbEntity) { String field = "taxon"; - if (uiEntity.getTaxon() == null || StringUtils.isBlank(uiEntity.getTaxon().getCurie())) + if (uiEntity.getTaxon() == null || StringUtils.isBlank(uiEntity.getTaxon().getCurie())) { return null; - + } + NCBITaxonTerm taxon = ncbiTaxonTermService.getByCurie(uiEntity.getTaxon().getCurie()).getEntity(); if (taxon == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; } - + if (taxon.getObsolete() && (dbEntity.getTaxon() == null || !taxon.getCurie().equals(dbEntity.getTaxon().getCurie()))) { addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); return null; } - + return taxon; } - + public List validateRelatedNotes(ConstructComponentSlotAnnotation uiEntity, ConstructComponentSlotAnnotation dbEntity) { String field = "relatedNotes"; @@ -171,7 +166,7 @@ public List validateRelatedNotes(ConstructComponentSlotAnnotation uiEntity return null; } note = noteResponse.getEntity(); - + String noteIdentity = NoteIdentityHelper.noteIdentity(note); if (validatedNoteIdentities.contains(noteIdentity)) { addMessageResponse(field, ValidationConstants.DUPLICATE_MESSAGE + " (" + noteIdentity + ")"); @@ -183,11 +178,13 @@ public List validateRelatedNotes(ConstructComponentSlotAnnotation uiEntity } List previousNoteIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(dbEntity.getRelatedNotes())) + if (CollectionUtils.isNotEmpty(dbEntity.getRelatedNotes())) { previousNoteIds = dbEntity.getRelatedNotes().stream().map(Note::getId).collect(Collectors.toList()); + } List validatedNoteIds = new ArrayList(); - if (CollectionUtils.isNotEmpty(validatedNotes)) + if (CollectionUtils.isNotEmpty(validatedNotes)) { validatedNoteIds = validatedNotes.stream().map(Note::getId).collect(Collectors.toList()); + } for (Note validatedNote : validatedNotes) { if (!previousNoteIds.contains(validatedNote.getId())) { noteDAO.persist(validatedNote); @@ -198,8 +195,9 @@ public List validateRelatedNotes(ConstructComponentSlotAnnotation uiEntity constructComponentDAO.deleteAttachedNote(id); } - if (CollectionUtils.isEmpty(validatedNotes)) + if (CollectionUtils.isEmpty(validatedNotes)) { return null; + } return validatedNotes; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationValidator.java index d6252942b..afe2d23b1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class ConstructFullNameSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - ConstructFullNameSlotAnnotationDAO constructFullNameDAO; - @Inject - ConstructDAO constructDAO; + @Inject ConstructFullNameSlotAnnotationDAO constructFullNameDAO; + @Inject ConstructDAO constructDAO; public ObjectResponse validateConstructFullNameSlotAnnotation(ConstructFullNameSlotAnnotation uiEntity) { ConstructFullNameSlotAnnotation fullName = validateConstructFullNameSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationValidator.java index b9ec60de6..ac7a6bb07 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class ConstructSymbolSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - ConstructSymbolSlotAnnotationDAO constructSymbolDAO; - @Inject - ConstructDAO constructDAO; + @Inject ConstructSymbolSlotAnnotationDAO constructSymbolDAO; + @Inject ConstructDAO constructDAO; public ObjectResponse validateConstructSymbolSlotAnnotation(ConstructSymbolSlotAnnotation uiEntity) { ConstructSymbolSlotAnnotation symbol = validateConstructSymbolSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationValidator.java index 1bd683e26..c4f744944 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class ConstructSynonymSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - ConstructSynonymSlotAnnotationDAO constructSynonymDAO; - @Inject - ConstructDAO constructDAO; + @Inject ConstructSynonymSlotAnnotationDAO constructSynonymDAO; + @Inject ConstructDAO constructDAO; public ObjectResponse validateConstructSynonymSlotAnnotation(ConstructSynonymSlotAnnotation uiEntity) { ConstructSynonymSlotAnnotation synonym = validateConstructSynonymSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationValidator.java index dc087460a..cd0e6a8bd 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class GeneFullNameSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - GeneFullNameSlotAnnotationDAO geneFullNameDAO; - @Inject - GeneDAO geneDAO; + @Inject GeneFullNameSlotAnnotationDAO geneFullNameDAO; + @Inject GeneDAO geneDAO; public ObjectResponse validateGeneFullNameSlotAnnotation(GeneFullNameSlotAnnotation uiEntity) { GeneFullNameSlotAnnotation fullName = validateGeneFullNameSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationValidator.java index d12ef5b6c..387efd7f6 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotationValidator.java @@ -12,8 +12,7 @@ @RequestScoped public class GeneSecondaryIdSlotAnnotationValidator extends SecondaryIdSlotAnnotationValidator { - @Inject - GeneSecondaryIdSlotAnnotationDAO geneSecondaryIdDAO; + @Inject GeneSecondaryIdSlotAnnotationDAO geneSecondaryIdDAO; public ObjectResponse validateGeneSecondaryIdSlotAnnotation(GeneSecondaryIdSlotAnnotation uiEntity) { GeneSecondaryIdSlotAnnotation secondaryId = validateGeneSecondaryIdSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationValidator.java index de26489a9..9bc81fa42 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class GeneSymbolSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - GeneSymbolSlotAnnotationDAO geneSymbolDAO; - @Inject - GeneDAO geneDAO; + @Inject GeneSymbolSlotAnnotationDAO geneSymbolDAO; + @Inject GeneDAO geneDAO; public ObjectResponse validateGeneSymbolSlotAnnotation(GeneSymbolSlotAnnotation uiEntity) { GeneSymbolSlotAnnotation symbol = validateGeneSymbolSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationValidator.java index 680b67124..f8798376b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class GeneSynonymSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - GeneSynonymSlotAnnotationDAO geneSynonymDAO; - @Inject - GeneDAO geneDAO; + @Inject GeneSynonymSlotAnnotationDAO geneSynonymDAO; + @Inject GeneDAO geneDAO; public ObjectResponse validateGeneSynonymSlotAnnotation(GeneSynonymSlotAnnotation uiEntity) { GeneSynonymSlotAnnotation synonym = validateGeneSynonymSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationValidator.java index fadff4712..99ee88357 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotationValidator.java @@ -15,10 +15,8 @@ @RequestScoped public class GeneSystematicNameSlotAnnotationValidator extends NameSlotAnnotationValidator { - @Inject - GeneSystematicNameSlotAnnotationDAO geneSystematicNameDAO; - @Inject - GeneDAO geneDAO; + @Inject GeneSystematicNameSlotAnnotationDAO geneSystematicNameDAO; + @Inject GeneDAO geneDAO; public ObjectResponse validateGeneSystematicNameSlotAnnotation(GeneSystematicNameSlotAnnotation uiEntity) { GeneSystematicNameSlotAnnotation systematicName = validateGeneSystematicNameSlotAnnotation(uiEntity, false, false); diff --git a/src/main/java/org/alliancegenome/curation_api/util/DefaultProcessDisplayHandler.java b/src/main/java/org/alliancegenome/curation_api/util/DefaultProcessDisplayHandler.java index 8bcde52d2..c8d682620 100644 --- a/src/main/java/org/alliancegenome/curation_api/util/DefaultProcessDisplayHandler.java +++ b/src/main/java/org/alliancegenome/curation_api/util/DefaultProcessDisplayHandler.java @@ -13,10 +13,11 @@ public class DefaultProcessDisplayHandler implements ProcessDisplayHandler { @Override public void startProcess(String message, long startTime, long totalSize) { - if (totalSize > 0) + if (totalSize > 0) { logInfoMessage(message + "Starting Process [total = " + ProcessDisplayHandler.getBigNumber(totalSize) + "] " + new Date(startTime)); - else + } else { logInfoMessage(message + "Starting Process... (" + new Date(startTime) + ")"); + } } @Override @@ -24,17 +25,17 @@ public void progressProcess(String message, String data, long startTime, long no double percent = 0; if (totalSize > 0) { - percent = ((double) (currentCount) / totalSize); + percent = (double) currentCount / totalSize; } - long processedAmount = (currentCount - lastCount); + long processedAmount = currentCount - lastCount; StringBuffer sb = new StringBuffer(message == null ? "" : message); sb.append(ProcessDisplayHandler.getBigNumber(currentCount)); if (totalSize > 0) { sb.append(" of [" + ProcessDisplayHandler.getBigNumber(totalSize) + "] " + (int) (percent * 100L) + "%"); } - long time = (nowTime - lastTime); - long diff = (nowTime - startTime); + long time = nowTime - lastTime; + long diff = nowTime - startTime; sb.append(", " + (time / 1000) + "s to process " + ProcessDisplayHandler.getBigNumber(processedAmount) + " records at " + ProcessDisplayHandler.getBigNumber((processedAmount * 1000L) / time) + "r/s"); if (data != null) { sb.append(" " + data); @@ -83,7 +84,7 @@ private void checkMemory(String message, String data) { } private double memoryPercent() { - return ((double) runtime.totalMemory() - (double) runtime.freeMemory()) / (double) runtime.maxMemory(); + return ((double) runtime.totalMemory() - (double) runtime.freeMemory()) / runtime.maxMemory(); } private void logWarnMessage(String message) { diff --git a/src/main/java/org/alliancegenome/curation_api/util/FileTransferHelper.java b/src/main/java/org/alliancegenome/curation_api/util/FileTransferHelper.java index 390bfcda4..36313c9db 100644 --- a/src/main/java/org/alliancegenome/curation_api/util/FileTransferHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/util/FileTransferHelper.java @@ -45,7 +45,7 @@ public String saveIncomingURLFile(String url) { URL redirectUrl = response.url(); log.info("Saving file to local filesystem: " + saveFilePath.getAbsolutePath()); FileUtils.copyURLToFile(redirectUrl, saveFilePath); - if(!saveFilePath.exists() || saveFilePath.length() == 0) { + if (!saveFilePath.exists() || saveFilePath.length() == 0) { log.error("Downloading URL failed: " + redirectUrl); saveFilePath.delete(); return null; @@ -87,17 +87,17 @@ public String saveIncomingFile(MultipartFormDataInput input, String formField) { public String compressInputFile(String fullFilePath) { - if(fullFilePath == null) { + if (fullFilePath == null) { return null; } - + File inFilePath = new File(fullFilePath); - - if(!inFilePath.exists() || inFilePath.length() == 0) { + + if (!inFilePath.exists() || inFilePath.length() == 0) { log.error("Input file does not exist"); return null; } - + try { GZIPInputStream gs = new GZIPInputStream(new FileInputStream(inFilePath)); gs.close(); @@ -121,13 +121,13 @@ public String compressInputFile(String fullFilePath) { } - public File downloadFileFromS3(String AWSAccessKey, String AWSSecretKey, String bucket, String fullS3Path) { + public File downloadFileFromS3(String aWSAccessKey, String aWSSecretKey, String bucket, String fullS3Path) { File localOutFile = generateFilePath(); try { log.info("Download file From S3: " + "s3://" + bucket + "/" + fullS3Path + " -> " + localOutFile.getAbsolutePath()); - AmazonS3 s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(AWSAccessKey, AWSSecretKey))).withRegion(Regions.US_EAST_1).build(); + AmazonS3 s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(aWSAccessKey, aWSSecretKey))).withRegion(Regions.US_EAST_1).build(); TransferManager tm = TransferManagerBuilder.standard().withS3Client(s3).build(); final Download downloadFile = tm.download(bucket, fullS3Path, localOutFile); downloadFile.waitForCompletion(); @@ -142,11 +142,11 @@ public File downloadFileFromS3(String AWSAccessKey, String AWSSecretKey, String } } - public String uploadFileToS3(String AWSAccessKey, String AWSSecretKey, String bucket, String prefix, String path, File inFile) { + public String uploadFileToS3(String aWSAccessKey, String aWSSecretKey, String bucket, String prefix, String path, File inFile) { try { String fullS3Path = prefix + "/" + path; log.info("Uploading file to S3: " + inFile.getAbsolutePath() + " -> s3://" + bucket + "/" + fullS3Path); - AmazonS3 s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(AWSAccessKey, AWSSecretKey))).withRegion(Regions.US_EAST_1).build(); + AmazonS3 s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(aWSAccessKey, aWSSecretKey))).withRegion(Regions.US_EAST_1).build(); TransferManager tm = TransferManagerBuilder.standard().withS3Client(s3).build(); final Upload uploadFile = tm.upload(bucket, fullS3Path, inFile); uploadFile.waitForCompletion(); diff --git a/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHandler.java b/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHandler.java index 70ce1ab5d..a88563c6d 100644 --- a/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHandler.java +++ b/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHandler.java @@ -4,20 +4,20 @@ public interface ProcessDisplayHandler { - public static String getBigNumber(long number) { + static String getBigNumber(long number) { return String.format("%,d", number); } - public static String getHumanReadableTimeDisplay(long duration) { + static String getHumanReadableTimeDisplay(long duration) { long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration)); long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration)); long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration)); return String.format("%02d:%02d:%02d", hours, minutes, seconds); } - public void startProcess(String message, long startTime, long totalSize); + void startProcess(String message, long startTime, long totalSize); - public void progressProcess(String message, String data, long startTime, long nowTime, long lastTime, long currentCount, long lastCount, long totalSize); + void progressProcess(String message, String data, long startTime, long nowTime, long lastTime, long currentCount, long lastCount, long totalSize); - public void finishProcess(String message, String data, long currentCount, long totalSize, long duration); + void finishProcess(String message, String data, long currentCount, long totalSize, long duration); } diff --git a/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHelper.java b/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHelper.java index fa85d8314..9542990a7 100644 --- a/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/util/ProcessDisplayHelper.java @@ -8,10 +8,10 @@ public class ProcessDisplayHelper { - private long startTime = 0; - private long lastTime = 0; + private long startTime; + private long lastTime; private String message; - private long lastSizeCounter = 0; + private long lastSizeCounter; private long totalSize; private final Semaphore sem = new Semaphore(1); diff --git a/src/main/java/org/alliancegenome/curation_api/view/View.java b/src/main/java/org/alliancegenome/curation_api/view/View.java index a188edc58..03c1ea2ab 100644 --- a/src/main/java/org/alliancegenome/curation_api/view/View.java +++ b/src/main/java/org/alliancegenome/curation_api/view/View.java @@ -3,13 +3,13 @@ public class View { // Curation Views - + public static class FieldsOnly { } public static class FieldsAndLists extends FieldsOnly { } - + public static class ConditionRelationView extends FieldsOnly { } @@ -45,7 +45,7 @@ public static class ReportHistory extends FieldsOnly { public static class ConstructView extends FieldsOnly { } - + public static class DiseaseAnnotation extends FieldsOnly { } @@ -54,7 +54,7 @@ public static class DiseaseAnnotationUpdate extends DiseaseAnnotation { public static class DiseaseAnnotationCreate extends DiseaseAnnotation { } - + public static class PhenotypeAnnotationView extends FieldsOnly { } @@ -63,7 +63,7 @@ public static class PhenotypeAnnotationUpdate extends PhenotypeAnnotationView { public static class PhenotypeAnnotationCreate extends PhenotypeAnnotationView { } - + public static class AffectedGenomicModelView extends FieldsOnly { } @@ -99,7 +99,7 @@ public static class VariantUpdate extends GeneView { public static class VariantCreate extends GeneView { } - + public static class GeneInteractionView extends FieldsOnly { } @@ -108,13 +108,15 @@ public static class PersonSettingView { public static class PrivateOnlyView { } - + // Public only views - + public static class ForPublic { } + public static class DiseaseAnnotationForPublic extends ForPublic { } + public static class BulkLoadFileHistoryView extends FieldsOnly { } } diff --git a/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java b/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java index d6c9d0b55..8fbf88d94 100644 --- a/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java +++ b/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java @@ -36,7 +36,7 @@ public void onOpen(Session session) { //Log.info("Creating New Session: " + session); try { sessions.put(session.getId(), session); - if(event != null) { + if (event != null) { session.getAsyncRemote().sendText(mapper.writeValueAsString(event)); } } catch (Exception e) { diff --git a/src/test/java/org/alliancegenome/curation_api/AffectedGenomicModelITCase.java b/src/test/java/org/alliancegenome/curation_api/AffectedGenomicModelITCase.java index 293b72014..cd35865e7 100644 --- a/src/test/java/org/alliancegenome/curation_api/AffectedGenomicModelITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/AffectedGenomicModelITCase.java @@ -37,7 +37,7 @@ @Order(303) public class AffectedGenomicModelITCase extends BaseITCase { - private final String AGM = "AGM:0001"; + private static final String AGM = "AGM:0001"; private NCBITaxonTerm taxon; private NCBITaxonTerm taxon2; @@ -113,7 +113,7 @@ public void createValidAGM() { @Order(2) public void editAGM() { AffectedGenomicModel agm = getAffectedGenomicModel(AGM); - agm.setName("AGM edited");; + agm.setName("AGM edited"); agm.setTaxon(taxon2); agm.setInternal(true); agm.setObsolete(true); diff --git a/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java b/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java index 07b8288d3..9f8023fe9 100644 --- a/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java @@ -57,7 +57,7 @@ @Order(302) public class AlleleITCase extends BaseITCase { - private final String ALLELE = "Allele:0001"; + private static final String ALLELE = "Allele:0001"; private Vocabulary inheritanceModeVocabulary; private Vocabulary germlineTransmissionStatusVocabulary; @@ -1003,7 +1003,7 @@ public void editAlleleWithInvalidFields() { "synonymScope - " + ValidationConstants.INVALID_MESSAGE)))). body("errorMessages.alleleSecondaryIds", is("evidence - " + ValidationConstants.INVALID_MESSAGE)). body("errorMessages.dataProvider", is("sourceOrganization - " + ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.alleleFunctionalImpacts", is(String.join( " | ", List.of( + body("errorMessages.alleleFunctionalImpacts", is(String.join(" | ", List.of( "evidence - " + ValidationConstants.INVALID_MESSAGE, "functionalImpacts - " + ValidationConstants.INVALID_MESSAGE, "phenotypeTerm - " + ValidationConstants.INVALID_MESSAGE)))). @@ -1091,7 +1091,7 @@ public void createAlleleWithObsoleteFields() { "synonymScope - " + ValidationConstants.OBSOLETE_MESSAGE)))). body("errorMessages.alleleSecondaryIds", is("evidence - " + ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.dataProvider", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.alleleFunctionalImpacts", is(String.join( " | ", List.of( + body("errorMessages.alleleFunctionalImpacts", is(String.join(" | ", List.of( "evidence - " + ValidationConstants.OBSOLETE_MESSAGE, "functionalImpacts - " + ValidationConstants.OBSOLETE_MESSAGE, "phenotypeTerm - " + ValidationConstants.OBSOLETE_MESSAGE)))). @@ -1197,7 +1197,7 @@ public void editAlleleWithObsoleteFields() { "synonymScope - " + ValidationConstants.OBSOLETE_MESSAGE)))). body("errorMessages.alleleSecondaryIds", is("evidence - " + ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.dataProvider", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.alleleFunctionalImpacts", is(String.join( " | ", List.of( + body("errorMessages.alleleFunctionalImpacts", is(String.join(" | ", List.of( "evidence - " + ValidationConstants.OBSOLETE_MESSAGE, "functionalImpacts - " + ValidationConstants.OBSOLETE_MESSAGE, "phenotypeTerm - " + ValidationConstants.OBSOLETE_MESSAGE)))). @@ -1593,7 +1593,7 @@ public void deleteAllele() { statusCode(200); } - private AlleleMutationTypeSlotAnnotation createAlleleMutationTypeSlotAnnotation (List evidence, List mutationTypes) { + private AlleleMutationTypeSlotAnnotation createAlleleMutationTypeSlotAnnotation(List evidence, List mutationTypes) { AlleleMutationTypeSlotAnnotation amt = new AlleleMutationTypeSlotAnnotation(); amt.setEvidence(evidence); amt.setMutationTypes(mutationTypes); @@ -1601,7 +1601,7 @@ private AlleleMutationTypeSlotAnnotation createAlleleMutationTypeSlotAnnotation return amt; } - private AlleleGermlineTransmissionStatusSlotAnnotation createAlleleGermlineTransmissionStatusSlotAnnotation (List evidence, VocabularyTerm status) { + private AlleleGermlineTransmissionStatusSlotAnnotation createAlleleGermlineTransmissionStatusSlotAnnotation(List evidence, VocabularyTerm status) { AlleleGermlineTransmissionStatusSlotAnnotation agts = new AlleleGermlineTransmissionStatusSlotAnnotation(); agts.setEvidence(evidence); agts.setGermlineTransmissionStatus(status); @@ -1609,7 +1609,7 @@ private AlleleGermlineTransmissionStatusSlotAnnotation createAlleleGermlineTrans return agts; } - private AlleleDatabaseStatusSlotAnnotation createAlleleDatabaseStatusSlotAnnotation (List evidence, VocabularyTerm status) { + private AlleleDatabaseStatusSlotAnnotation createAlleleDatabaseStatusSlotAnnotation(List evidence, VocabularyTerm status) { AlleleDatabaseStatusSlotAnnotation ads = new AlleleDatabaseStatusSlotAnnotation(); ads.setEvidence(evidence); ads.setDatabaseStatus(status); @@ -1681,7 +1681,7 @@ private AlleleFunctionalImpactSlotAnnotation createAlleleFunctionalImpactSlotAnn return functionalImpact; } - private AlleleNomenclatureEventSlotAnnotation createAlleleNomenclatureEventSlotAnnotation (List evidence, VocabularyTerm event) { + private AlleleNomenclatureEventSlotAnnotation createAlleleNomenclatureEventSlotAnnotation(List evidence, VocabularyTerm event) { AlleleNomenclatureEventSlotAnnotation ane = new AlleleNomenclatureEventSlotAnnotation(); ane.setEvidence(evidence); ane.setNomenclatureEvent(event); diff --git a/src/test/java/org/alliancegenome/curation_api/CHEBITermITCase.java b/src/test/java/org/alliancegenome/curation_api/CHEBITermITCase.java index 8f02dcfef..b398a77d7 100644 --- a/src/test/java/org/alliancegenome/curation_api/CHEBITermITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/CHEBITermITCase.java @@ -29,10 +29,10 @@ @DisplayName("501 - CHEBITermITCase") @Order(501) public class CHEBITermITCase { - private String CHEBITERMCURIE = "CH:0001"; + private static final String CHEBITERMCURIE = "CH:0001"; private TypeRef> getObjectResponseTypeRef() { - return new TypeRef>() { }; + return new TypeRef>() { }; } @BeforeEach @@ -90,7 +90,7 @@ void testEdit() { get("/api/chebiterm/" + CHEBITERMCURIE). then(). statusCode(200). - body("entity.definition",is("Changed definition")); + body("entity.definition", is("Changed definition")); } @Test diff --git a/src/test/java/org/alliancegenome/curation_api/ConstructBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/ConstructBulkUploadITCase.java index 7f38e3d41..6741f762e 100644 --- a/src/test/java/org/alliancegenome/curation_api/ConstructBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/ConstructBulkUploadITCase.java @@ -295,7 +295,7 @@ public void constructBulkUploadInvalidFields() throws Exception { checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_03_invalid_reference.json"); checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_04_invalid_construct_component_evidence.json"); checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_05_invalid_construct_component_taxon.json"); - checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_06_invalid_construct_component_note_note_type.json");; + checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_06_invalid_construct_component_note_note_type.json"); checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_07_invalid_data_provider_source_organization_abbreviation.json"); checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_08_invalid_data_provider_cross_reference_prefix.json"); checkFailedBulkLoad(constructBulkPostEndpoint, constructTestFilePath + "IV_09_invalid_data_provider_cross_reference_page_area.json"); diff --git a/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java b/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java index 1ea5af898..48a6200e4 100644 --- a/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java @@ -48,7 +48,7 @@ @Order(307) public class ConstructITCase extends BaseITCase { - private final String CONSTRUCT = "Construct:0001"; + private static final String CONSTRUCT = "Construct:0001"; private Vocabulary noteTypeVocabulary; private VocabularyTerm noteType; @@ -563,7 +563,7 @@ public void createConstructWithInvalidFields() { body("errorMessages.references", is("curie - " + ValidationConstants.INVALID_MESSAGE)). body("errorMessages.constructComponents", is(String.join(" | ", List.of( "evidence - " + ValidationConstants.INVALID_MESSAGE, - "relatedNotes - " + String.join( " | ", List.of( + "relatedNotes - " + String.join(" | ", List.of( "noteType - " + ValidationConstants.INVALID_MESSAGE, "references - " + ValidationConstants.INVALID_MESSAGE )), @@ -637,7 +637,7 @@ public void editConstructWithInvalidFields() { body("errorMessages.references", is("curie - " + ValidationConstants.INVALID_MESSAGE)). body("errorMessages.constructComponents", is(String.join(" | ", List.of( "evidence - " + ValidationConstants.INVALID_MESSAGE, - "relatedNotes - " + String.join( " | ", List.of( + "relatedNotes - " + String.join(" | ", List.of( "noteType - " + ValidationConstants.INVALID_MESSAGE, "references - " + ValidationConstants.INVALID_MESSAGE )), @@ -1001,7 +1001,7 @@ public void updateConstructWithInvalidAssociations() { body("errorMessages.constructGenomicEntityAssociations", is("relation - " + ValidationConstants.INVALID_MESSAGE)); } - private ConstructComponentSlotAnnotation createConstructComponentSlotAnnotation (VocabularyTerm relation, List evidence, String symbol, NCBITaxonTerm taxon, String taxonText, List notes) { + private ConstructComponentSlotAnnotation createConstructComponentSlotAnnotation(VocabularyTerm relation, List evidence, String symbol, NCBITaxonTerm taxon, String taxonText, List notes) { ConstructComponentSlotAnnotation cc = new ConstructComponentSlotAnnotation(); cc.setComponentSymbol(symbol); cc.setRelation(relation); diff --git a/src/test/java/org/alliancegenome/curation_api/DOTermITCase.java b/src/test/java/org/alliancegenome/curation_api/DOTermITCase.java index f0153c642..a0e8a20d8 100644 --- a/src/test/java/org/alliancegenome/curation_api/DOTermITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/DOTermITCase.java @@ -30,10 +30,10 @@ @DisplayName("502 - DOTermITCase") @Order(502) public class DOTermITCase { - private String DOTERMCURIE = "DOID:10001"; + private static final String DOTERMCURIE = "DOID:10001"; private TypeRef> getObjectResponseTypeRef() { - return new TypeRef>() { }; + return new TypeRef>() { }; } @BeforeEach @@ -69,7 +69,7 @@ void testCreate() { get("/api/doterm/" + DOTERMCURIE). then(). statusCode(200). - body("entity.definition",is("DO term definition")). + body("entity.definition", is("DO term definition")). body("entity.name", is("DO Term 1")). body("entity.namespace", is("disease_ontology")). body("entity.obsolete", is(false)); @@ -104,7 +104,7 @@ void testEdit() { get("/api/doterm/" + DOTERMCURIE). then(). statusCode(200). - body("entity.definition",is("changed definition")). + body("entity.definition", is("changed definition")). body("entity.name", is("changed name")). body("entity.namespace", is("changed_namespace")). body("entity.obsolete", is(true)); diff --git a/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java b/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java index 879679327..a38630e57 100644 --- a/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java @@ -49,9 +49,9 @@ @Order(304) public class DiseaseAnnotationITCase extends BaseITCase { - private final String GENE_DISEASE_ANNOTATION = "GeneDisease:0001"; - private final String ALLELE_DISEASE_ANNOTATION = "AlleleDisease:0001"; - private final String AGM_DISEASE_ANNOTATION = "AgmDisease:0001"; + private static final String GENE_DISEASE_ANNOTATION = "GeneDisease:0001"; + private static final String ALLELE_DISEASE_ANNOTATION = "AlleleDisease:0001"; + private static final String AGM_DISEASE_ANNOTATION = "AgmDisease:0001"; private DOTerm doTerm; private DOTerm doTerm2; @@ -175,14 +175,14 @@ private void loadRequiredEntities() { diseaseQualifier = getVocabularyTerm(diseaseQualifierVocabulary, "severity"); diseaseQualifier2 = createVocabularyTerm(diseaseQualifierVocabulary, "onset", false); obsoleteDiseaseQualifier = createVocabularyTerm(diseaseQualifierVocabulary, "obsolete_qualifier", true); - geneticSex = createVocabularyTerm(geneticSexVocabulary,"hermaphrodite", false); - geneticSex2 = getVocabularyTerm(geneticSexVocabulary,"female"); + geneticSex = createVocabularyTerm(geneticSexVocabulary, "hermaphrodite", false); + geneticSex2 = getVocabularyTerm(geneticSexVocabulary, "female"); obsoleteGeneticSex = createVocabularyTerm(geneticSexVocabulary, "obsolete_sex", true); diseaseGeneticModifierRelation = getVocabularyTerm(diseaseGeneticModifierRelationVocabulary, "ameliorated_by"); diseaseGeneticModifierRelation2 = getVocabularyTerm(diseaseGeneticModifierRelationVocabulary, "exacerbated_by"); obsoleteDiseaseGeneticModifierRelation = createVocabularyTerm(diseaseGeneticModifierRelationVocabulary, "obsolete_modifier_relation", true); - annotationType = getVocabularyTerm(annotationTypeVocabulary,"computational"); - annotationType2 = getVocabularyTerm(annotationTypeVocabulary,"manually_curated"); + annotationType = getVocabularyTerm(annotationTypeVocabulary, "computational"); + annotationType2 = getVocabularyTerm(annotationTypeVocabulary, "manually_curated"); obsoleteAnnotationType = createVocabularyTerm(annotationTypeVocabulary, "obsolete_annotation_type", true); person = createPerson("TEST:Person0001"); noteType = getVocabularyTerm(noteTypeVocabulary, "disease_note"); diff --git a/src/test/java/org/alliancegenome/curation_api/GeneITCase.java b/src/test/java/org/alliancegenome/curation_api/GeneITCase.java index 182c592ca..d68596782 100644 --- a/src/test/java/org/alliancegenome/curation_api/GeneITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/GeneITCase.java @@ -47,7 +47,7 @@ @Order(301) public class GeneITCase extends BaseITCase { - private final String GENE = "GENE:0001"; + private static final String GENE = "GENE:0001"; private Vocabulary nameType; private Vocabulary synonymScope; private VocabularyTerm exactSynonymScope; diff --git a/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java index 9b2db1f5b..ac2678c2e 100644 --- a/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java @@ -76,7 +76,7 @@ private void loadRequiredEntities() throws Exception { loadGenes(List.of(gene1, gene2), "NCBITaxon:6239", symbolTerm, dataProvider); loadGeneWithXref(gene3, "NCBITaxon:6239", symbolTerm, dataProvider, gene3xref); loadAllele(allele1, "GGITestVar1", "NCBITaxon:6239", symbolTerm, dataProvider); - loadAllele(allele2, "GGITestVar2","NCBITaxon:6239", symbolTerm, dataProvider); + loadAllele(allele2, "GGITestVar2", "NCBITaxon:6239", symbolTerm, dataProvider); loadMITerm(miTerm1, "Test MITerm 1"); loadMITerm(miTerm2, "Test MITerm 2"); loadMITerm(miTerm3, "Test MITerm 3"); diff --git a/src/test/java/org/alliancegenome/curation_api/MoleculeBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/MoleculeBulkUploadFmsITCase.java index cfcaba964..61046cab7 100644 --- a/src/test/java/org/alliancegenome/curation_api/MoleculeBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/MoleculeBulkUploadFmsITCase.java @@ -91,7 +91,7 @@ public void moleculeBulkUploadNoId() throws Exception { statusCode(200); RestAssured.given(). - when(). + when(). header("Content-Type", "application/json"). body("{}"). post("/api/molecule/find?limit=20&page=0"). @@ -115,7 +115,7 @@ public void moleculeBulkUploadNoName() throws Exception { statusCode(200); RestAssured.given(). - when(). + when(). header("Content-Type", "application/json"). body("{}"). post("/api/molecule/find?limit=20&page=0"). diff --git a/src/test/java/org/alliancegenome/curation_api/NCBITaxonTermITCase.java b/src/test/java/org/alliancegenome/curation_api/NCBITaxonTermITCase.java index 0758d8c0b..0383defdf 100644 --- a/src/test/java/org/alliancegenome/curation_api/NCBITaxonTermITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/NCBITaxonTermITCase.java @@ -26,9 +26,9 @@ @DisplayName("503 - NCBITaxonTermITCase") @Order(503) public class NCBITaxonTermITCase { - private String VALID_TAXON_CURIE = "NCBITaxon:1"; - private String INVALID_TAXON_PREFIX = "NCBI:1"; - private String INVALID_TAXON_SUFFIX = "NCBITaxon:0"; + private static final String VALID_TAXON_CURIE = "NCBITaxon:1"; + private static final String INVALID_TAXON_PREFIX = "NCBI:1"; + private static final String INVALID_TAXON_SUFFIX = "NCBITaxon:0"; @BeforeEach public void init() { diff --git a/src/test/java/org/alliancegenome/curation_api/NoteITCase.java b/src/test/java/org/alliancegenome/curation_api/NoteITCase.java index 59dc704bc..764bf2cd4 100644 --- a/src/test/java/org/alliancegenome/curation_api/NoteITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/NoteITCase.java @@ -46,7 +46,7 @@ private void createRequiredObjects() { testVocabulary = createVocabulary("Note test vocabulary", false); testVocabularyTerm = createVocabularyTerm(testVocabulary, "Note test vocabulary term", false); testVocabularyTerm2 = createVocabularyTerm(testVocabulary, "Note test vocabulary term 2", false); - testObsoleteVocabularyTerm = createVocabularyTerm( testVocabulary, "Obsolete Note test vocabularyTerm", true); + testObsoleteVocabularyTerm = createVocabularyTerm(testVocabulary, "Obsolete Note test vocabularyTerm", true); Reference testReference = createReference("AGRKB:000000007", false); testReferences.add(testReference); Reference testReference2 = createReference("AGRKB:000000008", false); diff --git a/src/test/java/org/alliancegenome/curation_api/VariantITCase.java b/src/test/java/org/alliancegenome/curation_api/VariantITCase.java index b22d51bc2..1d3ae1cfa 100644 --- a/src/test/java/org/alliancegenome/curation_api/VariantITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/VariantITCase.java @@ -42,7 +42,7 @@ @Order(309) public class VariantITCase extends BaseITCase { - private final String VARIANT = "Variant:0001"; + private static final String VARIANT = "Variant:0001"; private Vocabulary variantStatusVocabulary; private Vocabulary noteTypeVocabulary; diff --git a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java index 594c98cfa..e509b1b95 100644 --- a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java @@ -259,8 +259,9 @@ public Construct createConstruct(String modEntityId, Boolean obsolete, Vocabular public DataProvider createDataProvider(String organizationAbbreviation, Boolean obsolete) { DataProvider dataProvider = new DataProvider(); Organization sourceOrganization = getOrganization(organizationAbbreviation); - if (sourceOrganization == null) + if (sourceOrganization == null) { sourceOrganization = createOrganization(organizationAbbreviation, false); + } dataProvider.setSourceOrganization(sourceOrganization); dataProvider.setObsolete(obsolete); @@ -299,8 +300,9 @@ public ECOTerm createEcoTerm(String curie, String name, Boolean obsolete, Boolea ecoTerm.setName(name); ecoTerm.setObsolete(obsolete); ecoTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - if (inAgrSubset) + if (inAgrSubset) { ecoTerm.setSubsets(List.of(OntologyConstants.AGR_ECO_TERM_SUBSET)); + } ObjectResponse response = given(). contentType("application/json"). @@ -451,7 +453,7 @@ public Person createPerson(String uniqueId) { body().as(getObjectResponseTypeRefLoggedInPerson()); person = response.getEntity(); - return (Person) person; + return person; } public Reference createReference(String curie, Boolean obsolete) { @@ -799,39 +801,42 @@ public Variant getVariant(String curie) { } private TypeRef> getObjectListResponseTypeRefVocabularyTerm() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } - + private TypeRef> getObjectResponseTypeRefAffectedGenomicModel() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } private TypeRef> getObjectResponseTypeRefAGMDiseaseAnnotation() { - return new TypeRef>() { + return new TypeRef>() { }; } - + private TypeRef> getObjectResponseTypeRefAllele() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } private TypeRef> getObjectResponseTypeRefAlleleDiseaseAnnotation() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefAlleleGeneAssociation() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefBiologicalEntity() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefCHEBITerm() { - return new TypeRef>() { + return new TypeRef>() { }; } @@ -841,17 +846,18 @@ public TypeRef> getObjectResponseTypeRefCondit } public TypeRef> getObjectResponseTypeRefConstruct() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefConstructGenomicEntityAssociation() { - return new TypeRef>() { + return new TypeRef>() { }; } - + private TypeRef> getObjectResponseTypeRefCrossReference() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } private TypeRef> getObjectResponseTypeRefDataProvider() { @@ -860,12 +866,12 @@ private TypeRef> getObjectResponseTypeRefDataProvid } private TypeRef> getObjectResponseTypeRefDOTerm() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefECOTerm() { - return new TypeRef>() { + return new TypeRef>() { }; } @@ -875,81 +881,87 @@ private TypeRef> getObjectResponseTypeRefE } private TypeRef> getObjectResponseTypeRefGene() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } private TypeRef> getObjectResponseTypeRefGeneDiseaseAnnotation() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefGOTerm() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefLoggedInPerson() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefMPTerm() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefNCBITaxonTerm() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } - + public TypeRef> getObjectResponseTypeRefNote() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } private TypeRef> getObjectResponseTypeRefOrganization() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefReference() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefResourceDescriptor() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefResourceDescriptorPage() { - return new TypeRef>() { + return new TypeRef>() { }; } private TypeRef> getObjectResponseTypeRefSOTerm() { - return new TypeRef>() { + return new TypeRef>() { }; } - + private TypeRef> getObjectResponseTypeRefVariant() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } - + private TypeRef> getObjectResponseTypeRefVocabulary() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } - + private TypeRef> getObjectResponseTypeRefVocabularyTerm() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } private TypeRef> getObjectResponseTypeRefZecoTerm() { return new TypeRef<>() { }; } - + private TypeRef> getObjectResponseTypeRefZFATerm() { - return new TypeRef>() { + return new TypeRef>() { }; } @@ -980,24 +992,28 @@ public Organization getOrganization(String abbreviation) { } protected TypeRef> getSearchResponseTypeRefAGMPhenotypeAnnotation() { - return new TypeRef>() { + return new TypeRef>() { }; } + protected TypeRef> getSearchResponseTypeRefAllelePhenotypeAnnotation() { - return new TypeRef>() { + return new TypeRef>() { }; } + private TypeRef> getSearchResponseTypeRefOrganization() { - return new TypeRef>() { + return new TypeRef>() { }; } - + private TypeRef> getSearchResponseTypeRefVocabulary() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } - + private TypeRef> getSearchResponseTypeRefVocabularyTermSet() { - return new TypeRef>() { }; + return new TypeRef>() { + }; } public SOTerm getSoTerm(String curie) { diff --git a/src/test/java/org/alliancegenome/curation_api/util/SearchDocumentStatsGather.java b/src/test/java/org/alliancegenome/curation_api/util/SearchDocumentStatsGather.java index c42dcd197..bfc6bcff2 100644 --- a/src/test/java/org/alliancegenome/curation_api/util/SearchDocumentStatsGather.java +++ b/src/test/java/org/alliancegenome/curation_api/util/SearchDocumentStatsGather.java @@ -21,40 +21,39 @@ public class SearchDocumentStatsGather { HashMap sizeMap = new HashMap(); - + public static void main(String[] args) throws Exception { new SearchDocumentStatsGather(); } - + public SearchDocumentStatsGather() throws Exception { - - //RestHighLevelClient client = createClient("olin-dev.alliancegenome.org"); + + // RestHighLevelClient client = createClient("olin-dev.alliancegenome.org"); RestHighLevelClient client = createClient("alpha.cluster01.alliancegenome.org"); - - //final Scroll scroll = new Scroll(); + // final Scroll scroll = new Scroll(); SearchRequest searchRequest = new SearchRequest("allele-000001"); - - //searchRequest.scroll(scroll); + + // searchRequest.scroll(scroll); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); searchSourceBuilder.query(); searchSourceBuilder.size(1000); searchRequest.source(searchSourceBuilder); searchRequest.scroll(TimeValue.timeValueSeconds(60)); - SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); String scrollId = searchResponse.getScrollId(); SearchHit[] searchHits = searchResponse.getHits().getHits(); - + int c = searchHits.length; - + while (searchHits != null && searchHits.length > 0) { - - for(SearchHit hit: searchHits) { + + for (SearchHit hit : searchHits) { processHit("", hit.getSourceAsMap()); } - + System.out.println(c + " -> " + sizeMap); SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); @@ -63,12 +62,12 @@ public SearchDocumentStatsGather() throws Exception { scrollId = searchResponse.getScrollId(); c += searchHits.length; searchHits = searchResponse.getHits().getHits(); - //System.out.println(searchHits); + // System.out.println(searchHits); } - + System.out.println(c + " -> " + sizeMap); - ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); + ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(scrollId); ClearScrollResponse clearScrollResponse = client.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); boolean succeeded = clearScrollResponse.isSucceeded(); @@ -76,25 +75,24 @@ public SearchDocumentStatsGather() throws Exception { client.close(); } - private void processHit(String path, Map map) { - for(String key: map.keySet()) { + for (String key : map.keySet()) { Object value = map.get(key); int size = String.valueOf(value).length(); - - //if(value != null) System.out.println(value.getClass()); - + + // if(value != null) System.out.println(value.getClass()); + String newKey = path + "." + key; - - if(value != null && value.getClass() == HashMap.class) { - processHit(newKey, (Map)value); + + if (value != null && value.getClass() == HashMap.class) { + processHit(newKey, (Map) value); } - - //System.out.println(value.getClass()); - //System.out.println("Size: " + size + " Key: " + key + " -> " + value); - - if(sizeMap.containsKey(newKey)) { + + // System.out.println(value.getClass()); + // System.out.println("Size: " + size + " Key: " + key + " -> " + value); + + if (sizeMap.containsKey(newKey)) { int currentSize = sizeMap.get(newKey); sizeMap.put(newKey, currentSize + size); } else { @@ -114,14 +112,10 @@ private RestHighLevelClient createClient(String hostName) { hosts = esHosts.toArray(hosts); int hours = 2 * (60 * 60 * 1000); - RestHighLevelClient client = new RestHighLevelClient( - RestClient.builder(hosts) - .setRequestConfigCallback( - // Timeout after 60 * 60 * 1000 milliseconds = 1 hour - // Needed for long running snapshots - requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000).setSocketTimeout(hours).setConnectionRequestTimeout(hours) - ) - ); + RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(hosts).setRequestConfigCallback( + // Timeout after 60 * 60 * 1000 milliseconds = 1 hour + // Needed for long running snapshots + requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000).setSocketTimeout(hours).setConnectionRequestTimeout(hours))); return client; }