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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations