*
* @return the resource of the found collection
*/
public NonLiteral getCustomPropertyCollection(UriRef dependency,
String dependencyValue) {
LockableMGraph contentGraph = cgProvider.getContentGraph();
Lock lock = contentGraph.getLock().readLock();
lock.lock();
try {
Iterator<Triple> collections = contentGraph.filter(null, RDF.type,
CUSTOMPROPERTY.CustomFieldCollection);
while (collections.hasNext()) {
Iterator<Triple> collections2 = contentGraph
.filter(collections.next().getSubject(),
CUSTOMPROPERTY.dependency, dependency);
while (collections2.hasNext()) {
Iterator<Triple> collections3 = contentGraph.filter(
collections2.next().getSubject(),
CUSTOMPROPERTY.dependencyvalue, LiteralFactory
.getInstance().createTypedLiteral(
dependencyValue));
if (collections3.hasNext()) {
return collections3.next().getSubject();
}
}
}
} finally {
lock.unlock();
}
lock = contentGraph.getLock().writeLock();
lock.lock();
try {
Collection<Triple> tripleArray = new ArrayList<Triple>();
NonLiteral cfc = new BNode();
tripleArray.add(new TripleImpl(cfc, RDF.type,
CUSTOMPROPERTY.CustomFieldCollection));
tripleArray.add(new TripleImpl(cfc, CUSTOMPROPERTY.dependency,
dependency));
tripleArray.add(new TripleImpl(cfc, CUSTOMPROPERTY.dependencyvalue,
LiteralFactory.getInstance()
.createTypedLiteral(dependencyValue)));
contentGraph.addAll(tripleArray);
return getCustomPropertyCollection(dependency, dependencyValue);
} finally {
lock.unlock();
}
}