Search in sources :

Example 36 with EntitySearchFilter

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"));
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

Example 37 with EntitySearchFilter

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));
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

Example 38 with EntitySearchFilter

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));
    }
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

Example 39 with EntitySearchFilter

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));
    }
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 40 with EntitySearchFilter

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));
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Aggregations

EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)157 ArrayList (java.util.ArrayList)51 Date (java.util.Date)46 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)12 RequestContext (com.agiletec.aps.system.RequestContext)9 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)7 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)6 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)5 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 BigDecimal (java.math.BigDecimal)4 HashSet (java.util.HashSet)4 ApsEntityRecord (com.agiletec.aps.system.common.entity.model.ApsEntityRecord)3 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)3 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)3 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)3 Properties (java.util.Properties)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)2 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)2