use of org.vcell.sybil.models.miriam.MIRIAMQualifier 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.MIRIAMQualifier in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method addIdentifierDialog.
public void addIdentifierDialog() {
if (PopupGenerator.showComponentOKCancelDialog(MIRIAMAnnotationEditor.this, getJPanelNewIdentifier(), "Define New Formal Identifier") == JOptionPane.OK_OPTION) {
MIRIAMQualifier qualifier = (MIRIAMQualifier) jComboBoxQualifier.getSelectedItem();
MiriamManager.DataType objectNamespace = (MiriamManager.DataType) jComboBoxURI.getSelectedItem();
String objectID = jTextFieldFormalID.getText();
MiriamManager miriamManager = vcMetaData.getMiriamManager();
HashSet<MiriamResource> miriamResources = new HashSet<MiriamResource>();
try {
miriamResources.add(miriamManager.createMiriamResource(objectNamespace.getBaseURN() + ":" + objectID));
miriamManager.addMiriamRefGroup(getSelectedIdentifiable(), qualifier, miriamResources);
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "Add Identifier failed:\n" + e.getMessage(), e);
}
}
}
use of org.vcell.sybil.models.miriam.MIRIAMQualifier in project vcell by virtualcell.
the class MiriamTreeModel method createTree.
private void createTree() {
if (!createTree) {
return;
}
MiriamManager miriamManager = vcMetaData.getMiriamManager();
TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> dateMapMap = miriamManager.getDublinCoreDateMap();
Set<Identifiable> identifiables = vcMetaData.getIdentifiableProvider().getAllIdentifiables();
TreeSet<Identifiable> sortedIdentifiables = new TreeSet<Identifiable>(new IdentifiableComparator(vcMetaData.getIdentifiableProvider()));
sortedIdentifiables.addAll(identifiables);
((DefaultMutableTreeNode) getRoot()).removeAllChildren();
for (Identifiable identifiable : sortedIdentifiables) {
Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
Map<DateQualifier, Set<DublinCoreDate>> dateMap = dateMapMap.get(identifiable);
VCID vcid = vcMetaData.getIdentifiableProvider().getVCID(identifiable);
String modelComponentType = vcid.getClassName();
String modelComponentName = vcid.getLocalName();
IdentifiableNode modelComponentNode = new IdentifiableNode(identifiable, modelComponentType + " : " + modelComponentName);
String freeTextAnnotation = vcMetaData.getFreeTextAnnotation(identifiable);
if (freeTextAnnotation != null) {
modelComponentNode.add(new BioModelNode(new Annotation(freeTextAnnotation), false));
} else {
modelComponentNode.add(new BioModelNode(new Annotation(""), false));
}
if (refGroupMap != null) {
for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
LinkNode linkNode = new LinkNode(qualifier, miriamResource);
modelComponentNode.add(linkNode);
}
}
}
if (dateMap != null) {
for (DublinCoreQualifier.DateQualifier qualifier : dateMap.keySet()) {
Set<DublinCoreDate> dates = dateMap.get(qualifier);
for (DublinCoreDate date : dates) {
modelComponentNode.add(new DateNode(qualifier, date));
}
}
}
((DefaultMutableTreeNode) getRoot()).add(modelComponentNode);
}
}
use of org.vcell.sybil.models.miriam.MIRIAMQualifier in project vcell by virtualcell.
the class MiriamTreeModel method createTree.
public void createTree(Identifiable identifiable) {
if (identifiable == null) {
((DefaultMutableTreeNode) getRoot()).removeAllChildren();
fireTreeStructureChanged(this, getPathToRoot(((DefaultMutableTreeNode) getRoot())), null, null);
return;
}
((DefaultMutableTreeNode) getRoot()).removeAllChildren();
MiriamManager miriamManager = vcMetaData.getMiriamManager();
TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
VCID vcid = vcMetaData.getIdentifiableProvider().getVCID(identifiable);
// Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> dateMapMap = miriamManager.getDublinCoreDateMap();
// Map<DateQualifier, Set<DublinCoreDate>> dateMap = dateMapMap.get(identifiable);
List<LinkNode> nodeList = new ArrayList<>();
if (refGroupMap != null) {
for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
LinkNode ln = new LinkNode(qualifier, miriamResource);
nodeList.add(ln);
}
}
Collections.sort(nodeList);
for (LinkNode ln : nodeList) {
((DefaultMutableTreeNode) getRoot()).add(ln);
}
}
// if (dateMap!=null){
// for (DublinCoreQualifier.DateQualifier qualifier : dateMap.keySet()){
// Set<DublinCoreDate> dates = dateMap.get(qualifier);
// for (DublinCoreDate date : dates){
// ((DefaultMutableTreeNode)getRoot()).add(new DateNode(qualifier,date));
// }
// }
// }
fireTreeStructureChanged(this, getPathToRoot(((DefaultMutableTreeNode) getRoot())), null, null);
}
use of org.vcell.sybil.models.miriam.MIRIAMQualifier 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());
}
}
}
Aggregations