Example usage for java.text Annotation getValue

List of usage examples for java.text Annotation getValue

Introduction

In this page you can find the example usage for java.text Annotation getValue.

Prototype

public Object getValue() 

Source Link

Document

Returns the value of the attribute, which may be null.

Usage

From source file:uk.ac.ebi.intact.editor.controller.curate.experiment.ExperimentController.java

@Override
protected void loadCautionMessages() {
    if (this.experiment != null) {

        Annotation caution = AnnotationUtils.collectFirstAnnotationWithTopic(this.experiment.getAnnotations(),
                Annotation.CAUTION_MI, Annotation.CAUTION);
        setCautionMessage(caution != null ? caution.getValue() : null);
        Annotation internal = AnnotationUtils.collectFirstAnnotationWithTopic(this.experiment.getAnnotations(),
                null, "remark-internal");
        setInternalRemark(internal != null ? internal.getValue() : null);
        Annotation correctionComment = AnnotationUtils.collectFirstAnnotationWithTopic(
                this.experiment.getAnnotations(), null, Releasable.CORRECTION_COMMENT);
        this.correctedComment = correctionComment != null ? correctionComment.getValue() : null;
        Annotation toBeReviewed = AnnotationUtils.collectFirstAnnotationWithTopic(
                this.experiment.getAnnotations(), null, Releasable.TO_BE_REVIEWED);
        this.reasonForRejection = toBeReviewed != null ? toBeReviewed.getValue() : null;
        Annotation accepted = AnnotationUtils.collectFirstAnnotationWithTopic(this.experiment.getAnnotations(),
                null, Releasable.ACCEPTED);
        this.accepted = accepted != null ? accepted.getValue() : null;
    }/*from  ww w .ja  va 2  s  .c  o  m*/
}

From source file:uk.ac.ebi.intact.editor.controller.curate.experiment.ExperimentController.java

public void copyPublicationAnnotations(ActionEvent evt) {
    if (experiment.getPublication() instanceof IntactPublication) {
        for (Annotation annot : ((IntactPublication) experiment.getPublication()).getDbAnnotations()) {
            Annotation existingAnnot = AnnotationUtils.collectFirstAnnotationWithTopic(
                    experiment.getAnnotations(), annot.getTopic().getMIIdentifier(),
                    annot.getTopic().getShortName());
            if (existingAnnot != null) {
                existingAnnot.setValue(annot.getValue());
            } else {
                experiment.getAnnotations().add(new ExperimentAnnotation(annot.getTopic(), annot.getValue()));
            }//from   www.  ja  va  2s  . co m
        }

        addInfoMessage("Annotations copied from publication", "");
        setUnsavedChanges(true);
    }
}

From source file:uk.ac.ebi.intact.editor.controller.curate.AnnotatedObjectController.java

public void removeAnnotation(String topic, String topicMI, String value, Collection<Annotation> annots) {
    if (topic == null) {
        throw new IllegalArgumentException(
                "Impossible to replace or create annotations if the topic is not set.");
    }//from  w w  w .java  2 s . c om

    // modify if exists
    Collection<Annotation> existingAnnots = AnnotationUtils.collectAllAnnotationsHavingTopic(annots, topicMI,
            topic);
    for (Annotation ann : existingAnnots) {
        if (value == null && ann.getValue() == null) {
            annots.remove(ann);
        } else if (value != null && value.equals(ann.getValue())) {
            annots.remove(ann);
        }
    }
    setUnsavedChanges(true);
}

From source file:uk.ac.ebi.intact.editor.controller.curate.AnnotatedObjectController.java

public String externalLink(Xref xref) {
    if (xref == null)
        return null;
    if (xref.getId() == null || xref.getId().equals("to set"))
        return null;
    if (xref.getDatabase() == null || xref.getDatabase().getShortName().equals("to set"))
        return null;

    CvTerm ao = xref.getDatabase();/*from  w ww. jav  a 2  s . co  m*/

    final Annotation annotation = AnnotationUtils.collectFirstAnnotationWithTopic(ao.getAnnotations(),
            Annotation.SEARCH_URL_MI, Annotation.SEARCH_URL);
    if (annotation == null || annotation.getValue() == null)
        return null;

    String extUrl = annotation.getValue();
    return extUrl.replaceAll("\\$\\{ac\\}", xref.getId());
}

From source file:uk.ac.ebi.intact.editor.controller.curate.AnnotatedObjectController.java

