Search in sources :

Example 16 with Identifiable

use of org.vcell.util.document.Identifiable in project vcell by virtualcell.

the class VCMetaDataMiriamManager method getDublinCoreDateMap.

// this is not yet cached.
public Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> getDublinCoreDateMap() {
    Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> map = new HashMap<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>>();
    Set<Entry> allEntries = vcMetaData.getRegistry().getAllEntries();
    Graph rdfData = vcMetaData.getRdfData();
    for (Entry entry : allEntries) {
        Resource resource = entry.getResource();
        if (resource != null) {
            Identifiable identifiable = entry.getIdentifiable();
            Map<DateQualifier, Set<DublinCoreDate>> qualifierDateMap = new HashMap<DateQualifier, Set<DublinCoreDate>>();
            for (DublinCoreQualifier.DateQualifier dateQualifier : AnnotationQualifiers.DC_date_all) {
                Set<DublinCoreDate> dateStrings = new HashSet<DublinCoreDate>();
                Iterator<Statement> stmtIter = rdfData.match(resource, dateQualifier.getProperty(), null);
                while (stmtIter.hasNext()) {
                    Statement statement = stmtIter.next();
                    Value dateObject = statement.getObject();
                    if (dateObject instanceof Literal) {
                        Literal dateLiteral = (Literal) dateObject;
                        String dateString = dateLiteral.stringValue();
                        dateStrings.add(new DublinCoreDate(dateString));
                    }
                }
                if (!dateStrings.isEmpty()) {
                    qualifierDateMap.put(dateQualifier, dateStrings);
                }
            }
            if (!qualifierDateMap.isEmpty()) {
                map.put(identifiable, qualifierDateMap);
            }
        }
    }
    return map;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) DublinCoreDate(org.vcell.sybil.models.dublincore.DublinCoreDate) HashMap(java.util.HashMap) Statement(org.openrdf.model.Statement) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) Resource(org.openrdf.model.Resource) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) Identifiable(org.vcell.util.document.Identifiable) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Graph(org.openrdf.model.Graph) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) DublinCoreQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier) Literal(org.openrdf.model.Literal) Value(org.openrdf.model.Value) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) HashSet(java.util.HashSet)

Example 17 with Identifiable

use of org.vcell.util.document.Identifiable in project vcell by virtualcell.

the class AnnotationMapping method getRefInfo.

private HashMap<String, String> getRefInfo(BioModel bioModel, Identifiable identifiable) {
    HashMap<String, String> info = new HashMap<String, String>();
    VCMetaData vcMetaData = bioModel.getVCMetaData();
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
    if (refGroupMap != null) {
        for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
            MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
            String[] quaTemp = qualifier.toString().split("/");
            String bioQualifier = quaTemp[quaTemp.length - 1];
            bioQualifier = bioQualifier.substring(0, bioQualifier.length() - 1);
            for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                String refSource = miriamResource.getMiriamURN();
                String[] temp = refSource.split(":");
                String sourceInfo = temp[2] + ":" + bioQualifier;
                String refId = miriamResource.getIdentifier();
                info.put(refId, sourceInfo);
            // System.out.println(refId + "*********" + sourceInfo);
            }
        }
    }
    return info;
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) HashMap(java.util.HashMap) Identifiable(org.vcell.util.document.Identifiable) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)

Example 18 with Identifiable

use of org.vcell.util.document.Identifiable in project vcell by virtualcell.

the class AnnotationsPanel method initializeComboBoxURI.

@SuppressWarnings("unchecked")
private void initializeComboBoxURI() {
    Identifiable entity = getIdentifiable(selectedObject);
    defaultComboBoxModelURI.removeAllElements();
    List<String> tooltips = new ArrayList<String>();
    List<DataType> dataTypeList = new ArrayList<>();
    if (entity == null) {
        for (DataType dt : vcMetaData.getMiriamManager().getAllDataTypes().values()) {
            dataTypeList.add(dt);
        }
    } else {
        for (DataType dt : VCMetaDataMiriamManager.getSpecificDataTypes(entity)) {
            dataTypeList.add(dt);
        }
    }
    Collections.sort(dataTypeList);
    for (DataType dt : dataTypeList) {
        tooltips.add(dt.getDescription());
        defaultComboBoxModelURI.addElement(dt);
    }
    ((ComboboxToolTipRenderer) getJComboBoxURI().getRenderer()).setTooltips(tooltips);
}
Also used : ArrayList(java.util.ArrayList) DataType(cbit.vcell.biomodel.meta.MiriamManager.DataType) VCMetaDataDataType(cbit.vcell.biomodel.meta.VCMetaDataMiriamManager.VCMetaDataDataType) Identifiable(org.vcell.util.document.Identifiable)

