Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-16025

Provide access to jcr:path in DerivedDataFunction's

    XMLWordPrintable

Details

    • Improvement
    • Status: Review
    • High
    • Resolution: Unresolved
    • 15.7.0, 16.1.0
    • 15.7.1, 16.2.0
    • cms
    • 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

       

      Attachments

        Activity

          People

            jhoffman Jeroen Hoffman
            dsinclair David Sinclair
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: