diff --git a/source/org/zfin/feature/FeatureDnaMutationDetail.java b/source/org/zfin/feature/FeatureDnaMutationDetail.java index 082669a20c..4159706da6 100644 --- a/source/org/zfin/feature/FeatureDnaMutationDetail.java +++ b/source/org/zfin/feature/FeatureDnaMutationDetail.java @@ -1,10 +1,14 @@ package org.zfin.feature; +import lombok.Getter; +import lombok.Setter; import org.hibernate.annotations.GenericGenerator; import org.zfin.sequence.ReferenceDatabase; import javax.persistence.*; +@Setter +@Getter @Entity @Table(name = "feature_dna_mutation_detail") public class FeatureDnaMutationDetail implements Cloneable { @@ -51,118 +55,6 @@ public class FeatureDnaMutationDetail implements Cloneable { private DnaMutationTerm dnaMutationTerm; - public Feature getFeature() { - return feature; - } - - public void setFeature(Feature feature) { - this.feature = feature; - } - - public ReferenceDatabase getReferenceDatabase() { - return referenceDatabase; - } - - public void setReferenceDatabase(ReferenceDatabase referenceDatabase) { - this.referenceDatabase = referenceDatabase; - } - - public DnaMutationTerm getDnaMutationTerm() { - return dnaMutationTerm; - } - - public void setDnaMutationTerm(DnaMutationTerm dnaMutationTerm) { - this.dnaMutationTerm = dnaMutationTerm; - } - - public Integer getDnaPositionEnd() { - return dnaPositionEnd; - } - - public void setDnaPositionEnd(Integer dnaPositionEnd) { - this.dnaPositionEnd = dnaPositionEnd; - } - - public Integer getDnaPositionStart() { - return dnaPositionStart; - } - - public void setDnaPositionStart(Integer dnaPositionStart) { - this.dnaPositionStart = dnaPositionStart; - } - - public String getDnaSequenceReferenceAccessionNumber() { - return dnaSequenceReferenceAccessionNumber; - } - - public void setDnaSequenceReferenceAccessionNumber(String dnaSequenceReferenceAccessionNumber) { - this.dnaSequenceReferenceAccessionNumber = dnaSequenceReferenceAccessionNumber; - } - - public Integer getNumberAddedBasePair() { - return numberAddedBasePair; - } - - public void setNumberAddedBasePair(Integer numberAdditionalBasePair) { - this.numberAddedBasePair = numberAdditionalBasePair; - } - - public Integer getExonNumber() { - return exonNumber; - } - - public void setExonNumber(Integer exonNumber) { - this.exonNumber = exonNumber; - } - - public Integer getIntronNumber() { - return intronNumber; - } - - public void setIntronNumber(Integer intronNumber) { - this.intronNumber = intronNumber; - } - - public Integer getNumberRemovedBasePair() { - return numberRemovedBasePair; - } - - public void setNumberRemovedBasePair(Integer numberRemovedBasePair) { - this.numberRemovedBasePair = numberRemovedBasePair; - } - - public String getInsertedSequence() { - return insertedSequence; - } - - public void setInsertedSequence(String insertedSequence) { - this.insertedSequence = insertedSequence; - } - - public String getDeletedSequence() { - return deletedSequence; - } - - public void setDeletedSequence(String deletedSequence) { - this.deletedSequence = deletedSequence; - } - - public String getZdbID() { - return zdbID; - } - - public void setZdbID(String zdbID) { - this.zdbID = zdbID; - } - - public GeneLocalizationTerm getGeneLocalizationTerm() { - return geneLocalizationTerm; - } - - public void setGeneLocalizationTerm(GeneLocalizationTerm geneLocalizationTerm) { - this.geneLocalizationTerm = geneLocalizationTerm; - } - public FeatureDnaMutationDetail clone() { try { FeatureDnaMutationDetail detail = (FeatureDnaMutationDetail) super.clone(); diff --git a/source/org/zfin/feature/repository/FeatureRepository.java b/source/org/zfin/feature/repository/FeatureRepository.java index 5b15c26f2a..8dc18d323d 100644 --- a/source/org/zfin/feature/repository/FeatureRepository.java +++ b/source/org/zfin/feature/repository/FeatureRepository.java @@ -131,7 +131,7 @@ public interface FeatureRepository { Feature getFeatureByAbbreviation(String featureAbbrev); - String getFeatureByAbbreviationInTrackingTable(String featureAbbrev); + FeatureTracking getFeatureByAbbreviationInTrackingTable(String featureAbbrev); String getFeatureByIDInTrackingTable(String featTrackingFeatZdbID); diff --git a/source/org/zfin/feature/repository/HibernateFeatureRepository.java b/source/org/zfin/feature/repository/HibernateFeatureRepository.java index 4aa9653688..efb827a745 100644 --- a/source/org/zfin/feature/repository/HibernateFeatureRepository.java +++ b/source/org/zfin/feature/repository/HibernateFeatureRepository.java @@ -784,12 +784,12 @@ public Feature getFeatureByAbbreviation(String name) { } @Override - public String getFeatureByAbbreviationInTrackingTable(String featTrackingFeatAbbrev) { + public FeatureTracking getFeatureByAbbreviationInTrackingTable(String featTrackingFeatAbbrev) { Session session = HibernateUtil.currentSession(); - String hqlFtrTrack = " select ft.featTrackingFeatAbbrev from FeatureTracking ft where ft.feature.zdbID =:featTrackingFeatAbbrev "; - Query queryTracker = session.createQuery(hqlFtrTrack); + String hqlFtrTrack = "from FeatureTracking where featTrackingFeatAbbrev = :featTrackingFeatAbbrev"; + Query queryTracker = session.createQuery(hqlFtrTrack, FeatureTracking.class); queryTracker.setParameter("featTrackingFeatAbbrev", featTrackingFeatAbbrev); - return (String) queryTracker.uniqueResult(); + return queryTracker.uniqueResult(); } public String getFeatureByIDInTrackingTable(String featTrackingFeatZdbID) { diff --git a/source/org/zfin/gwt/curation/server/FeatureRPCServiceImpl.java b/source/org/zfin/gwt/curation/server/FeatureRPCServiceImpl.java index 0d4959f233..a80a75d818 100644 --- a/source/org/zfin/gwt/curation/server/FeatureRPCServiceImpl.java +++ b/source/org/zfin/gwt/curation/server/FeatureRPCServiceImpl.java @@ -47,6 +47,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import static org.zfin.framework.HibernateUtil.currentSession; @@ -96,14 +98,36 @@ private void checkDupes(FeatureDTO featureDTO) throws DuplicateEntryException { } } - private void checkDupesinTrackingTable(FeatureDTO featureDTO) throws DuplicateEntryException { - String featureInTrackingTable = featureRepository.getFeatureByAbbreviationInTrackingTable(featureDTO.getAbbreviation()); - + private void checkDupesinTrackingTable(String featureAbbreviation) throws DuplicateEntryException { + FeatureTracking featureInTrackingTable = featureRepository.getFeatureByAbbreviationInTrackingTable(featureAbbreviation); if (featureInTrackingTable != null) { - throw new DuplicateEntryException("Feature exists in the tracking table for this abbreviation: " + featureDTO.getAbbreviation()); + String labPrefix = getLabPrefixFromFeatureAbbreviation(featureAbbreviation); + + String nextLine = null; + if (labPrefix != null) { + nextLine = getFeatureRepository().getNextLineNumberForLabPrefix(labPrefix); + } + + String helpfulTip = ""; + if (nextLine != null && labPrefix != null) { + helpfulTip = " Next line number for this lab prefix is: " + nextLine + "."; + } + + throw new DuplicateEntryException( + "Feature exists in the tracking table for this abbreviation: " + featureAbbreviation + ". " + helpfulTip); } + } + + private String getLabPrefixFromFeatureAbbreviation(String line) { + String pattern = "(.*?)(\\d+)"; + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(line); + if (m.find()) { + return m.group(1); + } + return null; } private void updateFeatureLocation(FeatureLocation fl, FeatureDTO dto) { @@ -579,7 +603,7 @@ public FeatureDTO createFeature(FeatureDTO featureDTO) throws DuplicateEntryExce DTOConversionService.escapeFeatureDTO(featureDTO); checkDupes(featureDTO); - checkDupesinTrackingTable(featureDTO); + checkDupesinTrackingTable(featureDTO.getAbbreviation()); validateUnspecified(featureDTO); FeatureDTO newFeatureDTO; @@ -607,7 +631,7 @@ public FeatureDTO createFeature(FeatureDTO featureDTO) throws DuplicateEntryExce feature.getAliases().add(featureAlias); } - + checkDupesinTrackingTable(feature.getAbbreviation()); getFeatureRepository().saveFeature(feature, publication); if (CollectionUtils.isNotEmpty(featureDTO.getPublicNoteList())) { diff --git a/source/org/zfin/infrastructure/delete/DeleteFeatureRule.java b/source/org/zfin/infrastructure/delete/DeleteFeatureRule.java index 3b9d940bb1..91f86572f9 100644 --- a/source/org/zfin/infrastructure/delete/DeleteFeatureRule.java +++ b/source/org/zfin/infrastructure/delete/DeleteFeatureRule.java @@ -41,6 +41,16 @@ public List validate() { addToValidationReport(feature.getAbbreviation() + " has the following accession numbers associated: ", feature.getDbLinks()); } + // Can't delete the feature if it has mutation details + if (CollectionUtils.isNotEmpty(feature.getFeatureDnaMutationDetailSet())) { + addToValidationReport("Need to remove Mutation Detail data."); + } + + // Can't delete the feature if it has protein mutation details + if (CollectionUtils.isNotEmpty(feature.getFeatureProteinMutationDetailSet())) { + addToValidationReport("Need to remove Protein Mutation Detail data."); + } + // Can't delete the feature if it has more than 1 publications if (CollectionUtils.isNotEmpty(featurePublications) && featurePublications.size() > 1) { addToValidationReport(feature.getAbbreviation() + " associated with more than one publication: ", featurePublications);