com.psddev.dari.db.Query.getGroup()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中com.psddev.dari.db.Query.getGroup方法的一些代码示例,展示了Query.getGroup的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getGroup方法的具体详情如下:
包路径:com.psddev.dari.db.Query
类名称:Query
方法名:getGroup

Query.getGroup介绍

[英]Returns the ObjectType#getGroups that identifies the types of objects to query.
[中]返回标识要查询的对象类型的ObjectType#getGroups。

代码示例

代码示例来源:origin: perfectsense/dari

  1. /** Returns {@code true} if this queries over all objects. */
  2. public boolean isFromAll() {
  3. return getGroup() == null;
  4. }

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Creates an absolute version of the predicate that can be embedded
  3. * in other queries.
  4. */
  5. public Predicate createAbsolutePredicate() {
  6. Predicate predicate = getPredicate();
  7. return predicate != null ? addPrefix(getGroup() + "/", predicate) : null;
  8. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public void deleteByQuery(Query<?> query) {
  3. String group = query.getGroup();
  4. write(
  5. group != null ? getEnvironment().getTypesByGroup(query.getGroup()) : null,
  6. delegate -> delegate.deleteByQuery(query));
  7. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> List<Grouping<T>> readAllGrouped(Query<T> query, String... fields) {
  3. return read(query.getGroup(), delegate -> delegate.readAllGrouped(query, fields));
  4. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> PaginatedResult<T> readPartial(Query<T> query, long offset, int limit) {
  3. return read(query.getGroup(), delegate -> delegate.readPartial(query, offset, limit));
  4. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> T readFirst(Query<T> query) {
  3. return read(query.getGroup(), delegate -> delegate.readFirst(query));
  4. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> Iterable<T> readIterable(Query<T> query, int fetchSize) {
  3. return read(query.getGroup(), delegate -> delegate.readIterable(query, fetchSize));
  4. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> PaginatedResult<Grouping<T>> readPartialGrouped(Query<T> query, long offset, int limit, String... fields) {
  3. return read(query.getGroup(), delegate -> delegate.readPartialGrouped(query, offset, limit, fields));
  4. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public Date readLastUpdate(Query<?> query) {
  3. return read(query.getGroup(), delegate -> delegate.readLastUpdate(query));
  4. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public long readCount(Query<?> query) {
  3. return read(query.getGroup(), delegate -> delegate.readCount(query));
  4. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> List<T> readAll(Query<T> query) {
  3. return read(query.getGroup(), delegate -> delegate.readAll(query));
  4. }

代码示例来源:origin: perfectsense/dari

  1. /** Builds MongoDB query based on the given {@code query}. */
  2. public DBObject buildMongoQuery(Query<?> query) {
  3. Predicate predicate = query.getPredicate();
  4. List<DBObject> mongoChildren = new ArrayList<DBObject>();
  5. if (predicate != null) {
  6. mongoChildren.add(buildMongoPredicate(query, predicate));
  7. }
  8. if (!query.isFromAll()) {
  9. Set<ObjectType> types = getEnvironment().getTypesByGroup(query.getGroup());
  10. List<String> typeIds = new ArrayList<String>();
  11. for (ObjectType type : types) {
  12. typeIds.add(type.getId().toString());
  13. }
  14. mongoChildren.add(new BasicDBObject(
  15. TYPE_ID_KEY, new BasicDBObject("$in", typeIds)));
  16. }
  17. return new BasicDBObject("$and", mongoChildren);
  18. }

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Returns an SQL statement that can be used to delete all rows
  3. * matching the query.
  4. */
  5. public String deleteStatement() {
  6. StringBuilder statementBuilder = new StringBuilder();
  7. initializeClauses();
  8. if (hasAnyDeferredMetricPredicates()) {
  9. throw new Query.NoFieldException(query.getGroup(), recordMetricField.getInternalName());
  10. }
  11. statementBuilder.append("DELETE r\nFROM ");
  12. vendor.appendIdentifier(statementBuilder, "Record");
  13. statementBuilder.append(' ');
  14. statementBuilder.append(aliasPrefix);
  15. statementBuilder.append('r');
  16. statementBuilder.append(fromClause);
  17. statementBuilder.append(whereClause);
  18. statementBuilder.append(havingClause);
  19. statementBuilder.append(orderByClause);
  20. return statementBuilder.toString();
  21. }

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Returns all types that belong to this query's group in the given
  3. * {@code environment}. If this query was initialized with an object
  4. * class, the types that don't have backing Java classes are excluded.
  5. *
  6. * @param environment Can't be {@code null}.
  7. * @return Never {@code null}.
  8. */
  9. public Set<ObjectType> getConcreteTypes(DatabaseEnvironment environment) {
  10. Set<ObjectType> types = environment.getTypesByGroup(getGroup());
  11. Class<?> queryObjectClass = getObjectClass();
  12. for (Iterator<ObjectType> i = types.iterator(); i.hasNext();) {
  13. ObjectType type = i.next();
  14. Class<?> typeObjectClass = type.getObjectClass();
  15. if (!type.isConcrete()) {
  16. i.remove();
  17. } else if (queryObjectClass != null
  18. && (typeObjectClass == null
  19. || !queryObjectClass.isAssignableFrom(typeObjectClass))) {
  20. i.remove();
  21. }
  22. }
  23. return types;
  24. }

代码示例来源:origin: perfectsense/dari

  1. codeBuilder.append(getGroup());
  2. codeBuilder.append("\")");

代码示例来源:origin: perfectsense/dari

  1. private <T> List<T> createReplicationCacheObjects(List<T> objects, UUID typeId, UUID id, byte[] data, Map<String, Object> dataJson, Query<T> query) {
  2. if (typeId != null && query != null) {
  3. ObjectType type = ObjectType.getInstance(typeId);
  4. if (type != null) {
  5. Class<?> queryObjectClass = query.getObjectClass();
  6. if (queryObjectClass != null && !query.getObjectClass().isAssignableFrom(type.getObjectClass())) {
  7. return objects;
  8. }
  9. String queryGroup = query.getGroup();
  10. if (queryGroup != null && !type.getGroups().contains(queryGroup)) {
  11. return objects;
  12. }
  13. }
  14. }
  15. T object = createSavedObjectFromReplicationCache(id, data, dataJson, query);
  16. if (object != null) {
  17. if (objects == null) {
  18. objects = new ArrayList<>();
  19. }
  20. objects.add(object);
  21. }
  22. return objects;
  23. }

代码示例来源:origin: perfectsense/dari

  1. private Query.MappedKey mapFullyDenormalizedKey(Query<?> query, String key) {
  2. Query.MappedKey mappedKey = query.mapDenormalizedKey(getEnvironment(), key);
  3. if (mappedKey.hasSubQuery()) {
  4. throw new Query.NoFieldException(query.getGroup(), key);
  5. } else {
  6. return mappedKey;
  7. }
  8. }

代码示例来源:origin: perfectsense/dari

  1. recordMetricField = sortField;
  2. } else if (!recordMetricField.equals(sortField)) {
  3. throw new Query.NoFieldException(query.getGroup(), recordMetricField.getInternalName() + " AND " + sortField.getInternalName());

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Returns the database to be used with the read methods.
  3. *
  4. * @return The {@linkplain Database.Static#getDefault default database}
  5. * if not previously set.
  6. */
  7. public Database getDatabase() {
  8. if (database == null) {
  9. Database defaultDatabase = Database.Static.getDefault();
  10. Database source = null;
  11. // Change the query database if it's only querying over a single
  12. // type that has a source database.
  13. GROUP_TYPE: for (ObjectType groupType : defaultDatabase.getEnvironment().getTypesByGroup(getGroup())) {
  14. for (ObjectType type : groupType.findConcreteTypes()) {
  15. Database typeSource = type.getSourceDatabase();
  16. if (typeSource == null) {
  17. source = null;
  18. break GROUP_TYPE;
  19. } else if (source == null) {
  20. source = typeSource;
  21. } else if (!source.equals(typeSource)) {
  22. source = null;
  23. break GROUP_TYPE;
  24. }
  25. }
  26. }
  27. database = source != null ? source : defaultDatabase;
  28. }
  29. return database;
  30. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public int hashCode() {
  3. return ObjectUtils.hashCode(
  4. getGroup(),
  5. getObjectClass(),
  6. getPredicate(),
  7. getSorters(),
  8. getDatabase(),
  9. getFields(),
  10. getOptions(),
  11. isResolveToReferenceOnly(),
  12. getTimeout());
  13. }

相关文章