Hi

I'm trying to inject the ContentHub constraint fields into the content's metadata graph e.g. the "title" Solr field becomes a dc:title etc.

The code is as from the sample below. I get the metadata graph, acquire the lock, add the triple. If I check within that method whether it was added, i.e. with

ci.getMetadata().filter(null,DC.title,null)

I can find the triple. But as I leave the method and I check the content metadata again, I cannot find these changes. The metadata graph seems unaltered.

Given that the metadata graph seems to be a nonvolatile member of ContentItemImpl, I'm wondering why my changes are not being reflected. Does anyone have a clue?

Thanks

Alessandro

/*------- BEGIN code sample ---------*/

// All content items
SolrDocumentList docs = searchUtility.search("*:*").getResults();
for (SolrDocument doc : docs) {


    String id = (String) doc.getFieldValue(SolrFieldName.ID.toString());
    ContentItem ci = contentStore.get(id);
String title = (String) doc.getFieldValue(SolrFieldName.TITLE.toString());
    LockableMGraph mg = ci.getMetadata();

    // Acquire the lock and add the triple
    Lock writeLock = mg.getLock().writeLock();
    Triple t = new TripleImpl(ci.getUri(), DC.title,
ClerezzaBackendStatic.createLiteral(title, Locale.getDefault(), null));
    writeLock.lock();
    mg.add(t);
    writeLock.unlock();
}

/*------- END code sample ---------*/

--
M.Sc. Alessandro Adamou

Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy

Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy


"I will give you everything, so long as you do not demand anything."
(Ettore Petrolini, 1930)

Not sent from my iSnobTechDevice

Reply via email to