本文整理了Java中org.opencb.commons.datastore.core.QueryParam
类的一些代码示例,展示了QueryParam
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryParam
类的具体详情如下:
包路径:org.opencb.commons.datastore.core.QueryParam
类名称:QueryParam
暂无
代码示例来源:origin: opencb/opencga
protected static void addParam(ObjectMap query, QueryParam key, Collection value) {
if (CollectionUtils.isNotEmpty(value)) {
query.put(key.key(), value);
}
}
代码示例来源:origin: org.opencb.commons/commons-datastore-core
Objects.requireNonNull(enumType);
Map<String, E> enumFields = Arrays.asList(enumType.getEnumConstants()).stream().collect(
Collectors.toMap(queryParam -> queryParam.key(), Function.<E>identity()));
for (Map.Entry<String, Object> entry : entrySet()) {
if (!enumFields.containsKey(entry.getKey())) {
} else {
QueryParam queryParam = enumFields.get(entry.getKey());
switch (queryParam.type()) {
case TEXT:
put(queryParam.key(), getString(queryParam.key()));
break;
case TEXT_ARRAY:
put(queryParam.key(), getAsStringList(queryParam.key()));
break;
case INTEGER:
case LONG:
put(queryParam.key(), getLong(queryParam.key()));
break;
case INTEGER_ARRAY:
case LONG_ARRAY:
put(queryParam.key(), getAsLongList(queryParam.key()));
break;
case DECIMAL:
put(queryParam.key(), getDouble(queryParam.key()));
break;
case DECIMAL_ARRAY:
put(queryParam.key(), getAsDoubleList(queryParam.key()));
break;
代码示例来源:origin: opencb/opencga
public static VariantQueryException malformedParam(QueryParam queryParam, String value) {
return malformedParam(queryParam, value, "Expected: " + queryParam.description());
}
代码示例来源:origin: opencb/opencga
static List<Document> addCompQueryFilter(QueryParam option, String optionKey, String queryKey,
ObjectMap options, List<Document> andQuery) throws CatalogDBException {
List<String> optionsList = options.getAsStringList(optionKey);
if (queryKey == null) {
queryKey = "";
}
return addCompQueryFilter(option.type(), queryKey, optionsList, andQuery);
}
代码示例来源:origin: opencb/opencga
protected static void addParam(ObjectMap query, QueryParam key, boolean value) {
if (value) {
query.put(key.key(), true);
}
}
代码示例来源:origin: opencb/opencga
public static VariantQueryException unsupportedVariantQueryFilter(QueryParam param, String storageEngineId, String extra) {
return new VariantQueryException("Unsupported variant query filter '" + param.key()
+ "' with storage engine '" + storageEngineId + "'."
+ (StringUtils.isEmpty(extra) ? "" : (' ' + extra)));
}
代码示例来源:origin: opencb/opencga
public static VariantQueryException missingParam(QueryParam queryParam, String message) {
return new VariantQueryException("Missing param \"" + queryParam.key() + "\" . "
+ message);
}
代码示例来源:origin: opencb/opencga
public static VariantQueryException malformedParam(QueryParam queryParam, String value, String message) {
return new VariantQueryException("Malformed \"" + queryParam.key() + "\" query : \"" + value + "\". "
+ message);
}
代码示例来源:origin: opencb/opencga
protected static void addParam(ObjectMap query, QueryParam key, String value) {
query.putIfNotEmpty(key.key(), value);
}
代码示例来源:origin: opencb/opencga
public static Query getVariantQuery(Map<String, ?> queryOptions) {
Query query = new Query();
for (VariantQueryParam queryParams : VariantQueryParam.values()) {
if (queryOptions.containsKey(queryParams.key())) {
query.put(queryParams.key(), queryOptions.get(queryParams.key()));
}
}
if (queryOptions.containsKey(VariantCatalogQueryUtils.SAMPLE_ANNOTATION.key())) {
query.put(VariantCatalogQueryUtils.SAMPLE_ANNOTATION.key(), queryOptions.get(VariantCatalogQueryUtils.SAMPLE_ANNOTATION.key()));
}
if (queryOptions.containsKey(VariantCatalogQueryUtils.PROJECT.key())) {
query.put(VariantCatalogQueryUtils.PROJECT.key(), queryOptions.get(VariantCatalogQueryUtils.PROJECT.key()));
}
if (queryOptions.containsKey(VariantCatalogQueryUtils.FAMILY.key())) {
query.put(VariantCatalogQueryUtils.FAMILY.key(), queryOptions.get(VariantCatalogQueryUtils.FAMILY.key()));
}
if (queryOptions.containsKey(VariantCatalogQueryUtils.FAMILY_PHENOTYPE.key())) {
query.put(VariantCatalogQueryUtils.FAMILY_PHENOTYPE.key(), queryOptions.get(VariantCatalogQueryUtils.FAMILY_PHENOTYPE.key()));
}
if (queryOptions.containsKey(VariantCatalogQueryUtils.MODE_OF_INHERITANCE.key())) {
query.put(VariantCatalogQueryUtils.MODE_OF_INHERITANCE.key(),
queryOptions.get(VariantCatalogQueryUtils.MODE_OF_INHERITANCE.key()));
}
if (queryOptions.containsKey(VariantCatalogQueryUtils.PANEL.key())) {
query.put(VariantCatalogQueryUtils.PANEL.key(), queryOptions.get(VariantCatalogQueryUtils.PANEL.key()));
}
return query;
}
代码示例来源:origin: opencb/opencga
/**
* Check if the object query contains the value param, is not null and, if is an string or a list, is not empty.
* <p>
* isValidParam(new Query(), PARAM) == false
* isValidParam(new Query(PARAM.key(), null), PARAM) == false
* isValidParam(new Query(PARAM.key(), ""), PARAM) == false
* isValidParam(new Query(PARAM.key(), Collections.emptyList()), PARAM) == false
* isValidParam(new Query(PARAM.key(), 5), PARAM) == true
* isValidParam(new Query(PARAM.key(), "sdfas"), PARAM) == true
*
* @param query Query to parse
* @param param QueryParam to check
* @return If is valid or not
*/
public static boolean isValidParam(Query query, QueryParam param) {
Object value = query == null ? null : query.getOrDefault(param.key(), null);
return (value != null)
&& !(value instanceof String && ((String) value).isEmpty()
|| value instanceof Collection && ((Collection) value).isEmpty());
}
代码示例来源:origin: opencb/opencga
public static boolean isSupportedQueryParam(Query query, QueryParam param) {
return isSupportedQuery(new Query(param.key(), query.get(param.key())));
}
代码示例来源:origin: opencb/opencga
protected VariantDBIterator getVariantsToIndex(boolean overwrite, Query query, QueryOptions queryOptions, VariantDBAdaptor dbAdaptor)
throws StorageEngineException {
if (!overwrite) {
query.put(VariantQueryUtils.VARIANTS_TO_INDEX.key(), true);
}
return dbAdaptor.iterator(query, queryOptions);
}
代码示例来源:origin: opencb/opencga
@Override
protected VariantDBIterator getVariantsToIndex(boolean overwrite, Query query, QueryOptions queryOptions, VariantDBAdaptor dbAdaptor)
throws StorageEngineException {
if (!overwrite) {
query.put(VariantQueryUtils.VARIANTS_TO_INDEX.key(), true);
logger.info("Column intersect!");
// queryOptions.put("multiIteratorBatchSize", 1000);
return (VariantDBIterator) getOrIteratorHBaseColumnIntersect(query, queryOptions, true);
} else {
logger.info("Get variants to index");
return super.getVariantsToIndex(overwrite, query, queryOptions, dbAdaptor);
}
}
代码示例来源:origin: opencb/opencga
public static boolean isValidParam(Query query, QueryParam param, boolean discardNegated) {
boolean validParam = isValidParam(query, param);
if (!discardNegated || !validParam) {
return validParam;
} else {
String strValue = query.getString(param.key());
return splitValue(strValue, checkOperator(strValue))
.stream()
.anyMatch((v) -> !isNegated(v)); // Discard negated
}
}
代码示例来源:origin: opencb/opencga
public static void convertGenesToRegionsQuery(Query query, CellBaseUtils cellBaseUtils) {
VariantQueryXref variantQueryXref = VariantQueryUtils.parseXrefs(query);
List<String> genes = variantQueryXref.getGenes();
if (!genes.isEmpty()) {
List<Region> regions = cellBaseUtils.getGeneRegion(genes);
regions = mergeRegions(regions);
query.put(ANNOT_GENE_REGIONS.key(), regions);
}
}
代码示例来源:origin: opencb/opencga
private List<Region> getRegions(Query query) {
List<Region> regions = new ArrayList<>();
if (isValidParam(query, REGION)) {
regions.addAll(Region.parseRegions(query.getString(REGION.key())));
}
if (isValidParam(query, ANNOT_GENE_REGIONS)) {
regions.addAll(Region.parseRegions(query.getString(ANNOT_GENE_REGIONS.key())));
}
regions = mergeRegions(regions);
return regions;
}
代码示例来源:origin: opencb/opencga
public QueryResult<ProjectMetadata.VariantAnnotationMetadata> getAnnotationMetadata(String name, String project, String sessionId)
throws StorageEngineException, CatalogException, IOException {
Query query = new Query(VariantCatalogQueryUtils.PROJECT.key(), project);
return secure(query, empty(), sessionId, (engine) -> engine.getAnnotationMetadata(name));
}
代码示例来源:origin: opencb/opencga
public static void convertExpressionToGeneQuery(Query query, CellBaseUtils cellBaseUtils) {
if (isValidParam(query, VariantQueryParam.ANNOT_EXPRESSION)) {
String value = query.getString(VariantQueryParam.ANNOT_EXPRESSION.key());
// Check if comma separated of semi colon separated (AND or OR)
VariantQueryUtils.QueryOperation queryOperation = checkOperator(value);
// Split by comma or semi colon
List<String> expressionValues = splitValue(value, queryOperation);
if (queryOperation == VariantQueryUtils.QueryOperation.AND) {
throw VariantQueryException.malformedParam(VariantQueryParam.ANNOT_EXPRESSION, value, "Unimplemented AND operator");
}
// query.remove(VariantQueryParam.ANNOT_EXPRESSION.key());
Set<String> genesByExpression = cellBaseUtils.getGenesByExpression(expressionValues);
if (genesByExpression.isEmpty()) {
genesByExpression = Collections.singleton(NONE);
}
query.put(ANNOT_EXPRESSION_GENES.key(), genesByExpression);
}
}
代码示例来源:origin: opencb/opencga
public static void convertGoToGeneQuery(Query query, CellBaseUtils cellBaseUtils) {
if (isValidParam(query, VariantQueryParam.ANNOT_GO)) {
String value = query.getString(VariantQueryParam.ANNOT_GO.key());
// Check if comma separated of semi colon separated (AND or OR)
VariantQueryUtils.QueryOperation queryOperation = checkOperator(value);
// Split by comma or semi colon
List<String> goValues = splitValue(value, queryOperation);
if (queryOperation == VariantQueryUtils.QueryOperation.AND) {
throw VariantQueryException.malformedParam(VariantQueryParam.ANNOT_GO, value, "Unimplemented AND operator");
}
// query.remove(VariantQueryParam.ANNOT_GO.key());
Set<String> genesByGo = cellBaseUtils.getGenesByGo(goValues);
if (genesByGo.isEmpty()) {
genesByGo = Collections.singleton(NONE);
}
query.put(ANNOT_GO_GENES.key(), genesByGo);
}
}
内容来源于网络,如有侵权,请联系作者删除!