Search in sources :

Example 41 with EntitySearchFilter

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

the class TestContentManager method testSearchContents_1_6.

public void testSearchContents_1_6() throws Throwable {
    // forcing case sensitive search
    WorkContentSearcherDAO searcherDao = (WorkContentSearcherDAO) this.getApplicationContext().getBean("jacmsWorkContentSearcherDAO");
    EntitySearchFilter creationOrder = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
    creationOrder.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter descrFilter = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, "CoNt", true);
    EntitySearchFilter[] filters1 = { creationOrder, descrFilter };
    List<String> contentIds = this._contentManager.searchId(filters1);
    assertEquals(9, contentIds.size());
    EntitySearchFilter lastEditorFilter = new EntitySearchFilter(IContentManager.CONTENT_LAST_EDITOR_FILTER_KEY, false, "AdMin", true);
    EntitySearchFilter[] filters2 = { creationOrder, descrFilter, lastEditorFilter };
    contentIds = this._contentManager.searchId(filters2);
    assertNotNull(contentIds);
    assertEquals(9, contentIds.size());
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 42 with EntitySearchFilter

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

the class TestContentManager method testLoadOrderedPublicEvents_1.

public void testLoadOrderedPublicEvents_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.loadPublicContentsId("EVN", null, filters, null);
    String[] expectedFreeContentsId = { "EVN24", "EVN23", "EVN191", "EVN192", "EVN193", "EVN194", "EVN20", "EVN21", "EVN25" };
    assertEquals(expectedFreeContentsId.length, contents.size());
    for (int i = 0; i < expectedFreeContentsId.length; i++) {
        assertEquals(expectedFreeContentsId[i], contents.get(i));
    }
    filterForDescr.setOrder(EntitySearchFilter.DESC_ORDER);
    contents = _contentManager.loadPublicContentsId("EVN", null, filters, null);
    assertEquals(expectedFreeContentsId.length, contents.size());
    for (int i = 0; i < expectedFreeContentsId.length; i++) {
        assertEquals(expectedFreeContentsId[expectedFreeContentsId.length - i - 1], contents.get(i));
    }
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 43 with EntitySearchFilter

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

the class TestContentManager method testLoadPublicEvents_5.

public void testLoadPublicEvents_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> contents = _contentManager.loadPublicContentsId("EVN", null, filters, groups);
    String[] expectedOrderedContentsId2 = { "EVN23", "EVN192" };
    assertEquals(expectedOrderedContentsId2.length, contents.size());
    for (int i = 0; i < expectedOrderedContentsId2.length; i++) {
        assertEquals(expectedOrderedContentsId2[i], contents.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) Date(java.util.Date)

Example 44 with EntitySearchFilter

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

the class UserProfileFinderAction method execute.

@Override
public String execute() {
    try {
        String username = this.getUsername();
        EntitySearchFilter filter = null;
        if (username != null && username.trim().length() > 0) {
            filter = new EntitySearchFilter(IEntityManager.ENTITY_ID_FILTER_KEY, false, username, true);
        } else {
            filter = new EntitySearchFilter(IEntityManager.ENTITY_ID_FILTER_KEY, false);
        }
        filter.setOrder(EntitySearchFilter.ASC_ORDER);
        this.addFilter(filter);
    } catch (Throwable t) {
        _logger.error("error in execute", t);
        return FAILURE;
    }
    return super.execute();
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 45 with EntitySearchFilter

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

the class ContentUpdaterService method getContentsId.

@Override
public Set<String> getContentsId(String categoryCode) throws ApsSystemException {
    Set<String> allContents = new HashSet<String>();
    try {
        // Ricerca contenuti per
        EntitySearchFilter[] filters = null;
        boolean orCategoryFilter = false;
        // tutti i gruppi
        List<String> userGroupCodes = new ArrayList<String>();
        userGroupCodes.add(Group.ADMINS_GROUP_NAME);
        // associati alla categoria che รจ stata spostata...
        String[] categories = new String[] { categoryCode };
        List<String> publicContents = this.getContentManager().loadPublicContentsId(categories, orCategoryFilter, filters, userGroupCodes);
        ApsSystemUtils.getLogger().debug("public contents: " + publicContents.size());
        List<String> workContents = this.getContentManager().loadWorkContentsId(categories, filters, userGroupCodes);
        ApsSystemUtils.getLogger().debug("work contents: " + workContents.size());
        allContents.addAll(publicContents);
        allContents.addAll(workContents);
    } catch (Throwable t) {
        ApsSystemUtils.logThrowable(t, this, "getContentsId");
        throw new ApsSystemException("Error loading contents to update", t);
    }
    return allContents;
}
Also used : ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) HashSet(java.util.HashSet)

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