use of org.apache.commons.text.StringSubstitutor in project Insights by CognizantOneDevOps.
the class PDFKPIVisualizationProcesser method addFieldInVQuery.
private String addFieldInVQuery(String vQuery, int kpiId) {
Map<String, String> dateReplaceMap = new HashMap<>();
dateReplaceMap.put("assessmentId", String.valueOf(assessmentReportDTO.getConfigId()));
dateReplaceMap.put("executionId", String.valueOf(assessmentReportDTO.getExecutionId()));
dateReplaceMap.put(AssessmentReportAndWorkflowConstants.KPIID, String.valueOf(kpiId));
dateReplaceMap.put("assessmentReportName", "'" + assessmentReportDTO.getAsseementreportname() + "'");
StringSubstitutor sub = new StringSubstitutor(dateReplaceMap, "{", "}");
return sub.replace(vQuery);
}
use of org.apache.commons.text.StringSubstitutor in project Insights by CognizantOneDevOps.
the class InsightsKPIProcessor method getQueryWithScheduleDates.
protected void getQueryWithScheduleDates(long nextRuntime, WorkflowTaskEnum.WorkflowSchedule schedule, String neo4jQuery, long oneTimeEndDate, List<QueryModel> queryModelList) {
long startTime = System.nanoTime();
QueryModel queryModel = new QueryModel();
Map<String, Long> dateReplaceMap = new HashMap<>();
long fromDate = InsightsUtils.getStartFromTime(nextRuntime, schedule.name()) - 1;
long toDate;
if (schedule.name().equalsIgnoreCase(WorkflowTaskEnum.WorkflowSchedule.ONETIME.name())) {
toDate = oneTimeEndDate;
} else {
// minus 2 sec to get time 23:59:59
toDate = nextRuntime - 2;
}
dateReplaceMap.put(ReportEngineUtils.START_TIME_FIELD, fromDate);
dateReplaceMap.put(ReportEngineUtils.END_TIME_FIELD, toDate);
StringSubstitutor sub = new StringSubstitutor(dateReplaceMap, "{", "}");
queryModel.setRecordDate(fromDate);
queryModel.setQuery(sub.replace(neo4jQuery));
queryModelList.add(queryModel);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", kpiConfigDTO.getExecutionId(), kpiConfigDTO.getWorkflowId(), kpiConfigDTO.getReportId(), "-", kpiConfigDTO.getKpiId(), kpiConfigDTO.getCategory(), processingTime, "queryStartTime: " + fromDate + "queryEndTime: " + toDate + "schedule: " + kpiConfigDTO.getSchedule());
}
use of org.apache.commons.text.StringSubstitutor in project Insights by CognizantOneDevOps.
the class TraceabilitySummaryUtil method calCount.
public static String calCount(String operandName, JsonArray operandValue, List<JsonObject> toolRespPayload, String message) {
String returnMessage = "";
try {
int totalCount = toolRespPayload.size();
Map<String, Integer> valueMap = new HashMap<>();
List<String> operanValueList = StreamSupport.stream(operandValue.spliterator(), false).map(e -> e.getAsString()).collect(Collectors.toList());
if (totalCount >= 0) {
for (int i = 0; i < operanValueList.size(); i++) {
String operandSingleValue = operanValueList.get(i);
int count = (int) toolRespPayload.stream().filter(payload -> payload.has(operandName) && operandSingleValue.contains(payload.get(operandName).getAsString())).count();
valueMap.put(String.valueOf(i), count);
}
StringSubstitutor sub = new StringSubstitutor(valueMap, "{", "}");
returnMessage = sub.replace(message);
}
} catch (Exception e) {
log.error(e);
}
return returnMessage;
}
use of org.apache.commons.text.StringSubstitutor in project metersphere by metersphere.
the class AbstractNoticeSender method getContent.
protected String getContent(String template, Map<String, Object> context) {
// 处理 null
context.forEach((k, v) -> {
if (v == null) {
context.put(k, "");
}
});
// 处理时间格式的数据
handleTime(context);
StringSubstitutor sub = new StringSubstitutor(context);
return sub.replace(template);
}
use of org.apache.commons.text.StringSubstitutor in project alf.io by alfio-event.
the class LocationDescriptor method getMapUrl.
public static String getMapUrl(String lat, String lng, Map<ConfigurationKeys, ConfigurationManager.MaybeConfiguration> geoConf) {
Map<String, String> params = new HashMap<>();
params.put("latitude", lat);
params.put("longitude", lng);
ConfigurationKeys.GeoInfoProvider provider = getProvider(geoConf);
String mapUrl = mapUrl(provider);
fillParams(provider, geoConf, params);
return new StringSubstitutor(params).replace(mapUrl);
}
Aggregations