use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testSearchDataObjects_1_1.
public void testSearchDataObjects_1_1() throws Throwable {
List<String> dataObjectIds = this._dataObjectManager.searchId(null);
assertNotNull(dataObjectIds);
assertEquals(25, dataObjectIds.size());
EntitySearchFilter creationOrder = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
creationOrder.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Cont", true);
EntitySearchFilter[] filters1 = { creationOrder, descrFilter };
dataObjectIds = this._dataObjectManager.searchId(filters1);
assertNotNull(dataObjectIds);
String[] expected1 = { "RAH101", "ART102", "EVN103", "ART104", "ART111", "ART112", "ART120", "ART121", "ART122" };
assertEquals(expected1.length, dataObjectIds.size());
this.verifyOrder(dataObjectIds, expected1);
EntitySearchFilter lastEditorFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_LAST_EDITOR_FILTER_KEY, false, "admin", true);
EntitySearchFilter[] filters2 = { creationOrder, descrFilter, lastEditorFilter };
dataObjectIds = this._dataObjectManager.searchId(filters2);
assertNotNull(dataObjectIds);
assertEquals(expected1.length, dataObjectIds.size());
this.verifyOrder(dataObjectIds, expected1);
descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Cont", true, FieldSearchFilter.LikeOptionType.RIGHT);
EntitySearchFilter[] filters3 = { creationOrder, descrFilter };
dataObjectIds = this._dataObjectManager.searchId(filters3);
assertNotNull(dataObjectIds);
String[] expected3 = expected1;
assertEquals(expected3.length, dataObjectIds.size());
this.verifyOrder(dataObjectIds, expected3);
descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Cont", true, FieldSearchFilter.LikeOptionType.LEFT);
EntitySearchFilter[] filters4 = { creationOrder, descrFilter };
dataObjectIds = this._dataObjectManager.searchId(filters4);
assertNotNull(dataObjectIds);
assertTrue(dataObjectIds.isEmpty());
descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "1", true, FieldSearchFilter.LikeOptionType.LEFT);
EntitySearchFilter[] filters5 = { creationOrder, descrFilter };
dataObjectIds = this._dataObjectManager.searchId(filters5);
assertNotNull(dataObjectIds);
String[] expected5 = { "EVN191", "ART120" };
assertEquals(expected5.length, dataObjectIds.size());
this.verifyOrder(dataObjectIds, expected5);
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadWorkContentsByAttribute_2.
public void testLoadWorkContentsByAttribute_2() throws ApsSystemException {
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
EntitySearchFilter filter0 = new EntitySearchFilter(IContentManager.ENTITY_ID_FILTER_KEY, false);
filter0.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter filter1 = new EntitySearchFilter(IContentManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "EVN", true);
EntitySearchFilter filter2 = new EntitySearchFilter("Titolo", true);
filter2.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter[] filters = { filter0, filter1, filter2 };
String[] expectedContentsId = { "EVN103", "EVN191", "EVN192", "EVN193", "EVN194", "EVN20", "EVN21", "EVN23", "EVN24", "EVN25", "EVN41" };
List<String> contents = this._contentManager.loadWorkContentsId(filters, groups);
assertEquals(expectedContentsId.length, contents.size());
for (int i = 0; i < expectedContentsId.length; i++) {
assertEquals(expectedContentsId[i], contents.get(i));
}
filter2.setNullOption(true);
EntitySearchFilter[] filters2 = { filter0, filter1, filter2 };
contents = this._contentManager.loadWorkContentsId(filters2, groups);
assertEquals(0, contents.size());
filter2.setLangCode("it");
EntitySearchFilter[] filters3 = { filter0, filter1, filter2 };
contents = this._contentManager.loadWorkContentsId(filters3, groups);
assertEquals(0, contents.size());
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadOrderedPublicEvents_4.
public void testLoadOrderedPublicEvents_4() throws Throwable {
Content masterContent = this._contentManager.loadContent("EVN193", true);
masterContent.setId(null);
DateAttribute dateAttribute = (DateAttribute) masterContent.getAttribute("DataInizio");
dateAttribute.setDate(DateConverter.parseDate("17/06/2019", "dd/MM/yyyy"));
try {
this._contentManager.saveContent(masterContent);
this._contentManager.insertOnLineContent(masterContent);
this.waitNotifyingThread();
EntitySearchFilter filterForDate = new EntitySearchFilter("DataInizio", true);
filterForDate.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { filterForDate };
List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, null);
String[] expectedFreeOrderedContentsId = { "EVN194", masterContent.getId(), "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
assertEquals(expectedFreeOrderedContentsId.length, contents.size());
for (int i = 0; i < expectedFreeOrderedContentsId.length; i++) {
assertEquals(expectedFreeOrderedContentsId[i], contents.get(i));
}
} catch (Throwable t) {
throw t;
} finally {
if (null != masterContent.getId() && !"EVN193".equals(masterContent.getId())) {
this._contentManager.removeOnLineContent(masterContent);
this._contentManager.deleteContent(masterContent);
}
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadWorkContentsForCategory_2.
public void testLoadWorkContentsForCategory_2() throws ApsSystemException {
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
String[] categories1 = { "general_cat1" };
EntitySearchFilter filter1 = new EntitySearchFilter(IContentManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
EntitySearchFilter[] filters = { filter1 };
List<String> contents = this._contentManager.loadWorkContentsId(categories1, filters, groups);
assertEquals(4, contents.size());
assertTrue(contents.contains("ART102"));
assertTrue(contents.contains("ART111"));
assertTrue(contents.contains("ART180"));
assertTrue(contents.contains("ART179"));
String[] categories2 = { "general_cat2" };
contents = this._contentManager.loadWorkContentsId(categories2, filters, groups);
assertEquals(4, contents.size());
assertTrue(contents.contains("ART111"));
assertTrue(contents.contains("ART112"));
assertTrue(contents.contains("ART120"));
assertTrue(contents.contains("ART179"));
String[] categories12 = { "general_cat1", "general_cat2" };
contents = this._contentManager.loadWorkContentsId(categories12, false, filters, groups);
assertEquals(2, contents.size());
assertTrue(contents.contains("ART111"));
assertTrue(contents.contains("ART179"));
contents = this._contentManager.loadWorkContentsId(categories12, true, filters, groups);
assertEquals(6, contents.size());
assertTrue(contents.contains("ART102"));
assertTrue(contents.contains("ART111"));
assertTrue(contents.contains("ART112"));
assertTrue(contents.contains("ART120"));
assertTrue(contents.contains("ART180"));
assertTrue(contents.contains("ART179"));
String[] categories3 = { "general_cat3" };
contents = this._contentManager.loadWorkContentsId(categories3, filters, groups);
assertEquals(3, contents.size());
assertTrue(contents.contains("ART120"));
assertTrue(contents.contains("ART121"));
assertTrue(contents.contains("ART122"));
String[] categories23 = { "general_cat2", "general_cat3" };
contents = this._contentManager.loadWorkContentsId(categories23, false, filters, groups);
assertEquals(1, contents.size());
assertTrue(contents.contains("ART120"));
contents = this._contentManager.loadWorkContentsId(categories23, true, filters, groups);
assertEquals(6, contents.size());
assertTrue(contents.contains("ART111"));
assertTrue(contents.contains("ART112"));
assertTrue(contents.contains("ART120"));
assertTrue(contents.contains("ART179"));
assertTrue(contents.contains("ART121"));
assertTrue(contents.contains("ART122"));
String[] categories123 = { "general_cat1", "general_cat2", "general_cat3" };
contents = this._contentManager.loadWorkContentsId(categories123, false, filters, groups);
assertEquals(0, contents.size());
contents = this._contentManager.loadWorkContentsId(categories123, true, filters, groups);
assertEquals(8, contents.size());
assertTrue(contents.contains("ART102"));
assertTrue(contents.contains("ART111"));
assertTrue(contents.contains("ART112"));
assertTrue(contents.contains("ART120"));
assertTrue(contents.contains("ART121"));
assertTrue(contents.contains("ART122"));
assertTrue(contents.contains("ART180"));
assertTrue(contents.contains("ART179"));
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadPublicEvents_8.
protected void testLoadPublicEvents_8(boolean useRoleFilter) throws ApsSystemException {
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
List<String> allowedDescription = new ArrayList<String>();
// EVN24
allowedDescription.add("Castello");
// EVN24
allowedDescription.add("dei bambini");
EntitySearchFilter filter = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(JacmsSystemConstants.ATTRIBUTE_ROLE_TITLE, allowedDescription, true) : new EntitySearchFilter("Titolo", true, allowedDescription, true);
filter.setLangCode("it");
filter.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { filter };
List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, groups);
String[] expectedOrderedContentsId2 = { "EVN24" };
assertEquals(expectedOrderedContentsId2.length, contents.size());
for (int i = 0; i < expectedOrderedContentsId2.length; i++) {
assertEquals(expectedOrderedContentsId2[i], contents.get(i));
}
}
Aggregations