diff --git a/Docs/dss-dashboard/DSS Analytics Dashboard YAML Spec 1.0.0.yaml b/Docs/dss-dashboard/DSS Analytics Dashboard YAML Spec 1.0.0.yaml
new file mode 100644
index 000000000..a254b6c90
--- /dev/null
+++ b/Docs/dss-dashboard/DSS Analytics Dashboard YAML Spec 1.0.0.yaml
@@ -0,0 +1,369 @@
+
+swagger: '2.0'
+info:
+ title: DSS Analytics APIs
+ description: |
+ APIs for DSS Analytics Dashboard will mainly consist of 2 APIs.
+ The one which is used to get Configuration based on which the Dashboard has to be painted.
+ The other one will be the API which gets the data which is needed for the Visualization to paint different Graphs.
+ version: "1.0.0"
+# the domain of the service, only for example
+host: 'egov-micro-dev.egovernments.org'
+# array of all schemes that the API supports, preferred https
+schemes:
+ - http
+# will be prefixed to all paths
+basePath: '/dashboard/[APIEndPoint]'
+produces:
+ - application/json
+
+paths:
+ /getDashboardConfig/{dashboardId}:
+ get:
+ summary: API to get the Dashboard Configuration which gives the Visualizations and Layout to paint
+ description:
+ This endpoint will pass the Dashboard ID from the URL to this API and will get the Dashboard Configuration from
+ the backend which will have the details of the Visualization Layouts which are to be designed in this Dashboard.
+ tags:
+ - Dashboard
+ parameters:
+ - name: dashboardId
+ in: path
+ description: ID of the Dashboard
+ required: true
+ type: string
+ responses:
+ '200':
+ description: Response for Success State of the API
+ schema:
+ $ref: '#/definitions/DashboardConfigResponse'
+ '400':
+ description: Invalid input.
+ schema:
+ $ref: '#/definitions/ErrorRes'
+
+ /getChartV2:
+ post:
+ summary: Get Chart API will be responding with the Data for each visualization based on the Chart ID which has been sent
+ description:
+ Based on the Chart ID and the Visualization Type and the Request Dates and Filters, the API will aggregate the data and give the data which needs to be painted on Visualization Charts
+ tags:
+ - Order
+ parameters:
+ - in: body
+ name: order
+ required: true
+ description: This request object contains the Visualization for which the data has to be served.
+ schema:
+ $ref: '#/definitions/DashboardRequest'
+ responses:
+ '200':
+ description: Response for Success State of the API
+ schema:
+ $ref: '#/definitions/DashboardResponse'
+ '400':
+ description: Invalid input.
+ schema:
+ $ref: '#/definitions/ErrorRes'
+
+
+definitions:
+ Chart:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ description: This field holds the Unique Identifier of the Charts
+ name:
+ type: string
+ description: Name of the Chart
+ code:
+ type: string
+ description: Unique Code to recognize the Chart
+ chartType:
+ type: string
+ description: Type of the Chart or Graph which will be painted on the UI for this partifular Chart Data is represented here.
+ format: enum
+ - PIE
+ - BAR
+ - METRIC
+ - LINE
+ - TABLE
+ filter:
+ type: object
+ description: A map of String and and String to hold the Filters which are applied on this chart
+ additionalProperties:
+ type: string
+
+ Dimension:
+ type: object
+ properties:
+ height:
+ type: integer
+ description: Describes the Height of the Visualization
+ width:
+ type: integer
+ description: Describes the Width of the Visualization
+
+ Plot:
+ type: object
+ properties:
+ label:
+ type: string
+ description: Label which has to be printed in the Visualization Charts
+ name:
+ type: string
+ description: Name of the legends which are to be used in the Charts
+ value:
+ type: integer
+ format: int64
+ description: Holds the value of plot response
+ symbol:
+ type: string
+ description: Symbol that has to be used with the Value. Amount or Value or Percentage etc.,
+
+ Data:
+ type: object
+ properties:
+ headerName:
+ type: string
+ description: Name of the header when the grouping of all the plots are done
+ headerValue:
+ type: integer
+ format: int64
+ description: Total Value of all the plots are put as Header Value
+ headerSymbol:
+ type: string
+ description: Symbol which has to be used to represent
+ plots:
+ type: array
+ description: Symbol that has to be used with the Value. Amount or Value or Percentage etc.,
+ items:
+ $ref: "#/definitions/Plot"
+
+ Visualization:
+ type: object
+ properties:
+ id:
+ type: integer
+ description: Unique Identifier for a Visualization
+ name:
+ type: string
+ description: Name of the Visualization
+ dimensions:
+ $ref: "#/definitions/Dimension"
+ vizType:
+ type: string
+ description: Type of Visualization which groups the type of different charts in specific
+ charts:
+ type: array
+ items:
+ $ref: "#/definitions/Chart"
+
+ Tab:
+ type: object
+ properties:
+ row:
+ type: integer
+ description: This defines the row number in which this Visualization will have to appear on UI
+ name:
+ type: string
+ description: Name of the tab on which the visualization has to appear is defined here
+ vizArray:
+ type: array
+ items:
+ $ref: "#/definitions/Visualization"
+
+ Dashboard:
+ type: object
+ properties:
+ name:
+ type: string
+ description: Name of the Dashboard
+ id:
+ type: string
+ description: Unique ID of the Dashboard
+ isActive:
+ type: boolean
+ description: Active / Inactive Status of the Dashboard
+ style:
+ type: string
+ description: Type of the Style which will be represented
+ format: enum
+ - LINEAR
+ - TABBED
+ visualizations:
+ type: array
+ items:
+ $ref: "#/definitions/Tab"
+
+ RequestDate:
+ type: object
+ properties:
+ startDate:
+ type: string
+ description: Request Date Starting Date field
+ endDate:
+ type: string
+ description: Request Date Ending Date Field
+
+ AggregationRequest:
+ type: object
+ properties:
+ visualizationType:
+ type: string
+ description: Request mentions the type of Visualization which it needs the data for
+ format: enum
+ - PIE
+ - BAR
+ - METRIC
+ - LINE
+ - TABLE
+ visualizationCode:
+ type: string
+ description: Code of the Visualization for which the data has to be obtained.
+ queryType:
+ type: string
+ description: Type of Query which has to be used to get the data for this visualization
+ filter:
+ type: object
+ description: A map of String and and String to hold the Filters which are applied on this chart
+ additionalProperties:
+ type: string
+ moduleLevel:
+ type: string
+ description: Which Module is being represented is to be added here.
+ format: enum
+ - PT
+ - TL
+ - PGR
+ - HOME_REVENUE
+ - HOME_SERVICES
+ requestDate:
+ type: object
+ $ref: "#/definitions/RequestDate"
+
+ DashboardRequest:
+ type: object
+ properties:
+ header:
+ type: object
+ description: A map of String and and String to hold the Header Filters which are applied on this dashboard
+ additionalProperties:
+ type: string
+ aggregationRequest:
+ $ref: "#/definitions/AggregationRequest"
+
+ DashboardConfigResponse:
+ type: object
+ properties:
+ statusInfo:
+ type: object
+ description: Status Info
+ $ref: "#/definitions/StatusInfo"
+ responseData:
+ type: array
+ items:
+ $ref: "#/definitions/Dashboard"
+
+ DashboardResponse:
+ type: object
+ properties:
+ statusInfo:
+ type: object
+ description: Status Info
+ $ref: "#/definitions/StatusInfo"
+ responseData:
+ type: array
+ items:
+ $ref: "#/definitions/ChartApiResponse"
+
+ ChartApiResponse:
+ type: object
+ properties:
+ chartType:
+ type: string
+ description: Type of Chart which are to be used to represent the data on Dashboard
+ maxLength: 128
+ chartFormat:
+ type: string
+ description: Format specifies as which library to be used to paint the visualizations
+ maxLength: 32
+ drillDownChartId:
+ type: string
+ description: Chart ID which is to be used for Drill Downs
+ filter:
+ type: object
+ description: A map of String and and String to hold the Filters which are applied on this chart
+ additionalProperties:
+ type: string
+ data:
+ type: array
+ items:
+ $ref: "#/definitions/Data"
+
+ SuccessResponse:
+ type: object
+ properties:
+ status:
+ $ref: "#/definitions/StatusInfo"
+
+ StatusInfo:
+ type: object
+ readOnly: true
+ description: Status Information object will hold the run time status and the live response obtained from the server for the respective API Call.
+ properties:
+ statusCode:
+ type: string
+ description: unique API ID
+ maxLength: 128
+ statusMessage:
+ type: string
+ description: API version
+ maxLength: 32
+ errorCode:
+ type: integer
+ format: int64
+ description: response time in epoch
+ errorMessage:
+ type: string
+ description: unique response message id (UUID) - will usually be the correlation id from the server
+ maxLength: 256
+
+ Error:
+ type: object
+ description: Error object will be returned as a part of reponse body in conjunction with ResponseInfo as part of ErrorResponse whenever the request processing status in the ResponseInfo is FAILED. HTTP return in this scenario will usually be HTTP 400.
+ properties:
+ code:
+ type: string
+ description: Error Code will be module specific error label/code to identiffy the error. All modules should also publish the Error codes with their specific localized values in localization service to ensure clients can print locale specific error messages. Example for error code would be User.NotFound to indicate User Not Found by User/Authentication service. All services must declare their possible Error Codes with brief description in the error response section of their API path.
+ message:
+ type: string
+ description: English locale message of the error code. Clients should make a separate call to get the other locale description if configured with the service.
+ description:
+ type: string
+ description: Optional long description of the error to help clients take remedial action. This will not be available as part of localization service.
+ params:
+ type: array
+ description: Some error messages may carry replaceable fields (say $1, $2) to provide more context to the message. E.g. Format related errors may want to indicate the actual field for which the format is invalid. Client's should use the values in the param array to replace those fields.
+ items:
+ type: string
+ required:
+ - code
+ - message
+
+ ErrorRes:
+ type: object
+ description: All APIs will return ErrorRes in case of failure which will carry ResponseInfo as metadata and Error object as actual representation of error. In case of bulk apis, some apis may chose to return the array of Error objects to indicate individual failure.
+ properties:
+ statusInfo:
+ $ref: '#/definitions/StatusInfo'
+ errors:
+ description: Error response array corresponding to Request Object array. In case of single object submission or _search related paths this may be an array of one error element
+ type: array
+ minLength: 1
+ items:
+ $ref: '#/definitions/Error'
+ required:
+ - statusInfo
\ No newline at end of file
diff --git a/build/build-config.yml b/build/build-config.yml
index 5b2882dad..3e7071d16 100644
--- a/build/build-config.yml
+++ b/build/build-config.yml
@@ -17,7 +17,7 @@
# -
# -
config:
- - name: "business-services/billing-service"
+ - name: "builds/business-services/billing-service"
build:
- work-dir: "billing-service"
image-name: "billing-service"
@@ -25,7 +25,7 @@ config:
- work-dir: "billing-service/src/main/resources/db"
image-name: "billing-service-db"
- - name: "business-services/collection-services"
+ - name: "builds/business-services/collection-services"
build:
- work-dir: "collection-services"
image-name: "collection-services"
@@ -33,7 +33,7 @@ config:
- work-dir: "collection-services/src/main/resources/db"
image-name: "collection-services-db"
- - name: "business-services/egf-instrument"
+ - name: "builds/business-services/egf-instrument"
build:
- work-dir: "egf-instrument"
image-name: "egf-instrument"
@@ -41,7 +41,7 @@ config:
- work-dir: "egf-instrument/src/main/resources/db"
image-name: "egf-instrument-db"
- - name: "business-services/egf-master"
+ - name: "builds/business-services/egf-master"
build:
- work-dir: "egf-master"
image-name: "egf-master"
@@ -49,7 +49,7 @@ config:
- work-dir: "egf-master/src/main/resources/db"
image-name: "egf-master-db"
- - name: "business-services/egov-apportion-service"
+ - name: "builds/business-services/egov-apportion-service"
build:
- work-dir: "egov-apportion-service"
image-name: "egov-apportion-service"
@@ -57,7 +57,7 @@ config:
- work-dir: "egov-apportion-service/src/main/resources/db"
image-name: "egov-apportion-service-db"
- - name: "business-services/egov-hrms"
+ - name: "builds/business-services/egov-hrms"
build:
- work-dir: "egov-hrms"
image-name: "egov-hrms"
@@ -65,7 +65,7 @@ config:
- work-dir: "egov-hrms/src/main/resources/db"
image-name: "egov-hrms-db"
- - name: "business-services/finance-collections-voucher-consumer"
+ - name: "builds/business-services/finance-collections-voucher-consumer"
build:
- work-dir: "finance-collections-voucher-consumer"
image-name: "finance-collections-voucher-consumer"
@@ -73,13 +73,13 @@ config:
- work-dir: "finance-collections-voucher-consumer/src/main/resources/db"
image-name: "finance-collections-voucher-consumer-db"
- - name: "business-services/dashboard-analytics"
+ - name: "builds/business-services/dashboard-analytics"
build:
- work-dir: "dashboard-analytics"
image-name: "dashboard-analytics"
dockerfile: "build/maven/Dockerfile"
- - name: "business-services/dashboard-ingest"
+ - name: "builds/business-services/dashboard-ingest"
build:
- work-dir: "dashboard-ingest"
image-name: "dashboard-ingest"
diff --git a/dashboard-analytics/pom.xml b/dashboard-analytics/pom.xml
new file mode 100644
index 000000000..5e83d1569
--- /dev/null
+++ b/dashboard-analytics/pom.xml
@@ -0,0 +1,155 @@
+
+ 4.0.0
+ com.tarento
+ analytics
+ 0.0.1-SNAPSHOT
+
+ Analytic Service
+ Project for handling the data for analytics visualization
+ http://maven.apache.org
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.3.RELEASE
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 3.0.1
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ org.springframework.kafka
+ spring-kafka
+ 1.1.2.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+ 2.0.0.RELEASE
+
+
+
+ com.google.code.gson
+ gson
+ 2.8.0
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jersey
+ 1.2.0.RELEASE
+
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+
+
+ org.projectlombok
+ lombok
+
+
+ org.apache.poi
+ poi-ooxml
+ 3.10-FINAL
+
+
+
+ javax.ws.rs
+ jsr311-api
+ 1.1.1
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxws
+ ${cxf.version}
+
+
+ org.apache.cxf
+ cxf-rt-transports-http
+ ${cxf.version}
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxrs
+ ${cxf.version}
+
+
+ org.apache.cxf
+ cxf-tools-java2ws
+ ${cxf.version}
+
+
+ org.apache.commons
+ commons-lang3
+ 3.4
+
+
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-high-level-client
+ 6.2.4
+
+
+ org.elasticsearch
+ elasticsearch
+ 6.2.4
+
+
+ com.github.fge
+ json-schema-validator
+ 2.2.6
+
+
+
+ commons-io
+ commons-io
+ 2.6
+
+
+
+ org.json
+ json
+ 20180813
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1
+
+
+ com.amazonaws
+ aws-java-sdk
+ 1.11.550
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
diff --git a/dashboard-analytics/src/main/java/com/tarento/analytics/AnalyticApp.java b/dashboard-analytics/src/main/java/com/tarento/analytics/AnalyticApp.java
new file mode 100644
index 000000000..883def0f5
--- /dev/null
+++ b/dashboard-analytics/src/main/java/com/tarento/analytics/AnalyticApp.java
@@ -0,0 +1,35 @@
+package com.tarento.analytics;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+import com.tarento.analytics.constant.Constants;
+
+
+@SpringBootApplication
+public class AnalyticApp {
+ public static void main( String[] args ) {
+ SpringApplication.run(AnalyticApp.class, args);
+ }
+
+ @Bean
+ public RestTemplate restTemplate() {
+ return new RestTemplate();
+ }
+
+ @Bean
+ public WebMvcConfigurer corsConfigurer() {
+ return new WebMvcConfigurerAdapter() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**").allowedMethods(Constants.GET, Constants.POST,Constants.PUT, Constants.DELETE, Constants.OPTIONS).allowedOrigins("*")
+ .allowedHeaders("*");
+ }
+ };
+ }
+}
diff --git a/dashboard-analytics/src/main/java/com/tarento/analytics/ConfigurationLoader.java b/dashboard-analytics/src/main/java/com/tarento/analytics/ConfigurationLoader.java
new file mode 100644
index 000000000..6353ff4a7
--- /dev/null
+++ b/dashboard-analytics/src/main/java/com/tarento/analytics/ConfigurationLoader.java
@@ -0,0 +1,97 @@
+package com.tarento.analytics;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.ResourcePatternUtils;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+
+@Component("configurationLoader")
+public class ConfigurationLoader {
+
+ private static Logger logger = LoggerFactory.getLogger(ConfigurationLoader.class);
+ private Map nameContentMap = new HashMap<>();
+ @Autowired
+ private ResourceLoader resourceLoader;
+ @Autowired
+ private ObjectMapper objectMapper;
+
+ @Value("${config.schema.paths}")
+ private String RESOURCE_LOCATION;
+
+ // private static final String RESOURCE_LOCATION = "file://home/darshan/Tarento/DataPlatform/analytics2/analytics/src/main/resources/schema/*.json";
+ public static final String ROLE_DASHBOARD_CONFIG = "RoleDashboardMappingsConf.json";
+ public static final String MASTER_DASHBOARD_CONFIG = "MasterDashboardConfig.json";
+
+
+ /**
+ * Loads config resources
+ * @throws Exception
+ */
+ @PostConstruct
+ public void loadResources() throws Exception {
+ Resource[] resources = getResources(RESOURCE_LOCATION);
+
+ for (Resource resource : resources) {
+ String jsonContent = getContent(resource);
+ ObjectNode jsonNode = (ObjectNode) objectMapper.readTree(jsonContent);
+ nameContentMap.put(resource.getFilename(), jsonNode);
+ }
+ logger.info("Number of resources loaded " + nameContentMap.size());
+
+ }
+
+ /**
+ * Obtains a ObjectNode w.r.t given resource/file name in classpath*:schema
+ * @param name
+ * @return
+ */
+ public ObjectNode get(String name) {
+ return nameContentMap.get(name);
+ }
+
+ /**
+ * Loads all the resources/files with a given pattern *.json
+ * @param pattern path with *json
+ * @return
+ * @throws IOException
+ */
+ private Resource[] getResources(String pattern) throws IOException {
+ Resource[] resources = ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(pattern);
+ return resources;
+ }
+
+ /**
+ * Returns a content of resource
+ *
+ * @param resource
+ * @return
+ */
+ private String getContent(Resource resource) {
+ String content = null;
+ try {
+ InputStream is = resource.getInputStream();
+ byte[] encoded = IOUtils.toByteArray(is);
+ content = new String(encoded, Charset.forName("UTF-8"));
+
+ } catch (IOException e) {
+ logger.error("Cannot load resource " + resource.getFilename());
+
+ }
+ return content;
+ }
+
+}
diff --git a/dashboard-analytics/src/main/java/com/tarento/analytics/constant/Constants.java b/dashboard-analytics/src/main/java/com/tarento/analytics/constant/Constants.java
new file mode 100644
index 000000000..55b9a7a70
--- /dev/null
+++ b/dashboard-analytics/src/main/java/com/tarento/analytics/constant/Constants.java
@@ -0,0 +1,134 @@
+package com.tarento.analytics.constant;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class Constants {
+ /**
+ * Allowed Origins for CORS Bean
+ */
+ public static final String GET = "GET";
+ public static final String POST = "POST";
+ public static final String PUT = "PUT";
+ public static final String DELETE = "DELETE";
+ public static final String OPTIONS = "OPTIONS";
+
+
+ public static int UNAUTHORIZED_ID = 401;
+ public static int SUCCESS_ID = 200;
+ public static int FAILURE_ID = 320;
+ public static String UNAUTHORIZED = "Invalid credentials. Please try again.";
+ public static String PROCESS_FAIL = "Process failed, Please try again.";
+ public static String SUCCESS= "success";
+
+
+ //chart format
+
+ public static final String D3 = "d3";
+ public static final String CHARTJS = "chartjs";
+
+ //chart type
+ public static final String BAR = "bar";
+ public static final String PIE ="pie";
+ public static final String STACKEDBAR ="stackedbar";
+ public static final String LINE ="line";
+ public static final String HORIZONTAL_BAR="horizontalBar";
+ public static final String DOUGHNUT="doughnut";
+ public static final String Heat = "heat";
+ public static final String RADAR ="radar";
+
+ public static final Long FEEDBACK_MESSAGE_TIMEOUT = 2000l;
+
+ public static final String STORE_ID = "storeId";
+
+ public static final String PLACEMENTS_DASHBOARD = "DASHBOARD";
+ public static final String PLACEMENTS_HOME = "HOME";
+
+ public static final List RATING_LIST = new ArrayList<>(Arrays.asList(1l,2l,3l,4l,5l));
+ public static final List RATING_LIST_STRING = new ArrayList<>(Arrays.asList("1","2","3","4","5"));
+ public static final List RATING_LIST_STRING_STAR = new ArrayList<>(Arrays.asList("1 Star","2 Star","3 Star","4 Star","5 Star"));
+
+ public interface Modules {
+ final static String HOME_REVENUE = "HOME_REVENUE";
+ final static String HOME_SERVICES = "HOME_SERVICES";
+ final static String COMMON = "COMMON";
+ final static String PT = "PT";
+ final static String TL = "TL";
+ }
+
+ public interface KafkaTopics {
+ final static String NEW_CONTENT_MESSAGE = "SaveContent";
+ final static String SIMULATOR_TRANSACTION = "SaveTransaction";
+ }
+
+ public interface ConfigurationFiles {
+ final static String CHART_API_CONFIG = "ChartApiConfig.json";
+ }
+
+ public interface JsonPaths {
+ final static String CHART_TYPE = "chartType";
+ final static String QUERIES = "queries";
+ final static String AGGREGATION_QUERY= "aggrQuery";
+ final static String INDEX_NAME = "indexName";
+ final static String REQUEST_QUERY_MAP = "requestQueryMap";
+ final static String DATE_REF_FIELD = "dateRefField";
+ final static String AGGS = "aggs";
+ final static String AGGREGATIONS = "aggregations" ;
+ final static String MODULE = "module";
+ final static String INTERVAL_VAL = "intervalvalue";
+ final static String INTERVAL = "interval";
+ final static String IS_MDMS_ENABALED = "isMdmsEnabled";
+ final static String INSIGHT = "insight";
+ final static String DAYS = "days";
+ final static String TRANSLATE_CODE = "translateTenantCode";
+
+ }
+
+ public interface Filters {
+ final static String MODULE = "module";
+ final static String FILTER_ALL = "*";
+ }
+
+ public interface Catagory {
+ final static String SEVICE = "service";
+ final static String REVENUE = "revenue";
+ }
+
+ public interface DashBoardConfig {
+ final static String ROLES = "roles";
+ final static String ROLE_ID = "roleId";
+ final static String DASHBOARDS = "dashboards";
+ final static String VISUALISATIONS = "visualizations";
+ final static String NAME = "name";
+ final static String ID = "id";
+ final static String TITLE = "title";
+
+ }
+ public interface MDMSKeys {
+ final static String CODE = "code";
+ final static String DISTRICT_CODE = "districtCode";
+ final static String DDR_NAME = "ddrName";
+ final static String TENANTS = "tenants";
+ final static String KEY = "key";
+ final static String TENANT_ID = "tenantId";
+
+ }
+
+ public enum Interval {
+ week, month, year, day
+ }
+ public interface PostAggregationTheories {
+ final static String RESPONSE_DIFF_DATES = "repsonseToDifferenceOfDates";
+ }
+
+ public enum ClienServiceType {
+ DEFAULT_CLIENT ,
+ MDMS_CLIENT
+ }
+
+ public static final SimpleDateFormat DASHBOARD_DATE_FORMAT = new SimpleDateFormat("MMM dd, yyyy");
+
+
+}
diff --git a/dashboard-analytics/src/main/java/com/tarento/analytics/constant/ElasticSearchConstants.java b/dashboard-analytics/src/main/java/com/tarento/analytics/constant/ElasticSearchConstants.java
new file mode 100644
index 000000000..09963b4dc
--- /dev/null
+++ b/dashboard-analytics/src/main/java/com/tarento/analytics/constant/ElasticSearchConstants.java
@@ -0,0 +1,22 @@
+package com.tarento.analytics.constant;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class ElasticSearchConstants {
+ public static final String LTE = "<=";
+ public static final String LT = "<";
+ public static final String GTE = ">=";
+ public static final String GT = ">";
+ public static final String ASC_ORDER = "ASC";
+ public static final String STARTS_WITH = "startsWith";
+ public static final String ENDS_WITH = "endsWith";
+ public static final List upsertResults =
+ new ArrayList<>(Arrays.asList("CREATED", "UPDATED", "NOOP"));
+ public static final String SOFT_MODE = "soft";
+ public static final String RAW_APPEND = ".raw";
+ public static final String DAY_OF_WEEK = "dayOfWeek";
+ public static final String DAY = "day";
+ public static final String HOUR = "hour";
+}
diff --git a/dashboard-analytics/src/main/java/com/tarento/analytics/constant/ErrorCode.java b/dashboard-analytics/src/main/java/com/tarento/analytics/constant/ErrorCode.java
new file mode 100644
index 000000000..56a8e5cc4
--- /dev/null
+++ b/dashboard-analytics/src/main/java/com/tarento/analytics/constant/ErrorCode.java
@@ -0,0 +1,10 @@
+package com.tarento.analytics.constant;
+
+public class ErrorCode {
+
+ public static final String ERR320= "320";
+
+
+
+
+}
diff --git a/dashboard-analytics/src/main/java/com/tarento/analytics/controllers/DashboardController.java b/dashboard-analytics/src/main/java/com/tarento/analytics/controllers/DashboardController.java
new file mode 100644
index 000000000..079e3ae1d
--- /dev/null
+++ b/dashboard-analytics/src/main/java/com/tarento/analytics/controllers/DashboardController.java
@@ -0,0 +1,221 @@
+package com.tarento.analytics.controllers;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.tarento.analytics.org.service.ClientServiceFactory;
+import com.tarento.analytics.service.AmazonS3ClientService;
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONArray;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.context.request.ServletWebRequest;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.tarento.analytics.constant.Constants;
+import com.tarento.analytics.constant.ErrorCode;
+import com.tarento.analytics.dto.AggregateRequestDto;
+import com.tarento.analytics.dto.AggregateRequestDtoV3;
+import com.tarento.analytics.dto.RequestDto;
+import com.tarento.analytics.dto.RequestDtoV3;
+import com.tarento.analytics.dto.RoleDto;
+import com.tarento.analytics.dto.UserDto;
+import com.tarento.analytics.exception.AINException;
+import com.tarento.analytics.org.service.ClientService;
+import com.tarento.analytics.service.MetadataService;
+import com.tarento.analytics.utils.PathRoutes;
+import com.tarento.analytics.utils.ResponseGenerator;
+import org.springframework.web.multipart.MultipartFile;
+
+@RestController
+@RequestMapping(PathRoutes.DashboardApi.DASHBOARD_ROOT_PATH)
+public class DashboardController {
+
+ public static final Logger logger = LoggerFactory.getLogger(DashboardController.class);
+
+ @Autowired
+ private MetadataService metadataService;
+ @Autowired
+ private AmazonS3ClientService amazonS3ClientService;
+
+/* @Autowired
+ private ClientService clientService;*/
+
+ @Autowired
+ private ClientServiceFactory clientServiceFactory;
+
+ @RequestMapping(value = PathRoutes.DashboardApi.FILE_PATH, method = RequestMethod.POST)
+ public Map uploadFile(@RequestPart(value = "file") MultipartFile file)
+ {
+ Map response = new HashMap<>();
+ try{
+ String imgUrl = this.amazonS3ClientService.uploadFileToS3Bucket(file, true);
+ response.put("message", "file [" + file.getOriginalFilename() + "] uploading request submitted successfully.");
+ response.put("url", imgUrl);
+ }catch (Exception e){
+ logger.error("S3 file upload : "+e.getMessage());
+ response.put("message", e.getMessage());
+ response.put("url", "");
+ }
+
+ return response;
+ }
+
+ @DeleteMapping(value = PathRoutes.DashboardApi.FILE_PATH)
+ public Map deleteFile(@RequestParam("file_name") String fileName)
+ {
+ Map response = new HashMap<>();
+ try{
+ this.amazonS3ClientService.deleteFileFromS3Bucket(fileName);
+ response.put("message", "file [" + fileName + "] removing request submitted successfully.");
+ }catch (Exception e ){
+ logger.error("S3 file upload : "+e.getMessage());
+ response.put("message", e.getMessage());
+
+ }
+ return response;
+
+ }
+
+ @GetMapping(value = PathRoutes.DashboardApi.TEST_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
+ public String getTest() throws JsonProcessingException {
+ return ResponseGenerator.successResponse("success");
+
+ }
+
+ @RequestMapping(value = PathRoutes.DashboardApi.GET_DASHBOARD_CONFIG + "/{dashboardId}", method = RequestMethod.GET)
+ public String getDashboardConfiguration(@PathVariable String dashboardId, @RequestParam(value="catagory", required = false) String catagory, @RequestHeader(value = "x-user-info", required = false) String xUserInfo)
+ throws AINException, IOException {
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ UserDto user = new UserDto();
+ user.setId(new Long("10007"));
+ user.setOrgId("1");
+ user.setCountryCode("");
+ RoleDto role = new RoleDto();
+ role.setId(new Long("6"));
+ role.setName("HR User");
+ List roles = new ArrayList<>();
+ roles.add(role);
+ user.setRoles(roles);
+ //gson.fromJson(xUserInfo, UserDto.class);
+
+ return ResponseGenerator.successResponse(metadataService.getDashboardConfiguration(dashboardId, catagory, user.getRoles()));
+ }
+
+ @RequestMapping(value = PathRoutes.DashboardApi.GET_CHART_V2, method = RequestMethod.POST)
+ public String getVisualizationChartV2( @RequestBody RequestDto requestDto, @RequestHeader(value = "x-user-info", required = false) String xUserInfo, ServletWebRequest request)
+ throws IOException {
+
+ /*logger.info("Request Detail:" + requestDto);
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ UserDto user = gson.fromJson(xUserInfo, UserDto.class);*/
+
+ UserDto user = new UserDto();
+ logger.info("user"+xUserInfo);
+
+ //Getting the request information only from the Full Request
+ AggregateRequestDto requestInfo = requestDto.getAggregationRequestDto();
+ Map headers = requestDto.getHeaders();
+ //requestInfo.getFilters().putAll(headers);
+ String response = "";
+ try {
+ if (headers.isEmpty()) {
+ logger.error("Please provide header details");
+ throw new AINException(ErrorCode.ERR320, "header is missing");
+ }
+ if (headers.get("tenantId") == null) {
+ logger.error("Please provide tenant ID details");
+ throw new AINException(ErrorCode.ERR320, "tenant is missing");
+
+ }
+
+ if(requestDto.getAggregationRequestDto() == null) {
+ logger.error("Please provide requested Visualization Details");
+ throw new AINException(ErrorCode.ERR320, "Visualization Request is missing");
+ }
+ /*if(requestDto.getAggregationRequestDto().getRequestId() == null) {
+ logger.error("Please provide Request ID");
+ throw new AINException(ErrorCode.ERR320, "Request ID is missing. Insights will not work");
+ }*/
+
+
+ // To be removed once the development is complete
+ if(StringUtils.isBlank(requestInfo.getModuleLevel())) {
+ requestInfo.setModuleLevel(Constants.Modules.HOME_REVENUE);
+ }
+
+ Object responseData = clientServiceFactory.get(requestInfo.getVisualizationCode()).getAggregatedData(requestInfo, user.getRoles());
+ response = ResponseGenerator.successResponse(responseData);
+
+ } catch (AINException e) {
+ logger.error("error while executing api getVisualizationChart");
+ response = ResponseGenerator.failureResponse(e.getErrorCode(), e.getErrorMessage());
+ }
+ return response;
+ }
+
+/*
+ @RequestMapping(value = PathRoutes.DashboardApi.GET_CHART_V3, method = RequestMethod.POST)
+ public String getVisualizationChartV3(@RequestBody RequestDtoV3 requestDtoV3, @RequestHeader(value = "x-user-info", required = false) String xUserInfo, ServletWebRequest request)
+ throws IOException {
+
+ */
+/*logger.info("Request Detail:" + requestDto);
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ UserDto user = gson.fromJson(xUserInfo, UserDto.class);*//*
+
+
+ UserDto user = new UserDto();
+ logger.info("user"+xUserInfo);
+
+ //Getting the request information only from the Full Request
+ AggregateRequestDtoV3 requestInfoV3 = requestDtoV3.getAggregationRequestDto();
+ Map headers = requestDtoV3.getHeaders();
+ //requestInfo.getFilters().putAll(headers);
+ String response = "";
+ try {
+ if (headers.isEmpty()) {
+ logger.error("Please provide header details");
+ throw new AINException(ErrorCode.ERR320, "header is missing");
+ }
+ if (headers.get("tenantId") == null) {
+ logger.error("Please provide tenant ID details");
+ throw new AINException(ErrorCode.ERR320, "tenant is missing");
+ }
+ // To be removed once the development is complete
+ if(StringUtils.isBlank(requestInfoV3.getModuleLevel())) {
+ requestInfoV3.setModuleLevel(Constants.Modules.HOME_REVENUE);
+ }
+
+ List