Search in sources :

Example 61 with EntitySearchFilter

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

the class EntityTypesAction method checkDelete.

private String checkDelete() throws Throwable {
    IApsEntity entityType = this.getEntityPrototype(this.getEntityTypeCode());
    if (null == entityType) {
        String[] args = { this.getEntityTypeCode() };
        this.addFieldError("entityTypeCode", this.getText("error.entityTypeCode.is.null", args));
        return INPUT;
    }
    EntitySearchFilter typeCodeFilter = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, entityType.getTypeCode(), false);
    EntitySearchFilter[] filters = { typeCodeFilter };
    List<String> entityIds = this.getEntityManager().searchId(filters);
    if (null != entityIds && !entityIds.isEmpty()) {
        this.setReferences(entityIds);
        return "hasReferences";
    }
    return null;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 62 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadPastEvents_1.

public void testLoadPastEvents_1() throws ApsSystemException {
    Date today = DateConverter.parseDate("2008-10-01", "yyyy-MM-dd");
    EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, null, today);
    filter.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter[] filters = { filter };
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, null);
    String[] expectedOrderedDataObjectsId = { "EVN191", "EVN192", "EVN21", "EVN20", "EVN25", "EVN23" };
    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 63 with EntitySearchFilter

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

the class TestDataObjectManager method testSearchDataObjects_1_5.

public void testSearchDataObjects_1_5() throws Throwable {
    // forcing case insensitive search
    DataObjectSearcherDAO searcherDao = (DataObjectSearcherDAO) this.getApplicationContext().getBean("DataObjectSearcherDAO");
    EntitySearchFilter creationOrder = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
    creationOrder.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "co", true, FieldSearchFilter.LikeOptionType.COMPLETE);
    EntitySearchFilter[] filters1 = { creationOrder, descrFilter };
    List<String> dataObjectIds = this._dataObjectManager.searchId(filters1);
    assertNotNull(dataObjectIds);
    String[] expected1 = { "ART1", "RAH1", "ART187", "RAH101", "ART102", "EVN103", "ART104", "ART111", "ART112", "EVN23", "ART120", "ART121", "ART122" };
    assertEquals(expected1.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected1);
    descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "co", true, FieldSearchFilter.LikeOptionType.RIGHT);
    EntitySearchFilter[] filters2 = { creationOrder, descrFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters2);
    assertNotNull(dataObjectIds);
    String[] expected2 = { "RAH101", "ART102", "EVN103", "ART104", "ART111", "ART112", "EVN23", "ART120", "ART121", "ART122" };
    assertEquals(expected2.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected2);
    EntitySearchFilter idFilter = new EntitySearchFilter(IDataObjectManager.ENTITY_ID_FILTER_KEY, false, "1", true, FieldSearchFilter.LikeOptionType.LEFT);
    EntitySearchFilter[] filters3 = { creationOrder, descrFilter, idFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters3);
    assertNotNull(dataObjectIds);
    String[] expected3 = { "RAH101", "ART111", "ART121" };
    assertEquals(expected3.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected3);
    descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "co", true, FieldSearchFilter.LikeOptionType.LEFT);
    EntitySearchFilter[] filters4 = { creationOrder, descrFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters4);
    assertNotNull(dataObjectIds);
    String[] expected4 = {};
    assertEquals(expected4.length, dataObjectIds.size());
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 64 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadEvents_5.

public void testLoadEvents_5() throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    List<Date> allowedDates = new ArrayList<Date>();
    // EVN192
    allowedDates.add(DateConverter.parseDate("1999-04-14", "yyyy-MM-dd"));
    // EVN23
    allowedDates.add(DateConverter.parseDate("2008-02-13", "yyyy-MM-dd"));
    EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true, allowedDates, false);
    filter.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { filter };
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
    String[] expectedOrderedDataObjectsId2 = { "EVN23", "EVN192" };
    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) Date(java.util.Date)

Example 65 with EntitySearchFilter

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

the class TestDataObjectManager method testLoadEvents_7.

protected void testLoadEvents_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(SystemConstants.DATA_TYPE_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> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
    String[] expectedOrderedDataObjectsId2 = { "EVN192", "EVN20" };
    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)

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