use of com.cognizant.devops.platformcommons.exception.InsightsCustomException in project Insights by CognizantOneDevOps.
the class OutComeController method saveOutcomeConfig.
@PostMapping(value = "/saveOutcomeConfig", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public JsonObject saveOutcomeConfig(@RequestBody String config) {
String message = null;
try {
JsonObject configJson = JsonUtils.parseStringAsJsonObject(config);
int result = outComeServiceImpl.saveOutcomeConfig(configJson);
log.debug("Outcome config saved successfully === {} ", result);
} catch (InsightsCustomException e) {
return PlatformServiceUtil.buildFailureResponse(e.getMessage());
}
return PlatformServiceUtil.buildSuccessResponseWithData(message);
}
use of com.cognizant.devops.platformcommons.exception.InsightsCustomException in project Insights by CognizantOneDevOps.
the class OutComeServiceImpl method updateOutcomeConfigStatus.
@Override
public void updateOutcomeConfigStatus(JsonObject configJson) throws InsightsCustomException {
try {
int outcomeId = configJson.get("id").getAsInt();
InsightsOutcomeTools insightsOutcomeTools = outComeConfigDAL.getOutcomeConfig(outcomeId);
insightsOutcomeTools.setIsActive(configJson.get("isActive").getAsBoolean());
outComeConfigDAL.updateOutcomeConfig(insightsOutcomeTools);
} catch (Exception e) {
log.error(e);
throw new InsightsCustomException(" Error while saving record " + e.getMessage());
}
}
use of com.cognizant.devops.platformcommons.exception.InsightsCustomException in project Insights by CognizantOneDevOps.
the class OutComeServiceImpl method updateOutcomeConfig.
@Override
public void updateOutcomeConfig(JsonObject configJson) throws InsightsCustomException {
try {
int outcomeId = configJson.get("id").getAsInt();
InsightsOutcomeTools insightsOutcomeTools = outComeConfigDAL.getOutcomeConfig(outcomeId);
insightsOutcomeTools.setOutcomeName(configJson.get("outcomeName").getAsString());
insightsOutcomeTools.setOutcomeType(configJson.get("outcomeType").getAsString());
insightsOutcomeTools.setConfigJson(configJson.get("toolConfigJson").getAsJsonObject().toString());
insightsOutcomeTools.setIsActive(configJson.get("isActive").getAsBoolean());
insightsOutcomeTools.setCreatedDate(configJson.get("createdDate").getAsLong());
insightsOutcomeTools.setMetricUrl(configJson.get("metricUrl").getAsString());
insightsOutcomeTools.setUpdatedDate(InsightsUtils.getCurrentTimeInEpochMilliSeconds());
insightsOutcomeTools.setRequestParameters(configJson.get("parameters").toString());
outComeConfigDAL.updateOutcomeConfig(insightsOutcomeTools);
} catch (Exception e) {
log.error(e);
throw new InsightsCustomException(" Error while saving record " + e.getMessage());
}
}
use of com.cognizant.devops.platformcommons.exception.InsightsCustomException in project Insights by CognizantOneDevOps.
the class OutComeServiceImpl method saveOutcomeConfig.
@Override
public int saveOutcomeConfig(JsonObject configJson) throws InsightsCustomException {
String outcomeName = configJson.get("outcomeName").getAsString();
InsightsOutcomeTools outcomeConfig = outComeConfigDAL.getOutComeConfigByName(outcomeName);
if (outcomeConfig != null) {
throw new InsightsCustomException("Outcome with given name already exists.");
}
InsightsOutcomeTools insightsOutcomeTools = new InsightsOutcomeTools();
insightsOutcomeTools.setOutcomeName(outcomeName);
insightsOutcomeTools.setOutcomeType(configJson.get("outcomeType").getAsString());
insightsOutcomeTools.setConfigJson(configJson.get("toolConfigJson").getAsJsonObject().toString());
insightsOutcomeTools.setIsActive(configJson.get(MilestoneConstants.ISACTIVE).getAsBoolean());
insightsOutcomeTools.setMetricUrl(configJson.get("metricUrl").getAsString());
InsightsTools insightsMilestoneTools = outComeConfigDAL.getOutComeByToolId(configJson.get("toolName").getAsInt());
insightsOutcomeTools.setInsightsTools(insightsMilestoneTools);
insightsOutcomeTools.setCreatedDate(InsightsUtils.getCurrentTimeInEpochMilliSeconds());
insightsOutcomeTools.setRequestParameters(configJson.get("parameters").getAsJsonArray().toString());
return outComeConfigDAL.saveOutcomeConfig(insightsOutcomeTools);
}
use of com.cognizant.devops.platformcommons.exception.InsightsCustomException in project Insights by CognizantOneDevOps.
the class OutComeServiceImpl method getAllActiveOutcome.
@Override
public JsonArray getAllActiveOutcome() throws InsightsCustomException {
try {
List<InsightsOutcomeTools> configs = outComeConfigDAL.getAllActiveOutcome();
Gson gson = new Gson();
JsonElement element = gson.toJsonTree(configs, new TypeToken<List<InsightsOutcomeTools>>() {
}.getType());
if (!element.isJsonArray()) {
throw new InsightsCustomException("Unable to parse Json");
}
return element.getAsJsonArray();
} catch (Exception e) {
log.error("Error getting milestone list ..", e);
throw new InsightsCustomException(e.getMessage());
}
}
Aggregations