Search in sources :

Example 16 with EntitySearchFilter

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

the class TestDataObjectManager 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> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
    String[] expectedOrderedDataObjectsId = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN41", "EVN25", "EVN20", "EVN21" };
    assertEquals(expectedOrderedDataObjectsId.length, dataObjects.size());
    for (int i = 0; i < expectedOrderedDataObjectsId.length; i++) {
        assertEquals(expectedOrderedDataObjectsId[i], dataObjects.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

Example 17 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadOrderedEvents_3.

public void testLoadOrderedEvents_3() throws ApsSystemException {
    EntitySearchFilter filterForCreation = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
    filterForCreation.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter filterForDate = new EntitySearchFilter("DataInizio", true);
    filterForDate.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { filterForCreation, filterForDate };
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, null);
    String[] expectedFreeOrderedDataObjectsId = { "EVN21", "EVN25", "EVN24", "EVN23", "EVN20", "EVN194", "EVN193", "EVN192", "EVN191" };
    assertEquals(expectedFreeOrderedDataObjectsId.length, dataObjects.size());
    for (int i = 0; i < expectedFreeOrderedDataObjectsId.length; i++) {
        assertEquals(expectedFreeOrderedDataObjectsId[i], dataObjects.get(i));
    }
    EntitySearchFilter[] filters2 = { filterForDate, filterForCreation };
    List<String> dataObjects2 = _dataObjectManager.loadDataObjectsId("EVN", null, filters2, null);
    String[] expectedFreeOrderedDataObjectsId2 = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
    assertEquals(expectedFreeOrderedDataObjectsId2.length, dataObjects2.size());
    for (int i = 0; i < expectedFreeOrderedDataObjectsId2.length; i++) {
        assertEquals(expectedFreeOrderedDataObjectsId2[i], dataObjects2.get(i));
    }
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 18 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadDataObjectsByAttribute_3.

public void testLoadDataObjectsByAttribute_3() throws Throwable {
    List<String> groups = new ArrayList<String>();
    String[] masterDataObjectIds = { "EVN193", "EVN191", "EVN192", "EVN194", "EVN23", "EVN24" };
    String[] newDataObjectIds = null;
    try {
        newDataObjectIds = this.addDraftDataObjectsForTest(masterDataObjectIds, false);
        for (int i = 0; i < newDataObjectIds.length; i++) {
            DataObject dataObject = this._dataObjectManager.loadDataObject(newDataObjectIds[i], false);
            TextAttribute titleAttribute = (TextAttribute) dataObject.getAttribute("Titolo");
            if (i % 2 == 1 && i < 4) {
                titleAttribute.setText(null, "en");
            }
            titleAttribute.setText(null, "it");
            this._dataObjectManager.saveDataObject(dataObject);
        }
        groups.add(Group.ADMINS_GROUP_NAME);
        EntitySearchFilter filter0 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
        filter0.setOrder(EntitySearchFilter.ASC_ORDER);
        EntitySearchFilter filter1 = new EntitySearchFilter(IDataObjectManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "EVN", false);
        EntitySearchFilter filter2 = new EntitySearchFilter(IDataObjectManager.ENTITY_ID_FILTER_KEY, false);
        filter2.setOrder(EntitySearchFilter.ASC_ORDER);
        EntitySearchFilter[] filters = { filter0, filter1, filter2 };
        String[] expectedDataObjectsId = { "EVN191", "EVN192", "EVN193", "EVN194", "EVN103", "EVN20", "EVN23", "EVN24", "EVN25", "EVN41", "EVN21", newDataObjectIds[0], newDataObjectIds[1], newDataObjectIds[2], newDataObjectIds[3], newDataObjectIds[4], newDataObjectIds[5] };
        List<String> dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters, groups);
        assertEquals(expectedDataObjectsId.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId.length; i++) {
            assertEquals(expectedDataObjectsId[i], dataObjects.get(i));
        }
        EntitySearchFilter filter3 = new EntitySearchFilter("Titolo", true);
        filter3.setLangCode("en");
        filter3.setOrder(EntitySearchFilter.ASC_ORDER);
        EntitySearchFilter[] filters1 = { filter0, filter1, filter2, filter3 };
        String[] expectedDataObjectsId1 = { "EVN191", "EVN192", "EVN193", "EVN194", "EVN103", "EVN20", "EVN23", "EVN24", "EVN25", "EVN41", "EVN21", newDataObjectIds[0], newDataObjectIds[2] };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters1, groups);
        assertEquals(expectedDataObjectsId1.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId1.length; i++) {
            assertEquals(expectedDataObjectsId1[i], dataObjects.get(i));
        }
        filter3.setNullOption(true);
        filter3.setLangCode("it");
        EntitySearchFilter[] filters2 = { filter0, filter1, filter2, filter3 };
        String[] expectedDataObjectsId2 = { newDataObjectIds[0], newDataObjectIds[1], newDataObjectIds[2], newDataObjectIds[3], newDataObjectIds[4], newDataObjectIds[5] };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters2, groups);
        assertEquals(expectedDataObjectsId2.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId2.length; i++) {
            assertEquals(expectedDataObjectsId2[i], dataObjects.get(i));
        }
        filter3.setNullOption(true);
        filter3.setLangCode("en");
        EntitySearchFilter[] filters3 = { filter0, filter1, filter2, filter3 };
        String[] expectedDataObjectsId3 = { newDataObjectIds[1], newDataObjectIds[3], newDataObjectIds[4], newDataObjectIds[5] };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters3, groups);
        assertEquals(expectedDataObjectsId3.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId3.length; i++) {
            assertEquals(expectedDataObjectsId3[i], dataObjects.get(i));
        }
        filter2.setNullOption(true);
        EntitySearchFilter[] filters4 = { filter0, filter1, filter2 };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters4, groups);
        assertEquals(0, dataObjects.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.deleteDataObjects(newDataObjectIds);
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) TextAttribute(com.agiletec.aps.system.common.entity.model.attribute.TextAttribute) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute) ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 19 with EntitySearchFilter

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

