use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_6.
public void testSearchContentsId_6() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general = this._categoryManager.getCategory("general");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.ADMINS_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
this.verify(contentsId, expected1);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class TestSearchEngineManager method testSearchFacetedContents_1.
public void testSearchFacetedContents_1() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general = this._categoryManager.getCategory("general");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
allowedGroup.add(Group.ADMINS_GROUP_NAME);
FacetedContentsResult result = sem.searchFacetedEntities(null, categories, allowedGroup);
assertNotNull(result);
String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
this.verify(result.getContentsId(), expected1);
assertEquals(4, result.getOccurrences().size());
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class SearcherDAO method createQuery.
protected Query createQuery(SearchEngineFilter[] filters, Collection<ITreeNode> categories, Collection<String> allowedGroups) {
BooleanQuery mainQuery = new BooleanQuery();
if (filters != null && filters.length > 0) {
for (int i = 0; i < filters.length; i++) {
SearchEngineFilter filter = filters[i];
Query fieldQuery = this.createQuery(filter);
mainQuery.add(fieldQuery, BooleanClause.Occur.MUST);
}
}
if (allowedGroups == null) {
allowedGroups = new HashSet<String>();
}
if (!allowedGroups.contains(Group.ADMINS_GROUP_NAME)) {
if (!allowedGroups.contains(Group.FREE_GROUP_NAME)) {
allowedGroups.add(Group.FREE_GROUP_NAME);
}
BooleanQuery groupsQuery = new BooleanQuery();
Iterator<String> iterGroups = allowedGroups.iterator();
while (iterGroups.hasNext()) {
String group = iterGroups.next();
TermQuery groupQuery = new TermQuery(new Term(IIndexerDAO.DATAOBJECT_GROUP_FIELD_NAME, group));
groupsQuery.add(groupQuery, BooleanClause.Occur.SHOULD);
}
mainQuery.add(groupsQuery, BooleanClause.Occur.MUST);
}
if (null != categories && !categories.isEmpty()) {
BooleanQuery categoriesQuery = new BooleanQuery();
Iterator<ITreeNode> cateIter = categories.iterator();
while (cateIter.hasNext()) {
ITreeNode category = cateIter.next();
String path = category.getPath(IIndexerDAO.DATAOBJECT_CATEGORY_SEPARATOR, false);
TermQuery categoryQuery = new TermQuery(new Term(IIndexerDAO.DATAOBJECT_CATEGORY_FIELD_NAME, path));
categoriesQuery.add(categoryQuery, BooleanClause.Occur.MUST);
}
mainQuery.add(categoriesQuery, BooleanClause.Occur.MUST);
}
return mainQuery;
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_5.
public void testSearchContentsId_5() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general_cat2 = this._categoryManager.getCategory("general_cat2");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general_cat2);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
assertTrue(contentsId.isEmpty());
allowedGroup.add(Group.ADMINS_GROUP_NAME);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
String[] expected1 = { "ART111", "ART120" };
this.verify(contentsId, expected1);
Category general_cat1 = this._categoryManager.getCategory("general_cat1");
categories.add(general_cat1);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected2 = { "ART111" };
this.verify(contentsId, expected2);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_5.
public void testSearchContentsId_5() throws Throwable {
try {
Thread thread = this._searchEngineManager.startReloadContentsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this._searchEngineManager;
Category general_cat2 = this._categoryManager.getCategory("general_cat2");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general_cat2);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
assertTrue(contentsId.isEmpty());
allowedGroup.add(Group.ADMINS_GROUP_NAME);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
String[] expected1 = { "ART111", "ART120" };
this.verify(contentsId, expected1);
Category general_cat1 = this._categoryManager.getCategory("general_cat1");
categories.add(general_cat1);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected2 = { "ART111" };
this.verify(contentsId, expected2);
} catch (Throwable t) {
throw t;
}
}
Aggregations