Search in sources :

Example 1 with InsightsOutcomeTools

use of com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools 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 outcome list ..", e);
        throw new InsightsCustomException(e.getMessage());
    }
}
Also used : InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) JsonElement(com.google.gson.JsonElement) TypeToken(com.google.gson.reflect.TypeToken) InsightsOutcomeTools(com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools) Gson(com.google.gson.Gson) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 2 with InsightsOutcomeTools

use of com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools 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());
        if (configJson.has("toolConfigJson")) {
            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 updating record " + e.getMessage());
    }
}
Also used : InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) InsightsOutcomeTools(com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 3 with InsightsOutcomeTools

use of com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools 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 updating outcome status " + e.getMessage());
    }
}
Also used : InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) InsightsOutcomeTools(com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 4 with InsightsOutcomeTools

use of com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools 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());
    if (configJson.has("toolConfigJson")) {
        insightsOutcomeTools.setConfigJson(configJson.get("toolConfigJson").getAsJsonObject().toString());
    }
    insightsOutcomeTools.setIsActive(configJson.get(CommonsAndDALConstants.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);
}
Also used : InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) InsightsTools(com.cognizant.devops.platformdal.outcome.InsightsTools) InsightsOutcomeTools(com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools)

Example 5 with InsightsOutcomeTools

use of com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools in project Insights by CognizantOneDevOps.

the class MileStoneServiceImpl method fetchOutcomeConfig.

@Override
public JsonArray fetchOutcomeConfig() throws InsightsCustomException {
    try {
        List<InsightsOutcomeTools> configs = mileStoneConfigDAL.getOutcomeConfigTools();
        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());
    }
}
Also used : InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) JsonElement(com.google.gson.JsonElement) TypeToken(com.google.gson.reflect.TypeToken) InsightsOutcomeTools(com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools) Gson(com.google.gson.Gson) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Aggregations

InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)7 InsightsOutcomeTools (com.cognizant.devops.platformdal.outcome.InsightsOutcomeTools)7 JsonElement (com.google.gson.JsonElement)4 InsightsMileStoneOutcomeConfig (com.cognizant.devops.platformdal.milestone.InsightsMileStoneOutcomeConfig)2 MileStoneConfig (com.cognizant.devops.platformdal.milestone.MileStoneConfig)2 Gson (com.google.gson.Gson)2 JsonArray (com.google.gson.JsonArray)2 TypeToken (com.google.gson.reflect.TypeToken)2 HashSet (java.util.HashSet)2 InsightsTools (com.cognizant.devops.platformdal.outcome.InsightsTools)1