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 });
}
Aggregations