use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadEvents_4.
protected void testLoadEvents_4(boolean useRoleFilter) throws ApsSystemException {
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
EntitySearchFilter filter1 = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(SystemConstants.DATA_TYPE_ATTRIBUTE_ROLE_TITLE, "Ce", "TF") : new EntitySearchFilter("Titolo", true, "Ce", "TF");
filter1.setLangCode("it");
filter1.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters1 = { filter1 };
List<String> dataObjects = this._dataObjectManager.loadDataObjectsId("EVN", null, filters1, groups);
String[] expectedOrderedDataObjectsId = { "EVN25", "EVN41", "EVN20", "EVN21", "EVN23" };
assertEquals(expectedOrderedDataObjectsId.length, dataObjects.size());
for (int i = 0; i < expectedOrderedDataObjectsId.length; i++) {
assertEquals(expectedOrderedDataObjectsId[i], dataObjects.get(i));
}
filter1 = new EntitySearchFilter("Titolo", true, null, "TF");
filter1.setLangCode("it");
filter1.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters2 = { filter1 };
dataObjects = this._dataObjectManager.loadDataObjectsId("EVN", null, filters2, groups);
String[] expectedOrderedDataObjectsId2 = { "EVN25", "EVN41", "EVN20", "EVN21", "EVN23", "EVN24" };
assertEquals(expectedOrderedDataObjectsId2.length, dataObjects.size());
for (int i = 0; i < expectedOrderedDataObjectsId2.length; i++) {
assertEquals(expectedOrderedDataObjectsId2[i], dataObjects.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadEvents_2_2.
public void testLoadEvents_2_2() throws ApsSystemException {
// forcing case sensitive search
DataObjectSearcherDAO searcherDao = (DataObjectSearcherDAO) this.getApplicationContext().getBean("DataObjectSearcherDAO");
List<String> groups = new ArrayList<String>();
groups.add("coach");
groups.add(Group.ADMINS_GROUP_NAME);
Date start = DateConverter.parseDate("1997-06-10", "yyyy-MM-dd");
Date end = DateConverter.parseDate("2020-09-19", "yyyy-MM-dd");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, start, end);
EntitySearchFilter filter_x1 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "even", true);
filter_x1.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters_1 = { filter, filter_x1 };
List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters_1, groups);
assertEquals(2, dataObjects.size());
EntitySearchFilter filter_x2 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Even", true);
filter_x2.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters_2 = { filter, filter_x2 };
dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters_2, groups);
assertEquals(2, dataObjects.size());
assertEquals("EVN193", dataObjects.get(0));
assertEquals("EVN192", dataObjects.get(1));
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadPastEvents_3.
public void testLoadPastEvents_3() throws ApsSystemException {
Date today = DateConverter.parseDate("2008-02-13", "yyyy-MM-dd");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, null, today);
filter.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter[] filters = { filter };
List<String> groups = new ArrayList<String>();
groups.add("coach");
List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
String[] expectedOrderedDataObjectsId = { "EVN191", "EVN192", "EVN103", "EVN21", "EVN20", "EVN25", "EVN41", "EVN23" };
assertEquals(expectedOrderedDataObjectsId.length, dataObjects.size());
for (int i = 0; i < expectedOrderedDataObjectsId.length; i++) {
assertEquals(expectedOrderedDataObjectsId[i], dataObjects.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadFutureEvents_2.
public void testLoadFutureEvents_2() throws ApsSystemException {
Date today = DateConverter.parseDate("2005-01-01", "yyyy-MM-dd");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, today, null);
filter.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { filter };
List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, null);
String[] expectedOrderedDataObjectsId = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21" };
assertEquals(expectedOrderedDataObjectsId.length, dataObjects.size());
for (int i = 0; i < expectedOrderedDataObjectsId.length; i++) {
assertEquals(expectedOrderedDataObjectsId[i], dataObjects.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadOrderedEvents_4.
public void testLoadOrderedEvents_4() throws Throwable {
DataObject masterDataObject = this._dataObjectManager.loadDataObject("EVN193", true);
masterDataObject.setId(null);
DateAttribute dateAttribute = (DateAttribute) masterDataObject.getAttribute("DataInizio");
dateAttribute.setDate(DateConverter.parseDate("17/06/2019", "dd/MM/yyyy"));
try {
this._dataObjectManager.saveDataObject(masterDataObject);
this._dataObjectManager.insertDataObject(masterDataObject);
this.waitNotifyingThread();
EntitySearchFilter filterForDate = new EntitySearchFilter("DataInizio", true);
filterForDate.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { filterForDate };
List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, null);
String[] expectedFreeOrderedDataObjectsId = { "EVN194", masterDataObject.getId(), "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
assertEquals(expectedFreeOrderedDataObjectsId.length, dataObjects.size());
for (int i = 0; i < expectedFreeOrderedDataObjectsId.length; i++) {
assertEquals(expectedFreeOrderedDataObjectsId[i], dataObjects.get(i));
}
} catch (Throwable t) {
throw t;
} finally {
if (null != masterDataObject.getId() && !"EVN193".equals(masterDataObject.getId())) {
this._dataObjectManager.removeDataObject(masterDataObject);
this._dataObjectManager.deleteDataObject(masterDataObject);
}
}
}
Aggregations