From 18cc016bcb74372da3bab01c94f00389c7793cc1 Mon Sep 17 00:00:00 2001 From: ajay-egov Date: Tue, 27 Jun 2023 16:25:54 +0530 Subject: [PATCH 1/4] PFM-2922 | Add metricCount to metric chart --- .../analytics/handler/MetricChartResponseHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java index e193b76d6f2..5f3a85205e9 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java @@ -90,7 +90,9 @@ public AggregateDto translate(AggregateRequestDto request, ObjectNode aggregatio boolean isRoundOff = (chartNode.get(IS_ROUND_OFF)!=null && chartNode.get(IS_ROUND_OFF).asBoolean()) ? true : false; Plot latestDateplot = new Plot("todaysDate", Double.valueOf(0), "number");; Plot lastUpdatedTime = new Plot("lastUpdatedTime", Double.valueOf(0), "number"); + Plot latestCount = new Plot("count",Double.valueOf(0),"number"); Boolean isTodaysCollection = (chartNode.get("TodaysCollection") == null ? Boolean.FALSE : chartNode.get("TodaysCollection").asBoolean()); + Boolean isLatestCount = (chartNode.get("metricCount") == null ? Boolean.FALSE : chartNode.get("metricCount").asBoolean()); for( JsonNode headerPath : aggrsPaths) { List values = aggregationNode.findValues(headerPath.asText()); int valueIndex = 0; @@ -172,6 +174,12 @@ public AggregateDto translate(AggregateRequestDto request, ObjectNode aggregatio } } + if (isLatestCount == Boolean.TRUE){ + JsonNode countNode = aggregationNode.findValue("Count"); + if(countNode != null && countNode.has(IResponseHandler.VALUE)){ + latestCount.setValue(countNode.findValue(IResponseHandler.VALUE).asDouble()); + } + } valueIndex++; } // Why is aggrsPaths.size()==2 required? Is there validation if action = @@ -199,7 +207,7 @@ public AggregateDto translate(AggregateRequestDto request, ObjectNode aggregatio else throw new CustomException("INVALID_NUMBER_OF_OPERANDS", "Division operation can be performed only with 2 operands."); } - data.setPlots( Arrays.asList(latestDateplot,lastUpdatedTime)); + data.setPlots( Arrays.asList(latestDateplot,lastUpdatedTime,latestCount)); request.getResponseRecorder().put(visualizationCode, request.getModuleLevel(), data); dataList.add(data); if(chartNode.get(POST_AGGREGATION_THEORY) != null) { From 908461910c7dcc17205be4fb765a2cbacb272409 Mon Sep 17 00:00:00 2001 From: ajay-egov Date: Tue, 18 Jul 2023 13:28:55 +0530 Subject: [PATCH 2/4] Add field check to additive computed field --- .../com/tarento/analytics/helper/AdditiveComputedField.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/AdditiveComputedField.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/AdditiveComputedField.java index b8bbb5c9852..fcfa8649b91 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/AdditiveComputedField.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/AdditiveComputedField.java @@ -39,8 +39,10 @@ public void add(Data data, List fields, String newField,JsonNode chartNo double total = 0.0; for (String field: fields){ - dataType = plotMap.get(field).getSymbol(); - total = total+ plotMap.get(field).getValue(); + if(plotMap.containsKey(field)) { + dataType = plotMap.get(field).getSymbol(); + total = total + plotMap.get(field).getValue(); + } } if(postAggrTheoryName != null && !postAggrTheoryName.isEmpty()) { ComputeHelper computeHelper = computeHelperFactory.getInstance(postAggrTheoryName); From fd9a2f7cf0c10db6e6305c00b60f0d844dbfa819 Mon Sep 17 00:00:00 2001 From: ajay-egov Date: Thu, 27 Jul 2023 14:52:17 +0530 Subject: [PATCH 3/4] Add compareTwoindices util to metric chart handler --- .../analytics/handler/IResponseHandler.java | 15 +++++++++++++++ .../handler/MetricChartResponseHandler.java | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java index bcc72b4e486..d64ee57582b 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java @@ -75,6 +75,8 @@ public interface IResponseHandler { public final String DOC_COUNT = "doc_count"; public static final String POST_AGGREGATION_THEORY = "postAggregationTheory"; + + public static final String COMPARE_TWO_INDICES = "compareTwoIndices"; public static final String CHART_SPECIFIC = "chartSpecificProperty"; @@ -207,4 +209,17 @@ default void appendMissingPlot(Set plotKeys, Data data, String symbol, b data.setPlots(sortedMap.values().stream().collect(Collectors.toList())); } + default Double compareTwoIndices(List> bucketList){ + List listA = bucketList.get(0); + List listB = bucketList.get(1); + + Double count = 0.0; + for (String str : listA) { + if (!listB.contains(str)) { + count++; + } + } + return count; + } + } diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java index 5f3a85205e9..a64970e6e10 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/MetricChartResponseHandler.java @@ -84,6 +84,8 @@ public AggregateDto translate(AggregateRequestDto request, ObjectNode aggregatio List percentageList = new ArrayList<>(); ArrayNode aggrsPaths = (ArrayNode) chartNode.get(AGGS_PATH); + boolean extractBuckets = chartNode.get(POST_AGGREGATION_THEORY).asText().equals(COMPARE_TWO_INDICES); + List> bucketList = new ArrayList<>(); /* * Sums all value of all aggrsPaths i.e all aggregations * */ @@ -98,6 +100,9 @@ public AggregateDto translate(AggregateRequestDto request, ObjectNode aggregatio int valueIndex = 0; Double headerPathValue = new Double(0); for (JsonNode value : values) { + if(extractBuckets){ + bucketList.add(value.findValuesAsText("key")); + } if (isRoundOff) { ObjectMapper mapper = new ObjectMapper(); JsonNode node = value.get("value"); @@ -193,7 +198,11 @@ public AggregateDto translate(AggregateRequestDto request, ObjectNode aggregatio } String symbol = chartNode.get(IResponseHandler.VALUE_TYPE).asText(); - + if (extractBuckets && bucketList.size() ==2){ + Double count = compareTwoIndices(bucketList); + totalValues.clear(); + totalValues.add(count); + } try{ Data data = new Data(chartName, action.equals(PERCENTAGE) && aggrsPaths.size()==2? percentageValue(percentageList, isRoundOff) : (totalValues==null || totalValues.isEmpty())? 0.0 :totalValues.stream().reduce(0.0, Double::sum), symbol); //Logic to perform DIVISION action From f08b3230d338c10185baefe6b98de827792ddbd5 Mon Sep 17 00:00:00 2001 From: ajay-egov Date: Mon, 31 Jul 2023 05:36:33 +0530 Subject: [PATCH 4/4] Added new chart type ctable to compare data in table --- .../tarento/analytics/enums/ChartType.java | 2 +- .../CompareTableChartResponseHandler.java | 190 ++++++++++++++++++ .../analytics/handler/IResponseHandler.java | 6 +- .../handler/ResponseHandlerFactory.java | 4 + .../helper/CompareComputedField.java | 68 +++++++ .../helper/ComputedFieldFactory.java | 5 +- 6 files changed, 271 insertions(+), 4 deletions(-) create mode 100644 business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/CompareTableChartResponseHandler.java create mode 100644 business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/CompareComputedField.java diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/enums/ChartType.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/enums/ChartType.java index 4e1377e630b..7694ae2caba 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/enums/ChartType.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/enums/ChartType.java @@ -7,7 +7,7 @@ public enum ChartType { - XTABLE("xtable"), TABLE("table"), PERFORM("perform"), METRIC("metric"), PIE("pie"), LINE("line"); + XTABLE("xtable"), TABLE("table"), PERFORM("perform"), METRIC("metric"), PIE("pie"), LINE("line"), CTABLE("ctable"); private String value; diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/CompareTableChartResponseHandler.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/CompareTableChartResponseHandler.java new file mode 100644 index 00000000000..c51453c6cff --- /dev/null +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/CompareTableChartResponseHandler.java @@ -0,0 +1,190 @@ +package com.tarento.analytics.handler; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.JsonNodeType; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.tarento.analytics.dto.AggregateDto; +import com.tarento.analytics.dto.AggregateRequestDto; +import com.tarento.analytics.dto.Data; +import com.tarento.analytics.dto.Plot; +import com.tarento.analytics.helper.ComputedFieldFactory; +import com.tarento.analytics.helper.IComputedField; +import com.tarento.analytics.model.ComputedFields; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +@Component +public class CompareTableChartResponseHandler implements IResponseHandler{ + + public static final Logger logger = LoggerFactory.getLogger(AdvanceTableChartResponseHandler.class); + + @Autowired + private ObjectMapper mapper; + + @Autowired + private ComputedFieldFactory computedFieldFactory; + + @Override + public AggregateDto translate(AggregateRequestDto requestDto, ObjectNode aggregations) throws IOException { + JsonNode aggregationNode = aggregations.get(AGGREGATIONS); + JsonNode chartNode = requestDto.getChartNode(); + String plotLabel = chartNode.get(PLOT_LABEL).asText(); + JsonNode computedFields = chartNode.get(COMPUTED_FIELDS); + JsonNode excludedFields = chartNode.get(EXCLUDED_COLUMNS); + + boolean executeComputedFields = computedFields !=null && computedFields.isArray(); + List aggrNodes = aggregationNode.findValues(BUCKETS); + boolean isPathSpecified = chartNode.get(IResponseHandler.AGGS_PATH)!=null && chartNode.get(IResponseHandler.AGGS_PATH).isArray(); + ArrayNode aggrsPaths = isPathSpecified ? (ArrayNode) chartNode.get(IResponseHandler.AGGS_PATH) : JsonNodeFactory.instance.arrayNode(); + + int[] idx = { 1 }; + List dataList = new ArrayList<>(); + Map> mappings = new HashMap<>(); + + aggrNodes.stream().forEach(node -> { + ArrayNode buckets = (ArrayNode) node; + buckets.forEach(bucket -> { + + Map plotMap = new LinkedHashMap<>(); + String key = bucket.get(IResponseHandler.KEY).asText(); + + if(aggrsPaths.size()>0){ + processWithSpecifiedKeys(aggrsPaths, bucket, mappings, key, plotMap,chartNode); + } + if (plotMap.size() > 0) { + Map plots = new LinkedHashMap<>(); + ObjectNode sno = mapper.createObjectNode(); + sno.put(NAME,SERIAL_NUMBER); + sno.put(SYMBOL,TABLE_TEXT); + sno.put(LABEL, ""+idx[0]++); + + ObjectNode plotkey = mapper.createObjectNode(); + plotkey.put(NAME,plotLabel.isEmpty() ? TABLE_KEY : plotLabel); + plotkey.put(SYMBOL,TABLE_TEXT); + plotkey.put(LABEL, key); + + plots.put(SERIAL_NUMBER, sno); + plots.put(plotLabel.isEmpty() ? TABLE_KEY : plotLabel, plotkey); + plots.putAll(plotMap); + mappings.put(key, plots); + + } + }); + }); + + mappings.entrySet().stream().forEach(plotMap -> { + List plotList = plotMap.getValue().values().stream().collect(Collectors.toList()); + + List filterPlot = plotList.stream().filter(c -> (!c.get("name").asText().equalsIgnoreCase(SERIAL_NUMBER) && !c.get("name").asText().equalsIgnoreCase(plotLabel))).collect(Collectors.toList()); + + if(filterPlot.size()>0){ + Data data = new Data(plotMap.getKey(), Integer.parseInt(plotMap.getValue().get(SERIAL_NUMBER).get(LABEL).asText()), null); + ObjectNode plotNode = mapper.convertValue(plotMap.getValue(),ObjectNode.class); + if(executeComputedFields){ + try { + List computedFieldsList = mapper.readValue(computedFields.toString(), new TypeReference>(){}); + computedFieldsList.forEach(cfs -> { + IComputedField computedFieldObject = computedFieldFactory.getInstance(cfs.getActionName()); + computedFieldObject.set(requestDto, cfs.getPostAggregationTheory()); + computedFieldObject.add(plotNode, cfs.getFields(), cfs.getNewField(), chartNode ); + + }); + List plots = new ArrayList<>(); + plotNode.forEach(node -> { + if(node.has(LABEL)){ + Plot plot = new Plot(node.get(NAME).asText(), node.get(SYMBOL).asText()); + plot.setLabel(node.get(LABEL).asText()); + plots.add(plot); + }else if(node.has(VALUE)){ + if(node.get(VALUE).getNodeType() == JsonNodeType.ARRAY){ + Plot plot = new Plot(node.get(NAME).asText(), (double) node.get(VALUE).size(), node.get(SYMBOL).asText()); + plots.add(plot); + }else { + Plot plot = new Plot(node.get(NAME).asText(), node.get(VALUE).asDouble(), node.get(SYMBOL).asText()); + plots.add(plot); + } + } + }); + if(excludedFields!=null){ + List list = mapper.readValue(excludedFields.toString(), new TypeReference>(){}); + List removeplots = plots.stream().filter(c -> list.contains(c.getName())).collect(Collectors.toList()); + plots.removeAll(removeplots); + } + data.setPlots(plots); + } catch (Exception e){ + logger.error("execution of computed field :"+e.getMessage()); + } + } + dataList.add(data); + } + }); + + return getAggregatedDto(chartNode, dataList, requestDto.getVisualizationCode()); + } + + private void processWithSpecifiedKeys(ArrayNode aggrsPaths, JsonNode bucket, Map> mappings, String key, Map plotMap,JsonNode chartNode ){ + + aggrsPaths.forEach(headerPath -> { + JsonNode valueNode = bucket.findValue(headerPath.asText()); + ObjectNode plotNode = mapper.createObjectNode(); + plotNode.put(NAME,headerPath.asText()); + if(valueNode!=null){ + if (valueNode.has(BUCKETS)){ + ArrayList keyList = (ArrayList) valueNode.findValuesAsText("key"); + plotNode.putPOJO(VALUE,keyList); + }else { + plotNode.put(VALUE, ( null == valueNode.findValue(VALUE) ? 0.0 : valueNode.findValue(VALUE).asDouble())); + } + }else{ + plotNode.put(VALUE,0.0); + } + String dataType = getDataType(chartNode, headerPath.asText(), valueNode); + plotNode.put(SYMBOL,dataType); + + if(chartNode.get(IS_ROUND_OFF)!=null && chartNode.get(IS_ROUND_OFF).asBoolean() && plotNode.get(VALUE).isDouble()) { + Double value = (double) Math.round(plotNode.get(VALUE).asDouble()); + plotNode.put(VALUE,value); + } + + if(mappings.containsKey(key)){ + if(mappings.get(key).get(headerPath.asText()) == null){ + mappings.get(key).put(headerPath.asText(), plotNode); + }else{ + if(mappings.get(key).get(headerPath.asText()).get(VALUE).isDouble() ){ + if(plotNode.get(VALUE).isDouble()){ + double newVal = mappings.get(key).get(headerPath.asText()).get(VALUE).asDouble() + plotNode.get(VALUE).asDouble(); + plotNode.put(VALUE,newVal); + } + mappings.get(key).put(headerPath.asText(), plotNode); + } + } + }else{ + plotMap.put(headerPath.asText(), plotNode); + } + + }); + } + + private String getDataType(JsonNode chartNode, String headerName, JsonNode valueNode) { + // TODO Auto-generated method stub + if (chartNode.get("pathDataTypeMapping") != null) { + JsonNode pathDataMapping = chartNode.get("pathDataTypeMapping"); + JsonNode node = pathDataMapping.findValue(headerName); + return node.textValue(); + } else if( chartNode.get(VALUE_TYPE) != null) { + return chartNode.get(VALUE_TYPE).asText(); + }else { + return valueNode.isDouble() ? "amount" : "number"; + } + } +} diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java index d64ee57582b..12e972ed3e5 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/IResponseHandler.java @@ -38,7 +38,7 @@ public interface IResponseHandler { // Table Chart Keys public static final String SERIAL_NUMBER = "S.N."; public static final String TABLE_TEXT = "text" ; - public static final String TABLE_KEY = "Key"; + public static final String TABLE_KEY = "Key"; // TODO remove the specific column names. @@ -70,7 +70,9 @@ public interface IResponseHandler { public static String BUCKETS = "buckets"; public static String KEY = "key"; public static String VALUE = "value"; - + public final String NAME = "name"; + public final String LABEL = "label"; + public final String SYMBOL = "symbol"; public final String PERCENTAGE = "percentage"; public final String DOC_COUNT = "doc_count"; diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/ResponseHandlerFactory.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/ResponseHandlerFactory.java index 65cb3aec946..5777964c76d 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/ResponseHandlerFactory.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/handler/ResponseHandlerFactory.java @@ -20,6 +20,8 @@ public class ResponseHandlerFactory { @Autowired private AdvanceTableChartResponseHandler advanceTableChartResponseHandler; + @Autowired + private CompareTableChartResponseHandler compareTableChartResponseHandler; public IResponseHandler getInstance(ChartType chartType) { @@ -40,6 +42,8 @@ public IResponseHandler getInstance(ChartType chartType) { } else if (chartType == chartType.XTABLE) { return advanceTableChartResponseHandler; + } else if (chartType == chartType.CTABLE) { + return compareTableChartResponseHandler; } return null; diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/CompareComputedField.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/CompareComputedField.java new file mode 100644 index 00000000000..1b99bb337e0 --- /dev/null +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/CompareComputedField.java @@ -0,0 +1,68 @@ +package com.tarento.analytics.helper; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.JsonNodeType; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.tarento.analytics.dto.AggregateRequestDto; +import com.tarento.analytics.handler.IResponseHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +@Component +public class CompareComputedField implements IComputedField{ + + public static final Logger logger = LoggerFactory.getLogger(AdditiveComputedField.class); + + private String postAggrTheoryName; + private AggregateRequestDto aggregateRequestDto; + @Autowired + private ComputeHelperFactory computeHelperFactory; + @Autowired + private ObjectMapper mapper; + + @Override + public void set(AggregateRequestDto requestDto, String postAggrTheoryName) { + this.aggregateRequestDto = requestDto; + this.postAggrTheoryName = postAggrTheoryName; + } + + @Override + public void add(ObjectNode data, List fields, String newField, JsonNode chartNode) { + ObjectNode newFieldNode = JsonNodeFactory.instance.objectNode(); + newFieldNode.put(IResponseHandler.NAME,newField); + newFieldNode.set(IResponseHandler.SYMBOL,data.get(fields.get(0)).get(IResponseHandler.SYMBOL)); + Double count = 0.0; + newFieldNode.put(IResponseHandler.VALUE,count); + try { + if(fields.size() == 2 && data.get(fields.get(0)) != null && data.get(fields.get(1)) != null){ + if(data.get(fields.get(0)).get(IResponseHandler.VALUE).isArray() + && data.get(fields.get(1)).get(IResponseHandler.VALUE).isArray()){ + List listA = mapper.convertValue(data.get(fields.get(0)).get(IResponseHandler.VALUE), new TypeReference() {}); + List listB = mapper.convertValue(data.get(fields.get(1)).get(IResponseHandler.VALUE), new TypeReference() {}); + for (String str : listA) { + if (!listB.contains(str)) { + count++; + } + } + + }else { + count = data.get(fields.get(0)).get(IResponseHandler.VALUE).isArray() ? (double) data.get(fields.get(0)).get(IResponseHandler.VALUE).size() + : data.get(fields.get(0)).get(IResponseHandler.VALUE).asDouble(); + } + newFieldNode.put(IResponseHandler.VALUE,count); + data.set(newField,newFieldNode); + } + }catch (Exception e) { + logger.error("could not be compared " +e.getMessage()); + data.set(newField, newFieldNode); + } + + } +} diff --git a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/ComputedFieldFactory.java b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/ComputedFieldFactory.java index 3af853d7ca9..5d9ce04ad62 100644 --- a/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/ComputedFieldFactory.java +++ b/business-services/dashboard-analytics/src/main/java/com/tarento/analytics/helper/ComputedFieldFactory.java @@ -12,6 +12,8 @@ public class ComputedFieldFactory { private AverageComputedField averageComputedField; @Autowired private AdditiveComputedField additiveComputedField; + @Autowired + private CompareComputedField compareComputedField; public IComputedField getInstance(String className){ @@ -23,7 +25,8 @@ public IComputedField getInstance(String className){ } else if(className.equalsIgnoreCase(additiveComputedField.getClass().getSimpleName())) { return additiveComputedField; - + } else if (className.equalsIgnoreCase(compareComputedField.getClass().getSimpleName())) { + return compareComputedField; } else { throw new RuntimeException("Computer field not found for className "+className); }