@PrePersist public void synchronizeShortLabel() { if( IntactContext.currentInstanceExists() ) { if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateExperimentLabel() ) { String shortLabel = getShortLabel(); String newShortLabel = shortLabel; try { newShortLabel = ExperimentUtils.syncShortLabelWithDb(shortLabel, ExperimentUtils.getPubmedId( this )); } catch (Exception e) { log.error("Exception synchronizing the label, probably due to an invalid format: "+newShortLabel, e); } if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Experiment with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); setShortLabel(newShortLabel); } } } else { log.warn( "There is no IntAct Context initialized, skipping experiment shortlabel synchronization." ); } }
public Collection<GeneralMessage> check( Experiment experiment ) throws SanityRuleException { Collection<GeneralMessage> messages = new ArrayList<GeneralMessage>(); if ( startingDateSuperCuration.before( experiment.getCreated() ) ) { if ( !ExperimentUtils.isAccepted( experiment ) ) { if ( ExperimentUtils.isToBeReviewed( experiment ) ) { // no 'accepted' and no 'to-be-reviewed' messages.add( new GeneralMessage( MessageDefinition.EXPERIMENT_TO_BE_REVIEWED, experiment ) ); } else { // no 'accepted' and has 'to-be-reviewed' messages.add( new GeneralMessage( MessageDefinition.EXPERIMENT_NOT_SUPER_CURATED, experiment ) ); } } } return messages; } }
String syncedLabel; if (matchesSyncedLabel(shortLabel)) { syncedLabel = shortLabel; } else if (matchesMotSyncedLabel(shortLabel)) { ExperimentDao experimentDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getExperimentDao(); List<String> expLabels = experimentDao.getShortLabelsLike(shortLabel+"-%");
public Collection<GeneralMessage> check(Experiment experiment) throws SanityRuleException { Collection<GeneralMessage> messages = new ArrayList<GeneralMessage>(); if(ExperimentUtils.isOnHold(experiment)){ messages.add(new GeneralMessage( MessageDefinition.EXPERIMENT_ON_HOLD, experiment)); } else { // TODO this can be removed when all the experiments have a Publication object in the DB String pubmedId = ExperimentUtils.getPubmedId(experiment); if (pubmedId != null) { final List<Experiment> experimentsSamePubmed = IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getExperimentDao().getByPubId(pubmedId); for (Experiment experimentSamePubmed : experimentsSamePubmed) { if (ExperimentUtils.isOnHold(experimentSamePubmed)) { messages.add(new GeneralMessage( MessageDefinition.EXPERIMENT_ON_HOLD, experiment)); } } } } return messages; } }
String syncedLabel = null; if (!(matchesMotSyncedLabel(shortLabel) || matchesSyncedLabel(shortLabel))) { throw new IllegalArgumentException("Short label with wrong format: " + shortLabel); final String expPubId = getPubmedId(exp);
&& ExperimentUtils.matchesSyncedLabel(synced.getShortLabel())) { return BehaviourType.NEW; final String syncedPubmedId = ExperimentUtils.getPubmedId(synced); final String candidatePubmedId = ExperimentUtils.getPubmedId(candidate); candidatePubmedId) && ExperimentUtils.matchesSyncedLabel(candidate.getShortLabel())) { throw new PersisterUnexpectedException("Trying to persist an Experiment with a short label that already exists in the database," + " but they have different pubmed IDs: " + synced.getShortLabel() + " (Existing: " + syncedPubmedId + ", Found: " + candidatePubmedId + ")");
/** * Syncs a short label with the database, checking that there are no duplicates and that the correct suffix is added. * <p/> * Concurrency note: just after getting the new short label, it is recommended to persist/update the interaction immediately * in the database - so this method should ONLY be used before saving the interaction to the database. In some * race conditions, two interactions could be created with the same id; currently there is no way to * reserve a short label * * @param shortLabel the short label to sync * @return the synced short label * @since 1.6.2 */ @Deprecated public static String syncShortLabelWithDb(String shortLabel) { return syncShortLabelWithDb(shortLabel, null); }
boolean accepted = isAccepted(experiment);
public Collection<GeneralMessage> check(Experiment experiment) throws SanityRuleException { Collection<GeneralMessage> messages = new ArrayList<GeneralMessage>(); if(ExperimentUtils.isToBeReviewed(experiment)){ messages.add(new GeneralMessage( MessageDefinition.EXPERIMENT_TO_BE_REVIEWED, experiment)); } return messages; }
public static boolean isOnHold(Publication publication) { if (publication == null) { throw new NullPointerException("You must give a non null publication"); } for (Annotation a : publication.getAnnotations()) { if (a.getCvTopic() != null && CvTopic.ON_HOLD.equals(a.getCvTopic().getShortLabel())) { return true; } } for (Experiment experiment : publication.getExperiments()) { if (ExperimentUtils.isOnHold(experiment)) { return true; } } return false; }
public static boolean isAccepted(Publication publication) { if (publication == null) { throw new NullPointerException("You must give a non null publication"); } if (publication.getStatus() != null) { final String statusId = publication.getStatus().getIdentifier(); return CvPublicationStatusType.ACCEPTED.identifier().equals(statusId) || CvPublicationStatusType.ACCEPTED_ON_HOLD.identifier().equals(statusId) || CvPublicationStatusType.READY_FOR_RELEASE.identifier().equals(statusId) || CvPublicationStatusType.RELEASED.identifier().equals(statusId); } for (Annotation a : publication.getAnnotations()) { if (a.getCvTopic() != null && CvTopic.ACCEPTED.equals(a.getCvTopic().getShortLabel())) { return true; } } return ExperimentUtils.areAllAccepted(publication.getExperiments()); }
/** * Gets the pubmed ID for an Experiment - whitout hitting the database * * @param experiment the experiment to get the pubmed id from * @return the pubmed id */ public static String getPubmedId(Experiment experiment) { String pubmedId = null; Publication publication = experiment.getPublication(); if (publication != null) { PublicationXref xref = PublicationUtils.getPubmedPrimaryReferenceXref(publication); if (xref != null){ pubmedId = xref.getPrimaryId(); } } if (pubmedId == null) { ExperimentXref xref = getPubmedPrimaryReferenceXref(experiment); if (xref != null) { pubmedId = xref.getPrimaryId(); } } return pubmedId; }
final ExperimentXref xref = ExperimentUtils.getPrimaryReferenceXref( experiment ); String pubId = (xref != null ? xref.getPrimaryId() : null );
String syncedLabel = null; if (!(matchesMotSyncedLabel(shortLabel) || matchesSyncedLabel(shortLabel))) { throw new IllegalArgumentException("Short label with wrong format: " + shortLabel); final String expPubId = getPubmedId(exp);
/** * Syncs a short label with the database, checking that there are no duplicates and that the correct suffix is added. * <p/> * Concurrency note: just after getting the new short label, it is recommended to persist/update the interaction immediately * in the database - so this method should ONLY be used before saving the interaction to the database. In some * race conditions, two interactions could be created with the same id; currently there is no way to * reserve a short label * * @param shortLabel the short label to sync * @return the synced short label * @since 1.6.2 */ @Deprecated public static String syncShortLabelWithDb(String shortLabel) { return syncShortLabelWithDb(shortLabel, null); }
boolean accepted = isAccepted(experiment);
public static boolean isToBeReviewed(Publication publication) { if (publication == null) { throw new NullPointerException("You must give a non null publication"); } for (Annotation a : publication.getAnnotations()) { if (a.getCvTopic() != null && CvTopic.TO_BE_REVIEWED.equals(a.getCvTopic().getShortLabel())) { return true; } } for (Experiment experiment : publication.getExperiments()) { if (ExperimentUtils.isToBeReviewed(experiment)) { return true; } } return false; }
public static boolean isOnHold(Publication publication) { if (publication == null) { throw new NullPointerException("You must give a non null publication"); } for (Annotation a : publication.getAnnotations()) { if (a.getCvTopic() != null && CvTopic.ON_HOLD.equals(a.getCvTopic().getShortLabel())) { return true; } } for (Experiment experiment : publication.getExperiments()) { if (ExperimentUtils.isOnHold(experiment)) { return true; } } return false; }
public static boolean isAccepted(Publication publication) { if (publication == null) { throw new NullPointerException("You must give a non null publication"); } if (publication.getStatus() != null) { final String statusId = publication.getStatus().getIdentifier(); return CvPublicationStatusType.ACCEPTED.identifier().equals(statusId) || CvPublicationStatusType.ACCEPTED_ON_HOLD.identifier().equals(statusId) || CvPublicationStatusType.READY_FOR_RELEASE.identifier().equals(statusId) || CvPublicationStatusType.RELEASED.identifier().equals(statusId); } for (Annotation a : publication.getAnnotations()) { if (a.getCvTopic() != null && CvTopic.ACCEPTED.equals(a.getCvTopic().getShortLabel())) { return true; } } return ExperimentUtils.areAllAccepted(publication.getExperiments()); }
/** * Gets the pubmed ID for an Experiment - whitout hitting the database * * @param experiment the experiment to get the pubmed id from * @return the pubmed id */ public static String getPubmedId(Experiment experiment) { String pubmedId = null; Publication publication = experiment.getPublication(); if (publication != null) { PublicationXref xref = PublicationUtils.getPubmedPrimaryReferenceXref(publication); if (xref != null){ pubmedId = xref.getPrimaryId(); } } if (pubmedId == null) { ExperimentXref xref = getPubmedPrimaryReferenceXref(experiment); if (xref != null) { pubmedId = xref.getPrimaryId(); } } return pubmedId; }