Details
-
Improvement
-
Status: Review
-
High
-
Resolution: Unresolved
-
15.7.0, 16.1.0
-
Flagged
-
Orion
-
Orion.Cycle8.Sprint
-
Undetermined
-
Small (1-2)
Description
It would be useful to have access to the jcr:path attribute within DerivedDataFunction.
Our use case for this is that we have a 'Publication' format which we arrange in the structure shown in the attached screenshot. We arrange them in a type, year, month structure due to the large volume of publications. We want to be able to efficiently filter by the publication type, and so we want to store it on the publication when it is created.
We would like to configure a DerivedDataFunction to access the jcr:path from which we can derive the type. This is similar to the 'ancestors' property provided by the class BuiltinPropertyReference, and used to populate hippo:paths.
I suggest this could be implemented by changing BuiltinPropertyReference to something like:
@Override Value[] getPropertyValues(Node modified, Collection<String> dependencies) throws RepositoryException { switch (getMethod()) { case "ancestors": final Collection<Value> ancestors = new ArrayList<Value>(); Node ancestor = modified; while (ancestor != null) { ancestors.add(getValueFactory().createValue(ancestor.getIdentifier())); try { ancestor = ancestor.getParent(); } catch (ItemNotFoundException ex) { ancestor = null; // valid exception outcome, no parent because we are at root } } return ancestors.toArray(new Value[ancestors.size()]); case "path": return new Value[] { new StringValue(modified.getPath()) }; default: DerivedDataEngine.log.warn("Derived data definition contains unrecognized builtin reference, skipped"); return null; } }
This would also require a change to hippostd.cnd to allow 'path' to be added to 'hipposys:builtinpropertyreference'.
[hipposys:builtinpropertyreference] > hipposys:propertyreference - hipposys:method (string) mandatory < 'ancestors', 'path'
Something along these lines was suggested by Woonsan Ko in this thread:
https://community.bloomreach.com/t/derived-functions-questions/188/5