Example 19 with Identifiable

use of org.vcell.util.document.Identifiable in project vcell by virtualcell.

the class AnnotationsPanel method updateInterface.

private void updateInterface() {
    if (bioModel == null) {
        return;
    }
    Identifiable entity = getIdentifiable(selectedObject);
    if (selectedObject != null && entity != null) {
        getJComboBoxURI().setEnabled(true);
        getJTextFieldFormalID().setEnabled(true);
        getJButtonAddRef().setEnabled(true);
        getJButtonRemoveText().setEnabled(true);
        VCMetaDataDataType mdt = (VCMetaDataDataType) getJComboBoxURI().getSelectedItem();
        miriamTreeModel.createTree(entity);
        String freeText = bioModel.getVCMetaData().getFreeTextAnnotation(entity);
        if (freeText == null || freeText.isEmpty()) {
            annotationTextArea.setText(null);
        } else {
            annotationTextArea.setText(freeText);
        }
        annotationTextArea.setEditable(true);
        annotationTextArea.setCaretPosition(0);
    } else {
        getJComboBoxURI().setEnabled(false);
        getJTextFieldFormalID().setEnabled(false);
        getJButtonAddRef().setEnabled(false);
        getJButtonRemoveText().setEnabled(false);
        miriamTreeModel.createTree(null);
        annotationTextArea.setText(null);
        annotationTextArea.setEditable(false);
    }
}
Also used : VCMetaDataDataType(cbit.vcell.biomodel.meta.VCMetaDataMiriamManager.VCMetaDataDataType) Identifiable(org.vcell.util.document.Identifiable)

Example 20 with Identifiable

use of org.vcell.util.document.Identifiable in project vcell by virtualcell.

the class AnnotationsPanel method changeTextAnnotation.

private void changeTextAnnotation() {
    try {
        if (bioModel == null || selectedObject == null) {
            return;
        }
        Identifiable entity = getIdentifiable(selectedObject);
        String textAreaStr = (annotationTextArea.getText() == null || annotationTextArea.getText().length() == 0 ? null : annotationTextArea.getText());
        String oldText = bioModel.getVCMetaData().getFreeTextAnnotation(entity);
        if (textAreaStr == null || textAreaStr.isEmpty() || emptyHtmlText.equals(textAreaStr)) {
            // no annotation now, the field is empty
            // delete, if there's something previously saved
            bioModel.getVCMetaData().deleteFreeTextAnnotation(entity);
            if (selectedObject instanceof ReactionStep) {
                // we tell ReactionPropertiesPanel to refresh the annotation icon
                ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true);
            }
        } else if (!Compare.isEqualOrNull(oldText, textAreaStr)) {
            // some text annotation different from what's already saved
            // overwrite
            bioModel.getVCMetaData().setFreeTextAnnotation(entity, textAreaStr);
            if (selectedObject instanceof ReactionStep) {
                // we tell ReactionPropertiesPanel to refresh the text annotation icon
                ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true);
            }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
        PopupGenerator.showErrorDialog(this, "Annotation Error\n" + e.getMessage(), e);
    }
}
Also used : ReactionStep(cbit.vcell.model.ReactionStep) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) Identifiable(org.vcell.util.document.Identifiable)

Aggregations

Identifiable (org.vcell.util.document.Identifiable)24 MIRIAMQualifier (org.vcell.sybil.models.miriam.MIRIAMQualifier)12 Map (java.util.Map)11 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)10 TreeMap (java.util.TreeMap)10 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)8 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)6 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)6 VCID (cbit.vcell.biomodel.meta.VCID)5 ReactionStep (cbit.vcell.model.ReactionStep)5 URNParseFailureException (org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)5 Registry (cbit.vcell.biomodel.meta.registry.Registry)4 ArrayList (java.util.ArrayList)4 VCMetaDataDataType (cbit.vcell.biomodel.meta.VCMetaDataMiriamManager.VCMetaDataDataType)3 HashMap (java.util.HashMap)3 Icon (javax.swing.Icon)3 Element (org.jdom.Element)3 Resource (org.openrdf.model.Resource)3 DataType (cbit.vcell.biomodel.meta.MiriamManager.DataType)2 VCMetaDataMiriamManager (cbit.vcell.biomodel.meta.VCMetaDataMiriamManager)2