本文整理汇总了Java中ch.ralscha.extdirectspring.bean.ExtDirectStoreResult类的典型用法代码示例。如果您正苦于以下问题:Java ExtDirectStoreResult类的具体用法?Java ExtDirectStoreResult怎么用?Java ExtDirectStoreResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExtDirectStoreResult类属于ch.ralscha.extdirectspring.bean包,在下文中一共展示了ExtDirectStoreResult类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
@Transactional(readOnly = true)
public ExtDirectStoreResult<User> read(ExtDirectStoreReadRequest request) {
JPQLQuery<User> query = this.jpaQueryFactory.selectFrom(QUser.user);
if (!request.getFilters().isEmpty()) {
StringFilter filter = (StringFilter) request.getFilters().iterator().next();
BooleanBuilder bb = new BooleanBuilder();
bb.or(QUser.user.loginName.containsIgnoreCase(filter.getValue()));
bb.or(QUser.user.lastName.containsIgnoreCase(filter.getValue()));
bb.or(QUser.user.firstName.containsIgnoreCase(filter.getValue()));
bb.or(QUser.user.email.containsIgnoreCase(filter.getValue()));
query.where(bb);
}
query.where(QUser.user.deleted.isFalse());
QuerydslUtil.addPagingAndSorting(query, request, User.class, QUser.user);
QueryResults<User> searchResult = query.fetchResults();
return new ExtDirectStoreResult<>(searchResult.getTotal(),
searchResult.getResults());
}
示例2: read
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
public ExtDirectStoreResult<User> read(ExtDirectStoreReadRequest readRequest) {
StringFilter nameFilter = readRequest.getFirstFilterForField("name");
StringFilter departmentFilter = readRequest.getFirstFilterForField("department");
String name = null;
if (nameFilter != null) {
name = nameFilter.getValue();
}
String department = null;
if (departmentFilter != null) {
department = departmentFilter.getValue();
}
Page<User> pageResult;
Pageable pageRequest = RepositoryUtil.createPageable(readRequest);
if (StringUtils.hasText(name) && !StringUtils.hasText(department)) {
pageResult = this.userRepository
.findByFirstNameStartsWithIgnoreCaseOrLastNameStartsWithIgnoreCaseOrEmailStartsWithIgnoreCase(
name, name, name, pageRequest);
}
else if (!StringUtils.hasText(name) && StringUtils.hasText(department)) {
pageResult = this.userRepository.findByDepartment(department, pageRequest);
}
else if (StringUtils.hasText(name) && StringUtils.hasText(department)) {
pageResult = this.userRepository.findByNameAndDepartment("^" + name,
department, pageRequest);
}
else {
pageResult = this.userRepository.findAll(pageRequest);
}
return new ExtDirectStoreResult<>(pageResult.getTotalElements(),
pageResult.getContent());
}
示例3: read
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
public ExtDirectStoreResult<User> read(ExtDirectStoreReadRequest readRequest) {
StringFilter nameFilter = readRequest.getFirstFilterForField("name");
StringFilter departmentFilter = readRequest.getFirstFilterForField("department");
String name = null;
if (nameFilter != null) {
name = nameFilter.getValue();
}
String department = null;
if (departmentFilter != null) {
department = departmentFilter.getValue();
}
Page<User> pageResult;
Pageable pageRequest = RepositoryUtil.createPageable(readRequest);
if (StringUtils.hasText(name) && !StringUtils.hasText(department)) {
pageResult = this.userRepository
.findByFirstNameStartsWithIgnoreCaseOrLastNameStartsWithIgnoreCaseOrEmailStartsWithIgnoreCase(
name, name, name, pageRequest);
}
else if (!StringUtils.hasText(name) && StringUtils.hasText(department)) {
pageResult = this.userRepository.findByDepartment(department, pageRequest);
}
else if (StringUtils.hasText(name) && StringUtils.hasText(department)) {
pageResult = this.userRepository.findByNameAndDepartment(name + "%",
department, pageRequest);
}
else {
pageResult = this.userRepository.findAll(pageRequest);
}
return new ExtDirectStoreResult<>(pageResult.getTotalElements(),
pageResult.getContent());
}
示例4: readSettings
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
@Transactional(readOnly = true)
public ExtDirectStoreResult<UserSettings> readSettings(
@AuthenticationPrincipal JpaUserDetails jpaUserDetails) {
UserSettings userSettings = new UserSettings(
jpaUserDetails.getUser(this.jpaQueryFactory));
return new ExtDirectStoreResult<>(userSettings);
}
示例5: destroy
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_MODIFY)
@Transactional
public ExtDirectStoreResult<User> destroy(User destroyUser) {
ExtDirectStoreResult<User> result = new ExtDirectStoreResult<>();
if (!isLastAdmin(destroyUser.getId())) {
User user = this.jpaQueryFactory.getEntityManager().find(User.class,
destroyUser.getId());
this.jpaQueryFactory.getEntityManager().remove(user);
result.setSuccess(Boolean.TRUE);
}
else {
result.setSuccess(Boolean.FALSE);
}
return result;
}
示例6: destroy
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_MODIFY)
@Transactional
public ExtDirectStoreResult<T> destroy(Long id) {
T dbEntity = this.entityManager.find(getTypeClass(), id);
this.entityManager.remove(dbEntity);
ExtDirectStoreResult<T> result = new ExtDirectStoreResult<>();
result.setSuccess(Boolean.TRUE);
return result;
}
示例7: read
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
public ExtDirectStoreResult<User> read(ExtDirectStoreReadRequest request) {
List<Bson> andFilters = new ArrayList<>();
StringFilter filter = request.getFirstFilterForField("filter");
if (filter != null) {
List<Bson> orFilters = new ArrayList<>();
orFilters.add(Filters.regex(CUser.loginName, filter.getValue(), "i"));
orFilters.add(Filters.regex(CUser.lastName, filter.getValue(), "i"));
orFilters.add(Filters.regex(CUser.firstName, filter.getValue(), "i"));
orFilters.add(Filters.regex(CUser.email, filter.getValue(), "i"));
andFilters.add(Filters.or(orFilters));
}
andFilters.add(Filters.eq(CUser.deleted, false));
long total = this.mongoDb.getCollection(User.class)
.count(Filters.and(andFilters));
FindIterable<User> find = this.mongoDb.getCollection(User.class)
.find(Filters.and(andFilters));
find.sort(Sorts.orderBy(QueryUtil.getSorts(request)));
find.skip(request.getStart());
find.limit(request.getLimit());
return new ExtDirectStoreResult<>(total, QueryUtil.toList(find));
}
示例8: destroy
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_MODIFY)
public ExtDirectStoreResult<User> destroy(User destroyUser) {
ExtDirectStoreResult<User> result = new ExtDirectStoreResult<>();
if (!isLastAdmin(destroyUser.getId())) {
this.mongoDb.getCollection(User.class)
.deleteOne(Filters.eq(CUser.id, destroyUser.getId()));
result.setSuccess(Boolean.TRUE);
deletePersistentLogins(destroyUser.getId());
}
else {
result.setSuccess(Boolean.FALSE);
}
return result;
}
示例9: read
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
public ExtDirectStoreResult<Customer> read(ExtDirectStoreReadRequest readRequest) {
Filter nameFilter = readRequest.getFirstFilterForField("name");
Filter categoryFilter = readRequest.getFirstFilterForField("category");
String name = null;
String category = null;
if (nameFilter != null) {
name = ((StringFilter) nameFilter).getValue();
}
if (categoryFilter != null) {
category = ((StringFilter) categoryFilter).getValue();
}
BooleanBuilder bb = new BooleanBuilder();
if (name != null && StringUtils.hasText(name)) {
bb.and(QCustomer.customer.firstName.containsIgnoreCase(name)
.or(QCustomer.customer.lastName.containsIgnoreCase(name)));
}
if (category != null && StringUtils.hasText(category) && !"All".equals(category)) {
bb.and(QCustomer.customer.category.eq(Category.valueOf(category)));
}
Pageable pageable = RepositoryUtil.createPageable(readRequest);
Page<Customer> page = this.customerRepository.findAll(bb, pageable);
return new ExtDirectStoreResult<>(page.getTotalElements(), page.getContent());
}
示例10: create
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_MODIFY)
public ExtDirectStoreResult<User> create(User newUser) {
newUser.setId(null);
User insertedUser = this.userRepository.save(newUser);
return new ExtDirectStoreResult<>(insertedUser);
}
示例11: update
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_MODIFY)
public ExtDirectStoreResult<User> update(User changedUser) {
User updatedUser = this.userRepository.save(changedUser);
return new ExtDirectStoreResult<>(updatedUser);
}
示例12: create
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_MODIFY)
public ExtDirectStoreResult<User> create(User newUser) {
User insertedUser = this.userRepository.save(newUser);
return new ExtDirectStoreResult<>(insertedUser);
}
示例13: read
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
@Transactional(readOnly = true)
public ExtDirectStoreResult<T> read(ExtDirectStoreReadRequest request) {
PathBuilder<T> pathBuilder = createPathBuilder();
JPQLQuery query = new JPAQuery(this.entityManager).from(pathBuilder);
addPagingAndSorting(request, query, pathBuilder);
if (!request.getFilters().isEmpty()) {
for (Filter filter : request.getFilters()) {
if (filter instanceof NumericFilter) {
NumericFilter nf = (NumericFilter) filter;
int pointPos = nf.getField().indexOf('.');
if (pointPos == -1) {
query.where(pathBuilder.get(nf.getField(), Long.class).eq(
nf.getValue().longValue()));
}
else {
String property = nf.getField().substring(0, pointPos);
String field = nf.getField().substring(pointPos + 1);
query.where(pathBuilder.get(property).get(field, Long.class)
.eq(nf.getValue().longValue()));
}
}
else if (filter instanceof StringFilter && filter.getField().equals("id")) {
String value = ((StringFilter) filter).getValue();
try {
List<Long> ids = this.objectMapper.readValue(value,
new TypeReference<List<Long>>() {
// nothing here
});
query.where(pathBuilder.get(filter.getField(), Long.class)
.in(ids));
}
catch (IOException e) {
// ignore this for now
e.printStackTrace();
}
}
}
}
SearchResults<T> result = query.listResults(pathBuilder);
return new ExtDirectStoreResult<>(result.getTotal(), result.getResults());
}
示例14: readSettings
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResult; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
public ExtDirectStoreResult<UserSettings> readSettings(
@AuthenticationPrincipal MongoUserDetails userDetails) {
UserSettings userSettings = new UserSettings(userDetails.getUser(this.mongoDb));
return new ExtDirectStoreResult<>(userSettings);
}