Search in sources :

Example 21 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadEvents_4.

protected void testLoadEvents_4(boolean useRoleFilter) throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    EntitySearchFilter filter1 = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(SystemConstants.DATA_TYPE_ATTRIBUTE_ROLE_TITLE, "Ce", "TF") : new EntitySearchFilter("Titolo", true, "Ce", "TF");
    filter1.setLangCode("it");
    filter1.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters1 = { filter1 };
    List<String> dataObjects = this._dataObjectManager.loadDataObjectsId("EVN", null, filters1, groups);
    String[] expectedOrderedDataObjectsId = { "EVN25", "EVN41", "EVN20", "EVN21", "EVN23" };
    assertEquals(expectedOrderedDataObjectsId.length, dataObjects.size());
    for (int i = 0; i < expectedOrderedDataObjectsId.length; i++) {
        assertEquals(expectedOrderedDataObjectsId[i], dataObjects.get(i));
    }
    filter1 = new EntitySearchFilter("Titolo", true, null, "TF");
    filter1.setLangCode("it");
    filter1.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters2 = { filter1 };
    dataObjects = this._dataObjectManager.loadDataObjectsId("EVN", null, filters2, groups);
    String[] expectedOrderedDataObjectsId2 = { "EVN25", "EVN41", "EVN20", "EVN21", "EVN23", "EVN24" };
    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 22 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadEvents_2_2.

public void testLoadEvents_2_2() throws ApsSystemException {
    // forcing case sensitive search
    DataObjectSearcherDAO searcherDao = (DataObjectSearcherDAO) this.getApplicationContext().getBean("DataObjectSearcherDAO");
    List<String> groups = new ArrayList<String>();
    groups.add("coach");
    groups.add(Group.ADMINS_GROUP_NAME);
    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 filter_x1 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "even", true);
    filter_x1.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters_1 = { filter, filter_x1 };
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters_1, groups);
    assertEquals(2, dataObjects.size());
    EntitySearchFilter filter_x2 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Even", true);
    filter_x2.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters_2 = { filter, filter_x2 };
    dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters_2, groups);
    assertEquals(2, dataObjects.size());
    assertEquals("EVN193", dataObjects.get(0));
    assertEquals("EVN192", dataObjects.get(1));
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

Example 23 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadPastEvents_3.

public void testLoadPastEvents_3() throws ApsSystemException {
    Date today = DateConverter.parseDate("2008-02-13", "yyyy-MM-dd");
    EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, null, today);
    filter.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter[] filters = { filter };
    List<String> groups = new ArrayList<String>();
    groups.add("coach");
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
    String[] expectedOrderedDataObjectsId = { "EVN191", "EVN192", "EVN103", "EVN21", "EVN20", "EVN25", "EVN41", "EVN23" };
    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 24 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadFutureEvents_2.

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

Example 25 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadOrderedEvents_4.

public void testLoadOrderedEvents_4() throws Throwable {
    DataObject masterDataObject = this._dataObjectManager.loadDataObject("EVN193", true);
    masterDataObject.setId(null);
    DateAttribute dateAttribute = (DateAttribute) masterDataObject.getAttribute("DataInizio");
    dateAttribute.setDate(DateConverter.parseDate("17/06/2019", "dd/MM/yyyy"));
    try {
        this._dataObjectManager.saveDataObject(masterDataObject);
        this._dataObjectManager.insertDataObject(masterDataObject);
        this.waitNotifyingThread();
        EntitySearchFilter filterForDate = new EntitySearchFilter("DataInizio", true);
        filterForDate.setOrder(EntitySearchFilter.DESC_ORDER);
        EntitySearchFilter[] filters = { filterForDate };
        List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, null);
        String[] expectedFreeOrderedDataObjectsId = { "EVN194", masterDataObject.getId(), "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
        assertEquals(expectedFreeOrderedDataObjectsId.length, dataObjects.size());
        for (int i = 0; i < expectedFreeOrderedDataObjectsId.length; i++) {
            assertEquals(expectedFreeOrderedDataObjectsId[i], dataObjects.get(i));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != masterDataObject.getId() && !"EVN193".equals(masterDataObject.getId())) {
            this._dataObjectManager.removeDataObject(masterDataObject);
            this._dataObjectManager.deleteDataObject(masterDataObject);
        }
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

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