Lock lock = existingNode.writeLock();
try {
lock.lock();
for (FeatureStructure uimaObject : uimaObjects) {
// create a new node for the current Annotation
GraphNode annotationNode = new GraphNode(new UriRef(new StringBuilder(ENTITY.Annotation.getUnicodeString()).
append(uimaObject.hashCode()).toString()), existingNode.getGraph());
log.info(new StringBuilder("Node created for Type ").append(uimaObject.getType().toString()).toString());
// set Annotation specific properties for the node
if (uimaObject instanceof Annotation) {
Annotation annotation = (Annotation) uimaObject;
String coveredText = annotation.getCoveredText();
annotationNode.addPropertyValue(ENTITY.coveredText, coveredText);
log.info(new StringBuilder("Node wraps Annotation with coveredText:").append(coveredText).toString());
}
//XXX : in OpenCalais the type is an URI so it maybe reasonable to put another node here
annotationNode.addPropertyValue(ENTITY.uimaType, uimaObject.getType().getName());
/* inspect features of the annotation */
Type type = uimaObject.getType();
for (Feature feature : type.getFeatures()) {
// create a new feature node
GraphNode featureNode = new GraphNode(new UriRef(new StringBuilder(ENTITY.Feature.getUnicodeString()).
append(feature.hashCode() / uimaObject.hashCode()).toString()), annotationNode.getGraph());
log.info(new StringBuilder("Node created for Feature ").append(feature.getName()).toString());
// set feature name and value if not null
featureNode.addPropertyValue(ENTITY.featureName, feature.getName());