Search in sources :

Example 1 with MiriamProvider

use of uk.ac.ebi.www.miriamws.main.MiriamWebServices.MiriamProvider 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

MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)1 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 Hashtable (java.util.Hashtable)1 BioPaxObject (org.vcell.pathway.BioPaxObject)1 RelationshipObject (org.vcell.relationship.RelationshipObject)1 URNParseFailureException (org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)1 MiriamProvider (uk.ac.ebi.www.miriamws.main.MiriamWebServices.MiriamProvider)1 MiriamProviderServiceLocator (uk.ac.ebi.www.miriamws.main.MiriamWebServices.MiriamProviderServiceLocator)1