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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/** Builds MongoDB query based on the given {@code query}. */
public DBObject buildMongoQuery(Query<?> query) {
  Predicate predicate = query.getPredicate();
  List<DBObject> mongoChildren = new ArrayList<DBObject>();
  if (predicate != null) {
    mongoChildren.add(buildMongoPredicate(query, predicate));
  }
  if (!query.isFromAll()) {
    Set<ObjectType> types = getEnvironment().getTypesByGroup(query.getGroup());
    List<String> typeIds = new ArrayList<String>();
    for (ObjectType type : types) {
      typeIds.add(type.getId().toString());
    }
    mongoChildren.add(new BasicDBObject(
        TYPE_ID_KEY, new BasicDBObject("$in", typeIds)));
  }
  return new BasicDBObject("$and", mongoChildren);
}

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

/**
 * Returns an SQL statement that can be used to delete all rows
 * matching the query.
 */
public String deleteStatement() {
  StringBuilder statementBuilder = new StringBuilder();
  initializeClauses();
  if (hasAnyDeferredMetricPredicates()) {
    throw new Query.NoFieldException(query.getGroup(), recordMetricField.getInternalName());
  }
  statementBuilder.append("DELETE r\nFROM ");
  vendor.appendIdentifier(statementBuilder, "Record");
  statementBuilder.append(' ');
  statementBuilder.append(aliasPrefix);
  statementBuilder.append('r');
  statementBuilder.append(fromClause);
  statementBuilder.append(whereClause);
  statementBuilder.append(havingClause);
  statementBuilder.append(orderByClause);
  return statementBuilder.toString();
}

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

/**
 * Returns all types that belong to this query's group in the given
 * {@code environment}. If this query was initialized with an object
 * class, the types that don't have backing Java classes are excluded.
 *
 * @param environment Can't be {@code null}.
 * @return Never {@code null}.
 */
public Set<ObjectType> getConcreteTypes(DatabaseEnvironment environment) {
  Set<ObjectType> types = environment.getTypesByGroup(getGroup());
  Class<?> queryObjectClass = getObjectClass();
  for (Iterator<ObjectType> i = types.iterator(); i.hasNext();) {
    ObjectType type = i.next();
    Class<?> typeObjectClass = type.getObjectClass();
    if (!type.isConcrete()) {
      i.remove();
    } else if (queryObjectClass != null
        && (typeObjectClass == null
        || !queryObjectClass.isAssignableFrom(typeObjectClass))) {
      i.remove();
    }
  }
  return types;
}

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

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

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

private <T> List<T> createReplicationCacheObjects(List<T> objects, UUID typeId, UUID id, byte[] data, Map<String, Object> dataJson, Query<T> query) {
  if (typeId != null && query != null) {
    ObjectType type = ObjectType.getInstance(typeId);
    if (type != null) {
      Class<?> queryObjectClass = query.getObjectClass();
      if (queryObjectClass != null && !query.getObjectClass().isAssignableFrom(type.getObjectClass())) {
        return objects;
      }
      String queryGroup = query.getGroup();
      if (queryGroup != null && !type.getGroups().contains(queryGroup)) {
        return objects;
      }
    }
  }
  T object = createSavedObjectFromReplicationCache(id, data, dataJson, query);
  if (object != null) {
    if (objects == null) {
      objects = new ArrayList<>();
    }
    objects.add(object);
  }
  return objects;
}

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

private Query.MappedKey mapFullyDenormalizedKey(Query<?> query, String key) {
  Query.MappedKey mappedKey = query.mapDenormalizedKey(getEnvironment(), key);
  if (mappedKey.hasSubQuery()) {
    throw new Query.NoFieldException(query.getGroup(), key);
  } else {
    return mappedKey;
  }
}

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

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

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

/**
 * Returns the database to be used with the read methods.
 *
 * @return The {@linkplain Database.Static#getDefault default database}
 * if not previously set.
 */
public Database getDatabase() {
  if (database == null) {
    Database defaultDatabase = Database.Static.getDefault();
    Database source = null;
    // Change the query database if it's only querying over a single
    // type that has a source database.
    GROUP_TYPE: for (ObjectType groupType : defaultDatabase.getEnvironment().getTypesByGroup(getGroup())) {
      for (ObjectType type : groupType.findConcreteTypes()) {
        Database typeSource = type.getSourceDatabase();
        if (typeSource == null) {
          source = null;
          break GROUP_TYPE;
        } else if (source == null) {
          source = typeSource;
        } else if (!source.equals(typeSource)) {
          source = null;
          break GROUP_TYPE;
        }
      }
    }
    database = source != null ? source : defaultDatabase;
  }
  return database;
}

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

@Override
public int hashCode() {
  return ObjectUtils.hashCode(
      getGroup(),
      getObjectClass(),
      getPredicate(),
      getSorters(),
      getDatabase(),
      getFields(),
      getOptions(),
      isResolveToReferenceOnly(),
      getTimeout());
}

相关文章