Search in sources :

Example 31 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class TestContentManager method testSearchContents_2.

public void testSearchContents_2() throws Throwable {
    EntitySearchFilter creationOrder = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
    creationOrder.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter groupFilter = new EntitySearchFilter(IContentManager.CONTENT_MAIN_GROUP_FILTER_KEY, false, "coach", false);
    EntitySearchFilter[] filters = { creationOrder, groupFilter };
    List<String> contentIds = this._contentManager.searchId(filters);
    assertNotNull(contentIds);
    String[] expected = { "EVN103", "ART104", "ART111", "ART112", "EVN25", "EVN41" };
    assertEquals(expected.length, contentIds.size());
    this.verifyOrder(contentIds, expected);
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 32 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class TestContentManager method testSearchContents_3.

public void testSearchContents_3() throws Throwable {
    EntitySearchFilter modifyOrder = new EntitySearchFilter(IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY, false);
    modifyOrder.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter onlineFilter = new EntitySearchFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY, false, "encoding=", true);
    EntitySearchFilter[] filters = { modifyOrder, onlineFilter };
    List<String> contentIds = this._contentManager.searchId(filters);
    assertNotNull(contentIds);
    String[] expected = { "ART187", "ART1", "EVN193", "EVN194", "ART180", "RAH1", "EVN191", "EVN192", "RAH101", "EVN103", "ART104", "ART102", "EVN23", "EVN24", "EVN25", "EVN41", "EVN20", "EVN21", "ART111", "ART120", "ART121", "ART122", "ART112", "ALL4" };
    assertEquals(expected.length, contentIds.size());
    this.verifyOrder(contentIds, expected);
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 33 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class TestContentManager method testLoadPublicEvents_7.

protected void testLoadPublicEvents_7(boolean useRoleFilter) throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    List<String> allowedDescription = new ArrayList<String>();
    // EVN20
    allowedDescription.add("Mostra Zootecnica");
    // EVN192
    allowedDescription.add("Title B - Event 2");
    EntitySearchFilter filter1 = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(JacmsSystemConstants.ATTRIBUTE_ROLE_TITLE, allowedDescription, false) : new EntitySearchFilter("Titolo", true, allowedDescription, false);
    filter1.setLangCode("en");
    EntitySearchFilter filter2 = new EntitySearchFilter("DataInizio", true);
    filter2.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter[] filters = { filter1, filter2 };
    List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, groups);
    String[] expectedOrderedContentsId2 = { "EVN192", "EVN20" };
    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 34 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class TestContentManager method testSearchWorkContents.

public void testSearchWorkContents() throws Throwable {
    List<String> contents = this._contentManager.loadWorkContentsId(null, null);
    assertNotNull(contents);
    assertEquals(0, contents.size());
    EntitySearchFilter creationOrder = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
    creationOrder.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter typeFilter = new EntitySearchFilter(IContentManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
    EntitySearchFilter[] filters1 = { creationOrder, typeFilter };
    contents = this._contentManager.loadWorkContentsId(filters1, null);
    assertEquals(0, contents.size());
    List<String> groupCodes = new ArrayList<String>();
    groupCodes.add("customers");
    contents = this._contentManager.loadWorkContentsId(filters1, groupCodes);
    String[] order1 = { "ART102" };
    assertEquals(order1.length, contents.size());
    this.verifyOrder(contents, order1);
    groupCodes.add(Group.FREE_GROUP_NAME);
    EntitySearchFilter statusFilter = new EntitySearchFilter(IContentManager.CONTENT_STATUS_FILTER_KEY, false, Content.STATUS_DRAFT, false);
    EntitySearchFilter[] filters2 = { creationOrder, typeFilter, statusFilter };
    contents = this._contentManager.loadWorkContentsId(filters2, groupCodes);
    String[] order2 = { "ART102", "ART187", "ART179", "ART1" };
    assertEquals(order2.length, contents.size());
    this.verifyOrder(contents, order2);
    EntitySearchFilter onlineFilter = new EntitySearchFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY, false);
    EntitySearchFilter[] filters3 = { creationOrder, typeFilter, onlineFilter };
    contents = this._contentManager.loadWorkContentsId(filters3, groupCodes);
    String[] order3 = { "ART102", "ART187", "ART180", "ART1" };
    assertEquals(order3.length, contents.size());
    this.verifyOrder(contents, order3);
    onlineFilter.setNullOption(true);
    contents = this._contentManager.loadWorkContentsId(filters3, groupCodes);
    String[] order4 = { "ART179" };
    assertEquals(order4.length, contents.size());
    this.verifyOrder(contents, order4);
    onlineFilter.setNullOption(false);
    EntitySearchFilter descrFilter = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, "scr", true);
    EntitySearchFilter[] filters5 = { creationOrder, typeFilter, onlineFilter, descrFilter };
    contents = this._contentManager.loadWorkContentsId(filters5, groupCodes);
    String[] order5 = { "ART187", "ART180" };
    assertEquals(order5.length, contents.size());
    this.verifyOrder(contents, order5);
    groupCodes.clear();
    groupCodes.add(Group.ADMINS_GROUP_NAME);
    contents = this._contentManager.loadWorkContentsId(null, groupCodes);
    assertNotNull(contents);
    assertEquals(25, contents.size());
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 35 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class TestContentManager method testLoadFutureEvents_3.

public void testLoadFutureEvents_3() throws ApsSystemException {
    Date today = DateConverter.parseDate("2005-01-01", "yyyy-MM-dd");
    List<String> groups = new ArrayList<String>();
    groups.add("coach");
    EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, today, null);
    filter.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { filter };
    List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, groups);
    String[] expectedOrderedContentsId = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN41", "EVN25", "EVN20", "EVN21" };
    assertEquals(expectedOrderedContentsId.length, contents.size());
    for (int i = 0; i < expectedOrderedContentsId.length; i++) {
        assertEquals(expectedOrderedContentsId[i], contents.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

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