Search in sources :

Example 1 with RuleQueryRequest

use of com.webank.wedatasphere.qualitis.query.request.RuleQueryRequest in project Qualitis by WeBankFinTech.

the class RuleQueryController method query.

@POST
@Path("query")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public GeneralResponse<?> query(RuleQueryRequest param, @Context HttpServletRequest request) {
    if (param == null) {
        param = new RuleQueryRequest();
    }
    // Get login user
    param.setUser(HttpUtils.getUserName(request));
    try {
        PageRequest pageRequest = new PageRequest();
        pageRequest.setPage(param.getPage());
        pageRequest.setSize(param.getSize());
        PageRequest.checkRequest(pageRequest);
        DataInfo<RuleQueryDataSource> results = new DataInfo<>();
        List<RuleQueryDataSource> ruleQueryDataSources = ruleQueryService.filter(pageRequest, param.getUser(), param.getCluster(), param.getDb(), param.getTable(), false);
        results.setContent(ruleQueryDataSources);
        List<RuleQueryDataSource> allRuleDataSource = ruleQueryService.filter(null, param.getUser(), param.getCluster(), param.getDb(), param.getTable(), true);
        results.setTotalCount(allRuleDataSource == null ? 0 : allRuleDataSource.size());
        LOG.info("[My DataSource] Query successfully. The number of results:{}", allRuleDataSource == null ? 0 : allRuleDataSource.size());
        return new GeneralResponse<>("200", "{&QUERY_SUCCESSFULLY}", results);
    } catch (Exception e) {
        LOG.error("[My DataSource] Query failed, internal error.", e);
        return new GeneralResponse<>("500", e.getMessage(), null);
    }
}
Also used : DataInfo(com.webank.wedatasphere.qualitis.metadata.response.DataInfo) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) PageRequest(com.webank.wedatasphere.qualitis.request.PageRequest) RuleQueryRequest(com.webank.wedatasphere.qualitis.query.request.RuleQueryRequest) RuleQueryDataSource(com.webank.wedatasphere.qualitis.query.response.RuleQueryDataSource) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Aggregations

UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)1 MetaDataAcquireFailedException (com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException)1 DataInfo (com.webank.wedatasphere.qualitis.metadata.response.DataInfo)1 RuleQueryRequest (com.webank.wedatasphere.qualitis.query.request.RuleQueryRequest)1 RuleQueryDataSource (com.webank.wedatasphere.qualitis.query.response.RuleQueryDataSource)1 PageRequest (com.webank.wedatasphere.qualitis.request.PageRequest)1 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1