allowedSortProperties.put("tenantId", ModelQueryProperty.MODEL_TENANT_ID);
}
@RequestMapping(value="/repository/models", method = RequestMethod.GET, produces = "application/json")
public DataResponse getModels(@RequestParam Map<String,String> allRequestParams, HttpServletRequest request) {
ModelQuery modelQuery = repositoryService.createModelQuery();
if (allRequestParams.containsKey("id")) {
modelQuery.modelId(allRequestParams.get("id"));
}
if (allRequestParams.containsKey("category")) {
modelQuery.modelCategory(allRequestParams.get("category"));
}
if (allRequestParams.containsKey("categoryLike")) {
modelQuery.modelCategoryLike(allRequestParams.get("categoryLike"));
}
if (allRequestParams.containsKey("categoryNotEquals")) {
modelQuery.modelCategoryNotEquals(allRequestParams.get("categoryNotEquals"));
}
if (allRequestParams.containsKey("name")) {
modelQuery.modelName(allRequestParams.get("name"));
}
if (allRequestParams.containsKey("nameLike")) {
modelQuery.modelNameLike(allRequestParams.get("nameLike"));
}
if (allRequestParams.containsKey("key")) {
modelQuery.modelKey(allRequestParams.get("key"));
}
if (allRequestParams.containsKey("version")) {
modelQuery.modelVersion(Integer.valueOf(allRequestParams.get("version")));
}
if (allRequestParams.containsKey("latestVersion")) {
boolean isLatestVersion = Boolean.valueOf(allRequestParams.get("latestVersion"));
if (isLatestVersion) {
modelQuery.latestVersion();
}
}
if (allRequestParams.containsKey("deploymentId")) {
modelQuery.deploymentId(allRequestParams.get("deploymentId"));
}
if (allRequestParams.containsKey("deployed")) {
boolean isDeployed = Boolean.valueOf(allRequestParams.get("deployed"));
if (isDeployed) {
modelQuery.deployed();
} else {
modelQuery.notDeployed();
}
}
if (allRequestParams.containsKey("tenantId")) {
modelQuery.modelTenantId(allRequestParams.get("tenantId"));
}
if (allRequestParams.containsKey("tenantIdLike")) {
modelQuery.modelTenantIdLike(allRequestParams.get("tenantIdLike"));
}
if (allRequestParams.containsKey("withoutTenantId")) {
boolean withoutTenantId = Boolean.valueOf(allRequestParams.get("withoutTenantId"));
if (withoutTenantId) {
modelQuery.modelWithoutTenantId();
}
}
return new ModelsPaginateList(restResponseFactory, request.getRequestURL().toString().replace("/repository/models", ""))
.paginateList(allRequestParams, modelQuery, "id", allowedSortProperties);
}