AEM querybuider predicate for string array - metadata

Is there a way to search for the assets where a metadata property is of type String[] instead of String ?
I tried below, but I am sure this is not correct:
path=/path/to/my/folder
p.limit=-1
1_property=jcr:content/metadata/myMetadata
1_property.type=array

Related

Fluid Query Result object to JSON

I have a result object in my view and want do put this in JSON format.
The Object looks like
TYPO3\CMS\Extbase\Persistence\Generic\QueryResultprototypeobject (32 items)
0 => KN\Operations\Domain\Model\Operationprototypepersistent entity (uid=853,
pid=90)
1 => KN\Operations\Domain\Model\Operationprototypepersistent entity (uid=852,
pid=90)
....
I tried to use format
{myObject-> f:format.json()}
but this doesn't work. Result is
{}
I want to give that informations to my JS. For me it is not possible to change the Controller because I don't want to change an existing extension.
the format.json viewhelper expects an array as the value. To get the right result you need to convert your result into an array.
If you set the first param of the execute function in your repository to true you will get an array instead of an Queryresult Object.
return $query->execute(true);
You can find additional information on the documentation page of the viewhelper: https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Format/Json.html
Happy Coding!

Get the string inside objectId

I have mongoId like this :
ObjectId("53056c1e211b6f2e5d8b4567")
I only want
"53056c1e211b6f2e5d8b4567"
I tried toString but it returns the whole thing as string. I know I can extract using string operations, but is there a native way to do so ?
You can do it:
ObjectId("53056c1e211b6f2e5d8b4567").valueOf()
it have to return the following string:
53056c1e211b6f2e5d8b4567
For more details, see docs

How do I add a 'where not' to a QueryBuilder Query

I want to search the entire content tree but not specific tress that have a 'Do Not Search' property at their base.
The Query Builder API page does not reference anything besides AND and OR.
Is it possible to exclude paths from the search or can I only explicitly include paths?
The first three lines are "/content AND /content/path/es". I want "/content AND NOT(/content/path/es)"
map.put("group.1_path", "/content");
map.put("group.2_path", "/content/path/es");
map.put("group.p.or","false");
I have tried the next two both true and false and they have no effect.
map.put("group.2_path.p.not", "true");
map.put("group.2_path.not", "true");
map.put("group.2_path", "not('/content/path/es')");
I can't find any documentation that mentions any other name that 'not' or '!' might be used instead.
Yes it is possible. But not exactly in the way you are trying.
You can exclude the pages with certain properties using the property predicate evaluator.
For ex. If you want to exclude pages which have the property "donotsearch" in its jcr:content node, then you can query it using property operation as exists
map.put("path", "/content/geometrixx/en/toolbar");
map.put("type", "cq:Page");
/* Relative path to the property to check for */
map.put("property", "jcr:content/donotsearch");
/* Operation to perform on the value of the prop, in this case existence check */
map.put("property.operation", "exists");
/* Value for the prop, false = not, by default it is true */
map.put("property.value", "false");
This would result in the following XPath Query
/jcr:root/content/geometrixx/en/toolbar//element(*, cq:Page)
[
not(jcr:content/#donotsearch)
]
But in case you would like to exclude pages with certain value for the property donotsearch, then you can change the above query as shown below
map.put("property", "jcr:content/donotsearch"); //the property to check for
map.put("property.operation", "equals"); // or unequals or like etc..
map.put("property.value", "/*the value of the property*/");
You can find a lot other info regarding querying by referring to the docs.
I'm not sure what version of CQ you're using (you linked to the 5.4 docs), but in 5.5 and above, the PredicateGroup class has a setNegated method to exclude results that would match the group defined.
You can't set negation on an individual Predicate, but there would be nothing to stop you creating a group with just the predicate that you wish to negate:
Predicate pathPredicate = new Predicate("path").set("path", "/content/path/es");
PredicateGroup doNotSearchGroup = new PredicateGroup();
doNotSearchGroup.setNegated(true);
doNotSearchGroup.add(pathPredicate);
Query query = queryBuilder.createQuery(doNotSearchGroup);
EDIT: Just to update in relation to your comment, you should be able to add a PredicateGroup to another PredicateGroup (as PredicateGroup is a subclass of Predicate). So once you have your negated group, combine it with the path search:
Predicate pathPredicate = new Predicate("path");
pathPredicate.set("path", "/content");
PredicateGroup combinedPredicate = new PredicateGroup();
combinedPredicate.add(pathPredicate);
combinedPredicate.add(doNotSearchGroup);
Query query - queryBuilder.createQuery(combinedPredicate);
It is pretty straightforward implementation.
Use
map.put("group.p.not",true)
map.put("group.1_path","/path1/where/you/donot/want/to/search")
map.put("group.2_path","/path2/where/you/donot/want/to/search")
I've run into the same problem and while I couldn't fully solve it I was able to come up with a workaround using groups and the unequals operator. Something like:
path=/var/xxx
1_property=jcr:primaryType
1_property.value=rep:ACL
1_property.operation=unequals
2_property=jcr:primaryType
2_property.value=rep:GrantACE
2_property.operation=unequals
Btw, map.put("group.p.not",true) did not work for me.
This link has a lot of useful information: https://hashimkhan.in/2015/12/02/query-builder/

How to use Cookies to store a List of String Array in GWT?

Based on the GWT ShowCase example (http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCookies) we can only store a Pair of String name - String value to Cookies.
What if we want to store a Triad such as (String ItemName, String ItemID, String CompanyID)? or even Foursome, FiveSome, SixSome.... of Info?
We can't set String Array for value in GWT Cookies
Cookies.setCookie(name, value, expires);
So How to use Gwt Cookies in that case?
A cookie is a key/value pair of strings, kinda like you'd do in a Java properties file. You can make some method that serializes/deserializes an array into a string and vice versa.
You can use the method described here to easily convert between Strings and arrays:
string to string array conversion in java
And you can use Arrays.toString(array); to parse an array to a String. Concatenating elements in an array to a string

RequestFactoryEditorDriver#getPaths() usage?

HI: Below code is from RequestFactoryEditorDriver:
/**
* Returns a new array containing the request paths.
*
* #return an array of Strings
*/
String[] getPaths();
My question is,
When and in what place to use this method, there is no place to set paths to the RequestFactoryEditorDriver, is the paths generated when creating the driver? if so, what's the rule of "generating paths"?
I think the client should provide the paths themselves, such as:
factory.find( proxyId ).with( myPaths).fire(...)
other than from RequestFactoryEditorDriver#getPaths(), if the paths get from 1 is not specified.
The paths are computed from the editor hierarchy. The list basically includes all the properties being edited that are not simple values (primitives, strings, dates, etc.)
If you have the following:
TextBox name;
DateBox dateOfBirth;
#Path("manager.name")
Label managerName;
AddressEditor address;
getPaths would return "manager", "address".
The idea is that you can pass the value directly to with() and you'll retrieve all the objects needed by the editor. If you add or remove a subeditor down the hierarchy, you don't have to change your request code, the getPaths value will be different and contain what's needed by the editor.