use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class DataObjectModelService method getDataObjectModels.
@Override
public PagedMetadata<DataModelDto> getDataObjectModels(RestListRequest restListReq) {
PagedMetadata<DataModelDto> pagedMetadata = null;
try {
List<FieldSearchFilter> filters = new ArrayList<>(restListReq.buildFieldSearchFilters());
// transforms the filters by overriding the key specified in the request with the correct one known by the dto
filters.stream().filter(searchFilter -> searchFilter.getKey() != null).forEach(searchFilter -> {
searchFilter.setKey(DataModelDto.getEntityFieldName(searchFilter.getKey()));
if (searchFilter.getKey().equals("modelid") && null != searchFilter.getValue()) {
String stringValue = searchFilter.getValue().toString();
Long value = Long.parseLong(stringValue);
searchFilter = new FieldSearchFilter("modelid", value, true);
}
});
SearcherDaoPaginatedResult<DataObjectModel> models = this.getDataObjectModelManager().getDataObjectModels(filters);
List<DataModelDto> dtoList = this.getDtoBuilder().convert(models.getList());
pagedMetadata = new PagedMetadata<>(restListReq, models);
pagedMetadata.setBody(dtoList);
} catch (Throwable t) {
logger.error("error in search data models", t);
throw new RestServerError("error in search data models", t);
}
return pagedMetadata;
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class GroupService method getGroups.
@SuppressWarnings("rawtypes")
@Override
public PagedMetadata<GroupDto> getGroups(RestListRequest restListReq) {
try {
// transforms the filters by overriding the key specified in the request with the correct one known by the dto
List<FieldSearchFilter> filters = new ArrayList<FieldSearchFilter>(restListReq.buildFieldSearchFilters());
filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(GroupDto.getEntityFieldName(i.getKey())));
SearcherDaoPaginatedResult<Group> groups = this.getGroupManager().getGroups(filters);
List<GroupDto> dtoList = dtoBuilder.convert(groups.getList());
PagedMetadata<GroupDto> pagedMetadata = new PagedMetadata<>(restListReq, groups);
pagedMetadata.setBody(dtoList);
return pagedMetadata;
} catch (Throwable t) {
logger.error("error in search groups", t);
throw new RestServerError("error in search groups", t);
}
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class GuiFragmentManager method getGuiFragments.
@Override
public SearcherDaoPaginatedResult<GuiFragment> getGuiFragments(List<FieldSearchFilter> filters) throws ApsSystemException {
SearcherDaoPaginatedResult<GuiFragment> pagedResult = null;
try {
List<GuiFragment> fragments = new ArrayList<>();
FieldSearchFilter[] filtersArray = filters.toArray(new FieldSearchFilter[filters.size()]);
int count = this.getGuiFragmentDAO().countGuiFragments(filtersArray);
List<String> codes = this.searchGuiFragments(filtersArray);
for (String code : codes) {
fragments.add(this.getGuiFragment(code));
}
pagedResult = new SearcherDaoPaginatedResult<>(count, fragments);
} catch (Throwable t) {
logger.error("Error searching GuiFragments", t);
throw new ApsSystemException("Error searching GuiFragments", t);
}
return pagedResult;
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ActionLogDAO method getActivityStream.
@Override
public List<Integer> getActivityStream(List<String> userGroupCodes) {
Connection conn = null;
List<Integer> idList = new ArrayList<Integer>();
PreparedStatement stat = null;
ResultSet result = null;
try {
conn = this.getConnection();
FieldSearchFilter filter1 = new FieldSearchFilter("actiondate");
filter1.setOrder(FieldSearchFilter.DESC_ORDER);
FieldSearchFilter filter2 = new FieldSearchFilter("activitystreaminfo");
FieldSearchFilter[] filters = { filter1, filter2 };
List<String> groupCodes = (null != userGroupCodes && userGroupCodes.contains(Group.ADMINS_GROUP_NAME)) ? null : userGroupCodes;
stat = this.buildStatement(filters, groupCodes, conn);
result = stat.executeQuery();
while (result.next()) {
idList.add(result.getInt(1));
}
} catch (Throwable t) {
_logger.error("Error loading activity stream records", t);
throw new RuntimeException("Error loading activity stream records", t);
} finally {
closeDaoResources(result, stat, conn);
}
return idList;
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ActionLogManager method addActionRecordByThread.
protected synchronized void addActionRecordByThread(ActionLogRecord actionRecord) throws ApsSystemException {
try {
Integer key = null;
List<Integer> ids = null;
do {
key = this.getKeyGeneratorManager().getUniqueKeyCurrentValue();
FieldSearchFilter filter = new FieldSearchFilter("id", key, true);
FieldSearchFilter[] filters = { filter };
ids = this.getActionLogDAO().getActionRecords(filters);
} while (!ids.isEmpty());
actionRecord.setId(key);
actionRecord.setActionDate(new Date());
this.getActionLogDAO().addActionRecord(actionRecord);
} catch (Throwable t) {
_logger.error("Error adding an actionlogger record", t);
throw new ApsSystemException("Error adding an actionlogger record", t);
}
}
Aggregations