Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
pmis-svc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mmahalingam
pmis-svc
Commits
7ced93f0
Commit
7ced93f0
authored
Aug 08, 2023
by
ksubash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project metric, weekly metric and excel API's
parent
4f8086d8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
737 additions
and
239 deletions
+737
-239
DemoDB.mv.db
DemoDB.mv.db
+0
-0
pom.xml
pom.xml
+123
-111
ExcelController.java
.../java/com/altimetrik/pmis/controller/ExcelController.java
+77
-0
MetricsController.java
...ava/com/altimetrik/pmis/controller/MetricsController.java
+38
-6
ProjectController.java
...ava/com/altimetrik/pmis/controller/ProjectController.java
+9
-3
Constants.java
src/main/java/com/altimetrik/pmis/core/common/Constants.java
+66
-0
AccountEntity.java
...n/java/com/altimetrik/pmis/core/entity/AccountEntity.java
+1
-1
AccountMetricEntity.java
.../com/altimetrik/pmis/core/entity/AccountMetricEntity.java
+0
-2
ProjectEntity.java
...n/java/com/altimetrik/pmis/core/entity/ProjectEntity.java
+6
-12
ProjectMetricEntity.java
.../com/altimetrik/pmis/core/entity/ProjectMetricEntity.java
+4
-8
ProjectSummaryEntity.java
...com/altimetrik/pmis/core/entity/ProjectSummaryEntity.java
+7
-5
ProjectSummaryRemarkEntity.java
...timetrik/pmis/core/entity/ProjectSummaryRemarkEntity.java
+2
-0
TrendEntity.java
...ain/java/com/altimetrik/pmis/core/entity/TrendEntity.java
+13
-20
WeeklyMetricEntity.java
...a/com/altimetrik/pmis/core/entity/WeeklyMetricEntity.java
+12
-7
Status.java
src/main/java/com/altimetrik/pmis/core/enums/Status.java
+1
-1
MetricsMapper.java
src/main/java/com/altimetrik/pmis/mapper/MetricsMapper.java
+0
-0
ProjectSummaryMapper.java
...java/com/altimetrik/pmis/mapper/ProjectSummaryMapper.java
+3
-5
CreateProjectSummaryRequest.java
...om/altimetrik/pmis/model/CreateProjectSummaryRequest.java
+7
-7
Metric.java
src/main/java/com/altimetrik/pmis/model/Metric.java
+2
-1
MetricIndicator.java
src/main/java/com/altimetrik/pmis/model/MetricIndicator.java
+6
-0
Project.java
src/main/java/com/altimetrik/pmis/model/Project.java
+4
-3
ProjectSummary.java
src/main/java/com/altimetrik/pmis/model/ProjectSummary.java
+7
-6
ProjectSummaryResponse.java
...ava/com/altimetrik/pmis/model/ProjectSummaryResponse.java
+22
-0
Trend.java
src/main/java/com/altimetrik/pmis/model/Trend.java
+5
-5
WeeklyMetric.java
src/main/java/com/altimetrik/pmis/model/WeeklyMetric.java
+32
-0
WeeklyMetricReport.java
...in/java/com/altimetrik/pmis/model/WeeklyMetricReport.java
+31
-0
ProjectMetricRepository.java
...m/altimetrik/pmis/repository/ProjectMetricRepository.java
+11
-0
ProjectMetricsRepository.java
.../altimetrik/pmis/repository/ProjectMetricsRepository.java
+0
-13
ProjectSummaryRepository.java
.../altimetrik/pmis/repository/ProjectSummaryRepository.java
+8
-0
TrendRepository.java
.../java/com/altimetrik/pmis/repository/TrendRepository.java
+12
-0
WeeklyMetricRepository.java
...om/altimetrik/pmis/repository/WeeklyMetricRepository.java
+11
-0
ExcelService.java
src/main/java/com/altimetrik/pmis/service/ExcelService.java
+21
-0
MetricsService.java
...main/java/com/altimetrik/pmis/service/MetricsService.java
+14
-2
ProjectService.java
...main/java/com/altimetrik/pmis/service/ProjectService.java
+5
-2
ExcelServiceImpl.java
...va/com/altimetrik/pmis/service/impl/ExcelServiceImpl.java
+0
-0
MetricsServiceImpl.java
.../com/altimetrik/pmis/service/impl/MetricsServiceImpl.java
+106
-11
ProjectServiceImpl.java
.../com/altimetrik/pmis/service/impl/ProjectServiceImpl.java
+45
-8
StringToDataTypeConverter.java
...a/com/altimetrik/pmis/util/StringToDataTypeConverter.java
+26
-0
No files found.
DemoDB.mv.db
View file @
7ced93f0
No preview for this file type
pom.xml
View file @
7ced93f0
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns
=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance
"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
3.1.1
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<project
xmlns
:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0
"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
3.1.1
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.altimetrik
</groupId>
<artifactId>
pmis-svc
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<packaging>
jar
</packaging>
<name>
PMIS
</name>
<description>
PMIS
</description>
<groupId>
com.altimetrik
</groupId>
<artifactId>
pmis-svc
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<packaging>
jar
</packaging>
<name>
PMIS
</name>
<description>
PMIS
</description>
<properties>
<java.version>
17
</java.version>
</properties>
<properties>
<java.version>
17
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
</dependency>
<dependency>
<groupId>
com.mysql
</groupId>
<artifactId>
mysql-connector-j
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
</dependency>
<dependency>
<groupId>
com.mysql
</groupId>
<artifactId>
mysql-connector-j
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.github.ulisesbocchio
</groupId>
<artifactId>
jasypt-spring-boot-starter
</artifactId>
<version>
3.0.3
</version>
</dependency>
<dependency>
<groupId>
org.springdoc
</groupId>
<artifactId>
springdoc-openapi-starter-webmvc-ui
</artifactId>
<version>
2.1.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-validation
</artifactId>
</dependency>
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
<version>
1.9.4
</version>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct
</artifactId>
<version>
1.5.5.Final
</version>
</dependency>
</dependencies>
<dependency>
<groupId>
com.github.ulisesbocchio
</groupId>
<artifactId>
jasypt-spring-boot-starter
</artifactId>
<version>
3.0.3
</version>
</dependency>
<dependency>
<groupId>
org.springdoc
</groupId>
<artifactId>
springdoc-openapi-starter-webmvc-ui
</artifactId>
<version>
2.1.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-validation
</artifactId>
</dependency>
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
<version>
1.9.4
</version>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct
</artifactId>
<version>
1.5.5.Final
</version>
</dependency>
<!--Excel dependencies -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
5.0.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
5.0.0
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
<annotationProcessorPaths>
<path>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.28
</version>
</path>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
<annotationProcessorPaths>
<path>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.28
</version>
</path>
<path>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
<version>
1.5.5.Final
</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<path>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
<version>
1.5.5.Final
</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
src/main/java/com/altimetrik/pmis/controller/ExcelController.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
controller
;
import
com.altimetrik.pmis.model.CreateProjectSummaryRequest
;
import
com.altimetrik.pmis.model.ProjectSummary
;
import
com.altimetrik.pmis.model.WeeklyMetricReport
;
import
com.altimetrik.pmis.service.ExcelService
;
import
jakarta.validation.Valid
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/excel"
)
@Validated
public
class
ExcelController
{
private
ExcelService
excelService
;
@Autowired
public
ExcelController
(
ExcelService
excelService
)
{
this
.
excelService
=
excelService
;
}
@PostMapping
(
value
=
"/download-excel/project-summary"
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
public
ResponseEntity
<
byte
[]>
downloadProjectSummaryExcel
(
@Valid
@RequestBody
CreateProjectSummaryRequest
createProjectSummaryRequest
)
throws
IOException
{
byte
[]
body
=
excelService
.
downloadProjectSummaryExcel
(
createProjectSummaryRequest
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM
);
headers
.
setContentDispositionFormData
(
"attachment"
,
createProjectSummaryRequest
.
getAccountName
()
+
"-account-project-summary.xlsx"
);
return
ResponseEntity
.
ok
()
.
headers
(
headers
)
.
body
(
body
);
}
@PostMapping
(
"/upload-excel/project-summary"
)
public
ResponseEntity
<
List
<
ProjectSummary
>>
uploadProjectSummaryExcel
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
IOException
{
List
<
ProjectSummary
>
projectSummaries
=
excelService
.
uploadProjectSummaryExcel
(
file
);
return
ResponseEntity
.
ok
(
projectSummaries
);
}
@PostMapping
(
value
=
"/download-excel/weekly-report/account/{accountId}/project/{projectId}/reportDate/{reportDate}"
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
public
ResponseEntity
<
byte
[]>
downloadWeeklyReportExcel
(
@PathVariable
(
"accountId"
)
Long
accountId
,
@PathVariable
(
"projectId"
)
Long
projectId
,
@PathVariable
(
"reportDate"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
LocalDate
reportDate
)
throws
IOException
{
byte
[]
body
=
excelService
.
downloadWeeklyReportExcel
(
accountId
,
projectId
,
reportDate
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM
);
headers
.
setContentDispositionFormData
(
"attachment"
,
"weekly_report.xlsx"
);
return
ResponseEntity
.
ok
()
.
headers
(
headers
)
.
body
(
body
);
}
@PostMapping
(
"/upload-excel/weekly-report"
)
public
ResponseEntity
<
WeeklyMetricReport
>
uploadWeeklyReportExcel
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
IOException
{
WeeklyMetricReport
weeklyMetricReport
=
excelService
.
uploadWeeklyReportExcel
(
file
);
return
ResponseEntity
.
ok
(
weeklyMetricReport
);
}
}
src/main/java/com/altimetrik/pmis/controller/MetricsController.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
controller
;
import
com.altimetrik.pmis.model.Metric
;
import
com.altimetrik.pmis.model.WeeklyMetricReport
;
import
com.altimetrik.pmis.service.MetricsService
;
import
jakarta.websocket.server.PathParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDate
;
import
java.util.Objects
;
@RestController
...
...
@@ -20,17 +22,47 @@ public class MetricsController {
}
@PostMapping
(
"/account"
)
public
ResponseEntity
<
Metric
>
save
(
@RequestBody
Metric
metric
)
{
return
ResponseEntity
.
ok
(
metricsService
.
save
(
metric
));
public
ResponseEntity
<
Metric
>
saveAccountMetric
(
@RequestBody
Metric
metric
)
{
return
ResponseEntity
.
ok
(
metricsService
.
saveAccountMetric
(
metric
));
}
@PostMapping
(
"/project"
)
public
ResponseEntity
<
Metric
>
saveProjectMetric
(
@RequestBody
Metric
metric
)
{
return
ResponseEntity
.
ok
(
metricsService
.
saveProjectMetric
(
metric
));
}
@GetMapping
(
"account/{accountId}"
)
public
ResponseEntity
<
Metric
>
getByAccountId
(
@PathParam
(
"accountId"
)
Long
accountId
)
{
Metric
metric
=
metricsService
.
getByAccountId
(
accountId
);
public
ResponseEntity
<
Metric
>
getAccountMetricsByAccountId
(
@PathVariable
(
"accountId"
)
Long
accountId
)
{
Metric
metric
=
metricsService
.
getAccountMetricsByAccountId
(
accountId
);
if
(
Objects
.
isNull
(
metric
))
{
return
ResponseEntity
.
noContent
().
build
();
}
return
ResponseEntity
.
ok
(
metric
);
}
@GetMapping
(
"project/{projectId}"
)
public
ResponseEntity
<
Metric
>
getProjectMetricsByProjectId
(
@PathVariable
(
"projectId"
)
Long
projectId
)
{
Metric
metric
=
metricsService
.
getProjectMetricsByProjectId
(
projectId
);
if
(
Objects
.
isNull
(
metric
))
{
return
ResponseEntity
.
noContent
().
build
();
}
return
ResponseEntity
.
ok
(
metricsService
.
getByAccountId
(
accountId
));
return
ResponseEntity
.
ok
(
metric
);
}
@GetMapping
(
"/weekly-report/account/{accountId}/project/{projectId}/reportDate/{reportDate}"
)
public
ResponseEntity
<
WeeklyMetricReport
>
getProjectMetricsByProjectId
(
@PathVariable
(
"accountId"
)
Long
accountId
,
@PathVariable
(
"projectId"
)
Long
projectId
,
@PathVariable
(
"reportDate"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
LocalDate
reportDate
)
{
WeeklyMetricReport
weeklyMetricReport
=
metricsService
.
getOrCreateWeeklyMetricReportForProject
(
accountId
,
projectId
,
reportDate
);
return
ResponseEntity
.
ok
(
weeklyMetricReport
);
}
@PutMapping
(
"/weekly-report"
)
public
ResponseEntity
<
WeeklyMetricReport
>
updateWeeklyReportForProject
(
@RequestBody
WeeklyMetricReport
weeklyMetricReport
)
{
WeeklyMetricReport
weeklyMetricReportResponse
=
metricsService
.
updateWeeklyReportForProject
(
weeklyMetricReport
);
return
ResponseEntity
.
ok
(
weeklyMetricReportResponse
);
}
}
src/main/java/com/altimetrik/pmis/controller/ProjectController.java
View file @
7ced93f0
...
...
@@ -3,6 +3,7 @@ package com.altimetrik.pmis.controller;
import
com.altimetrik.pmis.model.CreateProjectSummaryRequest
;
import
com.altimetrik.pmis.model.Project
;
import
com.altimetrik.pmis.model.ProjectSummary
;
import
com.altimetrik.pmis.model.ProjectSummaryResponse
;
import
com.altimetrik.pmis.service.ProjectService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
...
...
@@ -38,17 +39,22 @@ public class ProjectController {
}
@PostMapping
(
"/summary"
)
public
ResponseEntity
<
List
<
ProjectSummary
>
>
createProjectSummary
(
@RequestBody
CreateProjectSummaryRequest
createProjectSummaryRequest
)
{
public
ResponseEntity
<
ProjectSummaryResponse
>
createProjectSummary
(
@RequestBody
CreateProjectSummaryRequest
createProjectSummaryRequest
)
{
return
ResponseEntity
.
ok
(
projectService
.
createProjectSummary
(
createProjectSummaryRequest
));
}
@GetMapping
(
"/summary/account/{accountId}/reportDate/{reportDate}"
)
public
ResponseEntity
<
List
<
ProjectSummary
>>
getProjectSummaryByAccountId
(
@PathVariable
(
"accountId"
)
Long
accountId
,
@PathVariable
(
"reportDate"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
LocalDate
reportDate
)
{
return
ResponseEntity
.
ok
(
projectService
.
getProjectSummaryByAccount
IdAndReportDate
(
accountId
,
reportDate
));
public
ResponseEntity
<
ProjectSummaryResponse
>
getProjectSummaryByAccountAndReportDate
(
@PathVariable
(
"accountId"
)
Long
accountId
,
@PathVariable
(
"reportDate"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
LocalDate
reportDate
)
{
return
ResponseEntity
.
ok
(
projectService
.
getProjectSummaryByAccount
AndReportDate
(
accountId
,
null
,
reportDate
));
}
@PutMapping
(
"/summary"
)
public
ResponseEntity
<
ProjectSummary
>
updateProjectSummary
(
@RequestBody
ProjectSummary
projectSummary
)
{
return
ResponseEntity
.
ok
(
projectService
.
updateProjectSummary
(
projectSummary
));
}
@PutMapping
(
"/summary/multiple"
)
public
ResponseEntity
<
List
<
ProjectSummary
>>
updateMultipleProjectSummary
(
@RequestBody
List
<
ProjectSummary
>
projectSummaries
)
{
return
ResponseEntity
.
ok
(
projectService
.
updateMultipleProjectSummary
(
projectSummaries
));
}
}
src/main/java/com/altimetrik/pmis/core/common/Constants.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
core
.
common
;
public
class
Constants
{
//Project Summary Excel constants
public
static
final
String
PS_EXCEL_ACCOUNT_NAME_TITLE
=
"ACCOUNT NAME"
;
public
static
final
String
PS_EXCEL_REPORT_DATE_TITLE
=
"REPORT DATE"
;
public
static
final
String
[]
PS_EXCEL_HEADER1_TITLES
=
{
"SUMMARY ID"
,
"PID"
,
"PROJECT"
,
"ENGINEERING"
,
"PEOPLE"
,
""
,
""
,
""
,
"REMARKS"
};
public
static
final
String
[]
PS_EXCEL_HEADER2_TITLES
=
{
"SID"
,
"ID"
,
"NAME"
,
"STATUS"
,
"PLANNED"
,
"ACTUAL"
,
"OPEN"
,
"STATUS"
,
""
};
public
static
final
int
PS_EXCEL_ACCOUNT_NAME_ROW
=
0
;
public
static
final
int
PS_EXCEL_ACCOUNT_ID_CELL
=
0
;
public
static
final
int
PS_EXCEL_ACCOUNT_NAME_TITLE_CELL
=
2
;
public
static
final
int
PS_EXCEL_ACCOUNT_NAME_VALUE_CELL
=
3
;
public
static
final
int
PS_EXCEL_REPORT_DATE_ROW
=
1
;
public
static
final
int
PS_EXCEL_REPORT_DATE_TITLE_CELL
=
3
;
public
static
final
int
PS_EXCEL_REPORT_DATE_VALUE_CELL
=
4
;
public
static
final
int
PS_EXCEL_HEADER1_ROW
=
3
;
public
static
final
int
PS_EXCEL_HEADER2_ROW
=
4
;
public
static
final
int
PS_EXCEL_SUMMARY_ID_VALUE_CELL
=
0
;
public
static
final
int
PS_EXCEL_PROJECT_ID_VALUE_CELL
=
1
;
public
static
final
int
PS_EXCEL_PROJECT_NAME_VALUE_CELL
=
2
;
public
static
final
int
PS_EXCEL_ENGINEERING_STATUS_VALUE_CELL
=
3
;
public
static
final
int
PS_EXCEL_PEOPLE_PLANNED_VALUE_CELL
=
4
;
public
static
final
int
PS_EXCEL_PEOPLE_ACTUAL_VALUE_CELL
=
5
;
public
static
final
int
PS_EXCEL_PEOPLE_OPEN_VALUE_CELL
=
6
;
public
static
final
int
PS_EXCEL_PEOPLE_STATUS_VALUE_CELL
=
7
;
public
static
final
int
PS_EXCEL_REMARKS_VALUE_CELL
=
8
;
public
static
final
String
INT
=
"int"
;
public
static
final
String
DOUBLE
=
"double"
;
public
static
final
String
FLOAT
=
"float"
;
public
static
final
String
LONG
=
"long"
;
public
static
final
String
BOOLEAN
=
"boolean"
;
public
static
final
String
WR_EXCEL_PROJECT_NAME_TITLE
=
"PROJECT NAME"
;
public
static
final
String
WR_EXCEL_REPORT_DATE_TITLE
=
"REPORT DATE"
;
public
static
final
String
WR_EXCEL_CURRENT_WEEK_TREND_TITLE
=
"STATUS"
;
public
static
final
int
WR_EXCEL_PROJECT_NAME_ROW
=
0
;
public
static
final
int
WR_EXCEL_PROJECT_ID_CELL
=
0
;
public
static
final
int
WR_EXCEL_PROJECT_NAME_TITLE_CELL
=
3
;
public
static
final
int
WR_EXCEL_PROJECT_NAME_VALUE_CELL
=
4
;
public
static
final
int
WR_EXCEL_REPORT_DATE_ROW
=
1
;
public
static
final
int
WR_EXCEL_REPORT_DATE_TITLE_CELL
=
3
;
public
static
final
int
WR_EXCEL_REPORT_DATE_VALUE_CELL
=
4
;
public
static
final
int
WR_EXCEL_CURRENT_WEEK_TREND_ROW
=
2
;
public
static
final
int
WR_EXCEL_CURRENT_WEEK_TREND_ID_CELL
=
0
;
public
static
final
int
WR_EXCEL_CURRENT_WEEK_TREND_TITLE_CELL
=
3
;
public
static
final
int
WR_EXCEL_CURRENT_WEEK_TREND_VALUE_CELL
=
4
;
public
static
final
int
WR_EXCEL_HEADER_ROW
=
4
;
public
static
final
String
[]
WR_EXCEL_HEADER_TITLES
=
{
"WEEKLY_MID"
,
"PM_ID"
,
"AM_ID"
,
"TYPE"
,
"CATEGORY"
,
"INDICATOR"
,
"TARGET"
,
"ACTUAL"
,
"REMARK"
};
public
static
final
int
WR_EXCEL_WEEKLY_MID_VALUE_CELL
=
0
;
public
static
final
int
WR_EXCEL_AM_ID_VALUE_CELL
=
1
;
public
static
final
int
WR_EXCEL_PM_ID_VALUE_CELL
=
2
;
public
static
final
int
WR_EXCEL_TYPE_VALUE_CELL
=
3
;
public
static
final
int
WR_EXCEL_CATEGORY_VALUE_CELL
=
4
;
public
static
final
int
WR_EXCEL_INDICATOR_VALUE_CELL
=
5
;
public
static
final
int
WR_EXCEL_TARGET_VALUE_CELL
=
6
;
public
static
final
int
WR_EXCEL_ACTUAL_VALUE_CELL
=
7
;
public
static
final
int
WR_EXCEL_REMARK_VALUE_CELL
=
8
;
}
src/main/java/com/altimetrik/pmis/core/entity/AccountEntity.java
View file @
7ced93f0
...
...
@@ -21,7 +21,7 @@ public class AccountEntity {
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Long
id
;
@Column
(
length
=
100
)
@Column
(
length
=
100
,
unique
=
true
)
private
String
name
;
@Column
(
length
=
100
)
...
...
src/main/java/com/altimetrik/pmis/core/entity/AccountMetricEntity.java
View file @
7ced93f0
...
...
@@ -26,6 +26,4 @@ public class AccountMetricEntity {
@Column
private
boolean
isActive
;
@Column
private
String
description
;
}
src/main/java/com/altimetrik/pmis/core/entity/ProjectEntity.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
core
.
entity
;
import
com.altimetrik.pmis.core.enums.
Project
Status
;
import
com.altimetrik.pmis.core.enums.Status
;
import
jakarta.persistence.*
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.*
;
@Entity
@Table
(
name
=
"tbl_project"
)
...
...
@@ -13,12 +10,13 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
ProjectEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Long
id
;
@Column
(
length
=
100
)
@Column
(
length
=
100
,
unique
=
true
)
private
String
name
;
@ManyToOne
...
...
@@ -38,10 +36,7 @@ public class ProjectEntity {
private
String
description
;
@Column
@Enumerated
(
EnumType
.
ORDINAL
)
private
Project
Status
status
;
@Enumerated
(
EnumType
.
STRING
)
private
Status
status
;
@OneToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
,
cascade
=
CascadeType
.
ALL
)
@JoinColumn
(
name
=
"trend"
,
referencedColumnName
=
"id"
)
private
TrendEntity
trend
;
}
\ No newline at end of file
src/main/java/com/altimetrik/pmis/core/entity/ProjectMetricEntity.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
core
.
entity
;
import
jakarta.persistence.*
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.*
;
@Entity
@Table
(
name
=
"tbl_project_metric"
)
...
...
@@ -12,22 +9,21 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
ProjectMetricEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Long
id
;
@
One
ToOne
@
Many
ToOne
@JoinColumn
(
name
=
"project_id"
,
referencedColumnName
=
"id"
)
private
ProjectEntity
project
;
@
One
ToOne
@
Many
ToOne
@JoinColumn
(
name
=
"indicator_id"
,
referencedColumnName
=
"id"
)
private
IndicatorEntity
indicator
;
@Column
private
boolean
isActive
;
@Column
private
String
description
;
}
src/main/java/com/altimetrik/pmis/core/entity/ProjectSummaryEntity.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
core
.
entity
;
import
com.altimetrik.pmis.core.enums.Status
;
import
jakarta.persistence.*
;
import
lombok.*
;
import
java.time.LocalDate
;
import
java.util.List
;
@Entity
@Table
(
name
=
"tbl_project_summary"
)
...
...
@@ -23,7 +23,8 @@ public class ProjectSummaryEntity {
private
ProjectEntity
project
;
@Column
private
char
engineeringStatus
;
@Enumerated
(
EnumType
.
STRING
)
private
Status
engineeringStatus
;
@Temporal
(
TemporalType
.
DATE
)
private
LocalDate
reportDate
;
...
...
@@ -35,8 +36,9 @@ public class ProjectSummaryEntity {
private
int
actual
;
@Column
private
char
peopleStatus
;
@Enumerated
(
EnumType
.
STRING
)
private
Status
peopleStatus
;
@
OneToMany
(
mappedBy
=
"projectSummary"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
ProjectSummaryRemarkEntity
>
remarks
;
@
Column
(
columnDefinition
=
"LONGTEXT"
)
private
String
remarks
;
}
src/main/java/com/altimetrik/pmis/core/entity/ProjectSummaryRemarkEntity.java
View file @
7ced93f0
/*
package com.altimetrik.pmis.core.entity;
import jakarta.persistence.*;
...
...
@@ -22,3 +23,4 @@ public class ProjectSummaryRemarkEntity {
@JoinColumn(name = "project_summary_id", referencedColumnName = "id")
private ProjectSummaryEntity projectSummary;
}
*/
src/main/java/com/altimetrik/pmis/core/entity/TrendEntity.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
core
.
entity
;
import
com.altimetrik.pmis.core.enums.
Project
Status
;
import
com.altimetrik.pmis.core.enums.Status
;
import
jakarta.persistence.*
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.*
;
import
java.time.LocalDate
;
@Entity
@Table
(
name
=
"tbl_trend"
)
...
...
@@ -13,27 +12,22 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
TrendEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Long
id
;
@Column
@Enumerated
(
EnumType
.
ORDINAL
)
private
ProjectStatus
weekOne
;
@Enumerated
(
EnumType
.
STRING
)
private
Status
overallStatus
;
@
Column
@
Enumerated
(
EnumType
.
ORDINAL
)
private
ProjectStatus
weekTwo
;
@
Temporal
(
TemporalType
.
DATE
)
@
Column
(
updatable
=
false
)
private
LocalDate
reportDate
;
@ManyToOne
@JoinColumn
(
name
=
"project_id"
,
referencedColumnName
=
"id"
)
private
ProjectEntity
project
;
@Column
@Enumerated
(
EnumType
.
ORDINAL
)
private
ProjectStatus
weekThree
;
@Column
@Enumerated
(
EnumType
.
ORDINAL
)
private
ProjectStatus
weekFour
;
}
\ No newline at end of file
src/main/java/com/altimetrik/pmis/core/entity/WeeklyMetricEntity.java
View file @
7ced93f0
...
...
@@ -6,7 +6,7 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
java.
sql.
Date
;
import
java.
time.Local
Date
;
@Entity
@Table
(
name
=
"tbl_weekly_metric"
)
...
...
@@ -19,20 +19,20 @@ public class WeeklyMetricEntity {
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Long
id
;
@
One
ToOne
@
Many
ToOne
@JoinColumn
(
name
=
"project_id"
,
referencedColumnName
=
"id"
)
private
ProjectEntity
project
;
@
One
ToOne
@
Many
ToOne
@JoinColumn
(
name
=
"account_metric_id"
,
referencedColumnName
=
"id"
)
private
AccountMetricEntity
accountMetric
;
@
One
ToOne
@
Many
ToOne
@JoinColumn
(
name
=
"project_metric_id"
,
referencedColumnName
=
"id"
)
private
ProjectMetricEntity
projectMetric
;
@
Column
private
Date
reportDate
;
@
Temporal
(
TemporalType
.
DATE
)
private
Local
Date
reportDate
;
@Column
private
Long
target
;
...
...
@@ -44,5 +44,10 @@ public class WeeklyMetricEntity {
private
String
remark
;
@Column
private
boolean
shouldApplyToSummary
;
private
boolean
shouldApplyRemarkToSummary
;
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
@JoinColumn
(
name
=
"trend_entity_id"
,
referencedColumnName
=
"id"
)
private
TrendEntity
trendEntity
;
}
src/main/java/com/altimetrik/pmis/core/enums/
Project
Status.java
→
src/main/java/com/altimetrik/pmis/core/enums/Status.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
core
.
enums
;
public
enum
Project
Status
{
public
enum
Status
{
NA
,
GREEN
,
AMBER
,
RED
}
src/main/java/com/altimetrik/pmis/mapper/MetricsMapper.java
View file @
7ced93f0
This diff is collapsed.
Click to expand it.
src/main/java/com/altimetrik/pmis/mapper/ProjectSummaryMapper.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
mapper
;
import
com.altimetrik.pmis.core.entity.ProjectSummaryEntity
;
import
com.altimetrik.pmis.core.entity.ProjectSummaryRemarkEntity
;
import
com.altimetrik.pmis.model.ProjectSummary
;
import
com.altimetrik.pmis.model.ProjectSummaryRemark
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.factory.Mappers
;
...
...
@@ -31,14 +29,14 @@ public interface ProjectSummaryMapper {
default
ProjectSummaryEntity
mapProjectSummaryDomainToEntity
(
ProjectSummary
projectSummary
)
{
ProjectSummaryEntity
projectSummaryEntity
=
projectSummaryDomainToEntity
(
projectSummary
);
projectSummaryEntity
.
setRemarks
(
mapProjectSummaryRemarkDomainsToEntities
(
projectSummary
.
getRemarks
(),
projectSummaryEntity
));
//
projectSummaryEntity.setRemarks(mapProjectSummaryRemarkDomainsToEntities(projectSummary.getRemarks(), projectSummaryEntity));
return
projectSummaryEntity
;
}
@Mapping
(
target
=
"project.id"
,
source
=
"projectId"
)
ProjectSummaryEntity
projectSummaryDomainToEntity
(
ProjectSummary
projectSummary
);
default
List
<
ProjectSummaryRemarkEntity
>
mapProjectSummaryRemarkDomainsToEntities
(
List
<
ProjectSummaryRemark
>
projectSummaryRemarks
,
ProjectSummaryEntity
projectSummaryEntity
)
{
/*
default List<ProjectSummaryRemarkEntity> mapProjectSummaryRemarkDomainsToEntities(List<ProjectSummaryRemark> projectSummaryRemarks, ProjectSummaryEntity projectSummaryEntity) {
return projectSummaryRemarks.stream()
.map(projectSummaryRemark -> mapProjectSummaryRemarkDomainToEntity(projectSummaryRemark, projectSummaryEntity))
.collect(Collectors.toList());
...
...
@@ -52,6 +50,6 @@ public interface ProjectSummaryMapper {
}
ProjectSummaryRemarkEntity projectSummaryRemarkDomainToEntity(ProjectSummaryRemark projectSummaryRemark);
*/
}
src/main/java/com/altimetrik/pmis/model/CreateProjectSummaryRequest.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
jakarta.validation.constraints.NotEmpty
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.*
;
import
java.time.LocalDate
;
...
...
@@ -12,11 +9,14 @@ import java.time.LocalDate;
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
CreateProjectSummaryRequest
{
@Not
Empty
(
message
=
"account id cannot be null or empty"
)
@Not
Null
(
message
=
"account id cannot be null or empty"
)
private
Long
accountId
;
@NotEmpty
(
message
=
"week date cannot be null or empty"
)
private
String
accountName
;
@NotNull
(
message
=
"week date cannot be null or empty"
)
private
LocalDate
reportDate
;
}
src/main/java/com/altimetrik/pmis/model/Metric.java
View file @
7ced93f0
...
...
@@ -15,7 +15,8 @@ import java.util.List;
public
class
Metric
{
private
Long
accountId
;
private
Long
projectId
;
private
List
<
MetricIndicator
>
metricIndicators
=
new
ArrayList
<>();
private
String
description
;
}
src/main/java/com/altimetrik/pmis/model/MetricIndicator.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
com.altimetrik.pmis.core.enums.CategoryType
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -13,10 +14,15 @@ public class MetricIndicator {
private
Long
metricId
;
private
CategoryType
categoryType
;
private
String
categoryName
;
private
Long
indicatorId
;
private
String
indicatorName
;
private
boolean
isActive
;
private
String
description
;
}
src/main/java/com/altimetrik/pmis/model/Project.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
com.altimetrik.pmis.core.enums.
Project
Status
;
import
com.altimetrik.pmis.core.enums.Status
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -25,7 +25,7 @@ public class Project {
private
String
description
;
private
Project
Status
status
;
private
Status
status
;
private
Trend
trend
;
//
private Trend trend;
}
\ No newline at end of file
src/main/java/com/altimetrik/pmis/model/ProjectSummary.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
com.altimetrik.pmis.core.enums.Status
;
import
lombok.*
;
import
java.time.LocalDate
;
import
java.util.List
;
@Getter
@Setter
...
...
@@ -17,15 +17,16 @@ public class ProjectSummary {
private
String
projectName
;
private
char
engineeringStatus
;
private
LocalDate
reportDate
;
private
Status
engineeringStatus
;
private
int
planned
;
private
int
actual
;
private
char
peopleStatus
;
private
Status
peopleStatus
;
private
List
<
ProjectSummaryRemark
>
remarks
;
private
LocalDate
reportDate
;
private
String
remarks
;
}
src/main/java/com/altimetrik/pmis/model/ProjectSummaryResponse.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
lombok.*
;
import
java.time.LocalDate
;
import
java.util.List
;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
ProjectSummaryResponse
{
private
Long
accountId
;
private
String
accountName
;
private
LocalDate
reportDate
;
private
List
<
ProjectSummary
>
projectSummaries
;
}
src/main/java/com/altimetrik/pmis/model/Trend.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
com.altimetrik.pmis.core.enums.
Project
Status
;
import
com.altimetrik.pmis.core.enums.Status
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -13,8 +13,8 @@ import lombok.Setter;
public
class
Trend
{
private
Long
id
;
private
Project
Status
weekOne
;
private
Project
Status
weekTwo
;
private
Project
Status
weekThree
;
private
Project
Status
weekFour
;
private
Status
weekOne
;
private
Status
weekTwo
;
private
Status
weekThree
;
private
Status
weekFour
;
}
src/main/java/com/altimetrik/pmis/model/WeeklyMetric.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
com.altimetrik.pmis.core.enums.CategoryType
;
import
lombok.*
;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
WeeklyMetric
{
private
Long
id
;
private
Long
projectMetricId
;
private
Long
accountMetricId
;
private
CategoryType
categoryType
;
private
String
categoryName
;
private
String
indicatorName
;
private
Long
target
;
private
Long
actual
;
private
String
remark
;
private
boolean
shouldApplyRemarkToSummary
;
}
src/main/java/com/altimetrik/pmis/model/WeeklyMetricReport.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
model
;
import
com.altimetrik.pmis.core.enums.Status
;
import
lombok.*
;
import
java.time.LocalDate
;
import
java.util.List
;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
WeeklyMetricReport
{
private
LocalDate
reportDate
;
private
List
<
Status
>
weeklyTrends
;
private
Status
currentWeekOverallStatus
;
private
Long
trendId
;
private
Long
projectId
;
private
String
projectName
;
private
List
<
WeeklyMetric
>
weeklyMetrics
;
}
src/main/java/com/altimetrik/pmis/repository/ProjectMetricRepository.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
repository
;
import
com.altimetrik.pmis.core.entity.ProjectMetricEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
ProjectMetricRepository
extends
JpaRepository
<
ProjectMetricEntity
,
Long
>
{
List
<
ProjectMetricEntity
>
findByProjectIdAndIsActive
(
Long
projectId
,
boolean
isActive
);
}
src/main/java/com/altimetrik/pmis/repository/ProjectMetricsRepository.java
deleted
100644 → 0
View file @
4f8086d8
//package com.altimetrik.pmis.repository;
//
//import com.altimetrik.pmis.core.entity.ProjectMetricsEntity;
//import org.springframework.data.jpa.repository.JpaRepository;
//
//import java.util.List;
//
//public interface ProjectMetricsRepository extends JpaRepository<ProjectMetricsEntity, Long> {
// List<ProjectMetricsEntity> findByProjectAccountId(Long accountId);
//
// List<ProjectMetricsEntity> findByProjectId(Long projectId);
//
//}
src/main/java/com/altimetrik/pmis/repository/ProjectSummaryRepository.java
View file @
7ced93f0
...
...
@@ -2,6 +2,8 @@ package com.altimetrik.pmis.repository;
import
com.altimetrik.pmis.core.entity.ProjectSummaryEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
java.time.LocalDate
;
import
java.util.List
;
...
...
@@ -10,4 +12,10 @@ import java.util.Optional;
public
interface
ProjectSummaryRepository
extends
JpaRepository
<
ProjectSummaryEntity
,
Long
>
{
Optional
<
List
<
ProjectSummaryEntity
>>
findByProjectAccountIdAndReportDate
(
Long
accountId
,
LocalDate
reportDate
);
Optional
<
List
<
ProjectSummaryEntity
>>
findByProjectAccountIdAndProjectAccountNameAndReportDate
(
Long
accountId
,
String
accountName
,
LocalDate
reportDate
);
@Query
(
value
=
"select pse from ProjectSummaryEntity pse where pse.project.account.id = :accountId and pse.reportDate= :reportDate"
)
Optional
<
List
<
ProjectSummaryEntity
>>
findByProjectAccountIdAndReportDate1
(
@Param
(
"accountId"
)
Long
accountId
,
@Param
(
"reportDate"
)
LocalDate
reportDate
);
}
src/main/java/com/altimetrik/pmis/repository/TrendRepository.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
repository
;
import
com.altimetrik.pmis.core.entity.TrendEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.time.LocalDate
;
import
java.util.List
;
public
interface
TrendRepository
extends
JpaRepository
<
TrendEntity
,
Long
>
{
List
<
TrendEntity
>
findTop4ByProjectIdAndReportDateOrderByReportDateDesc
(
Long
projectId
,
LocalDate
reportDate
);
}
src/main/java/com/altimetrik/pmis/repository/WeeklyMetricRepository.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
repository
;
import
com.altimetrik.pmis.core.entity.WeeklyMetricEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
WeeklyMetricRepository
extends
JpaRepository
<
WeeklyMetricEntity
,
Long
>
{
List
<
WeeklyMetricEntity
>
findByProjectId
(
Long
projectId
);
}
src/main/java/com/altimetrik/pmis/service/ExcelService.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
service
;
import
com.altimetrik.pmis.model.CreateProjectSummaryRequest
;
import
com.altimetrik.pmis.model.ProjectSummary
;
import
com.altimetrik.pmis.model.WeeklyMetricReport
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.util.List
;
public
interface
ExcelService
{
byte
[]
downloadProjectSummaryExcel
(
CreateProjectSummaryRequest
createProjectSummaryRequest
)
throws
IOException
;
List
<
ProjectSummary
>
uploadProjectSummaryExcel
(
MultipartFile
file
)
throws
IOException
;
byte
[]
downloadWeeklyReportExcel
(
Long
accountId
,
Long
projectId
,
LocalDate
reportDate
)
throws
IOException
;
WeeklyMetricReport
uploadWeeklyReportExcel
(
MultipartFile
file
)
throws
IOException
;
}
src/main/java/com/altimetrik/pmis/service/MetricsService.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
service
;
import
com.altimetrik.pmis.model.Metric
;
import
com.altimetrik.pmis.model.WeeklyMetricReport
;
import
java.time.LocalDate
;
public
interface
MetricsService
{
Metric
save
(
Metric
metric
);
Metric
saveAccountMetric
(
Metric
metric
);
Metric
saveProjectMetric
(
Metric
metric
);
Metric
getAccountMetricsByAccountId
(
Long
accountId
);
Metric
getProjectMetricsByProjectId
(
Long
projectId
);
WeeklyMetricReport
getOrCreateWeeklyMetricReportForProject
(
Long
accountId
,
Long
projectId
,
LocalDate
reportDate
);
Metric
getByAccountId
(
Long
accountId
);
WeeklyMetricReport
updateWeeklyReportForProject
(
WeeklyMetricReport
weeklyMetricReport
);
}
src/main/java/com/altimetrik/pmis/service/ProjectService.java
View file @
7ced93f0
...
...
@@ -3,6 +3,7 @@ package com.altimetrik.pmis.service;
import
com.altimetrik.pmis.model.CreateProjectSummaryRequest
;
import
com.altimetrik.pmis.model.Project
;
import
com.altimetrik.pmis.model.ProjectSummary
;
import
com.altimetrik.pmis.model.ProjectSummaryResponse
;
import
java.time.LocalDate
;
import
java.util.List
;
...
...
@@ -14,9 +15,11 @@ public interface ProjectService {
List
<
Project
>
getByAccount
(
Long
accountId
);
List
<
ProjectSummary
>
createProjectSummary
(
CreateProjectSummaryRequest
createProjectSummaryRequest
);
ProjectSummaryResponse
createProjectSummary
(
CreateProjectSummaryRequest
createProjectSummaryRequest
);
List
<
ProjectSummary
>
getProjectSummaryByAccountIdAndReportDate
(
Long
accountId
,
LocalDate
reportDate
);
ProjectSummaryResponse
getProjectSummaryByAccountAndReportDate
(
Long
accountId
,
String
accountName
,
LocalDate
reportDate
);
ProjectSummary
updateProjectSummary
(
ProjectSummary
projectSummary
);
List
<
ProjectSummary
>
updateMultipleProjectSummary
(
List
<
ProjectSummary
>
projectSummaries
);
}
src/main/java/com/altimetrik/pmis/service/impl/ExcelServiceImpl.java
0 → 100644
View file @
7ced93f0
This diff is collapsed.
Click to expand it.
src/main/java/com/altimetrik/pmis/service/impl/MetricsServiceImpl.java
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
service
.
impl
;
import
com.altimetrik.pmis.core.entity.AccountEntity
;
import
com.altimetrik.pmis.core.entity.AccountMetricEntity
;
import
com.altimetrik.pmis.core.entity.IndicatorEntity
;
import
com.altimetrik.pmis.core.entity.*
;
import
com.altimetrik.pmis.core.enums.Status
;
import
com.altimetrik.pmis.mapper.MetricsMapper
;
import
com.altimetrik.pmis.model.Metric
;
import
com.altimetrik.pmis.model.MetricIndicator
;
import
com.altimetrik.pmis.repository.AccountMetricsRepository
;
import
com.altimetrik.pmis.repository.AccountRepository
;
import
com.altimetrik.pmis.repository.IndicatorsRepository
;
import
com.altimetrik.pmis.model.WeeklyMetricReport
;
import
com.altimetrik.pmis.repository.*
;
import
com.altimetrik.pmis.service.MetricsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.time.LocalDate
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -28,29 +29,123 @@ public class MetricsServiceImpl implements MetricsService {
private
final
IndicatorsRepository
indicatorsRepository
;
private
final
ProjectRepository
projectRepository
;
private
final
ProjectMetricRepository
projectMetricRepository
;
private
final
WeeklyMetricRepository
weeklyMetricRepository
;
private
final
TrendRepository
trendRepository
;
@Autowired
public
MetricsServiceImpl
(
AccountMetricsRepository
metricsRepository
,
AccountRepository
accountRepository
,
IndicatorsRepository
indicatorsRepository
)
{
public
MetricsServiceImpl
(
AccountMetricsRepository
metricsRepository
,
AccountRepository
accountRepository
,
IndicatorsRepository
indicatorsRepository
,
ProjectRepository
projectRepository
,
ProjectMetricRepository
projectMetricRepository
,
WeeklyMetricRepository
weeklyMetricRepository
,
TrendRepository
trendRepository
)
{
this
.
accountMetricsRepository
=
metricsRepository
;
this
.
accountRepository
=
accountRepository
;
this
.
indicatorsRepository
=
indicatorsRepository
;
this
.
projectRepository
=
projectRepository
;
this
.
projectMetricRepository
=
projectMetricRepository
;
this
.
weeklyMetricRepository
=
weeklyMetricRepository
;
this
.
trendRepository
=
trendRepository
;
this
.
metricsMapper
=
MetricsMapper
.
INSTANCE
;
}
@Override
public
Metric
save
(
Metric
metric
)
{
public
Metric
save
AccountMetric
(
Metric
metric
)
{
if
(
Objects
.
isNull
(
metric
)
||
CollectionUtils
.
isEmpty
(
metric
.
getMetricIndicators
()))
{
return
null
;
}
Optional
<
AccountEntity
>
accountEntityOptional
=
accountRepository
.
findById
(
metric
.
getAccountId
());
Optional
<
List
<
IndicatorEntity
>>
indicatorEntitiesOptional
=
indicatorsRepository
.
findByIdIn
(
metric
.
getMetricIndicators
().
stream
().
map
(
MetricIndicator:
:
getIndicatorId
).
toList
());
return
metricsMapper
.
entityToDomain
(
accountMetricsRepository
.
saveAllAndFlush
(
metricsMapper
.
domainToEntity
(
metric
,
accountEntityOptional
,
indicatorEntitiesOptional
)));
return
accountEntityOptional
.
isPresent
()
?
metricsMapper
.
accountMetricEntitiesToDomain
(
accountMetricsRepository
.
saveAllAndFlush
(
metricsMapper
.
domainToEntity
(
metric
,
accountEntityOptional
.
get
(),
indicatorEntitiesOptional
)))
:
null
;
}
@Override
public
Metric
getByAccountId
(
Long
accountId
)
{
public
Metric
get
AccountMetrics
ByAccountId
(
Long
accountId
)
{
List
<
AccountMetricEntity
>
accountMetricEntities
=
accountMetricsRepository
.
findByAccountIdAndIsActive
(
accountId
,
true
);
return
metricsMapper
.
entityToDomain
(
accountMetricEntities
);
return
metricsMapper
.
accountMetricEntitiesToDomain
(
accountMetricEntities
);
}
@Override
public
Metric
getProjectMetricsByProjectId
(
Long
projectId
)
{
List
<
ProjectMetricEntity
>
projectMetricEntities
=
projectMetricRepository
.
findByProjectIdAndIsActive
(
projectId
,
true
);
return
metricsMapper
.
projectMetricEntitiesToDomain
(
projectMetricEntities
);
}
@Override
public
Metric
saveProjectMetric
(
Metric
metric
)
{
if
(
Objects
.
isNull
(
metric
)
||
CollectionUtils
.
isEmpty
(
metric
.
getMetricIndicators
()))
{
return
null
;
}
Optional
<
ProjectEntity
>
projectEntityOptional
=
projectRepository
.
findById
(
metric
.
getProjectId
());
Optional
<
List
<
IndicatorEntity
>>
indicatorEntitiesOptional
=
indicatorsRepository
.
findByIdIn
(
metric
.
getMetricIndicators
().
stream
().
map
(
MetricIndicator:
:
getIndicatorId
).
toList
());
return
projectEntityOptional
.
isPresent
()
?
metricsMapper
.
projectMetricEntitiesToDomain
(
projectMetricRepository
.
saveAllAndFlush
(
metricsMapper
.
domainToEntity
(
metric
,
projectEntityOptional
.
get
(),
indicatorEntitiesOptional
)))
:
null
;
}
@Override
@Transactional
public
WeeklyMetricReport
getOrCreateWeeklyMetricReportForProject
(
Long
accountId
,
Long
projectId
,
LocalDate
reportDate
)
{
WeeklyMetricReport
weeklyMetricReport
=
null
;
if
(
null
==
accountId
||
null
==
projectId
||
null
==
reportDate
)
{
//TODO:throw exception
return
weeklyMetricReport
;
}
List
<
WeeklyMetricEntity
>
weeklyMetricEntities
=
weeklyMetricRepository
.
findByProjectId
(
projectId
);
if
(!
CollectionUtils
.
isEmpty
(
weeklyMetricEntities
))
{
List
<
TrendEntity
>
trendEntities
=
getWeeklyTrend
(
projectId
,
reportDate
);
List
<
Status
>
weeklyTrend
=
!
CollectionUtils
.
isEmpty
(
trendEntities
)
?
trendEntities
.
stream
().
map
(
TrendEntity:
:
getOverallStatus
).
collect
(
Collectors
.
toList
())
:
null
;
weeklyMetricReport
=
metricsMapper
.
mapWeeklyMetricEntityToWeeklyMetricReport
(
weeklyMetricEntities
,
reportDate
,
weeklyTrend
);
}
else
{
createWeeklyMetricForProjectId
(
accountId
,
projectId
,
reportDate
);
List
<
WeeklyMetricEntity
>
weeklyMetricEntitiesAfterSave
=
weeklyMetricRepository
.
findByProjectId
(
projectId
);
List
<
TrendEntity
>
trendEntities
=
getWeeklyTrend
(
projectId
,
reportDate
);
List
<
Status
>
weeklyTrend
=
!
CollectionUtils
.
isEmpty
(
trendEntities
)
?
trendEntities
.
stream
().
map
(
TrendEntity:
:
getOverallStatus
).
collect
(
Collectors
.
toList
())
:
null
;
weeklyMetricReport
=
metricsMapper
.
mapWeeklyMetricEntityToWeeklyMetricReport
(
weeklyMetricEntitiesAfterSave
,
reportDate
,
weeklyTrend
);
}
return
weeklyMetricReport
;
}
@Override
@Transactional
public
WeeklyMetricReport
updateWeeklyReportForProject
(
WeeklyMetricReport
weeklyMetricReport
)
{
WeeklyMetricReport
weeklyMetricReportResponse
=
null
;
TrendEntity
trendEntity
=
TrendEntity
.
builder
().
id
(
weeklyMetricReport
.
getTrendId
()).
overallStatus
(
weeklyMetricReport
.
getCurrentWeekOverallStatus
()).
build
();
List
<
WeeklyMetricEntity
>
weeklyMetricEntities
=
metricsMapper
.
mapWeeklyMetricReportToWeeklyMetricEntity
(
weeklyMetricReport
,
trendRepository
.
save
(
trendEntity
));
if
(!
CollectionUtils
.
isEmpty
(
weeklyMetricEntities
))
{
weeklyMetricRepository
.
saveAllAndFlush
(
weeklyMetricEntities
);
List
<
WeeklyMetricEntity
>
weeklyMetricEntitiesAfterSave
=
weeklyMetricRepository
.
findByProjectId
(
weeklyMetricReport
.
getProjectId
());
List
<
TrendEntity
>
trendEntities
=
getWeeklyTrend
(
weeklyMetricReport
.
getProjectId
(),
weeklyMetricReport
.
getReportDate
());
List
<
Status
>
weeklyTrend
=
!
CollectionUtils
.
isEmpty
(
trendEntities
)
?
trendEntities
.
stream
().
map
(
TrendEntity:
:
getOverallStatus
).
collect
(
Collectors
.
toList
())
:
null
;
weeklyMetricReportResponse
=
metricsMapper
.
mapWeeklyMetricEntityToWeeklyMetricReport
(
weeklyMetricEntitiesAfterSave
,
weeklyMetricReport
.
getReportDate
(),
weeklyTrend
);
}
return
weeklyMetricReportResponse
;
}
private
void
createWeeklyMetricForProjectId
(
Long
accountId
,
Long
projectId
,
LocalDate
reportDate
)
{
List
<
AccountMetricEntity
>
accountMetricEntities
=
accountMetricsRepository
.
findByAccountIdAndIsActive
(
accountId
,
true
);
List
<
ProjectMetricEntity
>
projectMetricEntities
=
projectMetricRepository
.
findByProjectIdAndIsActive
(
projectId
,
true
);
TrendEntity
trendEntity
=
TrendEntity
.
builder
().
project
(
ProjectEntity
.
builder
().
id
(
projectId
).
build
()).
reportDate
(
reportDate
).
build
();
List
<
WeeklyMetricEntity
>
weeklyMetricEntities
=
metricsMapper
.
mapWeeklyMetricEntity
(
accountMetricEntities
,
projectMetricEntities
,
trendRepository
.
save
(
trendEntity
));
if
(!
CollectionUtils
.
isEmpty
(
weeklyMetricEntities
))
{
weeklyMetricRepository
.
saveAllAndFlush
(
weeklyMetricEntities
);
}
}
private
List
<
TrendEntity
>
getWeeklyTrend
(
Long
projectId
,
LocalDate
reportDate
)
{
return
trendRepository
.
findTop4ByProjectIdAndReportDateOrderByReportDateDesc
(
projectId
,
reportDate
);
}
}
src/main/java/com/altimetrik/pmis/service/impl/ProjectServiceImpl.java
View file @
7ced93f0
...
...
@@ -7,16 +7,17 @@ import com.altimetrik.pmis.mapper.ProjectSummaryMapper;
import
com.altimetrik.pmis.model.CreateProjectSummaryRequest
;
import
com.altimetrik.pmis.model.Project
;
import
com.altimetrik.pmis.model.ProjectSummary
;
import
com.altimetrik.pmis.model.ProjectSummaryResponse
;
import
com.altimetrik.pmis.repository.ProjectRepository
;
import
com.altimetrik.pmis.repository.ProjectSummaryRepository
;
import
com.altimetrik.pmis.service.AccountService
;
import
com.altimetrik.pmis.service.ProjectService
;
import
io.micrometer.common.util.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
...
...
@@ -61,10 +62,24 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public
List
<
ProjectSummary
>
createProjectSummary
(
CreateProjectSummaryRequest
createProjectSummaryRequest
)
{
Optional
<
List
<
ProjectSummaryEntity
>>
projectSummaryEntitiesOptional
=
projectSummaryRepository
.
findByProjectAccountIdAndReportDate
(
createProjectSummaryRequest
.
getAccountId
(),
createProjectSummaryRequest
.
getReportDate
());
public
ProjectSummaryResponse
createProjectSummary
(
CreateProjectSummaryRequest
createProjectSummaryRequest
)
{
List
<
ProjectSummary
>
projectSummaries
=
null
;
Optional
<
List
<
ProjectSummaryEntity
>>
projectSummaryEntitiesOptional
=
StringUtils
.
isEmpty
(
createProjectSummaryRequest
.
getAccountName
())
?
projectSummaryRepository
.
findByProjectAccountIdAndReportDate
(
createProjectSummaryRequest
.
getAccountId
(),
createProjectSummaryRequest
.
getReportDate
())
:
projectSummaryRepository
.
findByProjectAccountIdAndProjectAccountNameAndReportDate
(
createProjectSummaryRequest
.
getAccountId
(),
createProjectSummaryRequest
.
getAccountName
(),
createProjectSummaryRequest
.
getReportDate
());
if
(
projectSummaryEntitiesOptional
.
isPresent
()
&&
!
CollectionUtils
.
isEmpty
(
projectSummaryEntitiesOptional
.
get
()))
{
return
projectSummaryMapper
.
projectSummaryEntitiesToDomains
(
projectSummaryEntitiesOptional
.
get
());
projectSummaries
=
projectSummaryMapper
.
projectSummaryEntitiesToDomains
(
projectSummaryEntitiesOptional
.
get
());
createProjectSummaryRequest
.
setAccountName
(
StringUtils
.
isEmpty
(
createProjectSummaryRequest
.
getAccountName
())
?
projectSummaryEntitiesOptional
.
get
().
get
(
0
).
getProject
().
getAccount
().
getName
()
:
createProjectSummaryRequest
.
getAccountName
());
return
ProjectSummaryResponse
.
builder
()
.
accountId
(
createProjectSummaryRequest
.
getAccountId
())
.
accountName
(
createProjectSummaryRequest
.
getAccountName
())
.
reportDate
(
createProjectSummaryRequest
.
getReportDate
())
.
projectSummaries
(
projectSummaries
)
.
build
();
}
List
<
ProjectEntity
>
projectEntities
=
projectRepository
.
findByAccountId
(
createProjectSummaryRequest
.
getAccountId
());
...
...
@@ -73,17 +88,39 @@ public class ProjectServiceImpl implements ProjectService {
}).
collect
(
Collectors
.
toList
());
return
projectSummaryMapper
.
projectSummaryEntitiesToDomains
(
projectSummaryRepository
.
saveAllAndFlush
(
projectSummaryEntities
));
projectSummaries
=
projectSummaryMapper
.
projectSummaryEntitiesToDomains
(
projectSummaryRepository
.
saveAllAndFlush
(
projectSummaryEntities
));
createProjectSummaryRequest
.
setAccountName
(
StringUtils
.
isEmpty
(
createProjectSummaryRequest
.
getAccountName
())
?
projectSummaryEntities
.
get
(
0
).
getProject
().
getAccount
().
getName
()
:
createProjectSummaryRequest
.
getAccountName
());
return
ProjectSummaryResponse
.
builder
()
.
accountId
(
createProjectSummaryRequest
.
getAccountId
())
.
accountName
(
createProjectSummaryRequest
.
getAccountName
())
.
reportDate
(
createProjectSummaryRequest
.
getReportDate
())
.
projectSummaries
(
projectSummaries
)
.
build
();
}
@Override
public
List
<
ProjectSummary
>
getProjectSummaryByAccountIdAndReportDate
(
Long
accountId
,
LocalDate
reportDate
)
{
Optional
<
List
<
ProjectSummaryEntity
>>
projectSummaryEntitiesOptional
=
projectSummaryRepository
.
findByProjectAccountIdAndReportDate
(
accountId
,
reportDate
);
return
projectSummaryEntitiesOptional
.
isPresent
()
?
projectSummaryMapper
.
projectSummaryEntitiesToDomains
(
projectSummaryEntitiesOptional
.
get
())
:
new
ArrayList
<>();
public
ProjectSummaryResponse
getProjectSummaryByAccountAndReportDate
(
Long
accountId
,
String
accountName
,
LocalDate
reportDate
)
{
Optional
<
List
<
ProjectSummaryEntity
>>
projectSummaryEntitiesOptional
=
StringUtils
.
isEmpty
(
accountName
)
?
projectSummaryRepository
.
findByProjectAccountIdAndReportDate
(
accountId
,
reportDate
)
:
projectSummaryRepository
.
findByProjectAccountIdAndProjectAccountNameAndReportDate
(
accountId
,
accountName
,
reportDate
);
if
(
projectSummaryEntitiesOptional
.
isPresent
())
{
accountName
=
StringUtils
.
isEmpty
(
accountName
)
?
projectSummaryEntitiesOptional
.
get
().
get
(
0
).
getProject
().
getAccount
().
getName
()
:
accountName
;
List
<
ProjectSummary
>
projectSummaries
=
projectSummaryMapper
.
projectSummaryEntitiesToDomains
(
projectSummaryEntitiesOptional
.
get
());
return
ProjectSummaryResponse
.
builder
().
accountId
(
accountId
).
accountName
(
accountName
).
projectSummaries
(
projectSummaries
).
build
();
}
else
{
return
createProjectSummary
(
CreateProjectSummaryRequest
.
builder
().
accountId
(
accountId
).
reportDate
(
reportDate
).
build
());
}
}
@Override
public
ProjectSummary
updateProjectSummary
(
ProjectSummary
projectSummary
)
{
return
projectSummaryMapper
.
projectSummaryEntityToDomain
(
projectSummaryRepository
.
saveAndFlush
(
projectSummaryMapper
.
mapProjectSummaryDomainToEntity
(
projectSummary
)));
}
@Override
public
List
<
ProjectSummary
>
updateMultipleProjectSummary
(
List
<
ProjectSummary
>
projectSummaries
)
{
return
projectSummaryMapper
.
projectSummaryEntitiesToDomains
(
projectSummaryRepository
.
saveAllAndFlush
(
projectSummaryMapper
.
projectSummaryDomainsToEntities
(
projectSummaries
)));
}
}
src/main/java/com/altimetrik/pmis/util/StringToDataTypeConverter.java
0 → 100644
View file @
7ced93f0
package
com
.
altimetrik
.
pmis
.
util
;
import
com.altimetrik.pmis.core.common.Constants
;
import
io.micrometer.common.util.StringUtils
;
public
class
StringToDataTypeConverter
{
public
static
Object
convertStringToDataType
(
String
value
,
String
dataType
)
{
if
(
StringUtils
.
isEmpty
(
value
)
||
"null"
.
equalsIgnoreCase
(
value
)
||
StringUtils
.
isEmpty
(
dataType
))
{
return
null
;
}
switch
(
dataType
.
toLowerCase
())
{
case
Constants
.
INT
:
return
Integer
.
parseInt
(
value
);
case
Constants
.
DOUBLE
:
return
Double
.
parseDouble
(
value
);
case
Constants
.
FLOAT
:
return
Float
.
parseFloat
(
value
);
case
Constants
.
LONG
:
return
Long
.
parseLong
(
value
);
case
Constants
.
BOOLEAN
:
return
Boolean
.
parseBoolean
(
value
);
default
:
return
value
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment