com.hortonworks.registries.common.QueryParam类的使用及代码示例

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

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

QueryParam介绍

暂无

代码示例

代码示例来源:origin: hortonworks/streamline

public static List<QueryParam> currentVersionQueryParam() {
  return Collections.singletonList(new QueryParam(NAME, CURRENT_VERSION));
}

代码示例来源:origin: hortonworks/streamline

public static List<QueryParam> buildEdgesFromQueryParam(Long topologyId,
                            Long versionId,
                            Long componentId) {
  return QueryParam.params(
      TOPOLOGY_ID, topologyId.toString(),
      VERSION_ID, versionId.toString(),
      FROM_ID, componentId.toString()
  );
}

代码示例来源:origin: com.hortonworks.registries/storage-core

/**
 * Uses reflection to query the field or the method. Assumes
 * a public getXXX method is available to get the field value.
 */
private boolean matches(Storable val, List<QueryParam> queryParams, Class<?> clazz) {
  Object fieldValue;
  boolean res = true;
    for (QueryParam qp : queryParams) {
      try {
        fieldValue = ReflectionHelper.invokeGetter(qp.name, val);
        if (!fieldValue.toString().equals(qp.value)) {
          return false;
        }
      } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
        LOG.error("FAILED to invoke getter for query param {} , is your param name correct?", qp.getName(), e);
        return false;
      }
    }
  return res;
}

代码示例来源:origin: hortonworks/streamline

for (Rule rule : rulesProcessor.getRules()) {
  for (Udf udf : rule.getReferredUdfs()) {
    List<QueryParam> qps = QueryParam.params(UDF.NAME, udf.getName());
      qps.add(new QueryParam(UDF.CLASSNAME, udf.getClassName()));
      qps.add(new QueryParam(UDF.TYPE, udf.getType().toString()));

代码示例来源:origin: hortonworks/streamline

private Collection<TopologyComponentBundle> listCustomProcessorBundlesWithFilter(List<QueryParam> params) throws IOException {
  List<QueryParam> queryParamsForTopologyComponent = new ArrayList<>();
  queryParamsForTopologyComponent.add(new QueryParam(TopologyComponentBundle.SUB_TYPE, TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_SUB_TYPE));
  for (QueryParam qp : params) {
    if (qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE)) {
      queryParamsForTopologyComponent.add(qp);
    }
  }
  Collection<TopologyComponentBundle> customProcessors = this.listTopologyComponentBundlesForTypeWithFilter(TopologyComponentBundle.TopologyComponentType
      .PROCESSOR, queryParamsForTopologyComponent);
  Collection<TopologyComponentBundle> result = new ArrayList<>();
  for (TopologyComponentBundle cp : customProcessors) {
    Map<String, Object> config = new HashMap<>();
    for (ComponentUISpecification.UIField uiField: cp.getTopologyComponentUISpecification().getFields()) {
      config.put(uiField.getFieldName(), uiField.getDefaultValue());
    }
    boolean matches = true;
    for (QueryParam qp : params) {
      if (!qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE) && !qp.getValue().equals(config.get(qp.getName()))) {
        matches = false;
        break;
      }
    }
    if (matches) {
      result.add(cp);
    }
  }
  return result;
}

代码示例来源:origin: hortonworks/registry

private List<OrderByField> getOrderByFields(List<QueryParam> queryParams) {
  if (queryParams == null || queryParams.isEmpty()) {
    return Collections.emptyList();
  }
  List<OrderByField> orderByFields = new ArrayList<>();
  for (QueryParam queryParam : queryParams) {
    if (ORDER_BY_FIELDS_PARAM_NAME.equals(queryParam.getName())) {
      // _orderByFields=[<field-name>,<a/d>,]*
      // example can be : _orderByFields=foo,a,bar,d
      // order by foo with ascending then bar with descending
      String value = queryParam.getValue();
      String[] splitStrings = value.split(",");
      for (int i = 0; i < splitStrings.length; i += 2) {
        String ascStr = splitStrings[i + 1];
        boolean descending;
        if ("a".equals(ascStr)) {
          descending = false;
        } else if ("d".equals(ascStr)) {
          descending = true;
        } else {
          throw new IllegalArgumentException("Ascending or Descending identifier can only be 'a' or 'd' respectively.");
        }
        orderByFields.add(OrderByField.of(splitStrings[i], descending));
      }
    }
  }
  return orderByFields;
}

代码示例来源:origin: hortonworks/registry

