Derived functions questions

I started implementing a Derived Data class based on https://www.onehippo.org/library/concepts/content-repository/derived-data.html but have some more questions the documentation doesn’t cover:

  • the docs say it needs a zero-arg constructor. Can I still inject services into my class? Will that be done the same way as on the front-ent (site) code?

  • is there documentation for the other nodetypes to describe what they are and how to use them?

  • hipposys:relativepropertyreference is used in the example, and is relatively straightforward for properties on the document.

  • hipposys:resolvepropertyreference is this for properties on the handle node only?

  • hipposys:builtinpropertyreference is this similar to relative, but for built-in properties such as hippo:, hippostd:, hippostdpubwf:* ?

  • is there a way to access something based on the current author/editor?

I have been able to set a read-only field (only if it was blank) so far, but have several other properties we hope to set automatically.

Thanks for any advice.

You cannot inject services.

Not sure what yuo mean about other nodetypes.

hipposys:resolvepropertyreference should be able to access properties on other nodes, just remember that you have a relative path.

I’m not sure about builtinpropertyreference. It isn’t documented so I would avoid it. Most likely still there for historical reasons.

You cannot access something based on the current author.

The derived data engine was really designed to be used within the context of one document. You aren’t really supposed to step out of that context. If you require more complex logic I would look into workflow events.

Thanks for the clarifications!

How could I pass the node name as a parameter?

Thanks

You can’t. You have to already know it.

Unfortunately, there is not an easy way to configure something for node name or path.
If you add a dedicated daemon module [1] and your DDF invokes it somehow (by either service registration/access or simply static method access), then you can possibly configure “jcr:uuid” property and use it to retrieve the node in DDF implementation to know the detail of the node.

I personally think that it would be a simple, good improvement if DDF configuration allows pseudo properties like “jcr:name” and “jcr:path”. Please feel free to create a JIRA ticket in [2] if you think so too.

[1] https://www.onehippo.org/library/concepts/hippo-services/repository-managed-components.html
[2] https://issues.onehippo.com/projects/REPO

In the example on Derived Data, you show populating a field from the handle’s @hippo:name resolved property.

Is it possible to go the other direction? My test code didn’t appear to apply it the other way.

I have the same child nodes of name, title in both hipposys:accessed, hipposys:derived. I didn’t see any errors in the log, and it is configured well enough to setup the title property from the document name (just not the other way around).

Is the problem with updating a resolved property @relPath=../hippo:name) or is it 2 derived properties to update, or something else?

It is not possible to update any node other than the target node specified by the ‘hipposys:nodetype’. The handle, the parent node, is not the target node to apply updates by the DDF.