I've been trying to parse a node property into a java object, it is a string type that holds my asset path (e.g /content/dam/test).
I'm using the JRC query below but it always returns the full node with all its properties.
SELECT asset.[jcr:content/data/master:image] FROM [dam:Asset] AS asset
WHERE ISDESCENDANTNODE(asset, [/content/dam])
AND asset.[jcr:content/data/cq:model] = '/conf/settings/dam/cfm/models/item'
AND asset.[jcr:content/data/master/name] IN ("A","B")
I was thinking of getting only the property's value, in this case the asset path: "/content/dam/test_cf"
Solved! Go to Solution.
Views
Replies
Total Likes
What tool do you use to execute this query? Most tools are designed to display the nodes, not only the requested properties (although the raw JCR API allows you to do that).
For example see the QueryResult.getRows() method at https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/java...
You can get String path = resource.getPath() when you iterate the query results of resources.
JCR-SQL2 queries can be invoked from the JCR API:
Session session = ...
QueryManager queryManager = session.getWorkspace.getQueryManager();
Query query = queryManager.createQuery("{QUERY}", Query.JCR_SQL2);
QueryResult result = query.execute();
or through the Sling API:
ResourceResolver resolver = ...
Iterator<Resource> result = resolver.findResources("{QUERY}", Query.JCR_SQL2);
@rute Over here you can get the result and parse the result to get the property value from the result set.
Query query = queryBuilder.createQuery(PredicateGroup.create(queryBuilderMap), session); SearchResult searchResult = query.getResult(); if (null != searchResult) { for (Hit hit : searchResult.getHits()) { Resource resource = hit.getResource(); String propertyVal = resource.getValueMap().get("property-name", StringUtils.EMPTY); } }
Hope this helps!
What tool do you use to execute this query? Most tools are designed to display the nodes, not only the requested properties (although the raw JCR API allows you to do that).
For example see the QueryResult.getRows() method at https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/java...
Views
Likes
Replies
Views
Likes
Replies