Columns columns = queryExecutor.getColumns(namespace);
for (QueryParam qp : queryParams) {
  Schema.Type type = columns.getType(qp.getName());
  if (type == null) {
    log.warn("Query parameter [{}] does not exist for namespace [{}]. Query parameter ignored.", qp.getName(), namespace);
  } else {
    fieldsToVal.put(new Schema.Field(qp.getName(), type),
        type.getJavaType().getConstructor(String.class).newInstance(qp.getValue()));

代码示例来源:origin: com.hortonworks.registries/common

public static List<QueryParam> params(String... args) {
    List<QueryParam> queryParams = new ArrayList<>();
    if (args.length % 2 != 0) {
      throw new IllegalArgumentException("Expects even number of arguments");
    }
    for (int i = 0; i < args.length; i += 2) {
      queryParams.add(new QueryParam(args[i], args[i + 1]));
    }
    return queryParams;
  }
}

代码示例来源:origin: hortonworks/streamline

public static List<QueryParam> buildEdgesToQueryParam(Long topologyId,
                            Long versionId,
                            Long componentId) {
  return QueryParam.params(
      TOPOLOGY_ID, topologyId.toString(),
      VERSION_ID, versionId.toString(),
      TO_ID, componentId.toString()
  );
}

代码示例来源:origin: com.hortonworks.registries/storage-core

CaseAgnosticStringSet columnNames = queryExecutor.getColumnNames(namespace);
for (QueryParam qp : queryParams) {
  if (!columnNames.contains(qp.getName())) {
    log.warn("Query parameter [{}] does not exist for namespace [{}]. Query parameter ignored.", qp.getName(), namespace);
  } else {
    final String val = qp.getValue();
    final Schema.Type typeOfVal = Schema.Type.getTypeOfVal(val);
    fieldsToVal.put(new Schema.Field(qp.getName(), typeOfVal),
        typeOfVal.getJavaType().getConstructor(String.class).newInstance(val)); // instantiates object of the appropriate type

代码示例来源:origin: hortonworks/registry

/**
 * Uses reflection to query the field or the method. Assumes
 * a public getXXX method is available to get the field value.
 */
private boolean matches(Storable val, List<QueryParam> queryParams, Class<?> clazz) {
  Object fieldValue;
  boolean res = true;
    for (QueryParam qp : queryParams) {
      try {
        fieldValue = ReflectionHelper.invokeGetter(qp.name, val);
        if (!fieldValue.toString().equals(qp.value)) {
          return false;
        }
      } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
        LOG.error("FAILED to invoke getter for query param {} , is your param name correct?", qp.getName(), e);
        return false;
      }
    }
  return res;
}

代码示例来源:origin: hortonworks/registry

public static List<QueryParam> params(String... args) {
    List<QueryParam> queryParams = new ArrayList<>();
    if (args.length % 2 != 0) {
      throw new IllegalArgumentException("Expects even number of arguments");
    }
    for (int i = 0; i < args.length; i += 2) {
      queryParams.add(new QueryParam(args[i], args[i + 1]));
    }
    return queryParams;
  }
}

代码示例来源:origin: hortonworks/streamline

public Optional<Role> getRole(String roleName) {
  List<QueryParam> qps = QueryParam.params(Role.NAME, String.valueOf(roleName));
  Collection<Role> roles = listRoles(qps);
  return roles.isEmpty() ? Optional.empty() : Optional.of(roles.iterator().next());
}

代码示例来源:origin: hortonworks/streamline

public static List<QueryParam> versionIdQueryParam(Long version) {
  return Collections.singletonList(new QueryParam(VERSION_ID, version.toString()));
}

代码示例来源:origin: hortonworks/streamline

public Optional<TopologyEditorToolbar> getTopologyEditorToolbar(long userId) {
  List<QueryParam> qps = QueryParam.params(TopologyEditorToolbar.USER_ID, String.valueOf(userId));
  Collection<TopologyEditorToolbar> res = listTopologyEditorToolbar(qps);
  return res.isEmpty() ? Optional.empty() : Optional.ofNullable(res.iterator().next());
}

代码示例来源:origin: com.hortonworks.registries/registry-common

public static List<QueryParam> params(String... args) {
    List<QueryParam> queryParams = new ArrayList<>();
    if (args.length % 2 != 0) {
      throw new IllegalArgumentException("Expects even number of arguments");
    }
    for (int i = 0; i < args.length; i += 2) {
      queryParams.add(new QueryParam(args[i], args[i + 1]));
    }
    return queryParams;
  }
}

代码示例来源:origin: hortonworks/streamline

public User getUser(String name) {
  List<QueryParam> qps = QueryParam.params(User.NAME, name);
  Collection<User> users = listUsers(qps);
  if (users.size() == 1) {
    return fillRoles(users.iterator().next());
  }
  return null;
}

代码示例来源:origin: hortonworks/streamline

public Collection<NamespaceServiceClusterMap> listServiceClusterMapping(Long namespaceId, String serviceName) {
  return this.dao.find(NAMESPACE_SERVICE_CLUSTER_MAPPING_NAMESPACE,
      Lists.newArrayList(new QueryParam("namespaceId", namespaceId.toString()),
          new QueryParam("serviceName", serviceName)));
}

代码示例来源:origin: hortonworks/streamline

public Collection<AclEntry> listUserAcls(Long userId, String targetEntityNamespace, Long targetEntityId) {
  List<QueryParam> qps = QueryParam.params(AclEntry.SID_ID, userId.toString(),
      AclEntry.SID_TYPE, AclEntry.SidType.USER.toString(),
      AclEntry.OBJECT_NAMESPACE, targetEntityNamespace,
      AclEntry.OBJECT_ID, targetEntityId.toString());
  return listAcls(qps);
}

代码示例来源:origin: hortonworks/streamline

public Collection<TopologyTestRunCase> listTopologyTestRunCase(Long topologyId, Long versionId) {
  List<QueryParam> queryParams = new ArrayList<>();
  queryParams.add(new QueryParam("topologyId", String.valueOf(topologyId)));
  queryParams.add(new QueryParam("versionId", String.valueOf(versionId)));
  return dao.find(TopologyTestRunCase.NAMESPACE, queryParams);
}

相关文章