public void createPublication( psidev.psi.mi.jami.model.Publication publication ) throws BridgeFailedException { psidev.psi.mi.jami.model.Publication existingP = null; for ( psidev.psi.mi.jami.model.Publication p : allPublications ) { for (Xref i : p.getIdentifiers()){ if( !publication.getIdentifiers().isEmpty() && publication.getIdentifiers().iterator().next().getId().equals( i.getId() ) ) { existingP = p; break; } } } if (existingP == null){ allPublications.add(publication); } else { allPublications.remove(existingP); allPublications.add(publication); } }
public psidev.psi.mi.jami.model.Publication createPublicationById( String identifier, String source ) throws BridgeFailedException { psidev.psi.mi.jami.model.Publication p = new ImexPublication(new Publication()); p.getIdentifiers().add(XrefUtils.createIdentityXref(source, identifier)); allPublications.add( p ); return p; }
public psidev.psi.mi.jami.model.Publication fetchByIdentifier( String identifier, String source ) throws BridgeFailedException { for ( psidev.psi.mi.jami.model.Publication p : allPublications ) { for (Xref i : p.getIdentifiers()){ if( XrefUtils.doesXrefHaveDatabaseAndId(i, null, source, identifier) ) { return p; } } if (p.getImexId() != null && p.getImexId().equalsIgnoreCase(identifier)){ return p; } } return null; }
public static Xref getPubmedReference(Publication pub){ if (pub == null){ return null; } else if (pub.getPubmedId() == null){ return null; } else{ return XrefUtils.collectFirstIdentifierWithDatabaseAndId(pub.getIdentifiers(), Xref.PUBMED_MI, Xref.PUBMED, pub.getPubmedId()); } }
public static Xref getDoiReference(Publication pub){ if (pub == null){ return null; } else if (pub.getDoi() == null){ return null; } else{ return XrefUtils.collectFirstIdentifierWithDatabaseAndId(pub.getIdentifiers(), Xref.DOI_MI, Xref.DOI, pub.getDoi()); } } }
@Override public void onImexIdAssigned(Publication intactPublication, String imex) { String pubId = intactPublication.getPubmedId() != null ? intactPublication.getPubmedId() : intactPublication.getDoi(); if (pubId == null && !intactPublication.getIdentifiers().isEmpty()){ Xref id = intactPublication.getXrefs().iterator().next(); pubId = id.getId(); } NewAssignedImexEvent evt = new NewAssignedImexEvent(this, pubId, imex, null, null); getImexCentralManager().fireOnNewImexAssigned(evt); }
if (!pub.getIdentifiers().isEmpty()){ Iterator<Xref> identifierIterator = pub.getIdentifiers().iterator();
@Override public void onPublicationWhichCannotBeRegistered(Publication intactPublication) { String pubId = intactPublication.getPubmedId() != null ? intactPublication.getPubmedId() : intactPublication.getDoi(); if (pubId == null && !intactPublication.getIdentifiers().isEmpty()){ Xref id = intactPublication.getXrefs().iterator().next(); pubId = id.getId(); } // unassigned publication, cannot use the webservice to automatically assign IMEx id for now, ask the curator to manually register and assign IMEx id to this publication if (!Pattern.matches(ImexCentralManager.PUBMED_REGEXP.toString(), pubId)){ log.warn("It is not possible to register an unassigned publication. " + "The publication needs to be registered manually by a curator in IMEx central."); } // the publication is already registered, we just update status and users else { ImexErrorEvent evt = new ImexErrorEvent(this, ImexErrorType.no_record_created, pubId, null, null, null, "It is not possible to register the publication " + pubId + " in IMEx central."); getImexCentralManager().fireOnImexError(evt); } // do not update experiments and interactions getImexCentralManager().setEnableExperimentsAndInteractionsUpdate(false); }
else if (!publication1.getIdentifiers().isEmpty() && !publication2.getIdentifiers().isEmpty()){ return ComparatorUtils.findAtLeastOneMatchingIdentifier(publication1.getIdentifiers(), publication2.getIdentifiers()); else if (!publication1.getIdentifiers().isEmpty() || !publication2.getIdentifiers().isEmpty()){ return false;
hashcode = 31*hashcode + pub.getDoi().hashCode(); else if (!pub.getIdentifiers().isEmpty()){ List<Xref> list1 = new ArrayList<Xref>(pub.getIdentifiers());
@Override public void onMissingImexId(Publication intactPublication) { String pubId = intactPublication.getPubmedId() != null ? intactPublication.getPubmedId() : intactPublication.getDoi(); if (pubId == null && !intactPublication.getIdentifiers().isEmpty()){ Xref id = intactPublication.getXrefs().iterator().next(); pubId = id.getId(); } ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.no_IMEX_id, pubId, null, null, null, "Publication " + ((IntactPublication)intactPublication).getAc() + " does not have a valid IMEx id and is ignored."); imexCentralManager.fireOnImexError(errorEvt); // do not update experiments and interactions getImexCentralManager().setEnableExperimentsAndInteractionsUpdate(false); }
@Override public void onImexIdConflicts(Publication intactPublication, Collection<Xref> conflictingXrefs) { String pubId = intactPublication.getPubmedId() != null ? intactPublication.getPubmedId() : intactPublication.getDoi(); if (pubId == null && !intactPublication.getIdentifiers().isEmpty()){ Xref id = intactPublication.getXrefs().iterator().next(); pubId = id.getId(); } ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.publication_imex_conflict, pubId, null, null, null, "Publication " + pubId + " cannot be updated because of IMEx identifier conflicts."); getImexCentralManager().fireOnImexError(errorEvt); // do not update experiments and interactions getImexCentralManager().setEnableExperimentsAndInteractionsUpdate(false); }
@Override public void onPublicationAlreadyRegisteredInImexCentral(Publication intactPublication, String imex) { String pubId = intactPublication.getPubmedId() != null ? intactPublication.getPubmedId() : intactPublication.getDoi(); if (pubId == null && !intactPublication.getIdentifiers().isEmpty()){ Xref id = intactPublication.getXrefs().iterator().next(); pubId = id.getId(); } // we already have an IMEx id in IMEx central, it is not possible to update the intact publication because we have a conflict ImexErrorEvent evt = new ImexErrorEvent(this, ImexErrorType.publication_already_in_imex, pubId, imex, null, null, "It is not possible to assign a valid IMEx id to the publication " + pubId + " because it already registered in IMEx central with another institution"); getImexCentralManager().fireOnImexError(evt); // do not update experiments and interactions getImexCentralManager().setEnableExperimentsAndInteractionsUpdate(false); }
/*** * This method will copy properties of publication source in publication target and will override all the other properties of Target publication. * This method will ignore experiments * @param source * @param target */ public static void copyAndOverridePublicationProperties(Publication source, Publication target){ if (source != null && target != null){ target.setCurationDepth(source.getCurationDepth()); target.setJournal(source.getJournal()); target.setReleasedDate(source.getReleasedDate()); target.setTitle(source.getTitle()); target.setPublicationDate(source.getPublicationDate()); target.setSource(source.getSource()); // copy collections target.getAnnotations().clear(); target.getAnnotations().addAll(source.getAnnotations()); target.getIdentifiers().clear(); target.getIdentifiers().addAll(source.getIdentifiers()); target.getAuthors().clear(); target.getAuthors().addAll(source.getAuthors()); target.getXrefs().clear(); target.getXrefs().addAll(source.getXrefs()); } }
Xref newId = XrefUtils.createIdentityXref(source, newIdentifier); Iterator<Xref> refIterator = p.getIdentifiers().iterator(); for (Xref id : p.getIdentifiers()){ p.getIdentifiers().add(newId);
@Override public void onImexIdNotRecognized(Publication intactPublication, String imex) { String pubId = intactPublication.getPubmedId() != null ? intactPublication.getPubmedId() : intactPublication.getDoi(); if (pubId == null && !intactPublication.getIdentifiers().isEmpty()){ Xref id = intactPublication.getXrefs().iterator().next(); pubId = id.getId(); } ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.imex_not_recognized, pubId, imex, null, null, "Publication " + ((IntactPublication)intactPublication).getAc() + " is not matching any record in IMEx central with id " + imex); getImexCentralManager().fireOnImexError(errorEvt); // do not update experiments and interactions getImexCentralManager().setEnableExperimentsAndInteractionsUpdate(false); }
private void checkPublication(Collection<ValidatorMessage> messages, Publication p, Experiment parent) throws ValidatorException { Collection<ValidatorMessage> confMessages = this.publicationRuleWrapper.check(p); // validate with other rules if any if (!getObjectRules().isEmpty()){ messages.addAll(super.validate(p)); } // add context for (ValidatorMessage message : confMessages){ ((MiContext)message.getContext()).addAssociatedContext(RuleUtils.buildContext(parent, "experiment")); messages.add(message); } // validate identifier for (Xref ref : p.getIdentifiers()){ checkXref(messages, ref, p, "publication"); } // validate xref for (Xref ref : p.getXrefs()){ checkXref(messages, ref, p, "publication"); } // validate annotations for (Annotation a : p.getAnnotations()){ checkAnnotation(messages, a, p, "publication"); } }
pub.setTitle(publication.getTitle()); pub.setImexAccession(publication.getImexId()); for (Xref id : publication.getIdentifiers()){ Identifier identifier = buildIdentifier(id.getId(), id.getDatabase().getShortName()); if (identifier != null){
public void write(Publication object) throws IOException { if (!object.getIdentifiers().isEmpty()){ MIJsonUtils.writePropertyKey("pubid", writer); MIJsonUtils.writeOpenArray(writer); Iterator<Xref> identifierIterator = object.getIdentifiers().iterator(); while (identifierIterator.hasNext()){ getIdentifierWriter().write(identifierIterator.next()); if (identifierIterator.hasNext()){ MIJsonUtils.writeSeparator(writer); } } if (object.getImexId() != null){ MIJsonUtils.writeSeparator(writer); MIJsonUtils.writeProperty("imex", JSONValue.escape(object.getImexId()), writer); } MIJsonUtils.writeEndArray(writer); } else if (object.getImexId() != null){ MIJsonUtils.writePropertyKey("pubid", writer); MIJsonUtils.writeOpenArray(writer); MIJsonUtils.writeProperty("imex", JSONValue.escape(object.getImexId()), writer); MIJsonUtils.writeEndArray(writer); } // publication source if (object.getSource() != null){ MIJsonUtils.writeSeparator(writer); MIJsonUtils.writePropertyKey("sourceDatabase", writer); getCvWriter().write(object.getSource()); } }
String pubId = publication.getPubmedId() != null ? publication.getPubmedId() : publication.getDoi(); String source = publication.getPubmedId() != null ? Xref.PUBMED : Xref.DOI; if (pubId == null && !publication.getIdentifiers().isEmpty()){ Xref id = publication.getXrefs().iterator().next(); source = id.getDatabase().getShortName();