I have a problem with Dynamic Query in Liferay 6. I'm trying to make a query to get images (from the Liferay Documents and Media repository) that have a title determined, are in a folder specific, and that are in a particular category.
For the query to get the images that have a title and are in a folder specific, I have this:
...
DynamicQuery dynamicQueryFile = DynamicQueryFactoryUtil.forClass(DLFileEntry.class);
dynamicQueryFile.add(RestrictionsFactoryUtil.eq("groupId", groupId) );
dynamicQueryFile.add(RestrictionsFactoryUtil.ilike("title", "%"+titlefilter+"%") );
dynamicQueryFile.add(RestrictionsFactoryUtil.in("folderId", toArray(folders)));
List resultsFiles = new ArrayList();
resultsFiles.addAll(DLFileEntryLocalServiceUtil.dynamicQuery(dynamicQueryFile));
This works!.
For the query to get the images that are in a particular category, I have this:
...
AssetEntryQuery queryCategoriesFilter = new AssetEntryQuery();
long[] groupIds = {groupId};
queryCategoriesFilter.setGroupIds(groupIds);
ClassName nameClass = ClassNameLocalServiceUtil.getClassName(DLFileEntry.class.getName());
long classNameIdDLFileEntry = nameClass.getClassNameId();
long[] types = {classNameIdDLFileEntry};
queryCategoriesFilter.setClassNameIds(types);
queryCategoriesFilter.setAllCategoryIds(StringtoLongArray(categoryIds));
List<AssetEntry> results = AssetEntryLocalServiceUtil.getEntries(queryCategoriesFilter);
This works!.
And now, I need to combine the results of two queries, but as one of the results is with DynamicQuery and the other is with AssetEntryQuery, them I don't know how to do this.
It is possible to make two queries only with DynamicQuery? => How do I add the restrictions of the categories?
It is possible to make two queries only with AssetEntryQuery? => How do I add the restrictions of the title and folder?