use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadPublicEventsForCategory_1.
public void testLoadPublicEventsForCategory_1() throws ApsSystemException {
String[] categories = { "evento" };
List<String> contents = _contentManager.loadPublicContentsId("EVN", categories, null, null);
assertEquals(2, contents.size());
assertTrue(contents.contains("EVN192"));
assertTrue(contents.contains("EVN193"));
Date today = DateConverter.parseDate("2005-02-13", "yyyy-MM-dd");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, null, today);
filter.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter[] filters = { filter };
contents = _contentManager.loadPublicContentsId("EVN", categories, filters, null);
assertEquals(1, contents.size());
assertTrue(contents.contains("EVN192"));
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadPublicEvents_3.
public void testLoadPublicEvents_3() throws ApsSystemException {
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
Date value = DateConverter.parseDate("1999-04-14", "yyyy-MM-dd");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, value, false);
EntitySearchFilter[] filters = { filter };
List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, groups);
assertEquals(1, contents.size());
assertEquals("EVN192", contents.get(0));
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadFutureEvents_1.
public void testLoadFutureEvents_1() throws ApsSystemException {
Date today = DateConverter.parseDate("2005-01-01", "yyyy-MM-dd");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, today, null);
filter.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter[] filters = { filter };
List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, null);
String[] expectedOrderedContentsId = { "EVN21", "EVN20", "EVN25", "EVN23", "EVN24", "EVN193", "EVN194" };
assertEquals(expectedOrderedContentsId.length, contents.size());
for (int i = 0; i < expectedOrderedContentsId.length; i++) {
assertEquals(expectedOrderedContentsId[i], contents.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testLoadWorkEvents_1_b.
public void testLoadWorkEvents_1_b() throws ApsSystemException {
// forcing case insensitive search
WorkContentSearcherDAO searcherDao = (WorkContentSearcherDAO) this.getApplicationContext().getBean("jacmsWorkContentSearcherDAO");
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
List<String> allowedDescription = new ArrayList<String>();
// "ART179" "ART180" "ART187"
allowedDescription.add("descrizione");
// "ART179"
allowedDescription.add("on line");
// "ART102" "RAH101"
allowedDescription.add("customers");
EntitySearchFilter filter = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, allowedDescription, true);
EntitySearchFilter filter2 = new EntitySearchFilter(IContentManager.ENTITY_ID_FILTER_KEY, false);
filter2.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter[] filters = { filter, filter2 };
List<String> contents = _contentManager.loadWorkContentsId(filters, groups);
String[] expectedOrderedContentsId2 = { "ART102", "ART179", "ART180", "ART187", "RAH101" };
assertEquals(expectedOrderedContentsId2.length, contents.size());
for (int i = 0; i < expectedOrderedContentsId2.length; i++) {
assertEquals(expectedOrderedContentsId2[i], contents.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentManager method testSearchWorkContents_3.
public void testSearchWorkContents_3() throws Throwable {
List<String> groupCodes = new ArrayList<String>();
groupCodes.add(Group.ADMINS_GROUP_NAME);
EntitySearchFilter creationOrder = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
creationOrder.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { creationOrder };
String[] categories_1 = { "general_cat2" };
List<String> contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
String[] order_a = { "ART120", "ART112", "ART111", "EVN193", "ART179" };
assertEquals(order_a.length, contents.size());
this.verifyOrder(contents, order_a);
String[] categories_2 = { "general_cat1", "general_cat2" };
contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
String[] order_b = { "ART111", "ART179" };
assertEquals(order_b.length, contents.size());
assertEquals(order_b[0], contents.get(0));
Content newContent = this._contentManager.loadContent("EVN193", false);
newContent.setId(null);
try {
this._contentManager.saveContent(newContent);
contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
String[] order_c = { newContent.getId(), "ART120", "ART112", "ART111", "EVN193", "ART179" };
assertEquals(order_c.length, contents.size());
this.verifyOrder(contents, order_c);
ICategoryManager categoryManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
newContent.addCategory(categoryManager.getCategory("general_cat1"));
this._contentManager.saveContent(newContent);
contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
String[] order_d = { newContent.getId(), "ART111", "ART179" };
assertEquals(order_d.length, contents.size());
this.verifyOrder(contents, order_d);
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(newContent);
assertNull(this._contentManager.loadContent(newContent.getId(), false));
}
}
Aggregations