public String getCautionMessage(IntactPrimaryObject ao) {
    if (ao == null)
        return null;
    Collection<Annotation> annotations = Collections.EMPTY_LIST;
    if (ao instanceof IntactPublication) {
        IntactPublication publication = (IntactPublication) ao;
        if (publication.areAnnotationsInitialized()) {
            annotations = publication.getAnnotations();
        } else {/* w  ww  .j  a  v a2 s.com*/
            annotations = ((PublicationEditorService) ApplicationContextProvider
                    .getBean("publicationEditorService")).initialisePublicationAnnotations(publication);
        }
    } else if (ao instanceof IntactExperiment) {
        IntactExperiment experiment = (IntactExperiment) ao;
        if (experiment.areAnnotationsInitialized()) {
            annotations = experiment.getAnnotations();
        } else {
            annotations = ((ExperimentEditorService) ApplicationContextProvider
                    .getBean("experimentEditorService")).initialiseExperimentAnnotations(experiment);
        }
    } else if (ao instanceof IntactInteractionEvidence) {
        IntactInteractionEvidence interaction = (IntactInteractionEvidence) ao;
        if (interaction.areAnnotationsInitialized()) {
            annotations = interaction.getAnnotations();
        } else {
            annotations = ((InteractionEditorService) ApplicationContextProvider
                    .getBean("interactionEditorService")).initialiseInteractionAnnotations(interaction);
        }
    } else if (ao instanceof IntactInteractor) {
        IntactInteractor interactor = (IntactInteractor) ao;
        if (interactor.areAnnotationsInitialized()) {
            annotations = interactor.getAnnotations();
        } else {
            annotations = ((InteractorEditorService) ApplicationContextProvider
                    .getBean("interactorEditorService")).initialiseInteractorAnnotations(interactor);
        }
    } else if (ao instanceof AbstractIntactParticipant) {
        AbstractIntactParticipant participant = (AbstractIntactParticipant) ao;
        if (participant.areAnnotationsInitialized()) {
            annotations = participant.getAnnotations();
        } else {
            annotations = ((ParticipantEditorService) ApplicationContextProvider
                    .getBean("participantEditorService")).initialiseParticipantAnnotations(participant);
        }
    } else if (ao instanceof AbstractIntactFeature) {
        AbstractIntactFeature participant = (AbstractIntactFeature) ao;
        if (participant.areAnnotationsInitialized()) {
            annotations = participant.getAnnotations();
        } else {
            annotations = ((FeatureEditorService) ApplicationContextProvider.getBean("featureEditorService"))
                    .initialiseFeatureAnnotations(participant);
        }
    } else if (ao instanceof IntactCvTerm) {
        IntactCvTerm cv = (IntactCvTerm) ao;
        if (cv.areAnnotationsInitialized()) {
            annotations = cv.getAnnotations();
        } else {
            annotations = getCvService().initialiseCvAnnotations(cv);
        }
    } else if (ao instanceof IntactSource) {
        IntactSource source = (IntactSource) ao;
        if (source.areAnnotationsInitialized()) {
            annotations = source.getAnnotations();
        } else {
            annotations = ((InstitutionService) ApplicationContextProvider.getBean("institutionService"))
                    .initialiseSourceAnnotations(source);
        }
    }

    if (annotations.isEmpty()) {
        return null;
    }
    Annotation caution = AnnotationUtils.collectFirstAnnotationWithTopic(annotations, Annotation.CAUTION_MI,
            Annotation.CAUTION);
    return caution != null ? caution.getValue() : null;
}

From source file:uk.ac.ebi.intact.editor.controller.curate.AnnotatedObjectController.java

public boolean isXrefValid(Xref xref) {
    if (xref == null)
        return false;
    if (xref.getId() == null || xref.getId().equals("to set"))
        return false;
    if (xref.getDatabase() == null || xref.getDatabase().getShortName().equals("to set"))
        return false;

    CvTerm ao = xref.getDatabase();/*from   ww w.  j  a v  a  2 s. c om*/

    final Annotation annotation = AnnotationUtils.collectFirstAnnotationWithTopic(ao.getAnnotations(),
            Annotation.VALIDATION_REGEXP_MI, Annotation.VALIDATION_REGEXP);

    if (annotation == null)
        return true;
    else if (annotation.getValue() == null) {
        return false;
    }
    return xref.getId().matches(annotation.getValue());
}

From source file:uk.ac.ebi.intact.editor.controller.curate.complex.ComplexController.java

private void refreshInfoMessages() {
    this.toBeReviewed = this.complex.getToBeReviewedComment();
    this.onHold = this.complex.getOnHoldComment();
    this.correctionComment = this.complex.getCorrectionComment();
    Annotation remark = AnnotationUtils.collectFirstAnnotationWithTopic(this.complex.getAnnotations(), null,
            "remark-internal");
    this.internalRemark = remark != null ? remark.getValue() : null;
    Annotation caution = AnnotationUtils.collectFirstAnnotationWithTopic(this.complex.getAnnotations(),
            Annotation.CAUTION_MI, Annotation.CAUTION);
    this.cautionMessage = caution != null ? caution.getValue() : null;
    Annotation desc = AnnotationUtils.collectFirstAnnotationWithTopic(this.complex.getAnnotations(), null,
            "curated-complex");
    this.description = desc != null ? desc.getValue() : null;
    this.complexProperties = this.complex.getPhysicalProperties();
    this.obsoleteVersion = "";
}

