use of cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.
the class VCMetaData method compareEquals.
public boolean compareEquals(VCMetaData vcMetaData) {
if (!getRdfData().equals(vcMetaData.getRdfData())) {
return false;
}
if (!registry.compareEquals(vcMetaData.registry)) {
return false;
}
Set<Entry> oeSet = nonRDFAnnotationMap.keySet();
Set<VCID> vcidSet = new HashSet<VCID>();
for (Entry oe : oeSet) {
VCID vcid = identifiableProvider.getVCID(oe.getIdentifiable());
vcidSet.add(vcid);
}
Set<Entry> otherOeSet = vcMetaData.nonRDFAnnotationMap.keySet();
for (Entry oe : otherOeSet) {
VCID vcid = vcMetaData.identifiableProvider.getVCID(oe.getIdentifiable());
vcidSet.add(vcid);
}
NonRDFAnnotation emtpyAnnotation = new NonRDFAnnotation();
for (VCID vcid : vcidSet) {
Identifiable myIdentifiable = identifiableProvider.getIdentifiableObject(vcid);
Identifiable otherIdentifiable = vcMetaData.identifiableProvider.getIdentifiableObject(vcid);
if ((otherIdentifiable == null && myIdentifiable != null) || (myIdentifiable == null && otherIdentifiable != null)) {
return false;
}
NonRDFAnnotation nonRDFAnnotation = nonRDFAnnotationMap.get(registry.getEntry(myIdentifiable));
if (nonRDFAnnotation == null) {
nonRDFAnnotation = emtpyAnnotation;
}
NonRDFAnnotation otherNonRDFAnnotation = vcMetaData.nonRDFAnnotationMap.get(vcMetaData.registry.getEntry(otherIdentifiable));
if (otherNonRDFAnnotation == null) {
otherNonRDFAnnotation = emtpyAnnotation;
}
if (!Compare.isEqual(nonRDFAnnotation, otherNonRDFAnnotation)) {
return false;
}
}
return true;
}
use of cbit.vcell.biomodel.meta.registry.Registry.Entry 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);
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 cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.
the class VCMetaDataMiriamManager method remove.
public void remove(Identifiable identifiable, MIRIAMQualifier miriamQualifier, MiriamRefGroup miriamRefGroup) throws URNParseFailureException {
Entry openEntry = vcMetaData.getRegistry().getEntry(identifiable);
Resource resource = openEntry.getResource();
MIRIAMizer miriamizer = new MIRIAMizer();
RefGroup sybilRefGroup = miriamizer.newRefGroup(vcMetaData.getRdfData(), resource, miriamQualifier);
Set<MIRIAMRef> sybilMiriamRefs = new HashSet<MIRIAMRef>();
Set<MiriamResource> miriamResources = miriamRefGroup.getMiriamRefs();
for (MiriamResource miriamResource : miriamResources) {
sybilMiriamRefs.add(MIRIAMRef.createFromURN(miriamResource.getMiriamURN()));
}
for (MIRIAMRef sybilMiriamRef : sybilMiriamRefs) {
sybilRefGroup.add(vcMetaData.getRdfData(), sybilMiriamRef);
}
miriamizer.deleteRefGroup(vcMetaData.getRdfData(), resource, sybilRefGroup);
invalidateCache(identifiable);
vcMetaData.fireAnnotationEventListener(new VCMetaData.AnnotationEvent(identifiable));
}
use of cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.
the class VCMetaDataMiriamManager method addDate.
public void addDate(Identifiable identifiable, DateQualifier dateQualifier, DublinCoreDate date) {
Entry entry = vcMetaData.getRegistry().getEntry(identifiable);
if (entry.getResource() == null) {
String newURI = vcMetaData.getRegistry().generateFreeURI(identifiable);
entry.setURI(vcMetaData.getRdfData(), newURI);
}
Graph rdfData = vcMetaData.getRdfData();
Literal dateLiteral = rdfData.getValueFactory().createLiteral(date.getDateString());
rdfData.add(entry.getResource(), dateQualifier.getProperty(), dateLiteral);
vcMetaData.fireAnnotationEventListener(new VCMetaData.AnnotationEvent(identifiable));
}
use of cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.
the class VCMetaDataMiriamManager method getMiriamTreeMap.
public synchronized TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> getMiriamTreeMap() {
if (miriamTreeMap == null) {
final IdentifiableProvider identifiableProvider = vcMetaData.getIdentifiableProvider();
miriamTreeMap = new TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>>(new IdentifiableComparator(identifiableProvider));
Set<Entry> allEntries = vcMetaData.getRegistry().getAllEntries();
for (Entry entry : allEntries) {
if (entry.getResource() != null) {
Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = queryAllMiriamRefGroups(entry.getIdentifiable());
if (refGroupMap.size() > 0) {
miriamTreeMap.put(entry.getIdentifiable(), refGroupMap);
}
}
}
}
return miriamTreeMap;
}
Aggregations