Search in sources :

Example 26 with EntitySearchFilter

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

the class TestDataObjectManager method testSearchDataObjects_1_1.

public void testSearchDataObjects_1_1() throws Throwable {
    List<String> dataObjectIds = this._dataObjectManager.searchId(null);
    assertNotNull(dataObjectIds);
    assertEquals(25, dataObjectIds.size());
    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, "Cont", true);
    EntitySearchFilter[] filters1 = { creationOrder, descrFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters1);
    assertNotNull(dataObjectIds);
    String[] expected1 = { "RAH101", "ART102", "EVN103", "ART104", "ART111", "ART112", "ART120", "ART121", "ART122" };
    assertEquals(expected1.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected1);
    EntitySearchFilter lastEditorFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_LAST_EDITOR_FILTER_KEY, false, "admin", true);
    EntitySearchFilter[] filters2 = { creationOrder, descrFilter, lastEditorFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters2);
    assertNotNull(dataObjectIds);
    assertEquals(expected1.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected1);
    descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Cont", true, FieldSearchFilter.LikeOptionType.RIGHT);
    EntitySearchFilter[] filters3 = { creationOrder, descrFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters3);
    assertNotNull(dataObjectIds);
    String[] expected3 = expected1;
    assertEquals(expected3.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected3);
    descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "Cont", true, FieldSearchFilter.LikeOptionType.LEFT);
    EntitySearchFilter[] filters4 = { creationOrder, descrFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters4);
    assertNotNull(dataObjectIds);
    assertTrue(dataObjectIds.isEmpty());
    descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "1", true, FieldSearchFilter.LikeOptionType.LEFT);
    EntitySearchFilter[] filters5 = { creationOrder, descrFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters5);
    assertNotNull(dataObjectIds);
    String[] expected5 = { "EVN191", "ART120" };
    assertEquals(expected5.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected5);
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 27 with EntitySearchFilter

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

the class TestContentManager method testLoadWorkContentsByAttribute_2.

public void testLoadWorkContentsByAttribute_2() throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    EntitySearchFilter filter0 = new EntitySearchFilter(IContentManager.ENTITY_ID_FILTER_KEY, false);
    filter0.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter filter1 = new EntitySearchFilter(IContentManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "EVN", true);
    EntitySearchFilter filter2 = new EntitySearchFilter("Titolo", true);
    filter2.setOrder(EntitySearchFilter.ASC_ORDER);
    EntitySearchFilter[] filters = { filter0, filter1, filter2 };
    String[] expectedContentsId = { "EVN103", "EVN191", "EVN192", "EVN193", "EVN194", "EVN20", "EVN21", "EVN23", "EVN24", "EVN25", "EVN41" };
    List<String> contents = this._contentManager.loadWorkContentsId(filters, groups);
    assertEquals(expectedContentsId.length, contents.size());
    for (int i = 0; i < expectedContentsId.length; i++) {
        assertEquals(expectedContentsId[i], contents.get(i));
    }
    filter2.setNullOption(true);
    EntitySearchFilter[] filters2 = { filter0, filter1, filter2 };
    contents = this._contentManager.loadWorkContentsId(filters2, groups);
    assertEquals(0, contents.size());
    filter2.setLangCode("it");
    EntitySearchFilter[] filters3 = { filter0, filter1, filter2 };
    contents = this._contentManager.loadWorkContentsId(filters3, groups);
    assertEquals(0, contents.size());
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 28 with EntitySearchFilter

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

the class TestContentManager method testLoadOrderedPublicEvents_4.

