Search in sources :

Example 76 with EntitySearchFilter

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

the class UserProfileManagerIntegrationTest method testSearchProfileRecords.

public void testSearchProfileRecords() throws Throwable {
    List<ApsEntityRecord> records = this._profileManager.searchRecords(null);
    assertNotNull(records);
    assertEquals(4, records.size());
    EntitySearchFilter usernameFilter1 = new EntitySearchFilter(IUserProfileManager.ENTITY_ID_FILTER_KEY, false);
    usernameFilter1.setOrder(EntitySearchFilter.Order.ASC);
    EntitySearchFilter[] filters1 = { usernameFilter1 };
    records = this._profileManager.searchRecords(filters1);
    assertNotNull(records);
    String[] expected1 = { "editorCoach", "editorCustomers", "mainEditor", "pageManagerCoach" };
    assertEquals(expected1.length, records.size());
    this.verifyRecordOrder(records, expected1);
    EntitySearchFilter usernameFilter2 = new EntitySearchFilter(IUserProfileManager.ENTITY_ID_FILTER_KEY, false, "oa", true);
    usernameFilter2.setOrder(EntitySearchFilter.Order.ASC);
    EntitySearchFilter[] filters2 = { usernameFilter2 };
    records = this._profileManager.searchRecords(filters2);
    assertNotNull(records);
    String[] expected2 = { "editorCoach", "pageManagerCoach" };
    assertEquals(expected2.length, records.size());
    this.verifyRecordOrder(records, expected2);
}
Also used : ApsEntityRecord(com.agiletec.aps.system.common.entity.model.ApsEntityRecord) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 77 with EntitySearchFilter

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

the class UserProfileManagerIntegrationTest method testSearchProfiles_2.

public void testSearchProfiles_2() throws Throwable {
    EntitySearchFilter fullnameRoleFilter = EntitySearchFilter.createRoleFilter(SystemConstants.USER_PROFILE_ATTRIBUTE_ROLE_FULL_NAME);
    fullnameRoleFilter.setOrder(EntitySearchFilter.Order.ASC);
    EntitySearchFilter[] filters1 = { fullnameRoleFilter };
    List<String> usernames = this._profileManager.searchId(filters1);
    assertNotNull(usernames);
    String[] expected1 = { "mainEditor", "pageManagerCoach", "editorCoach", "editorCustomers" };
    assertEquals(expected1.length, usernames.size());
    this.verifyOrder(usernames, expected1);
    EntitySearchFilter fullnameRoleFilter2 = EntitySearchFilter.createRoleFilter(SystemConstants.USER_PROFILE_ATTRIBUTE_ROLE_FULL_NAME, "se", true);
    fullnameRoleFilter2.setOrder(EntitySearchFilter.Order.ASC);
    EntitySearchFilter[] filters2 = { fullnameRoleFilter2 };
    usernames = this._profileManager.searchId(filters2);
    assertNotNull(usernames);
    String[] expected2 = { "mainEditor", "editorCustomers" };
    assertEquals(expected2.length, usernames.size());
    this.verifyOrder(usernames, expected2);
    EntitySearchFilter fullnameRoleFilter3 = EntitySearchFilter.createRoleFilter(SystemConstants.USER_PROFILE_ATTRIBUTE_ROLE_FULL_NAME, "se", true);
    EntitySearchFilter usernameFilter3 = new EntitySearchFilter(IUserProfileManager.ENTITY_ID_FILTER_KEY, false);
    usernameFilter3.setOrder(EntitySearchFilter.Order.ASC);
    EntitySearchFilter[] filters3 = { fullnameRoleFilter3, usernameFilter3 };
    usernames = this._profileManager.searchId(filters3);
    assertNotNull(usernames);
    String[] expected3 = { "editorCustomers", "mainEditor" };
    assertEquals(expected3.length, usernames.size());
    this.verifyOrder(usernames, expected3);
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 78 with EntitySearchFilter

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

the class DataObjectSearcherDAO method loadDataObjectsId.

@Override
public List<String> loadDataObjectsId(String[] categories, boolean orClauseCategoryFilter, EntitySearchFilter[] filters, Collection<String> userGroupCodes) {
    Set<String> groupCodes = new HashSet<String>();
    if (null != userGroupCodes) {
        groupCodes.addAll(userGroupCodes);
    }
    groupCodes.add(Group.FREE_GROUP_NAME);
    EntitySearchFilter onLineFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_ONLINE_FILTER_KEY, false);
    filters = this.addFilter(filters, onLineFilter);
    List<String> contentsId = new ArrayList<String>();
    Connection conn = null;
    PreparedStatement stat = null;
    ResultSet result = null;
    try {
        conn = this.getConnection();
        stat = this.buildStatement(filters, categories, orClauseCategoryFilter, groupCodes, false, conn);
        result = stat.executeQuery();
        while (result.next()) {
            String id = result.getString(this.getMasterTableIdFieldName());
            if (!contentsId.contains(id)) {
                contentsId.add(id);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error loading dataObject id list", t);
        throw new RuntimeException("Error loading dataObject id list", t);
    // processDaoException(t, "Errore in caricamento lista id contenuti", "loadContentsId");
    } finally {
        closeDaoResources(result, stat, conn);
    }
    return contentsId;
}
Also used : ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) HashSet(java.util.HashSet)

Example 79 with EntitySearchFilter

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

the class DataObjectSearcherDAO method loadDataObjectsId.

@Override
public List<String> loadDataObjectsId(String contentType, String[] categories, boolean orClauseCategoryFilter, EntitySearchFilter[] filters, Collection<String> userGroupCodes) {
    if (contentType != null && contentType.trim().length() > 0) {
        EntitySearchFilter typeFilter = new EntitySearchFilter(IDataObjectManager.ENTITY_TYPE_CODE_FILTER_KEY, false, contentType, false);
        filters = this.addFilter(filters, typeFilter);
    }
    return this.loadDataObjectsId(categories, orClauseCategoryFilter, filters, userGroupCodes);
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 80 with EntitySearchFilter

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

the class DataObjectUpdaterService method getDataObjectsId.

@Override
public Set<String> getDataObjectsId(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().loadDataObjectsId(categories, orCategoryFilter, filters, userGroupCodes);
        ApsSystemUtils.getLogger().debug("public contents: " + publicContents.size());
        allContents.addAll(publicContents);
    } 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