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