mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-04 06:33:05 +00:00
Change static final naming in Dataset.java, reformat code (#672)
This commit is contained in:
parent
2ec25b3ef1
commit
6c8a8ce567
@ -18,15 +18,12 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.FlowsDAO;
|
||||
import dao.MetricsDAO;
|
||||
import dao.UserDAO;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.hikaricp.internal.HikariCPConnectionProvider;
|
||||
|
||||
@ -13,12 +13,12 @@
|
||||
*/
|
||||
package controllers;
|
||||
|
||||
import play.mvc.Security;
|
||||
import play.mvc.Http.Context;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Security;
|
||||
|
||||
public class Secured extends Security.Authenticator
|
||||
{
|
||||
|
||||
public class Secured extends Security.Authenticator {
|
||||
@Override
|
||||
public String getUsername(Context ctx) {
|
||||
return ctx.session().get("user");
|
||||
|
||||
@ -24,198 +24,158 @@ import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
|
||||
public class AdvSearch extends Controller
|
||||
{
|
||||
public static Result getDatasetSources()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("sources", Json.toJson(AdvSearchDAO.getDatasetSources()));
|
||||
public class AdvSearch extends Controller {
|
||||
public static Result getDatasetSources() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
return ok(result);
|
||||
result.put("status", "ok");
|
||||
result.set("sources", Json.toJson(AdvSearchDAO.getDatasetSources()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getDatasetScopes() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("scopes", Json.toJson(AdvSearchDAO.getDatasetScopes()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getDatasetTableNames() {
|
||||
ObjectNode result = Json.newObject();
|
||||
String scopes = request().getQueryString("scopes");
|
||||
result.put("status", "ok");
|
||||
result.set("tables", Json.toJson(AdvSearchDAO.getTableNames(scopes)));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getDatasetFields() {
|
||||
ObjectNode result = Json.newObject();
|
||||
String tables = request().getQueryString("tables");
|
||||
result.put("status", "ok");
|
||||
result.set("fields", Json.toJson(AdvSearchDAO.getFields(tables)));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowApplicationCodes() {
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("appcodes", Json.toJson(AdvSearchDAO.getFlowApplicationCodes()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowNames() {
|
||||
ObjectNode result = Json.newObject();
|
||||
String apps = request().getQueryString("apps");
|
||||
result.put("status", "ok");
|
||||
result.set("flowNames", Json.toJson(AdvSearchDAO.getFlowNames(apps)));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getJobNames() {
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("jobNames", Json.toJson(AdvSearchDAO.getFlowJobNames()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getDashboardNames() {
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("dashboardNames", Json.toJson(AdvSearchDAO.getMetricDashboardNames()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricGroups() {
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("metricGroups", Json.toJson(AdvSearchDAO.getMetricGroups()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricCategories() {
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("metricCategories", Json.toJson(AdvSearchDAO.getMetricCategories()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricNames() {
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("metricNames", Json.toJson(AdvSearchDAO.getMetricNames()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result search() {
|
||||
ObjectNode result = Json.newObject();
|
||||
String searchOptStr = request().getQueryString("searchOpts");
|
||||
JsonNode searchOpt = Json.parse(searchOptStr);
|
||||
int page = 1;
|
||||
int size = 10;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("AdvSearch Controller search wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getDatasetScopes()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("scopes", Json.toJson(AdvSearchDAO.getDatasetScopes()));
|
||||
|
||||
return ok(result);
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("AdvSearch Controller search wrong page parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
result.put("status", "ok");
|
||||
String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE_KEY);
|
||||
|
||||
public static Result getDatasetTableNames()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
String scopes = request().getQueryString("scopes");
|
||||
result.put("status", "ok");
|
||||
result.set("tables", Json.toJson(AdvSearchDAO.getTableNames(scopes)));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getDatasetFields()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
String tables = request().getQueryString("tables");
|
||||
result.put("status", "ok");
|
||||
result.set("fields", Json.toJson(AdvSearchDAO.getFields(tables)));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowApplicationCodes()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("appcodes", Json.toJson(AdvSearchDAO.getFlowApplicationCodes()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowNames()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
String apps = request().getQueryString("apps");
|
||||
result.put("status", "ok");
|
||||
result.set("flowNames", Json.toJson(AdvSearchDAO.getFlowNames(apps)));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getJobNames()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("jobNames", Json.toJson(AdvSearchDAO.getFlowJobNames()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getDashboardNames()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("dashboardNames", Json.toJson(AdvSearchDAO.getMetricDashboardNames()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricGroups()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("metricGroups", Json.toJson(AdvSearchDAO.getMetricGroups()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricCategories()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("metricCategories", Json.toJson(AdvSearchDAO.getMetricCategories()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricNames()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("metricNames", Json.toJson(AdvSearchDAO.getMetricNames()));
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result search()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
String searchOptStr = request().getQueryString("searchOpts");
|
||||
JsonNode searchOpt = Json.parse(searchOptStr);
|
||||
int page = 1;
|
||||
int size = 10;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
if (searchOpt != null && searchOpt.has("category")) {
|
||||
String category = searchOpt.get("category").asText();
|
||||
if (category.equalsIgnoreCase("flow")) {
|
||||
if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", Json.toJson(AdvSearchDAO.elasticSearchFlowJobs(searchOpt, page, size)));
|
||||
} else {
|
||||
result.set("result", Json.toJson(AdvSearchDAO.searchFlows(searchOpt, page, size)));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("AdvSearch Controller search wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("AdvSearch Controller search wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
result.put("status", "ok");
|
||||
String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE_KEY);
|
||||
|
||||
if (searchOpt != null && searchOpt.has("category"))
|
||||
{
|
||||
String category = searchOpt.get("category").asText();
|
||||
if(category.equalsIgnoreCase("flow"))
|
||||
{
|
||||
if(StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", Json.toJson(AdvSearchDAO.elasticSearchFlowJobs(searchOpt, page, size)));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", Json.toJson(AdvSearchDAO.searchFlows(searchOpt, page, size)));
|
||||
}
|
||||
return ok(result);
|
||||
}
|
||||
else if(category.equalsIgnoreCase("metric"))
|
||||
{
|
||||
if(StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", Json.toJson(AdvSearchDAO.elasticSearchMetric(searchOpt, page, size)));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", Json.toJson(AdvSearchDAO.searchMetrics(searchOpt, page, size)));
|
||||
}
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", Json.toJson(AdvSearchDAO.elasticSearch(searchOpt, page, size)));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", Json.toJson(AdvSearchDAO.search(searchOpt, page, size)));
|
||||
}
|
||||
|
||||
return ok(result);
|
||||
} else if (category.equalsIgnoreCase("metric")) {
|
||||
if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", Json.toJson(AdvSearchDAO.elasticSearchMetric(searchOpt, page, size)));
|
||||
} else {
|
||||
result.set("result", Json.toJson(AdvSearchDAO.searchMetrics(searchOpt, page, size)));
|
||||
}
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", Json.toJson(AdvSearchDAO.elasticSearch(searchOpt, page, size)));
|
||||
} else {
|
||||
result.set("result", Json.toJson(AdvSearchDAO.search(searchOpt, page, size)));
|
||||
}
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,80 +22,80 @@ import play.mvc.Result;
|
||||
|
||||
public class Dashboard extends Controller {
|
||||
|
||||
public static Result getOwnershipDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.Ownership));
|
||||
}
|
||||
|
||||
public static Result getConfidentialDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.SecuritySpec));
|
||||
}
|
||||
|
||||
public static Result getDescriptionDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.Description));
|
||||
}
|
||||
|
||||
public static Result getIdpcComplianceDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.PrivacyCompliance));
|
||||
}
|
||||
|
||||
public static Result getPagedOwnershipDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
int option = parseInt(request().getQueryString("option"), 1);
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedOwnershipDatasetsByManagerId(managerId, platform, option, page, size));
|
||||
}
|
||||
|
||||
public static Result getPagedConfidentialDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedConfidentialDatasetsByManagerId(managerId, platform, page, size));
|
||||
}
|
||||
|
||||
public static Result getPagedDescriptionDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
int option = parseInt(request().getQueryString("option"), 1);
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedDescriptionDatasetsByManagerId(managerId, platform, option, page, size));
|
||||
}
|
||||
|
||||
public static Result getPagedComplianceDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
String option = request().getQueryString("option");
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedComplianceDatasetsByManagerId(managerId, platform, option, page, size));
|
||||
}
|
||||
|
||||
public static Result getOwnershipBarData(String managerId) {
|
||||
return ok(DashboardDAO.getOwnershipBarChartData(managerId));
|
||||
}
|
||||
|
||||
public static Result getDescriptionBarData(String managerId) {
|
||||
int option = parseInt(request().getQueryString("option"), 1);
|
||||
|
||||
return ok(DashboardDAO.getDescriptionBarChartData(managerId, option));
|
||||
}
|
||||
|
||||
private static int parseInt(String queryString, int defaultValue) {
|
||||
if (!StringUtils.isBlank(queryString)) {
|
||||
try {
|
||||
return Integer.parseInt(queryString);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Dashboard Controller query string wrong parameter: " + queryString + ". Error message: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
public static Result getOwnershipDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.Ownership));
|
||||
}
|
||||
|
||||
public static Result getConfidentialDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.SecuritySpec));
|
||||
}
|
||||
|
||||
public static Result getDescriptionDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.Description));
|
||||
}
|
||||
|
||||
public static Result getIdpcComplianceDatasetsPercentage(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
return ok(DashboardDAO.getDashboardStatByUserId(managerId, platform, DashboardDAO.Category.PrivacyCompliance));
|
||||
}
|
||||
|
||||
public static Result getPagedOwnershipDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
int option = parseInt(request().getQueryString("option"), 1);
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedOwnershipDatasetsByManagerId(managerId, platform, option, page, size));
|
||||
}
|
||||
|
||||
public static Result getPagedConfidentialDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedConfidentialDatasetsByManagerId(managerId, platform, page, size));
|
||||
}
|
||||
|
||||
public static Result getPagedDescriptionDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
int option = parseInt(request().getQueryString("option"), 1);
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedDescriptionDatasetsByManagerId(managerId, platform, option, page, size));
|
||||
}
|
||||
|
||||
public static Result getPagedComplianceDatasets(String managerId) {
|
||||
String platform = request().getQueryString("platform");
|
||||
String option = request().getQueryString("option");
|
||||
int page = parseInt(request().getQueryString("page"), 1);
|
||||
int size = parseInt(request().getQueryString("size"), 10);
|
||||
|
||||
return ok(DashboardDAO.getPagedComplianceDatasetsByManagerId(managerId, platform, option, page, size));
|
||||
}
|
||||
|
||||
public static Result getOwnershipBarData(String managerId) {
|
||||
return ok(DashboardDAO.getOwnershipBarChartData(managerId));
|
||||
}
|
||||
|
||||
public static Result getDescriptionBarData(String managerId) {
|
||||
int option = parseInt(request().getQueryString("option"), 1);
|
||||
|
||||
return ok(DashboardDAO.getDescriptionBarChartData(managerId, option));
|
||||
}
|
||||
|
||||
private static int parseInt(String queryString, int defaultValue) {
|
||||
if (!StringUtils.isBlank(queryString)) {
|
||||
try {
|
||||
return Integer.parseInt(queryString);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error(
|
||||
"Dashboard Controller query string wrong parameter: " + queryString + ". Error message: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -15,230 +15,167 @@ package controllers.api.v1;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.FlowsDAO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.Logger;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.Logger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class Flow extends Controller
|
||||
{
|
||||
public static Result getPagedRootProjects()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedRootProjects wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedRootProjects wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedProjects(page, size));
|
||||
return ok(result);
|
||||
public class Flow extends Controller {
|
||||
public static Result getPagedRootProjects() {
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedRootProjects wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getPagedProjects(String application)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedDatasets wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedDatasets wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedProjectsByApplication(application, page, size));
|
||||
return ok(result);
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedRootProjects wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getPagedFlows(String application, String project)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedDatasets wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedProjects(page, size));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedDatasets wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedFlowsByProject(application, project, page, size));
|
||||
return ok(result);
|
||||
public static Result getPagedProjects(String application) {
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getPagedJobs(String application, Long flowId)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedDatasets wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Flow Controller getPagedDatasets wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedJobsByFlow(application, flowId, page, size));
|
||||
return ok(result);
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getFlowListViewClusters()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedProjectsByApplication(application, page, size));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewClusters()));
|
||||
return ok(result);
|
||||
public static Result getPagedFlows(String application, String project) {
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getFlowListViewProjects(String application)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewProjects(application)));
|
||||
return ok(result);
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getFlowListViewFlows(String application, String project)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedFlowsByProject(application, project, page, size));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewFlows(application, project)));
|
||||
return ok(result);
|
||||
public static Result getPagedJobs(String application, Long flowId) {
|
||||
ObjectNode result = Json.newObject();
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Flow Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", FlowsDAO.getPagedJobsByFlow(application, flowId, page, size));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowListViewClusters() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewClusters()));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowListViewProjects(String application) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewProjects(application)));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowListViewFlows(String application, String project) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewFlows(application, project)));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,62 +15,52 @@ package controllers.api.v1;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.JiraDAO;
|
||||
import wherehows.models.JiraTicket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import wherehows.models.JiraTicket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Jira extends Controller
|
||||
{
|
||||
public static String HEADLESS_COMPONENT = "Auto Purge Program - Headless";
|
||||
public class Jira extends Controller {
|
||||
public static String HEADLESS_COMPONENT = "Auto Purge Program - Headless";
|
||||
|
||||
public static Result getLdapInfo()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
public static Result getLdapInfo() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("ldapinfo", Json.toJson(JiraDAO.getLdapInfo()));
|
||||
return ok(result);
|
||||
}
|
||||
result.put("status", "ok");
|
||||
result.set("ldapinfo", Json.toJson(JiraDAO.getLdapInfo()));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFirstLevelLdapInfo(String managerId)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
public static Result getFirstLevelLdapInfo(String managerId) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("currentUser", Json.toJson(JiraDAO.getCurrentUserLdapInfo(managerId)));
|
||||
result.set("members", Json.toJson(JiraDAO.getFirstLevelLdapInfo(managerId)));
|
||||
return ok(result);
|
||||
}
|
||||
result.put("status", "ok");
|
||||
result.set("currentUser", Json.toJson(JiraDAO.getCurrentUserLdapInfo(managerId)));
|
||||
result.set("members", Json.toJson(JiraDAO.getFirstLevelLdapInfo(managerId)));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getJiraTickets(String managerId)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
public static Result getJiraTickets(String managerId) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
List<JiraTicket> headlessTickets = new ArrayList<JiraTicket>();
|
||||
List<JiraTicket> userTickets = new ArrayList<JiraTicket>();
|
||||
List<JiraTicket> tickets = JiraDAO.getUserTicketsByManagerId(managerId);
|
||||
if ( tickets != null && tickets.size() > 0)
|
||||
{
|
||||
for( JiraTicket ticket : tickets)
|
||||
{
|
||||
if (ticket.ticketComponent.equalsIgnoreCase(HEADLESS_COMPONENT))
|
||||
{
|
||||
headlessTickets.add(ticket);
|
||||
}
|
||||
else
|
||||
{
|
||||
userTickets.add(ticket);
|
||||
}
|
||||
}
|
||||
List<JiraTicket> headlessTickets = new ArrayList<JiraTicket>();
|
||||
List<JiraTicket> userTickets = new ArrayList<JiraTicket>();
|
||||
List<JiraTicket> tickets = JiraDAO.getUserTicketsByManagerId(managerId);
|
||||
if (tickets != null && tickets.size() > 0) {
|
||||
for (JiraTicket ticket : tickets) {
|
||||
if (ticket.ticketComponent.equalsIgnoreCase(HEADLESS_COMPONENT)) {
|
||||
headlessTickets.add(ticket);
|
||||
} else {
|
||||
userTickets.add(ticket);
|
||||
}
|
||||
result.put("status", "ok");
|
||||
result.set("headlessTickets", Json.toJson(headlessTickets));
|
||||
result.set("userTickets", Json.toJson(userTickets));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("headlessTickets", Json.toJson(headlessTickets));
|
||||
result.set("userTickets", Json.toJson(userTickets));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,109 +16,91 @@ package controllers.api.v1;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.DatasetsDAO;
|
||||
import dao.LineageDAO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.Logger;
|
||||
import play.Play;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.Logger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class Lineage extends Controller
|
||||
{
|
||||
private static final String LINEAGE_LOOK_BACK_TIME_KEY = "lineage.look.back.time";
|
||||
|
||||
public static Result getDatasetLineageGraphData(int id)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
if (id < 1)
|
||||
{
|
||||
result.put("status", "error");
|
||||
result.put("message", "wrong dataset id");
|
||||
return ok(result);
|
||||
}
|
||||
public class Lineage extends Controller {
|
||||
private static final String LINEAGE_LOOK_BACK_TIME_KEY = "lineage.look.back.time";
|
||||
|
||||
wherehows.models.Dataset dataset = DatasetsDAO.getDatasetByID(id, username);
|
||||
if (dataset == null || StringUtils.isBlank(dataset.urn))
|
||||
{
|
||||
result.put("status", "error");
|
||||
result.put("message", "wrong dataset id");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
int upLevel = 1;
|
||||
String upLevelStr = request().getQueryString("upLevel");
|
||||
if (StringUtils.isBlank(upLevelStr))
|
||||
{
|
||||
upLevel = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
upLevel = Integer.parseInt(upLevelStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Lineage Controller getDatasetLineageGraphData wrong upLevel parameter. Error message: "
|
||||
+ e.getMessage());
|
||||
upLevel = 1;
|
||||
}
|
||||
}
|
||||
if (upLevel < 1)
|
||||
upLevel = 1;
|
||||
|
||||
int downLevel = 1;
|
||||
String downLevelStr = request().getQueryString("downLevel");
|
||||
if (StringUtils.isBlank(downLevelStr))
|
||||
{
|
||||
downLevel = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
downLevel = Integer.parseInt(downLevelStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Lineage Controller getDatasetLineageGraphData wrong downLevel parameter. Error message: "
|
||||
+ e.getMessage());
|
||||
downLevel = 1;
|
||||
}
|
||||
}
|
||||
if (downLevel < 1)
|
||||
downLevel = 1;
|
||||
|
||||
int lookBackTimeDefault = Integer.valueOf(Play.application().configuration().getString(LINEAGE_LOOK_BACK_TIME_KEY, "30"));
|
||||
int lookBackTime = lookBackTimeDefault;
|
||||
String lookBackTimeStr = request().getQueryString("period");
|
||||
if (!StringUtils.isBlank(lookBackTimeStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
lookBackTime = Integer.parseInt(lookBackTimeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Lineage Controller getDatasetLineageGraphData wrong period parameter. Error message: "
|
||||
+ e.getMessage());
|
||||
lookBackTime = lookBackTimeDefault;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(LineageDAO.getObjectAdjacnet(dataset.urn, upLevel, downLevel, lookBackTime)));
|
||||
return ok(result);
|
||||
public static Result getDatasetLineageGraphData(int id) {
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
if (id < 1) {
|
||||
result.put("status", "error");
|
||||
result.put("message", "wrong dataset id");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowLineageGraphData(String application, String project, Long flowId)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(LineageDAO.getFlowLineage(application, project, flowId)));
|
||||
return ok(result);
|
||||
wherehows.models.Dataset dataset = DatasetsDAO.getDatasetByID(id, username);
|
||||
if (dataset == null || StringUtils.isBlank(dataset.urn)) {
|
||||
result.put("status", "error");
|
||||
result.put("message", "wrong dataset id");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
int upLevel = 1;
|
||||
String upLevelStr = request().getQueryString("upLevel");
|
||||
if (StringUtils.isBlank(upLevelStr)) {
|
||||
upLevel = 1;
|
||||
} else {
|
||||
try {
|
||||
upLevel = Integer.parseInt(upLevelStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error(
|
||||
"Lineage Controller getDatasetLineageGraphData wrong upLevel parameter. Error message: " + e.getMessage());
|
||||
upLevel = 1;
|
||||
}
|
||||
}
|
||||
if (upLevel < 1) {
|
||||
upLevel = 1;
|
||||
}
|
||||
|
||||
int downLevel = 1;
|
||||
String downLevelStr = request().getQueryString("downLevel");
|
||||
if (StringUtils.isBlank(downLevelStr)) {
|
||||
downLevel = 1;
|
||||
} else {
|
||||
try {
|
||||
downLevel = Integer.parseInt(downLevelStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Lineage Controller getDatasetLineageGraphData wrong downLevel parameter. Error message: "
|
||||
+ e.getMessage());
|
||||
downLevel = 1;
|
||||
}
|
||||
}
|
||||
if (downLevel < 1) {
|
||||
downLevel = 1;
|
||||
}
|
||||
|
||||
int lookBackTimeDefault =
|
||||
Integer.valueOf(Play.application().configuration().getString(LINEAGE_LOOK_BACK_TIME_KEY, "30"));
|
||||
int lookBackTime = lookBackTimeDefault;
|
||||
String lookBackTimeStr = request().getQueryString("period");
|
||||
if (!StringUtils.isBlank(lookBackTimeStr)) {
|
||||
try {
|
||||
lookBackTime = Integer.parseInt(lookBackTimeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error(
|
||||
"Lineage Controller getDatasetLineageGraphData wrong period parameter. Error message: " + e.getMessage());
|
||||
lookBackTime = lookBackTimeDefault;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(LineageDAO.getObjectAdjacnet(dataset.urn, upLevel, downLevel, lookBackTime)));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getFlowLineageGraphData(String application, String project, Long flowId) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(LineageDAO.getFlowLineage(application, project, flowId)));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,283 +15,219 @@ package controllers.api.v1;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.MetricsDAO;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.Logger;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.Logger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Map;
|
||||
|
||||
public class Metric extends Controller
|
||||
{
|
||||
public static Result getPagedMetrics()
|
||||
{
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
public class Metric extends Controller {
|
||||
public static Result getPagedMetrics() {
|
||||
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.warn("Metric Controller getPagedMetrics wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.warn("Metric Controller getPagedMetrics wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", MetricsDAO.getPagedMetrics("", "", page, size, username));
|
||||
return ok(result);
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.warn("Metric Controller getPagedMetrics wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getPagedMetricsByDashboard(String dashboardName)
|
||||
{
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.warn("Metric Controller getPagedMetricsByDashboard wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.warn("Metric Controller getPagedMetricsByDashboard wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", MetricsDAO.getPagedMetrics(dashboardName, "", page, size, username));
|
||||
return ok(result);
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.warn("Metric Controller getPagedMetrics wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getPagedMetricsByDashboardandGroup(String dashboardName, String group)
|
||||
{
|
||||
result.put("status", "ok");
|
||||
result.set("data", MetricsDAO.getPagedMetrics("", "", page, size, username));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
public static Result getPagedMetricsByDashboard(String dashboardName) {
|
||||
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.warn("Metric Controller getPagedMetricsByDashboardandGroup wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.warn("Metric Controller getPagedMetricsByDashboardandGroup wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", MetricsDAO.getPagedMetrics(dashboardName, group, page, size, username));
|
||||
return ok(result);
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.warn(
|
||||
"Metric Controller getPagedMetricsByDashboard wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getMetricByID(int id)
|
||||
{
|
||||
String user = session("user");
|
||||
wherehows.models.Metric metric = MetricsDAO.getMetricByID(id, user);
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
if (metric != null)
|
||||
{
|
||||
result.put("status", "ok");
|
||||
result.set("metric", Json.toJson(metric));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "error");
|
||||
result.put("message", "record not found");
|
||||
}
|
||||
|
||||
return ok(result);
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.warn(
|
||||
"Metric Controller getPagedMetricsByDashboard wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result watchMetric(int id)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
Map<String, String[]> params = request().body().asFormUrlEncoded();
|
||||
if (StringUtils.isNotBlank(username))
|
||||
{
|
||||
String message = MetricsDAO.watchMetric(id, params, username);
|
||||
if (StringUtils.isBlank(message))
|
||||
{
|
||||
result.put("status", "success");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", "User is not authenticated");
|
||||
}
|
||||
result.put("status", "ok");
|
||||
result.set("data", MetricsDAO.getPagedMetrics(dashboardName, "", page, size, username));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
return ok(result);
|
||||
public static Result getPagedMetricsByDashboardandGroup(String dashboardName, String group) {
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.warn("Metric Controller getPagedMetricsByDashboardandGroup wrong page parameter. Error message: "
|
||||
+ e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result unwatchMetric(int id, int watchId)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
if (MetricsDAO.unwatch(watchId))
|
||||
{
|
||||
result.put("status", "success");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
}
|
||||
|
||||
return ok(result);
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.warn("Metric Controller getPagedMetricsByDashboardandGroup wrong size parameter. Error message: "
|
||||
+ e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result updateMetric(int id)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
Map<String, String[]> params = request().body().asFormUrlEncoded();
|
||||
result.put("status", "ok");
|
||||
result.set("data", MetricsDAO.getPagedMetrics(dashboardName, group, page, size, username));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
String message = MetricsDAO.updateMetricValues(id, params);
|
||||
if (StringUtils.isBlank(message))
|
||||
{
|
||||
result.put("status", "success");
|
||||
return ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
return badRequest(result);
|
||||
}
|
||||
public static Result getMetricByID(int id) {
|
||||
String user = session("user");
|
||||
wherehows.models.Metric metric = MetricsDAO.getMetricByID(id, user);
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
if (metric != null) {
|
||||
result.put("status", "ok");
|
||||
result.set("metric", Json.toJson(metric));
|
||||
} else {
|
||||
result.put("status", "error");
|
||||
result.put("message", "record not found");
|
||||
}
|
||||
|
||||
public static Result getMetricListViewByMetricId(Integer id)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewMetricNodesByMetricId(id));
|
||||
return ok(result);
|
||||
public static Result watchMetric(int id) {
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
Map<String, String[]> params = request().body().asFormUrlEncoded();
|
||||
if (StringUtils.isNotBlank(username)) {
|
||||
String message = MetricsDAO.watchMetric(id, params, username);
|
||||
if (StringUtils.isBlank(message)) {
|
||||
result.put("status", "success");
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
}
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
result.put("message", "User is not authenticated");
|
||||
}
|
||||
|
||||
public static Result getMetricListViewDashboards()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewDashboardNodes());
|
||||
return ok(result);
|
||||
public static Result unwatchMetric(int id, int watchId) {
|
||||
ObjectNode result = Json.newObject();
|
||||
if (MetricsDAO.unwatch(watchId)) {
|
||||
result.put("status", "success");
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
}
|
||||
|
||||
public static Result getMetricListViewGroups(String dashboard)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewGroupsNodes(dashboard));
|
||||
return ok(result);
|
||||
public static Result updateMetric(int id) {
|
||||
ObjectNode result = Json.newObject();
|
||||
Map<String, String[]> params = request().body().asFormUrlEncoded();
|
||||
|
||||
String message = MetricsDAO.updateMetricValues(id, params);
|
||||
if (StringUtils.isBlank(message)) {
|
||||
result.put("status", "success");
|
||||
return ok(result);
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
return badRequest(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getMetricListViewNodes(String dashboard, String group)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
public static Result getMetricListViewByMetricId(Integer id) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewMetricNodes(dashboard, group));
|
||||
return ok(result);
|
||||
}
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewMetricNodesByMetricId(id));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricListViewDashboards() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewDashboardNodes());
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricListViewGroups(String dashboard) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewGroupsNodes(dashboard));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getMetricListViewNodes(String dashboard, String group) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("nodes", MetricsDAO.getMetricListViewMetricNodes(dashboard, group));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,85 +15,67 @@ package controllers.api.v1;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.SchemaHistoryDAO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.Logger;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.Logger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class SchemaHistory extends Controller
|
||||
{
|
||||
|
||||
public static Result getPagedDatasets()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
public class SchemaHistory extends Controller {
|
||||
|
||||
String name = request().getQueryString("name");
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("SchemaHistory Controller getPagedDatasets wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
public static Result getPagedDatasets() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
Long datasetId = 0L;
|
||||
String datasetIdStr = request().getQueryString("datasetId");
|
||||
if (StringUtils.isNotBlank(datasetIdStr))
|
||||
{
|
||||
try
|
||||
{
|
||||
datasetId = Long.parseLong(datasetIdStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
datasetId = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("SchemaHistory Controller getPagedDatasets wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", SchemaHistoryDAO.getPagedSchemaDataset(name, datasetId, page, size));
|
||||
return ok(result);
|
||||
String name = request().getQueryString("name");
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error(
|
||||
"SchemaHistory Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getSchemaHistory(int id)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(SchemaHistoryDAO.getSchemaHistoryByDatasetID(id)));
|
||||
return ok(result);
|
||||
Long datasetId = 0L;
|
||||
String datasetIdStr = request().getQueryString("datasetId");
|
||||
if (StringUtils.isNotBlank(datasetIdStr)) {
|
||||
try {
|
||||
datasetId = Long.parseLong(datasetIdStr);
|
||||
} catch (NumberFormatException e) {
|
||||
datasetId = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error(
|
||||
"SchemaHistory Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", SchemaHistoryDAO.getPagedSchemaDataset(name, datasetId, page, size));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getSchemaHistory(int id) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(SchemaHistoryDAO.getSchemaHistoryByDatasetID(id)));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
@ -17,143 +17,107 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.ScriptFinderDAO;
|
||||
import java.net.URLDecoder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.Logger;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.Logger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class ScriptFinder extends Controller
|
||||
{
|
||||
|
||||
public static Result getAllScriptTypes()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
public class ScriptFinder extends Controller {
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("scriptTypes", Json.toJson(ScriptFinderDAO.getAllScriptTypes()));
|
||||
return ok(result);
|
||||
public static Result getAllScriptTypes() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("scriptTypes", Json.toJson(ScriptFinderDAO.getAllScriptTypes()));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getScripts() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getScripts()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
int page = 1;
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (StringUtils.isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong size parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
String filterOptStr = request().getQueryString("query");
|
||||
JsonNode filterOpt = null;
|
||||
try
|
||||
{
|
||||
String filterOptStrDecode = URLDecoder.decode(filterOptStr, "UTF-8");
|
||||
filterOpt = Json.parse(filterOptStrDecode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.error("ScriptFinder Controller getScripts query filterOpt wrong JSON format. Error message: " +
|
||||
e.getMessage());
|
||||
filterOpt = null;
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", ScriptFinderDAO.getPagedScripts(filterOpt, page, size));
|
||||
return ok(result);
|
||||
int size = 10;
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (StringUtils.isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong size parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getScriptRuntimeByJobID(int applicationID, int jobID)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
int attemptNumber = 0;
|
||||
String attemptStr = request().getQueryString("attempt_number");
|
||||
if (StringUtils.isBlank(attemptStr))
|
||||
{
|
||||
attemptNumber = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
attemptNumber = Integer.parseInt(attemptStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
attemptNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(ScriptFinderDAO.getPagedScriptRuntime(applicationID, jobID)));
|
||||
return ok(result);
|
||||
String filterOptStr = request().getQueryString("query");
|
||||
JsonNode filterOpt = null;
|
||||
try {
|
||||
String filterOptStrDecode = URLDecoder.decode(filterOptStr, "UTF-8");
|
||||
filterOpt = Json.parse(filterOptStrDecode);
|
||||
} catch (Exception e) {
|
||||
Logger.error(
|
||||
"ScriptFinder Controller getScripts query filterOpt wrong JSON format. Error message: " + e.getMessage());
|
||||
filterOpt = null;
|
||||
}
|
||||
|
||||
public static Result getScriptLineageByJobID(int applicationID, int jobID)
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("data", ScriptFinderDAO.getPagedScripts(filterOpt, page, size));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
int attemptNumber = 0;
|
||||
String attemptStr = request().getQueryString("attempt_number");
|
||||
if (StringUtils.isBlank(attemptStr))
|
||||
{
|
||||
attemptNumber = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
attemptNumber = Integer.parseInt(attemptStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
attemptNumber = 0;
|
||||
}
|
||||
}
|
||||
public static Result getScriptRuntimeByJobID(int applicationID, int jobID) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(ScriptFinderDAO.getScriptLineage(applicationID, jobID)));
|
||||
return ok(result);
|
||||
int attemptNumber = 0;
|
||||
String attemptStr = request().getQueryString("attempt_number");
|
||||
if (StringUtils.isBlank(attemptStr)) {
|
||||
attemptNumber = 0;
|
||||
} else {
|
||||
try {
|
||||
attemptNumber = Integer.parseInt(attemptStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong page parameter. Error message: " + e.getMessage());
|
||||
attemptNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(ScriptFinderDAO.getPagedScriptRuntime(applicationID, jobID)));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getScriptLineageByJobID(int applicationID, int jobID) {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
int attemptNumber = 0;
|
||||
String attemptStr = request().getQueryString("attempt_number");
|
||||
if (StringUtils.isBlank(attemptStr)) {
|
||||
attemptNumber = 0;
|
||||
} else {
|
||||
try {
|
||||
attemptNumber = Integer.parseInt(attemptStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("ScriptFinder Controller getPagedScripts wrong page parameter. Error message: " + e.getMessage());
|
||||
attemptNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
result.set("data", Json.toJson(ScriptFinderDAO.getScriptLineage(applicationID, jobID)));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
@ -17,237 +17,187 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.SearchDAO;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import play.Logger;
|
||||
import play.Play;
|
||||
import play.cache.Cache;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.Logger;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
|
||||
public class Search extends Controller
|
||||
{
|
||||
private static final String AUTOCOMPLETE_ALL_KEY = "autocomplete.all";
|
||||
private static final String AUTOCOMPLETE_DATASET_KEY = "autocomplete.dataset";
|
||||
private static final String AUTOCOMPLETE_FLOW_KEY = "autocomplete.flow";
|
||||
private static final String AUTOCOMPLETE_METRIC_KEY = "autocomplete.metric";
|
||||
private static final int DEFAULT_AUTOCOMPLETE_SIZE = 20;
|
||||
private static final int DEFAULT_AUTOCOMPLETE_CACHE_TIME = 3600; // cache for an hour
|
||||
public class Search extends Controller {
|
||||
private static final String AUTOCOMPLETE_ALL_KEY = "autocomplete.all";
|
||||
private static final String AUTOCOMPLETE_DATASET_KEY = "autocomplete.dataset";
|
||||
private static final String AUTOCOMPLETE_FLOW_KEY = "autocomplete.flow";
|
||||
private static final String AUTOCOMPLETE_METRIC_KEY = "autocomplete.metric";
|
||||
private static final int DEFAULT_AUTOCOMPLETE_SIZE = 20;
|
||||
private static final int DEFAULT_AUTOCOMPLETE_CACHE_TIME = 3600; // cache for an hour
|
||||
|
||||
public static Result getSearchAutoComplete() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
|
||||
String cacheKey = AUTOCOMPLETE_ALL_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteList(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
public static Result getSearchAutoComplete() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
|
||||
public static Result getSearchAutoCompleteForDataset() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
|
||||
String cacheKey = AUTOCOMPLETE_DATASET_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteListDataset(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
String cacheKey = AUTOCOMPLETE_ALL_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteList(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
public static Result getSearchAutoCompleteForMetric() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
String cacheKey = AUTOCOMPLETE_METRIC_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteListMetric(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
public static Result getSearchAutoCompleteForDataset() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
|
||||
public static Result getSearchAutoCompleteForFlow() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
|
||||
String cacheKey = AUTOCOMPLETE_FLOW_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteListFlow(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
String cacheKey = AUTOCOMPLETE_DATASET_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteListDataset(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
public static Result searchByKeyword()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
int page = 1;
|
||||
int size = 10;
|
||||
String keyword = request().getQueryString("keyword");
|
||||
String category = request().getQueryString("category");
|
||||
String source = request().getQueryString("source");
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (isBlank(pageStr))
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(pageStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (isBlank(sizeStr))
|
||||
{
|
||||
size = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
size = Integer.parseInt(sizeStr);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " +
|
||||
e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
Boolean isDefault = false;
|
||||
if (isBlank(category))
|
||||
{
|
||||
category = "datasets";
|
||||
}
|
||||
if (isBlank(source) || source.equalsIgnoreCase("all") || source.equalsIgnoreCase("default"))
|
||||
{
|
||||
source = null;
|
||||
}
|
||||
|
||||
String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE_KEY);
|
||||
|
||||
if (category.toLowerCase().equalsIgnoreCase("metrics"))
|
||||
{
|
||||
if(isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", SearchDAO.elasticSearchMetricByKeyword(category, keyword, page, size));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", SearchDAO.getPagedMetricByKeyword(category, keyword, page, size));
|
||||
}
|
||||
}
|
||||
else if (category.toLowerCase().equalsIgnoreCase("flows"))
|
||||
{
|
||||
if(isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", SearchDAO.getPagedFlowByKeyword(category, keyword, page, size));
|
||||
}
|
||||
}
|
||||
else if (category.toLowerCase().equalsIgnoreCase("jobs"))
|
||||
{
|
||||
if(isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", SearchDAO.getPagedJobByKeyword(category, keyword, page, size));
|
||||
}
|
||||
}
|
||||
else if (category.toLowerCase().equalsIgnoreCase("comments"))
|
||||
{
|
||||
if(isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, null, page, size));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", SearchDAO.getPagedCommentsByKeyword(category, keyword, page, size));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch"))
|
||||
{
|
||||
result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, source, page, size));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.set("result", SearchDAO.getPagedDatasetByKeyword(category, keyword, source, page, size));
|
||||
}
|
||||
}
|
||||
|
||||
return ok(result);
|
||||
public static Result getSearchAutoCompleteForMetric() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
|
||||
String cacheKey = AUTOCOMPLETE_METRIC_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteListMetric(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getSearchAutoCompleteForFlow() {
|
||||
// if not input, then get all search names (without limit).
|
||||
String input = request().getQueryString("input");
|
||||
int size = 0; // size 0 means no limit
|
||||
if (isNotBlank(input)) {
|
||||
size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
|
||||
}
|
||||
|
||||
String cacheKey = AUTOCOMPLETE_FLOW_KEY + (isNotBlank(input) ? "." + input : "-all");
|
||||
List<String> names = (List<String>) Cache.get(cacheKey);
|
||||
if (names == null || names.size() == 0) {
|
||||
names = SearchDAO.getAutoCompleteListFlow(input, size);
|
||||
Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
|
||||
}
|
||||
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.put("input", input);
|
||||
result.set("source", Json.toJson(names));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result searchByKeyword() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
int page = 1;
|
||||
int size = 10;
|
||||
String keyword = request().getQueryString("keyword");
|
||||
String category = request().getQueryString("category");
|
||||
String source = request().getQueryString("source");
|
||||
String pageStr = request().getQueryString("page");
|
||||
if (isBlank(pageStr)) {
|
||||
page = 1;
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(pageStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " + e.getMessage());
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
String sizeStr = request().getQueryString("size");
|
||||
if (isBlank(sizeStr)) {
|
||||
size = 10;
|
||||
} else {
|
||||
try {
|
||||
size = Integer.parseInt(sizeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " + e.getMessage());
|
||||
size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("status", "ok");
|
||||
Boolean isDefault = false;
|
||||
if (isBlank(category)) {
|
||||
category = "datasets";
|
||||
}
|
||||
if (isBlank(source) || source.equalsIgnoreCase("all") || source.equalsIgnoreCase("default")) {
|
||||
source = null;
|
||||
}
|
||||
|
||||
String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE_KEY);
|
||||
|
||||
if (category.toLowerCase().equalsIgnoreCase("metrics")) {
|
||||
if (isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", SearchDAO.elasticSearchMetricByKeyword(category, keyword, page, size));
|
||||
} else {
|
||||
result.set("result", SearchDAO.getPagedMetricByKeyword(category, keyword, page, size));
|
||||
}
|
||||
} else if (category.toLowerCase().equalsIgnoreCase("flows")) {
|
||||
if (isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size));
|
||||
} else {
|
||||
result.set("result", SearchDAO.getPagedFlowByKeyword(category, keyword, page, size));
|
||||
}
|
||||
} else if (category.toLowerCase().equalsIgnoreCase("jobs")) {
|
||||
if (isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size));
|
||||
} else {
|
||||
result.set("result", SearchDAO.getPagedJobByKeyword(category, keyword, page, size));
|
||||
}
|
||||
} else if (category.toLowerCase().equalsIgnoreCase("comments")) {
|
||||
if (isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, null, page, size));
|
||||
} else {
|
||||
result.set("result", SearchDAO.getPagedCommentsByKeyword(category, keyword, page, size));
|
||||
}
|
||||
} else {
|
||||
if (isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
|
||||
result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, source, page, size));
|
||||
} else {
|
||||
result.set("result", SearchDAO.getPagedDatasetByKeyword(category, keyword, source, page, size));
|
||||
}
|
||||
}
|
||||
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,42 +17,35 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.TrackingDAO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class Tracking extends Controller
|
||||
{
|
||||
|
||||
public static Result addTrackingEvent()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
ObjectNode json = Json.newObject();
|
||||
ArrayNode res = json.arrayNode();
|
||||
JsonNode requestNode = request().body().asJson();
|
||||
public class Tracking extends Controller {
|
||||
|
||||
if (StringUtils.isNotBlank(username))
|
||||
{
|
||||
String message = TrackingDAO.addTrackingEvent(requestNode, username);
|
||||
if (StringUtils.isBlank(message))
|
||||
{
|
||||
result.put("status", "success");
|
||||
return ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
return badRequest(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", "User is not authenticated");
|
||||
return unauthorized(result);
|
||||
}
|
||||
public static Result addTrackingEvent() {
|
||||
ObjectNode result = Json.newObject();
|
||||
String username = session("user");
|
||||
ObjectNode json = Json.newObject();
|
||||
ArrayNode res = json.arrayNode();
|
||||
JsonNode requestNode = request().body().asJson();
|
||||
|
||||
if (StringUtils.isNotBlank(username)) {
|
||||
String message = TrackingDAO.addTrackingEvent(requestNode, username);
|
||||
if (StringUtils.isBlank(message)) {
|
||||
result.put("status", "success");
|
||||
return ok(result);
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
return badRequest(result);
|
||||
}
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
result.put("message", "User is not authenticated");
|
||||
return unauthorized(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,108 +16,97 @@ package controllers.api.v1;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import dao.UserDAO;
|
||||
import java.util.List;
|
||||
import wherehows.models.CompanyUser;
|
||||
import wherehows.models.Group;
|
||||
import wherehows.models.UserEntity;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.cache.Cache;
|
||||
import play.libs.Json;
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import java.util.Map;
|
||||
import wherehows.models.CompanyUser;
|
||||
import wherehows.models.Group;
|
||||
import wherehows.models.UserEntity;
|
||||
|
||||
|
||||
public class User extends Controller
|
||||
{
|
||||
private static final String CACHE_INTERNAL_USERS = "internal.users.cache";
|
||||
private static final String CACHE_INTERNAL_GROUPS = "internal.groups.cache";
|
||||
private static final String CACHE_INTERNAL_ENTITIES = "internal.entities.cache";
|
||||
public class User extends Controller {
|
||||
private static final String CACHE_INTERNAL_USERS = "internal.users.cache";
|
||||
private static final String CACHE_INTERNAL_GROUPS = "internal.groups.cache";
|
||||
private static final String CACHE_INTERNAL_ENTITIES = "internal.entities.cache";
|
||||
|
||||
public static Result getLoggedInUser()
|
||||
{
|
||||
ObjectNode result = Json.newObject();
|
||||
public static Result getLoggedInUser() {
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
String username = session("user");
|
||||
if (StringUtils.isBlank(username))
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", "no user in session");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
wherehows.models.User user = UserDAO.getCurrentUser(username);
|
||||
if (StringUtils.isBlank(user.userName))
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", "can't find user info");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
result.set("user", Json.toJson(user));
|
||||
result.put("status", "ok");
|
||||
return ok(result);
|
||||
String username = session("user");
|
||||
if (StringUtils.isBlank(username)) {
|
||||
result.put("status", "failed");
|
||||
result.put("message", "no user in session");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result updateSettings()
|
||||
{
|
||||
Map<String, String[]> params = request().body().asFormUrlEncoded();
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
String username = session("user");
|
||||
if (StringUtils.isNotBlank(username))
|
||||
{
|
||||
String message = UserDAO.updateUserSettings(params, username);
|
||||
if (StringUtils.isBlank(message))
|
||||
{
|
||||
result.put("status", "success");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put("status", "failed");
|
||||
result.put("message", "User is not authenticated");
|
||||
}
|
||||
return ok(result);
|
||||
wherehows.models.User user = UserDAO.getCurrentUser(username);
|
||||
if (StringUtils.isBlank(user.userName)) {
|
||||
result.put("status", "failed");
|
||||
result.put("message", "can't find user info");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getAllCompanyUsers() {
|
||||
List<CompanyUser> users = (List<CompanyUser>) Cache.get(CACHE_INTERNAL_USERS);
|
||||
if (users == null || users.size() == 0) {
|
||||
users = UserDAO.getAllCompanyUsers();
|
||||
Cache.set(CACHE_INTERNAL_USERS, users, 24 * 3600); // cache for 24 hours
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("employees", Json.toJson(users));
|
||||
return ok(result);
|
||||
}
|
||||
result.set("user", Json.toJson(user));
|
||||
result.put("status", "ok");
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getAllGroups() {
|
||||
List<Group> groups = (List<Group>) Cache.get(CACHE_INTERNAL_GROUPS);
|
||||
if (groups == null || groups.size() == 0) {
|
||||
groups = UserDAO.getAllGroups();
|
||||
Cache.set(CACHE_INTERNAL_GROUPS, groups, 24 * 3600); // cache for 24 hours
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("groups", Json.toJson(groups));
|
||||
return ok(result);
|
||||
}
|
||||
public static Result updateSettings() {
|
||||
Map<String, String[]> params = request().body().asFormUrlEncoded();
|
||||
ObjectNode result = Json.newObject();
|
||||
|
||||
public static Result getAllUserEntities() {
|
||||
List<UserEntity> entities = (List<UserEntity>) Cache.get(CACHE_INTERNAL_ENTITIES);
|
||||
if (entities == null || entities.size() == 0) {
|
||||
entities = UserDAO.getAllUserEntities();
|
||||
Cache.set(CACHE_INTERNAL_ENTITIES, entities, 24 * 3600); // cache for 24 hours
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("userEntities", Json.toJson(entities));
|
||||
return ok(result);
|
||||
String username = session("user");
|
||||
if (StringUtils.isNotBlank(username)) {
|
||||
String message = UserDAO.updateUserSettings(params, username);
|
||||
if (StringUtils.isBlank(message)) {
|
||||
result.put("status", "success");
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
result.put("message", message);
|
||||
}
|
||||
} else {
|
||||
result.put("status", "failed");
|
||||
result.put("message", "User is not authenticated");
|
||||
}
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getAllCompanyUsers() {
|
||||
List<CompanyUser> users = (List<CompanyUser>) Cache.get(CACHE_INTERNAL_USERS);
|
||||
if (users == null || users.size() == 0) {
|
||||
users = UserDAO.getAllCompanyUsers();
|
||||
Cache.set(CACHE_INTERNAL_USERS, users, 24 * 3600); // cache for 24 hours
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("employees", Json.toJson(users));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getAllGroups() {
|
||||
List<Group> groups = (List<Group>) Cache.get(CACHE_INTERNAL_GROUPS);
|
||||
if (groups == null || groups.size() == 0) {
|
||||
groups = UserDAO.getAllGroups();
|
||||
Cache.set(CACHE_INTERNAL_GROUPS, groups, 24 * 3600); // cache for 24 hours
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("groups", Json.toJson(groups));
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
public static Result getAllUserEntities() {
|
||||
List<UserEntity> entities = (List<UserEntity>) Cache.get(CACHE_INTERNAL_ENTITIES);
|
||||
if (entities == null || entities.size() == 0) {
|
||||
entities = UserDAO.getAllUserEntities();
|
||||
Cache.set(CACHE_INTERNAL_ENTITIES, entities, 24 * 3600); // cache for 24 hours
|
||||
}
|
||||
ObjectNode result = Json.newObject();
|
||||
result.put("status", "ok");
|
||||
result.set("userEntities", Json.toJson(entities));
|
||||
return ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,99 +15,79 @@ package utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import play.Logger;
|
||||
import play.cache.Cache;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.Logger;
|
||||
import play.cache.Cache;
|
||||
|
||||
public class Dataset
|
||||
{
|
||||
private static Cache currentCache = null;
|
||||
|
||||
public static final String URNIDMAPKey = "impactUrnIDMap";
|
||||
public class Dataset {
|
||||
public static final String URNIDMAPKey = "impactUrnIDMap";
|
||||
private static Cache currentCache = null;
|
||||
|
||||
public static Cache getChacheInstance()
|
||||
{
|
||||
if (currentCache == null)
|
||||
{
|
||||
currentCache = new Cache();
|
||||
}
|
||||
return currentCache;
|
||||
public static Cache getChacheInstance() {
|
||||
if (currentCache == null) {
|
||||
currentCache = new Cache();
|
||||
}
|
||||
return currentCache;
|
||||
}
|
||||
|
||||
public static JsonNode addDatasetIDtoImpactAnalysisResult(JsonNode impacts) {
|
||||
if (impacts == null || (!impacts.isArray())) {
|
||||
return impacts;
|
||||
}
|
||||
|
||||
public static JsonNode addDatasetIDtoImpactAnalysisResult(JsonNode impacts)
|
||||
{
|
||||
if (impacts == null || (!impacts.isArray()))
|
||||
{
|
||||
return impacts;
|
||||
}
|
||||
try {
|
||||
Map<String, Integer> urnIDMap = new HashMap<String, Integer>();
|
||||
if (getChacheInstance().get("URNIDMAPKey") != null) {
|
||||
urnIDMap = (Map<String, Integer>) getChacheInstance().get("URNIDMAPKey");
|
||||
} else {
|
||||
FileReader fr = new FileReader("/var/tmp/wherehows/resource/dataset_urn_list.txt");
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
String line;
|
||||
|
||||
try
|
||||
{
|
||||
Map<String, Integer> urnIDMap = new HashMap<String, Integer>();
|
||||
if (getChacheInstance().get("URNIDMAPKey") != null)
|
||||
{
|
||||
urnIDMap = (Map<String, Integer>)getChacheInstance().get("URNIDMAPKey");
|
||||
}
|
||||
else
|
||||
{
|
||||
FileReader fr = new FileReader("/var/tmp/wherehows/resource/dataset_urn_list.txt");
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
String line;
|
||||
|
||||
while((line = br.readLine()) != null)
|
||||
{
|
||||
String record = line.substring(0, line.length());
|
||||
String[] values = record.split("\t");
|
||||
if (values != null && values.length == 2)
|
||||
{
|
||||
String urn = values[0];
|
||||
Integer id = Integer.parseInt(values[1]);
|
||||
if (StringUtils.isNotBlank(urn) && id != null && id != 0)
|
||||
{
|
||||
urnIDMap.put(urn, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (urnIDMap != null && urnIDMap.size() > 0)
|
||||
{
|
||||
getChacheInstance().set(URNIDMAPKey, urnIDMap);
|
||||
}
|
||||
}
|
||||
|
||||
if (urnIDMap != null && urnIDMap.size() > 0)
|
||||
{
|
||||
Iterator<JsonNode> arrayIterator = impacts.elements();
|
||||
if (arrayIterator != null)
|
||||
{
|
||||
while (arrayIterator.hasNext())
|
||||
{
|
||||
JsonNode node = arrayIterator.next();
|
||||
if (node.isContainerNode() && node.has("urn"))
|
||||
{
|
||||
String urn = node.get("urn").asText();
|
||||
ObjectNode objectNode = (ObjectNode)node;
|
||||
int index = urn.lastIndexOf("/");
|
||||
String name = urn.substring(index+1);
|
||||
objectNode.put("name", name);
|
||||
if (urnIDMap.containsKey(urn))
|
||||
{
|
||||
Integer id = urnIDMap.get(urn);
|
||||
objectNode.put("id", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((line = br.readLine()) != null) {
|
||||
String record = line.substring(0, line.length());
|
||||
String[] values = record.split("\t");
|
||||
if (values != null && values.length == 2) {
|
||||
String urn = values[0];
|
||||
Integer id = Integer.parseInt(values[1]);
|
||||
if (StringUtils.isNotBlank(urn) && id != null && id != 0) {
|
||||
urnIDMap.put(urn, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
if (urnIDMap != null && urnIDMap.size() > 0) {
|
||||
getChacheInstance().set(URNIDMAPKey, urnIDMap);
|
||||
}
|
||||
return impacts;
|
||||
}
|
||||
|
||||
if (urnIDMap != null && urnIDMap.size() > 0) {
|
||||
Iterator<JsonNode> arrayIterator = impacts.elements();
|
||||
if (arrayIterator != null) {
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode node = arrayIterator.next();
|
||||
if (node.isContainerNode() && node.has("urn")) {
|
||||
String urn = node.get("urn").asText();
|
||||
ObjectNode objectNode = (ObjectNode) node;
|
||||
int index = urn.lastIndexOf("/");
|
||||
String name = urn.substring(index + 1);
|
||||
objectNode.put("name", name);
|
||||
if (urnIDMap.containsKey(urn)) {
|
||||
Integer id = urnIDMap.get(urn);
|
||||
objectNode.put("id", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
return impacts;
|
||||
}
|
||||
}
|
||||
@ -13,85 +13,69 @@
|
||||
*/
|
||||
package utils;
|
||||
|
||||
import wherehows.models.LineagePathInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import wherehows.models.LineagePathInfo;
|
||||
|
||||
public class Lineage
|
||||
{
|
||||
|
||||
public static final String URNIDMAPKey = "impactUrnIDMap";
|
||||
public class Lineage {
|
||||
|
||||
public static LineagePathInfo convertFromURN(String urn)
|
||||
{
|
||||
if (StringUtils.isBlank(urn))
|
||||
return null;
|
||||
public static final String URNIDMAPKey = "impactUrnIDMap";
|
||||
|
||||
LineagePathInfo pathInfo = new LineagePathInfo();
|
||||
|
||||
String[] pathArray = urn.split(":///");
|
||||
if (pathArray != null && pathArray.length > 0)
|
||||
{
|
||||
String storageType = pathArray[0];
|
||||
pathInfo.storageType = storageType;
|
||||
if (StringUtils.isNotBlank(storageType))
|
||||
{
|
||||
if (pathArray.length > 1 && StringUtils.isNotBlank(pathArray[1]))
|
||||
{
|
||||
pathInfo.filePath = "/" + pathArray[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
pathInfo.storageType = null;
|
||||
pathInfo.schemaName = null;
|
||||
pathInfo.filePath = urn;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pathInfo.storageType = null;
|
||||
pathInfo.schemaName = null;
|
||||
pathInfo.filePath = urn;
|
||||
}
|
||||
}
|
||||
|
||||
return pathInfo;
|
||||
public static LineagePathInfo convertFromURN(String urn) {
|
||||
if (StringUtils.isBlank(urn)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String convertToURN(LineagePathInfo pathInfo)
|
||||
{
|
||||
if (pathInfo == null)
|
||||
return null;
|
||||
LineagePathInfo pathInfo = new LineagePathInfo();
|
||||
|
||||
String filePath = "";
|
||||
if (StringUtils.isNotBlank(pathInfo.filePath))
|
||||
{
|
||||
if(pathInfo.filePath.charAt(0) == '/')
|
||||
{
|
||||
filePath = pathInfo.filePath.substring(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
filePath = pathInfo.filePath;
|
||||
}
|
||||
String[] pathArray = urn.split(":///");
|
||||
if (pathArray != null && pathArray.length > 0) {
|
||||
String storageType = pathArray[0];
|
||||
pathInfo.storageType = storageType;
|
||||
if (StringUtils.isNotBlank(storageType)) {
|
||||
if (pathArray.length > 1 && StringUtils.isNotBlank(pathArray[1])) {
|
||||
pathInfo.filePath = "/" + pathArray[1];
|
||||
} else {
|
||||
pathInfo.storageType = null;
|
||||
pathInfo.schemaName = null;
|
||||
pathInfo.filePath = urn;
|
||||
}
|
||||
return pathInfo.storageType.toLowerCase() + ":///" + filePath;
|
||||
} else {
|
||||
pathInfo.storageType = null;
|
||||
pathInfo.schemaName = null;
|
||||
pathInfo.filePath = urn;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInList(List<String> list, String source)
|
||||
{
|
||||
if (list == null || list.size() == 0 || StringUtils.isBlank(source))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for(String s : list)
|
||||
{
|
||||
if (source.equalsIgnoreCase(s))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return pathInfo;
|
||||
}
|
||||
|
||||
public static String convertToURN(LineagePathInfo pathInfo) {
|
||||
if (pathInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String filePath = "";
|
||||
if (StringUtils.isNotBlank(pathInfo.filePath)) {
|
||||
if (pathInfo.filePath.charAt(0) == '/') {
|
||||
filePath = pathInfo.filePath.substring(1);
|
||||
} else {
|
||||
filePath = pathInfo.filePath;
|
||||
}
|
||||
}
|
||||
return pathInfo.storageType.toLowerCase() + ":///" + filePath;
|
||||
}
|
||||
|
||||
public static boolean isInList(List<String> list, String source) {
|
||||
if (list == null || list.size() == 0 || StringUtils.isBlank(source)) {
|
||||
return false;
|
||||
}
|
||||
for (String s : list) {
|
||||
if (source.equalsIgnoreCase(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,205 +17,170 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.fasterxml.jackson.databind.node.TextNode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class SampleData
|
||||
{
|
||||
private final static String MEMBER_ID = "memberId";
|
||||
private final static String TREE_ID = "treeId";
|
||||
private final static String TRACKING_ID = "trackingId";
|
||||
private final static String IP_AS_BYTES_1 = "ipAsBytes";
|
||||
private final static String IP_AS_BYTES = "ip_as_bytes";
|
||||
private final static String ATTACHMENTS = "attachments";
|
||||
private final static String PAYLOAD = "payload";
|
||||
private final static String MEDIA = "MEDIA";
|
||||
private final static String HEADER = "header";
|
||||
private final static String GUID = "guid";
|
||||
private final static String AUDITHEADER = "auditHeader";
|
||||
private final static String MESSAGE_ID = "messageId";
|
||||
private final static String REQUEST = "request";
|
||||
private final static String REQUEST_HEADER = "requestHeader";
|
||||
|
||||
public static String convertToHexString(JsonNode node)
|
||||
{
|
||||
String result = null;
|
||||
if (node != null)
|
||||
{
|
||||
if (node.isArray())
|
||||
{
|
||||
Iterator<JsonNode> arrayIterator = node.elements();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode elementNode = arrayIterator.next();
|
||||
if (elementNode != null)
|
||||
{
|
||||
String text = elementNode.asText();
|
||||
if (StringUtils.isNotBlank(text))
|
||||
{
|
||||
byte[] bytes = text.getBytes();
|
||||
if (bytes != null && bytes.length > 0)
|
||||
{
|
||||
sb.append(String.format("%02x", text.getBytes()[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = sb.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = node.asText();
|
||||
public class SampleData {
|
||||
private final static String MEMBER_ID = "memberId";
|
||||
private final static String TREE_ID = "treeId";
|
||||
private final static String TRACKING_ID = "trackingId";
|
||||
private final static String IP_AS_BYTES_1 = "ipAsBytes";
|
||||
private final static String IP_AS_BYTES = "ip_as_bytes";
|
||||
private final static String ATTACHMENTS = "attachments";
|
||||
private final static String PAYLOAD = "payload";
|
||||
private final static String MEDIA = "MEDIA";
|
||||
private final static String HEADER = "header";
|
||||
private final static String GUID = "guid";
|
||||
private final static String AUDITHEADER = "auditHeader";
|
||||
private final static String MESSAGE_ID = "messageId";
|
||||
private final static String REQUEST = "request";
|
||||
private final static String REQUEST_HEADER = "requestHeader";
|
||||
|
||||
public static String convertToHexString(JsonNode node) {
|
||||
String result = null;
|
||||
if (node != null) {
|
||||
if (node.isArray()) {
|
||||
Iterator<JsonNode> arrayIterator = node.elements();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode elementNode = arrayIterator.next();
|
||||
if (elementNode != null) {
|
||||
String text = elementNode.asText();
|
||||
if (StringUtils.isNotBlank(text)) {
|
||||
byte[] bytes = text.getBytes();
|
||||
if (bytes != null && bytes.length > 0) {
|
||||
sb.append(String.format("%02x", text.getBytes()[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
result = sb.toString();
|
||||
} else {
|
||||
result = node.asText();
|
||||
}
|
||||
}
|
||||
|
||||
public static JsonNode secureSampleData(JsonNode sample) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String[] nameArray = new String[]{"member_sk", "membersk", "member_id", "memberid", "mem_sk", "mem_id"};
|
||||
if (sample != null && sample.has("sample")) {
|
||||
JsonNode sampleNode = sample.get("sample");
|
||||
if (sampleNode != null && sampleNode.has("columnNames") && sampleNode.has("data")) {
|
||||
JsonNode namesNode = sampleNode.get("columnNames");
|
||||
JsonNode dataNode = sampleNode.get("data");
|
||||
if (namesNode != null && namesNode.isArray()) {
|
||||
for (int i = 0; i < namesNode.size(); i++) {
|
||||
if (Arrays.asList(nameArray).contains(namesNode.get(i).asText().toLowerCase())) {
|
||||
if (dataNode != null && dataNode.isArray()) {
|
||||
for (JsonNode node : dataNode) {
|
||||
JsonNode valueNode = node.get(i);
|
||||
((ArrayNode) node).set(i, new TextNode("********"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = 0;
|
||||
Iterator<JsonNode> arrayIterator = sampleNode.elements();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode sampleRowNode = arrayIterator.next();
|
||||
if (sampleRowNode != null)
|
||||
{
|
||||
if (sampleRowNode.has(MEMBER_ID))
|
||||
{
|
||||
((ObjectNode) sampleRowNode).set(MEMBER_ID, new TextNode("********"));
|
||||
}
|
||||
if (sampleRowNode.has(TREE_ID))
|
||||
{
|
||||
JsonNode treeIdNode = sampleRowNode.get(TREE_ID);
|
||||
String convertedValue = convertToHexString(treeIdNode);
|
||||
((ObjectNode) sampleRowNode).set(TREE_ID, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(TRACKING_ID))
|
||||
{
|
||||
JsonNode trackingIdNode = sampleRowNode.get(TRACKING_ID);
|
||||
String convertedValue = convertToHexString(trackingIdNode);
|
||||
((ObjectNode) sampleRowNode).set(TRACKING_ID, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(IP_AS_BYTES))
|
||||
{
|
||||
JsonNode ipNode = sampleRowNode.get(IP_AS_BYTES);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) sampleRowNode).set(IP_AS_BYTES, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(IP_AS_BYTES_1))
|
||||
{
|
||||
JsonNode ipNode = sampleRowNode.get(IP_AS_BYTES_1);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) sampleRowNode).set(IP_AS_BYTES_1, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(ATTACHMENTS))
|
||||
{
|
||||
JsonNode attachmentNode = sampleRowNode.get(ATTACHMENTS);
|
||||
if (attachmentNode.has(PAYLOAD))
|
||||
{
|
||||
JsonNode payloadNode = attachmentNode.get(PAYLOAD);
|
||||
String value = "** " + Integer.toString(payloadNode.size()) + " bytes binary data **";
|
||||
((ObjectNode) attachmentNode).set(PAYLOAD, new TextNode(value));
|
||||
}
|
||||
}
|
||||
if (sampleRowNode.has(MEDIA))
|
||||
{
|
||||
JsonNode mediaNode = sampleRowNode.get(MEDIA);
|
||||
String convertedValue = convertToHexString(mediaNode);
|
||||
((ObjectNode) sampleRowNode).set(MEDIA, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(HEADER))
|
||||
{
|
||||
JsonNode headerNode = sampleRowNode.get(HEADER);
|
||||
if (headerNode != null)
|
||||
{
|
||||
if (headerNode.has(MEMBER_ID))
|
||||
{
|
||||
((ObjectNode) headerNode).set(MEMBER_ID, new TextNode("********"));
|
||||
}
|
||||
if (headerNode.has(GUID))
|
||||
{
|
||||
JsonNode guidNode = headerNode.get(GUID);
|
||||
String convertedValue = convertToHexString(guidNode);
|
||||
((ObjectNode) headerNode).set(GUID, new TextNode(convertedValue));
|
||||
}
|
||||
if (headerNode.has(TREE_ID))
|
||||
{
|
||||
JsonNode headerTreeIdNode = headerNode.get(TREE_ID);
|
||||
String convertedValue = convertToHexString(headerTreeIdNode);
|
||||
((ObjectNode) headerNode).set(TREE_ID, new TextNode(convertedValue));
|
||||
}
|
||||
if (headerNode.has(AUDITHEADER))
|
||||
{
|
||||
JsonNode auditHeaderNode = headerNode.get(AUDITHEADER);
|
||||
if (auditHeaderNode != null && auditHeaderNode.has(MESSAGE_ID))
|
||||
{
|
||||
JsonNode messageIdNode = auditHeaderNode.get(MESSAGE_ID);
|
||||
String convertedValue = convertToHexString(messageIdNode);
|
||||
((ObjectNode) auditHeaderNode).set(MESSAGE_ID, new TextNode(convertedValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sampleRowNode.has(REQUEST))
|
||||
{
|
||||
JsonNode requestNode = sampleRowNode.get(REQUEST);
|
||||
if (requestNode != null && requestNode.has(ATTACHMENTS))
|
||||
{
|
||||
JsonNode attachmentsNode = requestNode.get(ATTACHMENTS);
|
||||
if (attachmentsNode != null && attachmentsNode.has(PAYLOAD))
|
||||
{
|
||||
JsonNode payloadNode = attachmentsNode.get(PAYLOAD);
|
||||
String value = "** " +
|
||||
Integer.toString(payloadNode.size()) +
|
||||
" bytes binary data **";
|
||||
((ObjectNode) attachmentsNode).set(PAYLOAD, new TextNode(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sampleRowNode.has(REQUEST_HEADER))
|
||||
{
|
||||
JsonNode requestHeaderNode = sampleRowNode.get(REQUEST_HEADER);
|
||||
if (requestHeaderNode != null && requestHeaderNode.has(IP_AS_BYTES))
|
||||
{
|
||||
JsonNode ipNode = requestHeaderNode.get(IP_AS_BYTES);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) requestHeaderNode).set(IP_AS_BYTES, new TextNode(convertedValue));
|
||||
}
|
||||
if (requestHeaderNode != null && requestHeaderNode.has(IP_AS_BYTES_1))
|
||||
{
|
||||
JsonNode ipNode = requestHeaderNode.get(IP_AS_BYTES_1);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) requestHeaderNode).set(IP_AS_BYTES_1, new TextNode(convertedValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
public static JsonNode secureSampleData(JsonNode sample) {
|
||||
|
||||
String[] nameArray = new String[]{"member_sk", "membersk", "member_id", "memberid", "mem_sk", "mem_id"};
|
||||
if (sample != null && sample.has("sample")) {
|
||||
JsonNode sampleNode = sample.get("sample");
|
||||
if (sampleNode != null && sampleNode.has("columnNames") && sampleNode.has("data")) {
|
||||
JsonNode namesNode = sampleNode.get("columnNames");
|
||||
JsonNode dataNode = sampleNode.get("data");
|
||||
if (namesNode != null && namesNode.isArray()) {
|
||||
for (int i = 0; i < namesNode.size(); i++) {
|
||||
if (Arrays.asList(nameArray).contains(namesNode.get(i).asText().toLowerCase())) {
|
||||
if (dataNode != null && dataNode.isArray()) {
|
||||
for (JsonNode node : dataNode) {
|
||||
JsonNode valueNode = node.get(i);
|
||||
((ArrayNode) node).set(i, new TextNode("********"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sample;
|
||||
} else {
|
||||
int index = 0;
|
||||
Iterator<JsonNode> arrayIterator = sampleNode.elements();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode sampleRowNode = arrayIterator.next();
|
||||
if (sampleRowNode != null) {
|
||||
if (sampleRowNode.has(MEMBER_ID)) {
|
||||
((ObjectNode) sampleRowNode).set(MEMBER_ID, new TextNode("********"));
|
||||
}
|
||||
if (sampleRowNode.has(TREE_ID)) {
|
||||
JsonNode treeIdNode = sampleRowNode.get(TREE_ID);
|
||||
String convertedValue = convertToHexString(treeIdNode);
|
||||
((ObjectNode) sampleRowNode).set(TREE_ID, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(TRACKING_ID)) {
|
||||
JsonNode trackingIdNode = sampleRowNode.get(TRACKING_ID);
|
||||
String convertedValue = convertToHexString(trackingIdNode);
|
||||
((ObjectNode) sampleRowNode).set(TRACKING_ID, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(IP_AS_BYTES)) {
|
||||
JsonNode ipNode = sampleRowNode.get(IP_AS_BYTES);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) sampleRowNode).set(IP_AS_BYTES, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(IP_AS_BYTES_1)) {
|
||||
JsonNode ipNode = sampleRowNode.get(IP_AS_BYTES_1);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) sampleRowNode).set(IP_AS_BYTES_1, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(ATTACHMENTS)) {
|
||||
JsonNode attachmentNode = sampleRowNode.get(ATTACHMENTS);
|
||||
if (attachmentNode.has(PAYLOAD)) {
|
||||
JsonNode payloadNode = attachmentNode.get(PAYLOAD);
|
||||
String value = "** " + Integer.toString(payloadNode.size()) + " bytes binary data **";
|
||||
((ObjectNode) attachmentNode).set(PAYLOAD, new TextNode(value));
|
||||
}
|
||||
}
|
||||
if (sampleRowNode.has(MEDIA)) {
|
||||
JsonNode mediaNode = sampleRowNode.get(MEDIA);
|
||||
String convertedValue = convertToHexString(mediaNode);
|
||||
((ObjectNode) sampleRowNode).set(MEDIA, new TextNode(convertedValue));
|
||||
}
|
||||
if (sampleRowNode.has(HEADER)) {
|
||||
JsonNode headerNode = sampleRowNode.get(HEADER);
|
||||
if (headerNode != null) {
|
||||
if (headerNode.has(MEMBER_ID)) {
|
||||
((ObjectNode) headerNode).set(MEMBER_ID, new TextNode("********"));
|
||||
}
|
||||
if (headerNode.has(GUID)) {
|
||||
JsonNode guidNode = headerNode.get(GUID);
|
||||
String convertedValue = convertToHexString(guidNode);
|
||||
((ObjectNode) headerNode).set(GUID, new TextNode(convertedValue));
|
||||
}
|
||||
if (headerNode.has(TREE_ID)) {
|
||||
JsonNode headerTreeIdNode = headerNode.get(TREE_ID);
|
||||
String convertedValue = convertToHexString(headerTreeIdNode);
|
||||
((ObjectNode) headerNode).set(TREE_ID, new TextNode(convertedValue));
|
||||
}
|
||||
if (headerNode.has(AUDITHEADER)) {
|
||||
JsonNode auditHeaderNode = headerNode.get(AUDITHEADER);
|
||||
if (auditHeaderNode != null && auditHeaderNode.has(MESSAGE_ID)) {
|
||||
JsonNode messageIdNode = auditHeaderNode.get(MESSAGE_ID);
|
||||
String convertedValue = convertToHexString(messageIdNode);
|
||||
((ObjectNode) auditHeaderNode).set(MESSAGE_ID, new TextNode(convertedValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sampleRowNode.has(REQUEST)) {
|
||||
JsonNode requestNode = sampleRowNode.get(REQUEST);
|
||||
if (requestNode != null && requestNode.has(ATTACHMENTS)) {
|
||||
JsonNode attachmentsNode = requestNode.get(ATTACHMENTS);
|
||||
if (attachmentsNode != null && attachmentsNode.has(PAYLOAD)) {
|
||||
JsonNode payloadNode = attachmentsNode.get(PAYLOAD);
|
||||
String value = "** " + Integer.toString(payloadNode.size()) + " bytes binary data **";
|
||||
((ObjectNode) attachmentsNode).set(PAYLOAD, new TextNode(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sampleRowNode.has(REQUEST_HEADER)) {
|
||||
JsonNode requestHeaderNode = sampleRowNode.get(REQUEST_HEADER);
|
||||
if (requestHeaderNode != null && requestHeaderNode.has(IP_AS_BYTES)) {
|
||||
JsonNode ipNode = requestHeaderNode.get(IP_AS_BYTES);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) requestHeaderNode).set(IP_AS_BYTES, new TextNode(convertedValue));
|
||||
}
|
||||
if (requestHeaderNode != null && requestHeaderNode.has(IP_AS_BYTES_1)) {
|
||||
JsonNode ipNode = requestHeaderNode.get(IP_AS_BYTES_1);
|
||||
String convertedValue = convertToHexString(ipNode);
|
||||
((ObjectNode) requestHeaderNode).set(IP_AS_BYTES_1, new TextNode(convertedValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
@ -14,104 +14,87 @@
|
||||
package utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class SchemaHistory
|
||||
{
|
||||
|
||||
public static int calculateDict(JsonNode node) {
|
||||
int count = 0;
|
||||
Iterator<Map.Entry<String, JsonNode>> iterator = node.fields();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Map.Entry<String,JsonNode> element = iterator.next();
|
||||
if (element.getValue().isArray()) {
|
||||
if (element.getKey().toLowerCase() == "fields")
|
||||
{
|
||||
count += element.getValue().size();
|
||||
}
|
||||
count += calculateList(element.getValue());
|
||||
} else if (element.getValue().isContainerNode()) {
|
||||
if (element.getKey().toLowerCase() == "fields")
|
||||
{
|
||||
count += element.getValue().size();
|
||||
}
|
||||
count += calculateDict(element.getValue());
|
||||
}
|
||||
else if (element.getKey().toLowerCase() == "fields")
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
public class SchemaHistory {
|
||||
|
||||
public static int calculateDict(JsonNode node) {
|
||||
int count = 0;
|
||||
Iterator<Map.Entry<String, JsonNode>> iterator = node.fields();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, JsonNode> element = iterator.next();
|
||||
if (element.getValue().isArray()) {
|
||||
if (element.getKey().toLowerCase() == "fields") {
|
||||
count += element.getValue().size();
|
||||
}
|
||||
return count;
|
||||
count += calculateList(element.getValue());
|
||||
} else if (element.getValue().isContainerNode()) {
|
||||
if (element.getKey().toLowerCase() == "fields") {
|
||||
count += element.getValue().size();
|
||||
}
|
||||
count += calculateDict(element.getValue());
|
||||
} else if (element.getKey().toLowerCase() == "fields") {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static int calculateList(JsonNode node) {
|
||||
int count = 0;
|
||||
Iterator<JsonNode> arrayIterator = node.elements();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode element = arrayIterator.next();
|
||||
if (element.isArray()) {
|
||||
count += calculateList(element);
|
||||
} else if (element.isContainerNode()) {
|
||||
count += calculateDict(element);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
public static int calculateList(JsonNode node) {
|
||||
int count = 0;
|
||||
Iterator<JsonNode> arrayIterator = node.elements();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode element = arrayIterator.next();
|
||||
if (element.isArray()) {
|
||||
count += calculateList(element);
|
||||
} else if (element.isContainerNode()) {
|
||||
count += calculateDict(element);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static int calculateFieldCount(JsonNode node)
|
||||
{
|
||||
int count = 0;
|
||||
JsonNode schemaNode = null;
|
||||
|
||||
if (node != null && node.has("schema")) {
|
||||
schemaNode = node.get("schema");
|
||||
}
|
||||
else
|
||||
{
|
||||
schemaNode = node;
|
||||
}
|
||||
if (schemaNode.isArray()) {
|
||||
|
||||
Iterator<JsonNode> arrayIterator = schemaNode.elements();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode element = arrayIterator.next();
|
||||
if (element.isArray()) {
|
||||
count += calculateList(element);
|
||||
} else if (element.isContainerNode()) {
|
||||
count += calculateDict(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (schemaNode.isContainerNode())
|
||||
{
|
||||
Iterator<Map.Entry<String, JsonNode>> iterator = schemaNode.fields();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Map.Entry<String,JsonNode> element = iterator.next();
|
||||
if (element.getValue().isArray()) {
|
||||
if (element.getKey().toLowerCase() == "fields")
|
||||
{
|
||||
count += element.getValue().size();
|
||||
}
|
||||
count += calculateList(element.getValue());
|
||||
} else if (element.getValue().isContainerNode()) {
|
||||
if (element.getKey().toLowerCase() == "fields")
|
||||
{
|
||||
count += element.getValue().size();
|
||||
}
|
||||
count += calculateDict(element.getValue());
|
||||
}
|
||||
else if (element.getKey().toLowerCase() == "fields")
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
public static int calculateFieldCount(JsonNode node) {
|
||||
int count = 0;
|
||||
JsonNode schemaNode = null;
|
||||
|
||||
if (node != null && node.has("schema")) {
|
||||
schemaNode = node.get("schema");
|
||||
} else {
|
||||
schemaNode = node;
|
||||
}
|
||||
if (schemaNode.isArray()) {
|
||||
|
||||
Iterator<JsonNode> arrayIterator = schemaNode.elements();
|
||||
while (arrayIterator.hasNext()) {
|
||||
JsonNode element = arrayIterator.next();
|
||||
if (element.isArray()) {
|
||||
count += calculateList(element);
|
||||
} else if (element.isContainerNode()) {
|
||||
count += calculateDict(element);
|
||||
}
|
||||
}
|
||||
} else if (schemaNode.isContainerNode()) {
|
||||
Iterator<Map.Entry<String, JsonNode>> iterator = schemaNode.fields();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, JsonNode> element = iterator.next();
|
||||
if (element.getValue().isArray()) {
|
||||
if (element.getKey().toLowerCase() == "fields") {
|
||||
count += element.getValue().size();
|
||||
}
|
||||
count += calculateList(element.getValue());
|
||||
} else if (element.getValue().isContainerNode()) {
|
||||
if (element.getKey().toLowerCase() == "fields") {
|
||||
count += element.getValue().size();
|
||||
}
|
||||
count += calculateDict(element.getValue());
|
||||
} else if (element.getKey().toLowerCase() == "fields") {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -14,28 +14,27 @@
|
||||
package utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import play.Logger;
|
||||
import play.Play;
|
||||
import play.libs.Json;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Tree
|
||||
{
|
||||
public static JsonNode loadTreeJsonNode(String key) {
|
||||
if (StringUtils.isNotBlank(key)) {
|
||||
String treeName = Play.application().configuration().getString(key);
|
||||
if (StringUtils.isNotBlank(treeName)) {
|
||||
try {
|
||||
return Json.parse(new FileInputStream(new File(treeName)));
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
public class Tree {
|
||||
public static JsonNode loadTreeJsonNode(String key) {
|
||||
if (StringUtils.isNotBlank(key)) {
|
||||
String treeName = Play.application().configuration().getString(key);
|
||||
if (StringUtils.isNotBlank(treeName)) {
|
||||
try {
|
||||
return Json.parse(new FileInputStream(new File(treeName)));
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Json.toJson("");
|
||||
}
|
||||
}
|
||||
|
||||
return Json.toJson("");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user