Hi Alessandro,
Current version of Contenthub stores the enhancements of content items
in a single graph. When you retrieve enhancements of a certain content
item, they come within a temporary SimpleMGraph by filtering the main
graph. That is why your changes are not reflected permanently and it is
not possible to update enhancements of a content item through content
item itself. The workaround may be to update the actual enhancement
graph. The URI of the enhancement graph used by Contenthub is
"org.apache.stanbol.enhancer.standalone.store.enhancements" and its
defined in the "Constants" class of Contenthub servicesapi.
Best,
Suat
On 03/21/2012 06:39 PM, Alessandro Adamou wrote:
> 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 ---------*/
>