exteneding FolderWorkflowPlugin? please say there's a better way

45 views
Skip to first unread message

schi...@gmail.com

unread,
Oct 23, 2014, 4:54:14 PM10/23/14
to hippo-c...@googlegroups.com
 Hi Everybody!

So i've been trying to figure out how to enable prepopulating new document filds with the translated node name - aka the exact string the user types into a new document dialogue - i want the clean title to carry over into doc defaults, but all that seems to be available is the urk escaped node name denoted by $node

I traced through hippo code, and it appear that FolderWorkflowPlugin holds the value i'm after:
String localName = getLocalizeCodec().encode(addDocumentModel.getTargetName());

but it does not add it to the arguments map  (why not?) to pass to the add() method of folder workflow, and only creates the tran;ation node after add return. So, implementing a custom folder workflow is not enough, i have to create my own version of FolderWorkflowPlugin just to add localName to the arguments map?

Or is there a better way?

Thank you in advance for your help!

Svetlana

Niels van Kampenhout

unread,
Oct 27, 2014, 1:51:05 PM10/27/14
to hippo-c...@googlegroups.com
Hi Svetlana,

I had a quick look and I think your observation is correct. The
current workflow implementation is unfortunately not easily
customizable.

However you might want to take a look at Derived Data Functions [1]. A
DDF could copy the pretty document name to the title property. You
could make it so that it only does that if the title property is
empty, so it doesn't overwrite any value entered by a user later on.

Hope this helps,
Niels

[1] http://www.onehippo.org/library/concepts/content-repository/derived-data.html

schi...@gmail.com

unread,
Oct 28, 2014, 10:46:52 AM10/28/14
to hippo-c...@googlegroups.com
Hi Niels, thank you for getting back to me.

Unfortunately, the derivered data option will not work for this case, as the desired bekhaviour is to pre-populate fields of an editable instance of a new doc, with default values...

So in terms of overwritting the FolderWorkflowPlugin - where do i need to change the config to point to my custom class?
 here: /hippo:configuration/hippo:workflows/threepane/folder-extended/frontend:renderer/standard ?

other place too?


Thank you !

Niels van Kampenhout

unread,
Oct 28, 2014, 5:28:19 PM10/28/14
to hippo-c...@googlegroups.com
On Tue, Oct 28, 2014 at 7:46 AM, <schi...@gmail.com> wrote:
> Hi Niels, thank you for getting back to me.
>
> Unfortunately, the derivered data option will not work for this case, as the
> desired bekhaviour is to pre-populate fields of an editable instance of a
> new doc, with default values...

If you configure the properties you want to pre-populate as input as
well as output for the derived data function, you can check those
properties' values and only change them if they are empty. Effectively
this will then only happen when the document is created.

If you want to be 100% sure the derived data function could set a
boolean property on the document to true the first time it runs (after
populating the other properties).

>
> So in terms of overwritting the FolderWorkflowPlugin - where do i need to
> change the config to point to my custom class?
> here:
> /hippo:configuration/hippo:workflows/threepane/folder-extended/frontend:renderer/standard
> ?

I don't know from the top of my head but definitely somewhere under
/hippo:configuration/hippo:workflows. Note there could be multiple
places where the same workflow class is configured. Easiest way to
find them is to run a query in the repository servlet
(http://localhost:8080/cms/repository).

But I think the derived data function option is much easier and has
better maintainability.

Hope this helps.

Niels
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hippo-communi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

Svetlana Chirkova

unread,
Oct 29, 2014, 1:07:31 PM10/29/14
to hippo-c...@googlegroups.com
thanks Niels,
im my case they are after the 'translated' node name - as in the text they typed into the document creation. Think this can only be accessed via the translation on the handle node.
The derived data functions can only access fields below the doc node - this means the actual version node, not the handle, right? - so there's no way for me to access the text/message of the tranlastion....

and also, in the workflog pluging code- the translation node is created after add returns - so that value may not be around at all at the time of the derived data function being triggered?

Thanks!

You received this message because you are subscribed to a topic in the Google Groups "Hippo Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hippo-community/trEhYZLjBHE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hippo-communi...@googlegroups.com.

Niels van Kampenhout

unread,
Oct 29, 2014, 4:39:58 PM10/29/14
to hippo-c...@googlegroups.com
Hi Svetlana,

Well I'd feel bad if I sent you down the wrong path, so I did a quick
test and got it working. It is possible to derive data from a node
that is not below the document node, by using
"hipposys:resolvepropertyreference" instead of
"hipposys:relativepropertyreference". I don't think this is
documented, but you can see an example in the default
"reviewed-actions" DDF at
/hippo:configuration/hippo:derivatives/reviewed-action.

I included my Java class and console configuration below, you will
probably want to refine the code a bit but the basic stuff works.

Hope this helps,
Niels


public class Title extends DerivedDataFunction {

@Override
public Map<String, Value[]> compute(Map<String, Value[]> parameters) {
try {
if (parameters.get("message") != null &&
parameters.get("message")[0] != null) {
String message = parameters.get("message")[0].getString();
String title = parameters.get("title")[0].getString();
if (StringUtils.isEmpty(title)) {
parameters.put("title", new Value[] {
getValueFactory().createValue(message) });
}
}
} catch (RepositoryException e) {
e.printStackTrace();
}
return parameters;
}

}


<?xml version="1.0" encoding="UTF-8"?>
<sv:node sv:name="title" xmlns:sv="http://www.jcp.org/jcr/sv/1.0">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:deriveddefinition</sv:value>
</sv:property>
<sv:property sv:name="hipposys:classname" sv:type="String">
<sv:value>org.gogreen.deriveddata.Title</sv:value>
</sv:property>
<sv:property sv:name="hipposys:nodetype" sv:type="String">
<sv:value>gogreen:contentdocument</sv:value>
</sv:property>
<sv:property sv:name="hipposys:serialver" sv:type="Long">
<sv:value>1</sv:value>
</sv:property>
<sv:node sv:name="hipposys:accessed">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:propertyreferences</sv:value>
</sv:property>
<sv:node sv:name="message">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:resolvepropertyreference</sv:value>
</sv:property>
<sv:property sv:name="hipposys:relPath" sv:type="String">
<sv:value>../hippo:translation/hippo:message</sv:value>
</sv:property>
</sv:node>
<sv:node sv:name="title">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:relativepropertyreference</sv:value>
</sv:property>
<sv:property sv:name="hipposys:relPath" sv:type="String">
<sv:value>gogreen:title</sv:value>
</sv:property>
</sv:node>
</sv:node>
<sv:node sv:name="hipposys:derived">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:propertyreferences</sv:value>
</sv:property>
<sv:node sv:name="title">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:relativepropertyreference</sv:value>
</sv:property>
<sv:property sv:name="hipposys:relPath" sv:type="String">
<sv:value>gogreen:title</sv:value>
</sv:property>
</sv:node>
</sv:node>
</sv:node>

Svetlana Chirkova

unread,
Oct 29, 2014, 5:20:44 PM10/29/14
to hippo-c...@googlegroups.com
Niels! You're a hippo wizard!

Thank you so much! - it works
Reply all
Reply to author
Forward
0 new messages