FilterImpl how to check empty multivalue property

24 views
Skip to first unread message

Erik Alphenaar

unread,
Oct 15, 2014, 10:55:15 AM10/15/14
to <hippo-community@googlegroups.com>
Hi all, again .. :)

While I'm on the subject of filtering:
org.hippoecm.hst.content.beans.query.filter.FilterImpl
How can I check if a multivalue string property is empty?? So the property does exist in the node, but has no values.

I've been trying stuff like:
filter.addEqualTo(propName, "");
or
filter.addEqualTo(propName, new String[]{});

but no luck.. 

I can't seem to find anyhing in the docs, but maybe I missed it.
Will I have to extend the FilterImpl to add such a check on my own ??


Thanks in advance, Rgds,
Erik Alphenaar

Ard Schrijvers

unread,
Oct 15, 2014, 11:40:29 AM10/15/14
to hippo-c...@googlegroups.com
Hey Erik,

org.hippoecm.hst.content.beans.query.filter.Filter#addNotNull(String
fieldAttributeName) should work afaik

Regards Ard
> --
> 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 - 1 Broadway, Cambridge, MA 02142

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

Erik Alphenaar

unread,
Oct 16, 2014, 3:54:37 AM10/16/14
to <hippo-community@googlegroups.com>
Hi Ard,

Thanks for your reply.

addNotNull checks if the property exists. My property exists, but is empty (and multivalue).


Rgds,
Erik

Ard Schrijvers

unread,
Oct 20, 2014, 5:40:07 AM10/20/14
to hippo-c...@googlegroups.com
Hey Erik,

I tested a query in the repository servlet to query for an empty multi
valued property. This works as expected. For example

//*[@hippo:availability='']

I did not test it via the HST query. Can you post the toString version
of your HstQuery?

Regards Ard

On Thu, Oct 16, 2014 at 9:54 AM, Erik Alphenaar

Erik Alphenaar

unread,
Oct 20, 2014, 6:35:02 AM10/20/14
to <hippo-community@googlegroups.com>
Hi Ard,

Are you sure you have an empty multivalue? Or a multivalue with an empty entry.

Ard Schrijvers

unread,
Oct 20, 2014, 6:53:55 AM10/20/14
to hippo-c...@googlegroups.com
Hey Erik,

apologies, I misread your email wrt 'I check if a multivalue string
property is empty'

You need to check whether a multivalues property is present without
values, what you write after the part above :)

I think you can achieve what you need a bit dirty:

//*[@project:yourmultipvaluedprop and
not(jcr:contains(@project:yourmultipvaluedprop,'*')) and
@project:yourmultipvaluedprop != '']

This results in all nodes that have project:yourmultipvaluedprop
property but no values.

You should be able to construct this with HST Filter afaik. Let me
know. Hope this helps.

Regards Ard

On Mon, Oct 20, 2014 at 12:34 PM, Erik Alphenaar

Erik Alphenaar

unread,
Oct 20, 2014, 8:40:30 AM10/20/14
to <hippo-community@googlegroups.com>
Hi Ard,

Cool, that query works! Now to get it in the HST Query :) Thanks!

Ard Schrijvers

unread,
Oct 20, 2014, 8:47:06 AM10/20/14
to hippo-c...@googlegroups.com
On Mon, Oct 20, 2014 at 2:40 PM, Erik Alphenaar
<erik.al...@trifork.nl> wrote:
> Hi Ard,
>
> Cool, that query works! Now to get it in the HST Query :) Thanks!

I think that should work with addEqual and addNotNull constraints

Erik Alphenaar

unread,
Oct 20, 2014, 11:05:41 AM10/20/14
to <hippo-community@googlegroups.com>
Hi Ard,

FYI: I added a jcr expression to the query :)

Thanks for your help!


Rgds,
Erik
Reply all
Reply to author
Forward
0 new messages