Search in sources :

Example 1 with URNParseFailureException

use of org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException in project vcell by virtualcell.

the class MIRIAMAnnotationEditor method removeSelectedRefGroups.

public void removeSelectedRefGroups() {
    Object treeNode = jTreeMIRIAM.getLastSelectedPathComponent();
    if (treeNode instanceof IdentifiableNode) {
        Identifiable identifiable = ((IdentifiableNode) treeNode).getIdentifiable();
        Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = vcMetaData.getMiriamManager().getAllMiriamRefGroups(identifiable);
        for (MiriamRefGroup refGroup : refGroupsToRemove.keySet()) {
            MIRIAMQualifier qualifier = refGroupsToRemove.get(refGroup);
            try {
                vcMetaData.getMiriamManager().remove(identifiable, qualifier, refGroup);
            } catch (URNParseFailureException e) {
                e.printStackTrace(System.out);
            }
        }
    }
}
Also used : IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) Identifiable(org.vcell.util.document.Identifiable)

Example 2 with URNParseFailureException

use of org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException in project vcell by virtualcell.

the class VCMetaData method cleanupMetadata.

public void cleanupMetadata() {
    Set<Registry.Entry> entries = registry.getAllEntries();
    for (Registry.Entry entry : entries) {
        Identifiable entryIdentifiable = entry.getIdentifiable();
        VCID vcid = identifiableProvider.getVCID(entryIdentifiable);
        if (vcid == null) {
            continue;
        }
        Identifiable identifiable = identifiableProvider.getIdentifiableObject(vcid);
        if (identifiable == null) {
            // use miriamManager to remove RDF statements from resource for identifiable
            try {
                Map<MiriamRefGroup, MIRIAMQualifier> miriamRefGps = getMiriamManager().getAllMiriamRefGroups(entryIdentifiable);
                if (miriamRefGps != null) {
                    for (Map.Entry<MiriamRefGroup, MIRIAMQualifier> groupEntry : miriamRefGps.entrySet()) {
                        MiriamRefGroup refGroup = groupEntry.getKey();
                        MIRIAMQualifier qualifier = groupEntry.getValue();
                        getMiriamManager().remove(entryIdentifiable, qualifier, refGroup);
                    }
                }
            } catch (URNParseFailureException e) {
                e.printStackTrace(System.out);
            }
            // set nonRDF annotations to null
            NonRDFAnnotation nonRDFAnnotation = getExistingNonRDFAnnotation(entryIdentifiable);
            if (nonRDFAnnotation != null) {
                nonRDFAnnotation.setFreeTextAnnotation(null);
                nonRDFAnnotation.setXhtmlNotes(null);
                nonRDFAnnotation.setXmlAnnotations(null);
            }
            System.err.println("Deleting resource for identifiable '" + entryIdentifiable.toString() + "' since it is not found in " + identifiableProvider.getClass().getName());
        }
    }
}
Also used : Registry(cbit.vcell.biomodel.meta.registry.Registry) Identifiable(org.vcell.util.document.Identifiable) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) TreeMap(java.util.TreeMap) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)

Example 3 with URNParseFailureException

use of org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException in project vcell by virtualcell.

the class RefGroup method refs.

public Set<MIRIAMRef> refs(Graph graph) {
    Resource resource = getResource();
    Iterator<Statement> stmtIter = graph.match(resource, null, null);
    Set<MIRIAMRef> refs = new HashSet<MIRIAMRef>();
    while (stmtIter.hasNext()) {
        Statement statement = stmtIter.next();
        URI predicate = statement.getPredicate();
        if (RDFBagUtil.isRDFContainerMembershipProperty(predicate)) {
            Value object = statement.getObject();
            if (object instanceof URI) {
                URI resourceRef = (URI) object;
                try {
                    String value = resourceRef.stringValue();
                    MIRIAMRef ref = MIRIAMRef.createFromURN(value);
                    refs.add(ref);
                } catch (URNParseFailureException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return refs;
}
Also used : Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) URI(org.openrdf.model.URI) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) HashSet(java.util.HashSet)

Example 4 with URNParseFailureException

use of org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException in project vcell by virtualcell.

the class AnnotationsPanel method removeIdentifier.

private void removeIdentifier() {
    Object treeNode = jTreeMIRIAM.getLastSelectedPathComponent();
    if (treeNode instanceof LinkNode) {
        LinkNode linkNode = (LinkNode) treeNode;
        MiriamResource resourceToDelete = linkNode.getMiriamResource();
        Identifiable entity = getIdentifiable(selectedObject);
        // Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = vcMetaData.getMiriamManager().getAllMiriamRefGroups(entity);
        MiriamManager mm = vcMetaData.getMiriamManager();
        Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = mm.getMiriamTreeMap().get(entity);
        boolean found = false;
        for (MiriamRefGroup refGroup : refGroupsToRemove.keySet()) {
            MIRIAMQualifier qualifier = refGroupsToRemove.get(refGroup);
            for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                if (!isEqual(miriamResource, resourceToDelete)) {
                    continue;
                }
                try {
                    // remove the ref group for this resource
                    mm.remove2(entity, qualifier, refGroup);
                    System.out.println(vcMetaData.printRdfStatements());
                    found = true;
                    break;
                } catch (URNParseFailureException e) {
                    e.printStackTrace(System.out);
                }
            }
            if (found == true) {
                updateInterface();
                if (selectedObject instanceof ReactionStep) {
                    ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", true, false);
                }
                break;
            }
        }
    }
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) VCMetaDataMiriamManager(cbit.vcell.biomodel.meta.VCMetaDataMiriamManager) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) ReactionStep(cbit.vcell.model.ReactionStep) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode) BioPaxObject(org.vcell.pathway.BioPaxObject) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) Identifiable(org.vcell.util.document.Identifiable)