From source file:uk.ac.ebi.intact.editor.controller.curate.publication.PublicationController.java

private void loadFormFields() {
    // reset previous dataset actions in the form
    this.datasetsToRemove = null;
    this.datasetToAdd = null;
    this.datasetsSelectItems = new ArrayList<SelectItem>();

    Collection<Annotation> datasets = AnnotationUtils
            .collectAllAnnotationsHavingTopic(this.publication.getAnnotations(), DATASET_MI_REF, DATASET);
    for (Annotation annot : datasets) {
        if (annot.getValue() != null) {
            SelectItem item = getDatasetPopulator().createSelectItem(annot.getValue());
            if (item != null) {
                this.datasetsSelectItems.add(item);
            }//from   www  .jav a  2 s.  co m
        }
    }

    // load curationDepth
    this.curationDepth = this.publication.getCurationDepth().toString();
}

From source file:uk.ac.ebi.intact.editor.controller.curate.publication.PublicationController.java

@Override
protected void loadCautionMessages() {
    if (this.publication != null) {

        Annotation caution = AnnotationUtils.collectFirstAnnotationWithTopic(this.publication.getAnnotations(),
                Annotation.CAUTION_MI, Annotation.CAUTION);
        setCautionMessage(caution != null ? caution.getValue() : null);
        Annotation internal = AnnotationUtils.collectFirstAnnotationWithTopic(this.publication.getAnnotations(),
                null, "remark-internal");
        setInternalRemark(internal != null ? internal.getValue() : null);
        this.toBeReviewed = this.publication.getToBeReviewedComment();
        this.accepted = this.publication.getAcceptedComment();
        this.onHold = this.publication.getOnHoldComment();
        this.imexId = this.publication.getImexId();
        this.journal = this.publication.getJournal();
        this.identifier = this.publication.getPubmedId();
        this.curationDepth = this.publication.getCurationDepth().toString();
        this.authors = !this.publication.getAuthors().isEmpty()
                ? StringUtils.join(this.publication.getAuthors(), ", ")
                : null;// ww w.j  a  v a 2  s. c om
        Annotation contactEmail = AnnotationUtils.collectFirstAnnotationWithTopic(
                this.publication.getAnnotations(), Annotation.CONTACT_EMAIL_MI, Annotation.CONTACT_EMAIL);
        this.contactEmail = contactEmail != null ? contactEmail.getValue() : null;
        if (publication.getPublicationDate() == null) {
            this.year = null;
        } else {
            Calendar cal = Calendar.getInstance();
            cal.setTime(publication.getPublicationDate());
            int year = cal.get(Calendar.YEAR);
            this.year = (short) year;
        }
    }
}

From source file:uk.ac.ebi.intact.editor.controller.curate.publication.PublicationController.java

public void markAsReadyForChecking(ActionEvent evt) {
    if (!userSessionController.isItMe(publication.getCurrentOwner())) {
        addErrorMessage("Cannot mark as Ready for checking", "You are not the owner of this publication");
        return;//from ww w .j a  va 2s .  c  om
    }

    if (isBeenRejectedBefore()) {
        List<String> correctionComments = new ArrayList<String>();

        for (Experiment exp : publication.getExperiments()) {
            Annotation correctionCommentAnnot = AnnotationUtils
                    .collectFirstAnnotationWithTopic(exp.getAnnotations(), null, Releasable.CORRECTION_COMMENT);

            if (correctionCommentAnnot != null) {
                correctionComments.add(correctionCommentAnnot.getValue());
            }

            reasonForReadyForChecking = StringUtils.join(correctionComments, "; ");
        }

    }

    try {
        getEditorService().markAsReadyForChecking(publication, getCurrentUser(), reasonForReadyForChecking);

        reasonForReadyForChecking = null;

        addInfoMessage("Publication ready for checking",
                "Assigned to reviewer: " + publication.getCurrentReviewer().getLogin());
        // try to register/update record in IMEx central. IMEx records are updated automatically with a cron job so if it has an IMEx id we do nothing
        if (publication.getAc() != null && getImexId() == null) {
            try {
                getImexCentralManager().registerAndUpdatePublication(publication.getAc());
            } catch (EnricherException e) {
                addWarningMessage("Impossible to register/update status of " + identifier + " in IMEx central",
                        e.getMessage());
            }
        }
    } catch (IllegalTransitionException e) {
        addErrorMessage("Cannot mark as ready for checking: " + e.getMessage(),
                ExceptionUtils.getFullStackTrace(e));
    }
}