Skip to content

Commit

Permalink
Merge pull request #1490 from alliance-genome/SCRUM-3711_refactor.2
Browse files Browse the repository at this point in the history
Refactor to remove some classes SCRUM-3711.2
  • Loading branch information
oblodgett authored Apr 3, 2024
2 parents 646d1c8 + 876b050 commit 5acb0d1
Show file tree
Hide file tree
Showing 118 changed files with 775 additions and 764 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import org.alliancegenome.curation_api.dao.base.BaseSQLDAO;
import org.alliancegenome.curation_api.enums.BackendBulkDataProvider;
import org.alliancegenome.curation_api.exceptions.ObjectUpdateException;
import org.alliancegenome.curation_api.interfaces.base.BaseDTOCrudControllerInterface;
import org.alliancegenome.curation_api.interfaces.base.BaseUpsertControllerInterface;
import org.alliancegenome.curation_api.model.entities.Annotation;
import org.alliancegenome.curation_api.model.ingest.dto.AnnotationDTO;
import org.alliancegenome.curation_api.services.base.BaseAnnotationDTOCrudService;

public abstract class BaseAnnotationDTOCrudController<S extends BaseAnnotationDTOCrudService<E, T, D>, E extends Annotation, T extends AnnotationDTO, D extends BaseSQLDAO<E>> extends BaseEntityCrudController<S, E, D>
implements BaseDTOCrudControllerInterface<E, T> {
implements BaseUpsertControllerInterface<E, T> {

protected abstract void init();

Expand All @@ -21,7 +21,7 @@ protected void setService(S service) {
}

public E upsert(T dto) throws ObjectUpdateException {
return upsert(dto, null);
return service.upsert(dto);
}

public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

import org.alliancegenome.curation_api.dao.base.BaseDocumentDAO;
import org.alliancegenome.curation_api.document.base.BaseDocument;
import org.alliancegenome.curation_api.interfaces.base.BaseIdDocumentInterface;
import org.alliancegenome.curation_api.interfaces.base.BaseSearchControllerInterface;
import org.alliancegenome.curation_api.model.input.Pagination;
import org.alliancegenome.curation_api.response.ObjectResponse;
import org.alliancegenome.curation_api.response.SearchResponse;
import org.alliancegenome.curation_api.services.base.BaseDocumentService;

public abstract class BaseDocumentController<S extends BaseDocumentService<E, D>, E extends BaseDocument, D extends BaseDocumentDAO<E>> implements BaseIdDocumentInterface<E> {
public abstract class BaseDocumentController<S extends BaseDocumentService<E, D>, E extends BaseDocument, D extends BaseDocumentDAO<E>> implements BaseSearchControllerInterface<E> {

private BaseDocumentService<E, D> service;

Expand All @@ -20,10 +19,6 @@ protected void setService(S service) {

protected abstract void init();

public ObjectResponse<E> get(String curie) {
return service.get(curie);
}

public SearchResponse<E> search(Integer page, Integer limit, HashMap<String, Object> params) {
if (params == null)
params = new HashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

import org.alliancegenome.curation_api.dao.base.BaseEntityDAO;
import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface;
import org.alliancegenome.curation_api.model.entities.base.BaseEntity;
import org.alliancegenome.curation_api.model.entities.base.AuditedObject;
import org.alliancegenome.curation_api.model.input.Pagination;
import org.alliancegenome.curation_api.response.ObjectListResponse;
import org.alliancegenome.curation_api.response.ObjectResponse;
import org.alliancegenome.curation_api.response.SearchResponse;
import org.alliancegenome.curation_api.services.base.BaseEntityCrudService;

public abstract class BaseEntityCrudController<S extends BaseEntityCrudService<E, D>, E extends BaseEntity, D extends BaseEntityDAO<E>> implements BaseIdCrudInterface<E> {
public abstract class BaseEntityCrudController<S extends BaseEntityCrudService<E, D>, E extends AuditedObject, D extends BaseEntityDAO<E>> implements BaseIdCrudInterface<E> {

protected BaseEntityCrudService<E, D> service;

Expand All @@ -30,16 +30,24 @@ public ObjectListResponse<E> create(List<E> entities) {
return service.create(entities);
}

public ObjectResponse<E> get(Long id) {
return service.get(id);
public ObjectResponse<E> getById(Long id) {
return service.getById(id);
}

public ObjectResponse<E> getByCurie(String curie) {
return service.getByCurie(curie);
}

public ObjectResponse<E> update(E entity) {
return service.update(entity);
}

public ObjectResponse<E> delete(Long id) {
return service.delete(id);
public ObjectResponse<E> deleteByCurie(String curie) {
return service.deleteByCurie(curie);
}

public ObjectResponse<E> deleteById(Long id) {
return service.deleteById(id);
}

public SearchResponse<E> findByField(String field, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.alliancegenome.curation_api.services.helpers.GenericOntologyLoadHelper;
import org.alliancegenome.curation_api.util.ProcessDisplayHelper;

public abstract class BaseOntologyTermController<S extends BaseOntologyTermService<E, D>, E extends OntologyTerm, D extends BaseEntityDAO<E>> extends CurieObjectCrudController<S, E, BaseEntityDAO<E>> {
public abstract class BaseOntologyTermController<S extends BaseOntologyTermService<E, D>, E extends OntologyTerm, D extends BaseEntityDAO<E>> extends BaseEntityCrudController<S, E, BaseEntityDAO<E>> {

private GenericOntologyLoadHelper<E> loader;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import org.alliancegenome.curation_api.dao.base.BaseEntityDAO;
import org.alliancegenome.curation_api.enums.BackendBulkDataProvider;
import org.alliancegenome.curation_api.exceptions.ObjectUpdateException;
import org.alliancegenome.curation_api.interfaces.base.SubmittedObjectCrudInterface;
import org.alliancegenome.curation_api.interfaces.base.BaseUpsertControllerInterface;
import org.alliancegenome.curation_api.interfaces.base.BaseSubmittedObjectCrudInterface;
import org.alliancegenome.curation_api.model.entities.base.SubmittedObject;
import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO;
import org.alliancegenome.curation_api.response.ObjectResponse;
import org.alliancegenome.curation_api.services.base.SubmittedObjectCrudService;

public abstract class SubmittedObjectCrudController<S extends SubmittedObjectCrudService<E, T, D>, E extends SubmittedObject, T extends BaseDTO, D extends BaseEntityDAO<E>> extends CurieObjectCrudController<S, E, D> implements SubmittedObjectCrudInterface<E> {
public abstract class SubmittedObjectCrudController<S extends SubmittedObjectCrudService<E, T, D>, E extends SubmittedObject, T extends BaseDTO, D extends BaseEntityDAO<E>> extends BaseEntityCrudController<S, E, D> implements
BaseSubmittedObjectCrudInterface<E>,
BaseUpsertControllerInterface<E, T>
{

protected SubmittedObjectCrudService<E, T, D> service;

Expand All @@ -18,22 +22,20 @@ protected void setService(S service) {
this.service = service;
}

@Override
public ObjectResponse<E> get(String identifierString) {
return service.get(identifierString);
}

@Override
public ObjectResponse<E> delete(String identifierString) {
return service.delete(identifierString);
}

public E upsert(T dto) throws ObjectUpdateException {
return upsert(dto, null);
return service.upsert(dto);
}

public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException {
return service.upsert(dto, dataProvider);
}

public ObjectResponse<E> getByIdentifier(String identifierString) {
return service.getByIdentifier(identifierString);
}

public ObjectResponse<E> deleteByIdentifier(String identifierString) {
return service.deleteByIdentifier(identifierString);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public APIResponse updateAgmDiseaseAnnotations(String dataProvider, List<AGMDise
return agmDiseaseAnnotationExecutor.runLoad(dataProvider, annotations);
}

public ObjectResponse<AGMDiseaseAnnotation> get(String identifierString) {
return agmDiseaseAnnotationService.get(identifierString);
public ObjectResponse<AGMDiseaseAnnotation> getByIdentifier(String identifierString) {
return agmDiseaseAnnotationService.getByIdentifier(identifierString);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void init() {
setService(agmPhenotypeAnnotationService);
}

public ObjectResponse<AGMPhenotypeAnnotation> get(String identifierString) {
return agmPhenotypeAnnotationService.get(identifierString);
public ObjectResponse<AGMPhenotypeAnnotation> getByIdentifier(String identifierString) {
return agmPhenotypeAnnotationService.getByIdentifier(identifierString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public APIResponse updateAlleleDiseaseAnnotations(String dataProvider, List<Alle
return alleleDiseaseAnnotationExecutor.runLoad(dataProvider, annotations);
}

public ObjectResponse<AlleleDiseaseAnnotation> get(String identifierString) {
return alleleDiseaseAnnotationService.get(identifierString);
public ObjectResponse<AlleleDiseaseAnnotation> getByIdentifier(String identifierString) {
return alleleDiseaseAnnotationService.getByIdentifier(identifierString);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void init() {
setService(allelePhenotypeAnnotationService);
}

public ObjectResponse<AllelePhenotypeAnnotation> get(String identifierString) {
return allelePhenotypeAnnotationService.get(identifierString);
public ObjectResponse<AllelePhenotypeAnnotation> getByIdentifier(String identifierString) {
return allelePhenotypeAnnotationService.getByIdentifier(identifierString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
import jakarta.inject.Inject;

@RequestScoped
public class ConstructCrudController extends SubmittedObjectCrudController<ConstructService, Construct, ConstructDTO, ConstructDAO>
implements ConstructCrudInterface {
public class ConstructCrudController extends SubmittedObjectCrudController<ConstructService, Construct, ConstructDTO, ConstructDAO> implements ConstructCrudInterface {

@Inject
ConstructService constructService;
Expand All @@ -34,4 +33,6 @@ protected void init() {
public APIResponse updateConstructs(String dataProvider, List<ConstructDTO> annotations) {
return constructExecutor.runLoad(dataProvider, annotations);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void init() {
setService(diseaseAnnotationService);
}

public ObjectResponse<DiseaseAnnotation> get(String identifierString) {
return diseaseAnnotationService.get(identifierString);
public ObjectResponse<DiseaseAnnotation> getByIdentifier(String identifierString) {
return diseaseAnnotationService.getByIdentifier(identifierString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public APIResponse updateGeneDiseaseAnnotations(String dataProvider, List<GeneDi
return geneDiseaseAnnotationExecutor.runLoad(dataProvider, annotations);
}

public ObjectResponse<GeneDiseaseAnnotation> get(String identifierString) {
return geneDiseaseAnnotationService.get(identifierString);
public ObjectResponse<GeneDiseaseAnnotation> getByIdentifier(String identifierString) {
return geneDiseaseAnnotationService.getByIdentifier(identifierString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ protected void init() {
setService(geneGeneticInteractionService);
}

public ObjectResponse<GeneGeneticInteraction> get(String identifierString) {
return geneGeneticInteractionService.get(identifierString);
public ObjectResponse<GeneGeneticInteraction> getByIdentifier(String identifierString) {
return geneGeneticInteractionService.getByIdentifier(identifierString);
}

public APIResponse updateInteractions(List<PsiMiTabDTO> interactionData) {
return geneGeneticInteractionExecutor.runLoad(interactionData);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected void init() {
setService(geneInteractionService);
}

public ObjectResponse<GeneInteraction> get(String identifierString) {
return geneInteractionService.get(identifierString);
public ObjectResponse<GeneInteraction> getByIdentifier(String identifierString) {
return geneInteractionService.getByIdentifer(identifierString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ protected void init() {
setService(geneMolecularInteractionService);
}

public ObjectResponse<GeneMolecularInteraction> get(String identifierString) {
return geneMolecularInteractionService.get(identifierString);
public ObjectResponse<GeneMolecularInteraction> getByIdentifier(String identifierString) {
return geneMolecularInteractionService.getByIdentifier(identifierString);
}

public APIResponse updateInteractions(List<PsiMiTabDTO> interactionData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void init() {
setService(genePhenotypeAnnotationService);
}

public ObjectResponse<GenePhenotypeAnnotation> get(String identifierString) {
return genePhenotypeAnnotationService.get(identifierString);
public ObjectResponse<GenePhenotypeAnnotation> getByIdentifier(String identifierString) {
return genePhenotypeAnnotationService.getByIdentifier(identifierString);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.alliancegenome.curation_api.controllers.crud;

import org.alliancegenome.curation_api.controllers.base.CurieObjectCrudController;
import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController;
import org.alliancegenome.curation_api.dao.InformationContentEntityDAO;
import org.alliancegenome.curation_api.interfaces.crud.InformationContentEntityCrudInterface;
import org.alliancegenome.curation_api.model.entities.InformationContentEntity;
Expand All @@ -11,7 +11,7 @@
import jakarta.inject.Inject;

@RequestScoped
public class InformationContentEntityCrudController extends CurieObjectCrudController<InformationContentEntityService, InformationContentEntity, InformationContentEntityDAO>
public class InformationContentEntityCrudController extends BaseEntityCrudController<InformationContentEntityService, InformationContentEntity, InformationContentEntityDAO>
implements InformationContentEntityCrudInterface {

@Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.alliancegenome.curation_api.controllers.crud;

import org.alliancegenome.curation_api.controllers.base.CurieObjectCrudController;
import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController;
import org.alliancegenome.curation_api.dao.MoleculeDAO;
import org.alliancegenome.curation_api.interfaces.crud.MoleculeCrudInterface;
import org.alliancegenome.curation_api.jobs.executors.MoleculeExecutor;
Expand All @@ -16,7 +16,7 @@
import jakarta.inject.Inject;

@RequestScoped
public class MoleculeCrudController extends CurieObjectCrudController<MoleculeService, Molecule, MoleculeDAO> implements MoleculeCrudInterface {
public class MoleculeCrudController extends BaseEntityCrudController<MoleculeService, Molecule, MoleculeDAO> implements MoleculeCrudInterface {

@Inject
MoleculeService moleculeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ protected void init() {
setService(phenotypeAnnotationService);
}

public ObjectResponse<PhenotypeAnnotation> get(String identifierString) {
return phenotypeAnnotationService.get(identifierString);
public ObjectResponse<PhenotypeAnnotation> getByIdentifier(String identifierString) {
return phenotypeAnnotationService.getByIdentifier(identifierString);
}

public APIResponse updatePhenotypeAnnotations(String dataProvider, List<PhenotypeFmsDTO> annotations) {
Expand Down
Loading

0 comments on commit 5acb0d1

Please sign in to comment.