Example 5 with URNParseFailureException

use of org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException in project vcell by virtualcell.

the class SpeciesPropertiesPanel method saveSelectedXRef.

public void saveSelectedXRef(final XRef selectedXRef, final MIRIAMQualifier miriamQualifier) {
    AsynchClientTask task1 = new AsynchClientTask("retrieving metadata", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            String urn = XRefToURN.createURN(selectedXRef.db(), selectedXRef.id());
            try {
                MiriamManager miriamManager = bioModel.getModel().getVcMetaData().getMiriamManager();
                MiriamResource resource = miriamManager.createMiriamResource(urn);
                String urnstr = resource.getMiriamURN();
                if (urnstr != null && urnstr.toLowerCase().contains("uniprot")) {
                    String prettyName = UniProtConstants.getNameFromID(urnstr);
                    if (prettyName != null) {
                        miriamManager.setPrettyName(resource, prettyName);
                    }
                }
                Set<MiriamResource> miriamResources = new HashSet<MiriamResource>();
                miriamResources.add(resource);
                miriamManager.addMiriamRefGroup(getSpeciesContext().getSpecies(), miriamQualifier, miriamResources);
                MiriamProviderServiceLocator providerLocator = new MiriamProviderServiceLocator();
                MiriamProvider provider = providerLocator.getMiriamWebServices();
                String pcLink = resource.getMiriamURN();
                if (pcLink != null && pcLink.length() > 0) {
                    String[] locations = provider.getLocations(pcLink);
                    if (locations != null) {
                        for (String url : locations) {
                            try {
                                miriamManager.addStoredCrossReferencedLink(resource, new URL(url));
                            } catch (MalformedURLException e) {
                                e.printStackTrace(System.out);
                            }
                        }
                    }
                }
            } catch (URNParseFailureException e) {
                e.printStackTrace();
                DialogUtils.showErrorDialog(SpeciesPropertiesPanel.this, e.getMessage());
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("displaying metadata", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            updatePCLink();
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : MiriamProvider(uk.ac.ebi.www.miriamws.main.MiriamWebServices.MiriamProvider) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) MalformedURLException(java.net.MalformedURLException) Hashtable(java.util.Hashtable) URL(java.net.URL) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) MiriamProviderServiceLocator(uk.ac.ebi.www.miriamws.main.MiriamWebServices.MiriamProviderServiceLocator) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) HashSet(java.util.HashSet)

Aggregations

URNParseFailureException (org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)6 MIRIAMQualifier (org.vcell.sybil.models.miriam.MIRIAMQualifier)4 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)3 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)3 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)3 HashSet (java.util.HashSet)3 Identifiable (org.vcell.util.document.Identifiable)3 BioPaxObject (org.vcell.pathway.BioPaxObject)2 VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)1 VCMetaDataMiriamManager (cbit.vcell.biomodel.meta.VCMetaDataMiriamManager)1 Registry (cbit.vcell.biomodel.meta.registry.Registry)1 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 RbmModelContainer (cbit.vcell.model.Model.RbmModelContainer)1 ModelException (cbit.vcell.model.ModelException)1 ReactionStep (cbit.vcell.model.ReactionStep)1 IdentifiableNode (cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode)1 LinkNode (cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)1 PropertyVetoException (java.beans.PropertyVetoException)1 MalformedURLException (java.net.MalformedURLException)1