the class TestDataObjectManager method testSearchDataObjects.

public void testSearchDataObjects() throws Throwable {
    List<String> dataObjects = this._dataObjectManager.loadDataObjectsId(null, null, null);
    assertNotNull(dataObjects);
    assertEquals(15, dataObjects.size());
    EntitySearchFilter creationOrder = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
    creationOrder.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter typeFilter = new EntitySearchFilter(IDataObjectManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
    EntitySearchFilter[] filters1 = { creationOrder, typeFilter };
    dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters1, null);
    assertEquals(4, dataObjects.size());
    List<String> groupCodes = new ArrayList<String>();
    groupCodes.add("customers");
    dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters1, groupCodes);
    String[] order1 = { "ART122", "ART121", "ART112", "ART111", "ART102", "ART187", "ART180", "ART1" };
    assertEquals(order1.length, dataObjects.size());
    this.verifyOrder(dataObjects, order1);
    groupCodes.add(Group.FREE_GROUP_NAME);
    EntitySearchFilter statusFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_STATUS_FILTER_KEY, false, DataObject.STATUS_DRAFT, false);
    EntitySearchFilter[] filters2 = { creationOrder, typeFilter, statusFilter };
    dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters2, groupCodes);
    String[] order2 = { "ART121", "ART112", "ART102", "ART187", "ART1" };
    assertEquals(order2.length, dataObjects.size());
    this.verifyOrder(dataObjects, order2);
    EntitySearchFilter onlineFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_ONLINE_FILTER_KEY, false);
    EntitySearchFilter[] filters3 = { creationOrder, typeFilter, onlineFilter };
    dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters3, groupCodes);
    String[] order3 = { "ART122", "ART121", "ART112", "ART111", "ART102", "ART187", "ART180", "ART1" };
    assertEquals(order3.length, dataObjects.size());
    this.verifyOrder(dataObjects, order3);
    onlineFilter.setNullOption(true);
    dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters3, groupCodes);
    String[] order4 = {};
    assertEquals(order4.length, dataObjects.size());
    this.verifyOrder(dataObjects, order4);
    onlineFilter.setNullOption(false);
    EntitySearchFilter descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "scr", true);
    EntitySearchFilter[] filters5 = { creationOrder, typeFilter, onlineFilter, descrFilter };
    dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters5, groupCodes);
    String[] order5 = { "ART187", "ART180" };
    assertEquals(order5.length, dataObjects.size());
    this.verifyOrder(dataObjects, order5);
    groupCodes.clear();
    groupCodes.add(Group.ADMINS_GROUP_NAME);
    dataObjects = this._dataObjectManager.loadDataObjectsId(null, null, groupCodes);
    assertNotNull(dataObjects);
    assertEquals(24, dataObjects.size());
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 20 with EntitySearchFilter

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

the class TestDataObjectManager method testSearchDataObjects_2.

public void testSearchDataObjects_2() throws Throwable {
    EntitySearchFilter creationOrder = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
    creationOrder.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter groupFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_MAIN_GROUP_FILTER_KEY, false, "coach", false);
    EntitySearchFilter[] filters = { creationOrder, groupFilter };
    List<String> dataObjectIds = this._dataObjectManager.searchId(filters);
    assertNotNull(dataObjectIds);
    String[] expected = { "EVN103", "ART104", "ART111", "ART112", "EVN25", "EVN41" };
    assertEquals(expected.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected);
}
Also used : 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