Search in sources :

Example 91 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadEvents_6.

protected void testLoadEvents_6(boolean useRoleFilter) throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    List<String> allowedDescription = new ArrayList<String>();
    // EVN21, EVN20
    allowedDescription.add("Mostra");
    // EVN23
    allowedDescription.add("Collezione");
    EntitySearchFilter filter = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(SystemConstants.DATA_TYPE_ATTRIBUTE_ROLE_TITLE, allowedDescription, true) : new EntitySearchFilter("Titolo", true, allowedDescription, true);
    filter.setLangCode("it");
    filter.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { filter };
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
    String[] expectedOrderedDataObjectsId2 = { "EVN20", "EVN21", "EVN23" };
    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 92 with EntitySearchFilter

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

the class TestDataObjectEntityManager method testSearchEvents.

public void testSearchEvents() throws ApsSystemException {
    EntitySearchFilter filterIt = new EntitySearchFilter("Titolo", true, "it", false);
    filterIt.setLangCode("it");
    EntitySearchFilter[] filters = { filterIt };
    List<String> dataObjects = this._dataObjectManager.searchId("EVN", filters);
    assertTrue(dataObjects.isEmpty());
    filterIt = new EntitySearchFilter("Titolo", true, "it", true);
    filterIt.setLangCode("it");
    EntitySearchFilter[] filters1 = { filterIt };
    dataObjects = this._dataObjectManager.searchId("EVN", filters1);
    assertFalse(dataObjects.isEmpty());
    String[] expectedItalianContentsId = { "EVN194", "EVN193", "EVN192", "EVN191", "EVN103" };
    assertEquals(expectedItalianContentsId.length, dataObjects.size());
    for (int i = 0; i < expectedItalianContentsId.length; i++) {
        assertTrue(dataObjects.contains(expectedItalianContentsId[i]));
    }
    EntitySearchFilter filterEn = new EntitySearchFilter("Titolo", true, "it", true);
    filterEn.setLangCode("en");
    EntitySearchFilter[] filters2 = { filterEn };
    dataObjects = this._dataObjectManager.searchId("EVN", filters2);
    assertFalse(dataObjects.isEmpty());
    String[] expectedEnglishContentsId = { "EVN103", "EVN193", "EVN191", "EVN192", "EVN194" };
    assertEquals(expectedEnglishContentsId.length, dataObjects.size());
    for (int i = 0; i < expectedEnglishContentsId.length; i++) {
        assertTrue(dataObjects.contains(expectedEnglishContentsId[i]));
    }
    filterEn.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters3 = { filterEn };
    dataObjects = this._dataObjectManager.searchId("EVN", filters3);
    assertEquals(expectedEnglishContentsId.length, dataObjects.size());
    for (int i = 0; i < expectedEnglishContentsId.length; i++) {
        assertEquals(expectedEnglishContentsId[i], dataObjects.get(i));
    }
    filterEn.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter[] filters4 = { filterEn };
    dataObjects = this._dataObjectManager.searchId("EVN", filters4);
    assertEquals(expectedEnglishContentsId.length, dataObjects.size());
    for (int i = 0; i < expectedEnglishContentsId.length; i++) {
        assertEquals(expectedEnglishContentsId[expectedEnglishContentsId.length - i - 1], dataObjects.get(i));
    }
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 93 with EntitySearchFilter

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

the class TestDataObjectEntityManager method testLoadOrderedEvents_2.

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

Example 94 with EntitySearchFilter

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

the class TestDataObjectEntityManager method testLoadEvents2.

public void testLoadEvents2() throws ApsSystemException {
    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 filter2 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Even", true);
    filter2.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { filter, filter2 };
    List<String> dataObjects = _dataObjectManager.searchId("EVN", filters);
    assertEquals(2, dataObjects.size());
    assertEquals("EVN193", dataObjects.get(0));
    assertEquals("EVN192", dataObjects.get(1));
    EntitySearchFilter filter3 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_STATUS_FILTER_KEY, false, "pronto", true);
    EntitySearchFilter[] filters2 = { filter, filter3, filter2 };
    dataObjects = _dataObjectManager.searchId("EVN", filters2);
    assertEquals(0, dataObjects.size());
    EntitySearchFilter[] filters2_bis = { filter, filter2, filter3 };
    dataObjects = _dataObjectManager.searchId("EVN", filters2_bis);
    assertEquals(0, dataObjects.size());
    filter2 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false);
    filter2.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters3 = { filter, filter2 };
    dataObjects = _dataObjectManager.searchId("EVN", filters3);
    String[] expectedOrderedContentsId = { "EVN25", "EVN21", "EVN20", "EVN41", "EVN193", "EVN192", "EVN103", "EVN23", "EVN24" };
    assertEquals(expectedOrderedContentsId.length, dataObjects.size());
    for (int i = 0; i < expectedOrderedContentsId.length; i++) {
        assertEquals(expectedOrderedContentsId[i], dataObjects.get(i));
    }
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

Example 95 with EntitySearchFilter

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

the class TestDataObjectListHelper 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);
        MockDataObjectListTagBean bean = new MockDataObjectListTagBean();
        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)

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