Search in sources :

Example 11 with EntitySearchFilter

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

the class TestContentEntityManager method testLoadOrderedEvents_1.

public void testLoadOrderedEvents_1() throws ApsSystemException {
    EntitySearchFilter filterForDescr = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false);
    filterForDescr.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter[] filters = { filterForDescr };
    List<String> contents = _contentManager.searchId("EVN", filters);
    String[] expectedContentsId = { "EVN24", "EVN23", "EVN103", "EVN191", "EVN192", "EVN193", "EVN194", "EVN41", "EVN20", "EVN21", "EVN25" };
    assertEquals(expectedContentsId.length, contents.size());
    for (int i = 0; i < expectedContentsId.length; i++) {
        assertEquals(expectedContentsId[i], contents.get(i));
    }
    filterForDescr.setOrder(EntitySearchFilter.DESC_ORDER);
    contents = _contentManager.searchId("EVN", filters);
    assertEquals(expectedContentsId.length, contents.size());
    for (int i = 0; i < expectedContentsId.length; i++) {
        assertEquals(expectedContentsId[expectedContentsId.length - i - 1], contents.get(i));
    }
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 12 with EntitySearchFilter

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

the class TestContentListHelper method testGetContents_1.

public void testGetContents_1() throws Throwable {
    String pageCode = "pagina_1";
    int frame = 1;
    try {
        this.setUserOnSession("guest");
        RequestContext reqCtx = this.valueRequestContext(pageCode, frame);
        MockContentListTagBean bean = new MockContentListTagBean();
        bean.setContentType("EVN");
        EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true);
        filter.setOrder(EntitySearchFilter.DESC_ORDER);
        bean.addFilter(filter);
        List<String> contents = this._helper.getContentsId(bean, reqCtx);
        String[] expected = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
        assertEquals(expected.length, contents.size());
        for (int i = 0; i < expected.length; i++) {
            assertEquals(expected[i], contents.get(i));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        this.setPageWidgets(pageCode, frame, null);
    }
}
Also used : RequestContext(com.agiletec.aps.system.RequestContext) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 13 with EntitySearchFilter

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

the class TestDataObjectManager method testSearchDataObjects_3.

public void testSearchDataObjects_3() throws Throwable {
    EntitySearchFilter modifyOrder = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_MODIFY_DATE_FILTER_KEY, false);
    modifyOrder.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter onlineFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_ONLINE_FILTER_KEY, false, "encoding=", true);
    EntitySearchFilter[] filters = { modifyOrder, onlineFilter };
    List<String> dataObjectIds = this._dataObjectManager.searchId(filters);
    assertNotNull(dataObjectIds);
    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, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected);
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 14 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadEvents_1_b.

public void testLoadEvents_1_b() throws ApsSystemException {
    // forcing case insensitive search
    DataObjectSearcherDAO searcherDao = (DataObjectSearcherDAO) this.getApplicationContext().getBean("DataObjectSearcherDAO");
    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(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, allowedDescription, true);
    EntitySearchFilter filter2 = new EntitySearchFilter(IDataObjectManager.ENTITY_ID_FILTER_KEY, false);
    filter2.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter[] filters = { filter, filter2 };
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId(null, filters, groups);
    String[] expectedOrderedDataObjectsId2 = { "ART102", "ART180", "ART187", "RAH101" };
    assertEquals(expectedOrderedDataObjectsId2.length, dataObjects.size());
    for (int i = 0; i < expectedOrderedDataObjectsId2.length; i++) {
        assertEquals(expectedOrderedDataObjectsId2[i], dataObjects.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 15 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadDataObjectsForCategory_2.

public void testLoadDataObjectsForCategory_2() throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    String[] categories1 = { "general_cat1" };
    EntitySearchFilter filter1 = new EntitySearchFilter(IDataObjectManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
    EntitySearchFilter[] filters = { filter1 };
    List<String> dataObjects = this._dataObjectManager.loadDataObjectsId(categories1, filters, groups);
    assertEquals(2, dataObjects.size());
    assertTrue(dataObjects.contains("ART102"));
    assertTrue(dataObjects.contains("ART111"));
    // assertTrue(dataObjects.contains("ART180"));
    // assertTrue(dataObjects.contains("ART179"));
    String[] categories2 = { "general_cat2" };
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories2, filters, groups);
    assertEquals(2, dataObjects.size());
    assertTrue(dataObjects.contains("ART111"));
    // assertTrue(dataObjects.contains("ART112"));
    assertTrue(dataObjects.contains("ART120"));
    // assertTrue(dataObjects.contains("ART179"));
    String[] categories12 = { "general_cat1", "general_cat2" };
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories12, false, filters, groups);
    assertEquals(1, dataObjects.size());
    assertTrue(dataObjects.contains("ART111"));
    // assertTrue(dataObjects.contains("ART179"));
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories12, true, filters, groups);
    assertEquals(3, dataObjects.size());
    assertTrue(dataObjects.contains("ART102"));
    assertTrue(dataObjects.contains("ART111"));
    // assertTrue(dataObjects.contains("ART112"));
    assertTrue(dataObjects.contains("ART120"));
    // assertTrue(dataObjects.contains("ART180"));
    String[] categories3 = { "general_cat3" };
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories3, filters, groups);
    assertEquals(2, dataObjects.size());
    assertTrue(dataObjects.contains("ART120"));
    // assertTrue(dataObjects.contains("ART121"));
    assertTrue(dataObjects.contains("ART122"));
    String[] categories23 = { "general_cat2", "general_cat3" };
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories23, false, filters, groups);
    assertEquals(1, dataObjects.size());
    assertTrue(dataObjects.contains("ART120"));
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories23, true, filters, groups);
    assertEquals(3, dataObjects.size());
    assertTrue(dataObjects.contains("ART111"));
    // assertTrue(dataObjects.contains("ART112"));
    assertTrue(dataObjects.contains("ART120"));
    // assertTrue(dataObjects.contains("ART179"));
    // assertTrue(dataObjects.contains("ART121"));
    assertTrue(dataObjects.contains("ART122"));
    String[] categories123 = { "general_cat1", "general_cat2", "general_cat3" };
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories123, false, filters, groups);
    assertEquals(0, dataObjects.size());
    dataObjects = this._dataObjectManager.loadDataObjectsId(categories123, true, filters, groups);
    assertEquals(4, dataObjects.size());
    assertTrue(dataObjects.contains("ART102"));
    assertTrue(dataObjects.contains("ART111"));
    // assertTrue(dataObjects.contains("ART112"));
    assertTrue(dataObjects.contains("ART120"));
    // assertTrue(dataObjects.contains("ART121"));
    assertTrue(dataObjects.contains("ART122"));
// assertTrue(dataObjects.contains("ART180"));
// assertTrue(dataObjects.contains("ART179"));
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

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