Search in sources :

Example 6 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