public void testLoadOrderedPublicEvents_4() throws Throwable {
    Content masterContent = this._contentManager.loadContent("EVN193", true);
    masterContent.setId(null);
    DateAttribute dateAttribute = (DateAttribute) masterContent.getAttribute("DataInizio");
    dateAttribute.setDate(DateConverter.parseDate("17/06/2019", "dd/MM/yyyy"));
    try {
        this._contentManager.saveContent(masterContent);
        this._contentManager.insertOnLineContent(masterContent);
        this.waitNotifyingThread();
        EntitySearchFilter filterForDate = new EntitySearchFilter("DataInizio", true);
        filterForDate.setOrder(EntitySearchFilter.DESC_ORDER);
        EntitySearchFilter[] filters = { filterForDate };
        List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, null);
        String[] expectedFreeOrderedContentsId = { "EVN194", masterContent.getId(), "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
        assertEquals(expectedFreeOrderedContentsId.length, contents.size());
        for (int i = 0; i < expectedFreeOrderedContentsId.length; i++) {
            assertEquals(expectedFreeOrderedContentsId[i], contents.get(i));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != masterContent.getId() && !"EVN193".equals(masterContent.getId())) {
            this._contentManager.removeOnLineContent(masterContent);
            this._contentManager.deleteContent(masterContent);
        }
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 29 with EntitySearchFilter

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

the class TestContentManager method testLoadWorkContentsForCategory_2.

public void testLoadWorkContentsForCategory_2() throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    String[] categories1 = { "general_cat1" };
    EntitySearchFilter filter1 = new EntitySearchFilter(IContentManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
    EntitySearchFilter[] filters = { filter1 };
    List<String> contents = this._contentManager.loadWorkContentsId(categories1, filters, groups);
    assertEquals(4, contents.size());
    assertTrue(contents.contains("ART102"));
    assertTrue(contents.contains("ART111"));
    assertTrue(contents.contains("ART180"));
    assertTrue(contents.contains("ART179"));
    String[] categories2 = { "general_cat2" };
    contents = this._contentManager.loadWorkContentsId(categories2, filters, groups);
    assertEquals(4, contents.size());
    assertTrue(contents.contains("ART111"));
    assertTrue(contents.contains("ART112"));
    assertTrue(contents.contains("ART120"));
    assertTrue(contents.contains("ART179"));
    String[] categories12 = { "general_cat1", "general_cat2" };
    contents = this._contentManager.loadWorkContentsId(categories12, false, filters, groups);
    assertEquals(2, contents.size());
    assertTrue(contents.contains("ART111"));
    assertTrue(contents.contains("ART179"));
    contents = this._contentManager.loadWorkContentsId(categories12, true, filters, groups);
    assertEquals(6, contents.size());
    assertTrue(contents.contains("ART102"));
    assertTrue(contents.contains("ART111"));
    assertTrue(contents.contains("ART112"));
    assertTrue(contents.contains("ART120"));
    assertTrue(contents.contains("ART180"));
    assertTrue(contents.contains("ART179"));
    String[] categories3 = { "general_cat3" };
    contents = this._contentManager.loadWorkContentsId(categories3, filters, groups);
    assertEquals(3, contents.size());
    assertTrue(contents.contains("ART120"));
    assertTrue(contents.contains("ART121"));
    assertTrue(contents.contains("ART122"));
    String[] categories23 = { "general_cat2", "general_cat3" };
    contents = this._contentManager.loadWorkContentsId(categories23, false, filters, groups);
    assertEquals(1, contents.size());
    assertTrue(contents.contains("ART120"));
    contents = this._contentManager.loadWorkContentsId(categories23, true, filters, groups);
    assertEquals(6, contents.size());
    assertTrue(contents.contains("ART111"));
    assertTrue(contents.contains("ART112"));
    assertTrue(contents.contains("ART120"));
    assertTrue(contents.contains("ART179"));
    assertTrue(contents.contains("ART121"));
    assertTrue(contents.contains("ART122"));
    String[] categories123 = { "general_cat1", "general_cat2", "general_cat3" };
    contents = this._contentManager.loadWorkContentsId(categories123, false, filters, groups);
    assertEquals(0, contents.size());
    contents = this._contentManager.loadWorkContentsId(categories123, true, filters, groups);
    assertEquals(8, contents.size());
    assertTrue(contents.contains("ART102"));
    assertTrue(contents.contains("ART111"));
    assertTrue(contents.contains("ART112"));
    assertTrue(contents.contains("ART120"));
    assertTrue(contents.contains("ART121"));
    assertTrue(contents.contains("ART122"));
    assertTrue(contents.contains("ART180"));
    assertTrue(contents.contains("ART179"));
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 30 with EntitySearchFilter

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

the class TestContentManager method testLoadPublicEvents_8.

protected void testLoadPublicEvents_8(boolean useRoleFilter) throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    List<String> allowedDescription = new ArrayList<String>();
    // EVN24
    allowedDescription.add("Castello");
    // EVN24
    allowedDescription.add("dei bambini");
    EntitySearchFilter filter = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(JacmsSystemConstants.ATTRIBUTE_ROLE_TITLE, allowedDescription, true) : new EntitySearchFilter("Titolo", true, allowedDescription, true);
    filter.setLangCode("it");
    filter.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { filter };
    List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, groups);
    String[] expectedOrderedContentsId2 = { "EVN24" };
    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)

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