Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gitlab-playground-innovation
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
nagabhushan
gitlab-playground-innovation
Commits
cfba9e81
Commit
cfba9e81
authored
Apr 17, 2019
by
Vijay Sreenivas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Innovation Changes
parent
1b996ed5
Pipeline
#3478
failed with stages
in 2 seconds
Changes
79
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
79 changed files
with
4054 additions
and
93 deletions
+4054
-93
PlaygroundInnovationApplication.java
...layground/innovation/PlaygroundInnovationApplication.java
+68
-0
RolesAllowed.java
...metrik/playground/innovation/annotation/RolesAllowed.java
+35
-0
BaseRequestBean.java
...ltimetrik/playground/innovation/bean/BaseRequestBean.java
+1
-1
PgIdeaArtifact.java
...altimetrik/playground/innovation/bean/PgIdeaArtifact.java
+47
-0
PgIdeaArtifactListResponse.java
...layground/innovation/bean/PgIdeaArtifactListResponse.java
+28
-0
PgIdeaCategoryListResponse.java
...layground/innovation/bean/PgIdeaCategoryListResponse.java
+24
-0
PgIdeaCategoryRequest.java
...rik/playground/innovation/bean/PgIdeaCategoryRequest.java
+33
-0
PgIdeaCategoryResponse.java
...ik/playground/innovation/bean/PgIdeaCategoryResponse.java
+38
-0
PgIdeaRequest.java
.../altimetrik/playground/innovation/bean/PgIdeaRequest.java
+46
-0
PgIdeaResponse.java
...altimetrik/playground/innovation/bean/PgIdeaResponse.java
+46
-0
PgIdeaReviewer.java
...altimetrik/playground/innovation/bean/PgIdeaReviewer.java
+34
-0
PgIdeaSearchRequest.java
...etrik/playground/innovation/bean/PgIdeaSearchRequest.java
+36
-0
PgIdeaSearchResponse.java
...trik/playground/innovation/bean/PgIdeaSearchResponse.java
+27
-0
PgIdeaStatusChangeRequest.java
...playground/innovation/bean/PgIdeaStatusChangeRequest.java
+28
-0
PgIdeaTeamInviteRequest.java
...k/playground/innovation/bean/PgIdeaTeamInviteRequest.java
+35
-0
PgIdeaTeamListResponse.java
...ik/playground/innovation/bean/PgIdeaTeamListResponse.java
+27
-0
PgIdeaTeamResponse.java
...metrik/playground/innovation/bean/PgIdeaTeamResponse.java
+38
-0
PgMentorResponse.java
...timetrik/playground/innovation/bean/PgMentorResponse.java
+36
-0
PgReviewer.java
...com/altimetrik/playground/innovation/bean/PgReviewer.java
+39
-0
ResponseModel.java
.../altimetrik/playground/innovation/bean/ResponseModel.java
+0
-1
StatusDetails.java
.../altimetrik/playground/innovation/bean/StatusDetails.java
+8
-4
ErrorBean.java
.../playground/innovation/bean/usermanagement/ErrorBean.java
+29
-0
PgLocation.java
...playground/innovation/bean/usermanagement/PgLocation.java
+33
-0
PgPrivilegeMstr.java
...round/innovation/bean/usermanagement/PgPrivilegeMstr.java
+25
-0
PgRoleMstr.java
...playground/innovation/bean/usermanagement/PgRoleMstr.java
+26
-0
PgRolePrivilege.java
...round/innovation/bean/usermanagement/PgRolePrivilege.java
+32
-0
PgRoleUser.java
...playground/innovation/bean/usermanagement/PgRoleUser.java
+31
-0
PgUserInfoDtls.java
...ground/innovation/bean/usermanagement/PgUserInfoDtls.java
+89
-0
PgUserInfoMstr.java
...ground/innovation/bean/usermanagement/PgUserInfoMstr.java
+35
-0
UserResponseBean.java
...ound/innovation/bean/usermanagement/UserResponseBean.java
+22
-0
CorsConfig.java
...m/altimetrik/playground/innovation/config/CorsConfig.java
+22
-0
SecurityConfig.java
...timetrik/playground/innovation/config/SecurityConfig.java
+1
-1
WebMvcConfig.java
...altimetrik/playground/innovation/config/WebMvcConfig.java
+7
-2
IdeaModeEnum.java
...imetrik/playground/innovation/constants/IdeaModeEnum.java
+25
-0
IdeaStatusEnum.java
...etrik/playground/innovation/constants/IdeaStatusEnum.java
+64
-0
IdeaTypeEnum.java
...imetrik/playground/innovation/constants/IdeaTypeEnum.java
+25
-0
IdeaVisibilityEnum.java
...k/playground/innovation/constants/IdeaVisibilityEnum.java
+25
-0
ReviewLevelEnum.java
...trik/playground/innovation/constants/ReviewLevelEnum.java
+25
-0
RoleTypeEnum.java
...imetrik/playground/innovation/constants/RoleTypeEnum.java
+30
-0
TeamMemberRequestModeEnum.java
...round/innovation/constants/TeamMemberRequestModeEnum.java
+25
-0
TeamMemberRequestStatusEnum.java
...und/innovation/constants/TeamMemberRequestStatusEnum.java
+25
-0
UserTypeEnum.java
...imetrik/playground/innovation/constants/UserTypeEnum.java
+49
-0
BaseController.java
...trik/playground/innovation/controller/BaseController.java
+15
-21
PgIdeaCategoryContoller.java
...ground/innovation/controller/PgIdeaCategoryContoller.java
+46
-0
PgIdeaController.java
...ik/playground/innovation/controller/PgIdeaController.java
+183
-0
ServiceController.java
...k/playground/innovation/controller/ServiceController.java
+3
-0
BaseEntity.java
...m/altimetrik/playground/innovation/entity/BaseEntity.java
+23
-15
PgCategoryEntity.java
...metrik/playground/innovation/entity/PgCategoryEntity.java
+34
-0
PgIdeaArtifactEntity.java
...ik/playground/innovation/entity/PgIdeaArtifactEntity.java
+45
-0
PgIdeaEntity.java
...altimetrik/playground/innovation/entity/PgIdeaEntity.java
+79
-0
PgReviewStatusEntity.java
...ik/playground/innovation/entity/PgReviewStatusEntity.java
+31
-0
PgReviewersEntity.java
...etrik/playground/innovation/entity/PgReviewersEntity.java
+41
-0
PgTeamEntity.java
...altimetrik/playground/innovation/entity/PgTeamEntity.java
+36
-0
InnovationServiceException.java
...ound/innovation/exception/InnovationServiceException.java
+47
-0
InvalidRoleInfoException.java
...ground/innovation/exception/InvalidRoleInfoException.java
+21
-0
InvalidStatusTransitionException.java
...nnovation/exception/InvalidStatusTransitionException.java
+21
-0
PgApplicationException.java
...ayground/innovation/exception/PgApplicationException.java
+20
-10
PgIdeaCategoryRepository.java
...round/innovation/repository/PgIdeaCategoryRepository.java
+25
-0
PgIdeaRepository.java
...ik/playground/innovation/repository/PgIdeaRepository.java
+22
-0
AuthValidatorUtil.java
...rik/playground/innovation/security/AuthValidatorUtil.java
+9
-18
SecurityConfig.java
...metrik/playground/innovation/security/SecurityConfig.java
+1
-0
PgIdeaCategoryService.java
.../playground/innovation/service/PgIdeaCategoryService.java
+26
-0
PgIdeaReviewerService.java
.../playground/innovation/service/PgIdeaReviewerService.java
+15
-0
PgIdeaService.java
...timetrik/playground/innovation/service/PgIdeaService.java
+54
-0
PgIdeaCategoryServiceImpl.java
...nd/innovation/service/impl/PgIdeaCategoryServiceImpl.java
+121
-0
PgIdeaReviewerServiceImpl.java
...nd/innovation/service/impl/PgIdeaReviewerServiceImpl.java
+17
-0
PgIdeaServiceImpl.java
...playground/innovation/service/impl/PgIdeaServiceImpl.java
+738
-0
MongoUtils.java
...com/altimetrik/playground/innovation/util/MongoUtils.java
+2
-3
PlatformErrorConstant.java
...rik/playground/innovation/util/PlatformErrorConstant.java
+1
-1
UserUtil.java
...a/com/altimetrik/playground/innovation/util/UserUtil.java
+49
-0
RolesInterceptor.java
...metrik/playground/innovation/webmvc/RolesInterceptor.java
+145
-0
application.properties
src/main/resources/application.properties
+48
-0
banner.txt
src/main/resources/banner.txt
+5
-6
PgIdeaCategoryContollerTests.java
...d/innovation/controller/PgIdeaCategoryContollerTests.java
+126
-0
PgIdeaContollerTests.java
...layground/innovation/controller/PgIdeaContollerTests.java
+181
-0
PgIdeaCategoryServiceImplTests.java
...novation/service/impl/PgIdeaCategoryServiceImplTests.java
+145
-0
PgIdeaServiceImplTests.java
...round/innovation/service/impl/PgIdeaServiceImplTests.java
+301
-0
application-test.properties
src/test/resources/application-test.properties
+44
-0
db-config.properties
src/test/resources/db-config.properties
+15
-10
No files found.
src/main/java/com/altimetrik/playground/innovation/PlaygroundInnovationApplication.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
;
import
java.io.File
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.ServletComponentScan
;
import
org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.PropertySource
;
import
org.togglz.core.manager.EnumBasedFeatureProvider
;
import
org.togglz.core.repository.StateRepository
;
import
org.togglz.core.repository.file.FileBasedStateRepository
;
import
org.togglz.core.spi.FeatureProvider
;
import
org.togglz.core.user.NoOpUserProvider
;
import
org.togglz.core.user.UserProvider
;
import
com.altimetrik.playground.innovation.feature.Features
;
import
com.altimetrik.playground.innovation.properties.ErrorProperties
;
import
com.altimetrik.playground.innovation.properties.ServiceProperties
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
@ServletComponentScan
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableHystrixDashboard
@PropertySource
(
value
=
{
"classpath:db-config.properties"
,
"classpath:service.properties"
})
@EnableConfigurationProperties
({
ServiceProperties
.
class
,
ErrorProperties
.
class
})
public
class
PlaygroundInnovationApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
PlaygroundInnovationApplication
.
class
,
args
);
}
@Bean
public
FeatureProvider
featureProvider
()
{
return
new
EnumBasedFeatureProvider
(
Features
.
class
);
}
@Bean
public
UserProvider
userProvider
()
{
return
new
NoOpUserProvider
();
}
@Bean
public
StateRepository
getStateRepository
()
{
return
new
FileBasedStateRepository
(
new
File
(
"src/main/resources/features.properties"
),
10_000
);
}
@Bean
public
Gson
gson
()
{
return
new
GsonBuilder
().
serializeNulls
().
create
();
}
}
src/main/java/com/altimetrik/playground/innovation/annotation/RolesAllowed.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
com.altimetrik.playground.innovation.constants.ActionTypeEnum
;
import
com.altimetrik.playground.innovation.constants.RoleTypeEnum
;
/**
* Custom annotation which is used to tag a web service to specify the roles
* information which is used for validation by the RolesInterceptor.
*
* @author skondapalli.
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
METHOD
,
ElementType
.
TYPE
})
public
@interface
RolesAllowed
{
RoleTypeEnum
[]
roles
();
ActionTypeEnum
action
();
String
description
()
default
""
;
}
src/main/java/com/altimetrik/playground/innovation/bean/BaseRequestBean.java
View file @
cfba9e81
...
...
@@ -11,7 +11,7 @@ package com.altimetrik.playground.innovation.bean;
import
lombok.Data
;
@Data
public
class
BaseRequestBean
{
public
class
BaseRequestBean
{
public
BaseRequestBean
()
{
super
();
...
...
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaArtifact.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
com.altimetrik.playground.innovation.constants.ArtifactTypeEnum
;
import
lombok.Data
;
@Data
public
class
PgIdeaArtifact
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
8931921342171547040L
;
private
String
id
;
@NotBlank
private
String
linkName
;
@NotNull
private
ArtifactTypeEnum
artifactType
;
@NotBlank
private
String
linkUrl
;
private
String
fileName
;
private
String
createdBy
;
private
Date
createdOn
;
public
PgIdeaArtifact
(
String
id
,
String
linkName
,
ArtifactTypeEnum
artifactType
,
String
linkUrl
,
String
fileName
,
String
createdBy
,
Date
createdOn
)
{
super
();
this
.
id
=
id
;
this
.
linkName
=
linkName
;
this
.
artifactType
=
artifactType
;
this
.
linkUrl
=
linkUrl
;
this
.
fileName
=
fileName
;
this
.
createdBy
=
createdBy
;
this
.
createdOn
=
createdOn
;
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaArtifactListResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.List
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaArtifactListResponse
extends
ResponseModel
{
private
static
final
long
serialVersionUID
=
-
916706158688154611L
;
private
String
ideaId
;
private
List
<
PgIdeaArtifact
>
result
;
public
PgIdeaArtifactListResponse
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaCategoryListResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.List
;
import
lombok.Data
;
@Data
public
class
PgIdeaCategoryListResponse
extends
ResponseModel
{
private
List
<
PgIdeaCategoryResponse
>
result
;
public
PgIdeaCategoryListResponse
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaCategoryRequest.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.List
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaCategoryRequest
extends
BaseRequestBean
{
private
static
final
long
serialVersionUID
=
644473128186417688L
;
private
String
categoryName
;
private
List
<
PgMentorResponse
>
mentors
;
private
List
<
PgReviewer
>
reviewers
;
public
PgIdeaCategoryRequest
()
{
super
();
}
public
PgIdeaCategoryRequest
(
String
categoryName
)
{
super
();
this
.
categoryName
=
categoryName
;
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaCategoryResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.Date
;
import
java.util.List
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaCategoryResponse
extends
ResponseModel
{
private
static
final
long
serialVersionUID
=
644473128186417688L
;
private
String
categoryId
;
private
String
categoryName
;
private
List
<
PgMentorResponse
>
mentors
;
private
List
<
PgReviewer
>
reviewers
;
private
String
createdBy
;
private
Date
createdDate
;
public
PgIdeaCategoryResponse
()
{
super
();
}
public
PgIdeaCategoryResponse
(
String
categoryId
,
String
categoryName
)
{
super
();
this
.
categoryId
=
categoryId
;
this
.
categoryName
=
categoryName
;
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaRequest.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
javax.validation.constraints.NotBlank
;
import
com.altimetrik.playground.innovation.constants.IdeaStatusEnum
;
import
com.altimetrik.playground.innovation.constants.IdeaTypeEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaRequest
extends
BaseRequestBean
{
private
IdeaTypeEnum
ideaType
;
@NotBlank
private
String
title
;
private
String
description
;
private
String
businessRelevance
;
private
String
ideaCategoryId
;
private
Boolean
competenceCenter
;
private
IdeaStatusEnum
status
;
private
Boolean
published
;
private
Boolean
locked
;
private
String
businessDomain
;
private
String
technologyDomain
;
private
String
techStack
;
private
String
novelty
;
private
String
claims
;
private
String
completeness
;
private
Boolean
disclosed
;
private
String
accessLevel
;
public
PgIdeaRequest
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.Date
;
import
com.altimetrik.playground.innovation.constants.IdeaStatusEnum
;
import
com.altimetrik.playground.innovation.constants.IdeaTypeEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaResponse
extends
ResponseModel
{
private
static
final
long
serialVersionUID
=
-
4426625885342889037L
;
private
String
businessRelevance
;
private
String
description
;
private
String
ideaCategoryId
;
private
IdeaTypeEnum
ideaType
;
private
Boolean
competenceCenter
;
private
IdeaStatusEnum
ideaStatus
;
private
Boolean
published
;
private
Boolean
locked
;
private
String
businessDomain
;
private
String
technologyDomain
;
private
String
novelty
;
private
String
claims
;
private
String
completeness
;
private
String
techStack
;
private
String
title
;
private
Date
createdOn
;
private
String
createdById
;
private
String
ideaId
;
private
String
l0ReviewerId
;
private
Boolean
disclosed
;
private
String
accessLevel
;
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaReviewer.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
com.altimetrik.playground.innovation.constants.RoleTypeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestModeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestStatusEnum
;
import
lombok.Getter
;
import
lombok.Setter
;
@Setter
@Getter
public
class
PgIdeaReviewer
{
private
Long
teamMemberId
;
private
RoleTypeEnum
roleType
;
private
TeamMemberRequestModeEnum
teamMemberRequestMode
=
TeamMemberRequestModeEnum
.
STANDARD
;
private
TeamMemberRequestStatusEnum
teamMemberRequestStatus
;
private
String
approvedBy
;
private
String
teamMemberName
;
private
String
emailId
;
public
PgIdeaReviewer
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaSearchRequest.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaSearchRequest
extends
BaseRequestBean
{
private
String
search
;
private
Boolean
mine
;
private
Integer
offset
;
private
Integer
limit
;
private
String
[]
ids
;
public
PgIdeaSearchRequest
()
{
super
();
}
public
PgIdeaSearchRequest
(
String
search
,
boolean
mine
,
int
offset
,
int
limit
)
{
super
();
this
.
search
=
search
;
this
.
mine
=
mine
;
this
.
offset
=
offset
;
this
.
limit
=
limit
;
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaSearchResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.List
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaSearchResponse
extends
ResponseModel
{
private
static
final
long
serialVersionUID
=
2980698181408879679L
;
private
List
<
PgIdeaResponse
>
result
;
public
PgIdeaSearchResponse
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaStatusChangeRequest.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
com.altimetrik.playground.innovation.constants.IdeaStatusEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaStatusChangeRequest
extends
BaseRequestBean
{
private
String
message
;
private
IdeaStatusEnum
level
;
private
boolean
approved
;
public
PgIdeaStatusChangeRequest
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaTeamInviteRequest.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
javax.validation.constraints.NotBlank
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestModeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestStatusEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaTeamInviteRequest
extends
BaseRequestBean
{
private
String
id
;
@NotBlank
private
String
role
;
private
TeamMemberRequestModeEnum
type
;
private
TeamMemberRequestStatusEnum
teamMemberRequestStatus
;
@NotBlank
private
String
userId
;
public
PgIdeaTeamInviteRequest
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaTeamListResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.List
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaTeamListResponse
extends
ResponseModel
{
private
static
final
long
serialVersionUID
=
6278872172251374523L
;
private
List
<
PgIdeaTeamResponse
>
result
;
public
PgIdeaTeamListResponse
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgIdeaTeamResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.util.Date
;
import
com.altimetrik.playground.innovation.constants.RoleTypeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestModeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestStatusEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaTeamResponse
extends
BaseResponse
{
private
static
final
long
serialVersionUID
=
-
8642234932548387988L
;
private
String
id
;
private
RoleTypeEnum
role
;
private
TeamMemberRequestModeEnum
mode
;
private
TeamMemberRequestStatusEnum
teamMemberRequestStatus
;
private
String
userId
;
private
String
createdBy
;
private
Date
createdDate
;
private
String
lastModifiedBy
;
public
PgIdeaTeamResponse
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgMentorResponse.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgMentorResponse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
7228617477712740719L
;
private
Long
mentorId
;
private
String
mentorName
;
private
Long
categoryId
;
public
PgMentorResponse
()
{
super
();
}
public
PgMentorResponse
(
Long
mentorId
,
String
mentorName
,
Long
categoryId
)
{
super
();
this
.
mentorId
=
mentorId
;
this
.
mentorName
=
mentorName
;
this
.
categoryId
=
categoryId
;
}
}
src/main/java/com/altimetrik/playground/innovation/bean/PgReviewer.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.io.Serializable
;
import
com.altimetrik.playground.innovation.constants.ReviewLevelEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgReviewer
implements
Serializable
{
private
static
final
long
serialVersionUID
=
7282130044652525032L
;
private
String
id
;
private
String
reviewerId
;
private
String
reviewerName
;
private
ReviewLevelEnum
reviewLevel
;
public
PgReviewer
(
String
reviewerId
,
String
reviewerName
,
ReviewLevelEnum
reviewLevel
)
{
super
();
this
.
reviewerId
=
reviewerId
;
this
.
reviewerName
=
reviewerName
;
this
.
reviewLevel
=
reviewLevel
;
}
public
PgReviewer
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/bean/ResponseModel.java
View file @
cfba9e81
...
...
@@ -8,7 +8,6 @@
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.io.Serializable
;
import
lombok.Data
;
...
...
src/main/java/com/altimetrik/playground/innovation/bean/StatusDetails.java
View file @
cfba9e81
...
...
@@ -8,19 +8,25 @@
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
;
import
java.io.Serializable
;
import
lombok.Data
;
@Data
public
class
StatusDetails
{
public
class
StatusDetails
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
2104867973562059147L
;
/**
* Success Status code.
*/
public
static
final
int
SUCCESS
=
1
;
/**
* Failure Status code.
*/
public
static
final
int
FAILED
=
0
;
private
Integer
statusCode
;
private
String
errorCode
;
private
String
messageDescription
;
...
...
@@ -28,7 +34,6 @@ public class StatusDetails {
public
StatusDetails
()
{
super
();
}
public
StatusDetails
(
String
errorCode
,
String
messageDescription
)
{
super
();
...
...
@@ -36,7 +41,6 @@ public class StatusDetails {
this
.
messageDescription
=
messageDescription
;
}
public
StatusDetails
(
Integer
statusCode
)
{
super
();
this
.
statusCode
=
statusCode
;
...
...
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/ErrorBean.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
lombok.Data
;
/**
* @author sghosh
*
*/
@Data
public
class
ErrorBean
{
private
String
code
;
private
String
message
;
private
String
errorCode
;
private
String
errorMessage
;
public
ErrorBean
()
{
}
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/PgLocation.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
java.util.Date
;
import
lombok.Data
;
/**
* @author sghosh
*
*/
@Data
public
class
PgLocation
{
private
Long
locationId
;
private
String
status
;
private
String
address
;
private
String
city
;
private
String
state
;
private
String
zipCode
;
private
String
country
;
private
String
createdBy
;
private
String
updatedBy
;
private
Date
createdDt
;
private
Date
updatedDt
;
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/PgPrivilegeMstr.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
java.util.Date
;
import
lombok.Data
;
@Data
public
class
PgPrivilegeMstr
{
private
Long
privilegeId
=
null
;
private
String
accessType
=
null
;
private
String
description
=
null
;
private
String
createdBy
=
null
;
private
Date
createdDt
=
null
;
private
String
updatedBy
=
null
;
private
Date
updatedDt
=
null
;
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/PgRoleMstr.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
java.util.Date
;
import
lombok.Data
;
@Data
public
class
PgRoleMstr
{
private
Long
roleId
=
null
;
private
String
roleName
=
null
;
private
String
status
;
private
String
createdBy
=
null
;
private
Date
createdDt
=
null
;
private
String
updatedBy
=
null
;
private
Date
updatedDt
=
null
;
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/PgRolePrivilege.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
java.util.Date
;
import
lombok.Data
;
@Data
public
class
PgRolePrivilege
{
private
Long
rolePrivilegeId
=
null
;
private
PgRoleMstr
pgRoleMstr
=
null
;
private
PgPrivilegeMstr
pgPrivilegeMstr
=
null
;
private
String
createdBy
=
null
;
private
Date
createdDt
=
null
;
private
String
updatedBy
=
null
;
private
Date
updatedDt
=
null
;
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/PgRoleUser.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
java.util.Date
;
import
lombok.Data
;
/**
* @author sghosh
*
*/
@Data
public
class
PgRoleUser
{
private
Long
roleUserId
=
null
;
private
PgRolePrivilege
pgRolePrivilege
=
null
;
private
Long
userInfoMstrId
;
private
String
status
;
private
String
createdBy
=
null
;
private
Date
createdDt
=
null
;
private
String
updatedBy
=
null
;
private
Date
updatedDt
=
null
;
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/PgUserInfoDtls.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
java.util.Date
;
import
lombok.Data
;
/**
* The Class PgUserInfoDtls.
*/
@Data
public
class
PgUserInfoDtls
{
private
Long
userInfoDtlsId
=
null
;
private
PgUserInfoMstr
pgUserInfoMstr
=
null
;
private
String
adId
=
null
;
private
String
fullName
=
null
;
private
String
highestQualificationHeld
=
null
;
private
String
currentJobTitle
=
null
;
private
String
experienceInYrs
=
null
;
private
String
currentEmployer
=
null
;
private
String
skypeId
=
null
;
private
String
emailId
=
null
;
private
String
addressLine1
=
null
;
private
String
city
=
null
;
private
String
zipCode
=
null
;
private
String
country
=
null
;
private
String
stateName
=
null
;
private
String
additionalInfo
=
null
;
private
String
createdBy
=
null
;
private
Date
createdDt
=
null
;
private
String
updatedBy
=
null
;
private
Date
updatedDt
=
null
;
private
Long
taId
=
null
;
private
String
jobTitle
;
private
String
contactNumber
;
private
String
governmentId
;
private
String
alternativeEmail
;
private
String
alternativeContact
;
private
Long
profileId
;
private
String
profileName
;
private
String
employeeNo
;
private
boolean
firstTimeLogin
;
private
String
otherSkills
;
/**
* Instantiates a new pg user info dtls.
*/
public
PgUserInfoDtls
()
{
}
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/PgUserInfoMstr.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
java.util.Date
;
import
java.util.Set
;
import
lombok.Data
;
@Data
public
class
PgUserInfoMstr
{
private
Long
userInfoMstrId
;
private
String
firstName
=
null
;
private
String
lastName
=
null
;
private
String
fullName
=
null
;
private
String
emailId
=
null
;
private
Set
<
PgRoleUser
>
pgRoleUser
=
null
;
private
PgLocation
pgLocation
=
null
;
private
String
mobileNo
=
null
;
private
String
createdBy
=
null
;
private
Date
createdDt
=
null
;
private
String
updatedBy
=
null
;
private
Date
updatedDt
=
null
;
private
String
socialUserType
=
null
;
private
String
registrationType
=
null
;
private
String
status
=
null
;
}
src/main/java/com/altimetrik/playground/innovation/bean/usermanagement/UserResponseBean.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
bean
.
usermanagement
;
import
lombok.Data
;
/**
* @author sghosh
*
*/
@Data
public
class
UserResponseBean
{
private
PgUserInfoDtls
infoDetails
;
private
ErrorBean
error
;
}
src/main/java/com/altimetrik/playground/innovation/config/CorsConfig.java
0 → 100644
View file @
cfba9e81
package
com
.
altimetrik
.
playground
.
innovation
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
* CORS configuration.
* @author Tushar Das
*/
@Configuration
public
class
CorsConfig
implements
WebMvcConfigurer
{
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
).
allowedOrigins
(
"*"
)
.
allowedMethods
(
HttpMethod
.
GET
.
name
(),
HttpMethod
.
POST
.
name
(),
HttpMethod
.
PUT
.
name
(),
HttpMethod
.
DELETE
.
name
(),
HttpMethod
.
OPTIONS
.
name
(),
HttpMethod
.
PATCH
.
name
())
.
allowedHeaders
(
HttpHeaders
.
CONTENT_TYPE
,
HttpHeaders
.
AUTHORIZATION
,
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
);
}
}
src/main/java/com/altimetrik/playground/innovation/config/SecurityConfig.java
View file @
cfba9e81
...
...
@@ -19,7 +19,7 @@ import org.springframework.security.web.authentication.SavedRequestAwareAuthenti
*
* @author skondapalli
*/
//@Configuration
//
@Configuration
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Override
...
...
src/main/java/com/altimetrik/playground/innovation/config/WebMvcConfig.java
View file @
cfba9e81
...
...
@@ -8,17 +8,22 @@
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
config
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
@Configuration
import
com.altimetrik.playground.innovation.webmvc.RolesInterceptor
;
//@Configuration
public
class
WebMvcConfig
implements
WebMvcConfigurer
{
@Autowired
private
RolesInterceptor
rolesInterceptor
;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
rolesInterceptor
).
addPathPatterns
(
"/v1/role/**"
);
}
}
src/main/java/com/altimetrik/playground/innovation/constants/IdeaModeEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
public
enum
IdeaModeEnum
{
TEAM
(
"TEAM"
),
INDIVIDUAL
(
"INDIVIDUAL"
);
private
final
String
message
;
IdeaModeEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/IdeaStatusEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
import
java.util.HashSet
;
import
java.util.Set
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
public
enum
IdeaStatusEnum
{
NOT_SUBMITTED
(
"NOT_SUBMITTED"
),
SUBMITTED
(
"SUBMITTED"
),
DRAFT
(
"DRAFT"
),
PUBLISH
(
"PUBLISH"
),
L0_REVIEW
(
"L0_REVIEW"
),
L1_REVIEW
(
"L1_REVIEW"
),
L2_REVIEW
(
"L2_REVIEW"
),
REWORK
(
"REWORK"
),
APPROVED
(
"APPROVED"
),
REJECTED
(
"REJECTED"
);
private
final
String
message
;
IdeaStatusEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
public
Set
<
IdeaStatusEnum
>
getAllowedIdeaStatusTransitions
()
{
final
Set
<
IdeaStatusEnum
>
allowedIdeaStatusTransitions
=
new
HashSet
<
IdeaStatusEnum
>();
switch
(
this
)
{
case
DRAFT:
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
DRAFT
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
PUBLISH
);
break
;
case
PUBLISH:
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
PUBLISH
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
L0_REVIEW
);
break
;
case
L0_REVIEW:
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
L0_REVIEW
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
REWORK
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
REJECTED
);
break
;
case
REWORK:
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
REWORK
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
L0_REVIEW
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
L1_REVIEW
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
L2_REVIEW
);
break
;
case
REJECTED:
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
REJECTED
);
break
;
default
:
log
.
info
(
"Status transition not configured"
,
this
);
break
;
}
return
allowedIdeaStatusTransitions
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/IdeaTypeEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
public
enum
IdeaTypeEnum
{
PUBLIC
(
"PUBLIC"
),
PRIVATE
(
"PRIVATE"
);
private
final
String
message
;
IdeaTypeEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/IdeaVisibilityEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
public
enum
IdeaVisibilityEnum
{
PUBLIC
(
"PUBLIC"
),
PRIVATE
(
"PRIVATE"
);
private
final
String
message
;
IdeaVisibilityEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/ReviewLevelEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
public
enum
ReviewLevelEnum
{
LEVEL_0
(
"LEVEL_0"
),
LEVEL_1
(
"LEVEL_1"
),
LEVEL_2
(
"LEVEL_2"
),
LEVEL_3
(
"LEVEL_3"
);
private
final
String
message
;
ReviewLevelEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/RoleTypeEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
/**
* Indicates different types of roles.
*
* @author skondapalli.
*/
public
enum
RoleTypeEnum
{
L0_REVIEWER
(
"L0_REVIEWER"
),
L1_REVIEWER
(
"L1_REVIEWER"
),
L2_REVIEWER
(
"L2_REVIEWER"
),
INNOVATOR
(
"INNOVATOR"
),
CO_INNOVATOR
(
"CO_INNOVATOR"
),
MEMBER
(
"MEMBER"
),
MENTOR
(
"MENTOR"
);
private
final
String
message
;
RoleTypeEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/TeamMemberRequestModeEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
public
enum
TeamMemberRequestModeEnum
{
INVITE
(
"INVITE"
),
JOIN
(
"JOIN"
),
STANDARD
(
"STANDARD"
);
private
final
String
message
;
TeamMemberRequestModeEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/TeamMemberRequestStatusEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
public
enum
TeamMemberRequestStatusEnum
{
PENDING
(
"PENDING"
),
ACCEPTED
(
"ACCEPTED"
),
REJECTED
(
"REJECTED"
);
private
final
String
message
;
TeamMemberRequestStatusEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
}
src/main/java/com/altimetrik/playground/innovation/constants/UserTypeEnum.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
constants
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
* Indicates different possible user types available.
*
* @author skondapalli.
*/
public
enum
UserTypeEnum
{
TEAM_MEMBER
(
"TEAM_MEMBER"
),
REVIEWER
(
"REVIEWER"
);
private
final
String
message
;
UserTypeEnum
(
final
String
argMessage
)
{
message
=
argMessage
;
}
public
final
String
getMessage
()
{
return
message
;
}
public
Set
<
IdeaStatusEnum
>
getAllowedIdeaStatusTransitions
()
{
final
Set
<
IdeaStatusEnum
>
allowedIdeaStatusTransitions
=
new
HashSet
<
IdeaStatusEnum
>();
switch
(
this
)
{
case
REVIEWER:
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
REWORK
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
PUBLISH
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
REJECTED
);
break
;
case
TEAM_MEMBER:
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
DRAFT
);
allowedIdeaStatusTransitions
.
add
(
IdeaStatusEnum
.
L0_REVIEW
);
break
;
}
return
allowedIdeaStatusTransitions
;
}
}
src/main/java/com/altimetrik/playground/innovation/controller/BaseController.java
View file @
cfba9e81
...
...
@@ -37,19 +37,26 @@ import com.altimetrik.playground.innovation.exception.PgApplicationException;
public
abstract
class
BaseController
extends
ResponseEntityExceptionHandler
{
private
static
final
String
MESSAGE_DESCRIPTION
=
"messageDescription"
;
private
static
final
String
ERROR_CODE
=
"errorCode"
;
protected
static
final
String
PLATFORM_UNHANDLED_EXCEPTION_THROWN
=
"PG unhandled exception thrown."
;
protected
static
final
String
PLATFORM_FATAL_EXCEPTION_THROWN
=
"PG fatal exception thrown."
;
protected
static
final
String
PLATFORM_SYSTEM_EXCEPTION_THROWN
=
"PG system exception thrown."
;
protected
static
final
String
PLATFORM_VALIDATION_ERROR
=
"Validation errors encountered"
;
protected
static
final
String
PLATFORM_APPLICATION_EXCEPTION_THROWN
=
"PG application exception thrown."
;
private
static
final
String
MESSAGE_DESCRIPTION
=
"messageDescription"
;
private
static
final
String
ERROR_CODE
=
"errorCode"
;
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
getNativeException
(
Throwable
exp
,
Class
<
T
>
requiredType
)
{
if
(
requiredType
!=
null
)
{
if
(
requiredType
.
isInstance
(
exp
))
{
return
(
T
)
exp
;
}
else
if
(
exp
instanceof
Exception
)
{
return
getNativeException
(
exp
.
getCause
(),
requiredType
);
}
}
return
null
;
}
@ExceptionHandler
(
PgApplicationException
.
class
)
public
ResponseEntity
<
BaseResponse
>
resolveApplicationException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Exception
exception
)
{
...
...
@@ -139,17 +146,4 @@ public abstract class BaseController extends ResponseEntityExceptionHandler {
return
filteredErrors
;
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
getNativeException
(
Throwable
exp
,
Class
<
T
>
requiredType
)
{
if
(
requiredType
!=
null
)
{
if
(
requiredType
.
isInstance
(
exp
))
{
return
(
T
)
exp
;
}
else
if
(
exp
instanceof
Exception
)
{
return
getNativeException
(((
Exception
)
exp
).
getCause
(),
requiredType
);
}
}
return
null
;
}
}
src/main/java/com/altimetrik/playground/innovation/controller/PgIdeaCategoryContoller.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
controller
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryListResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponse
;
import
com.altimetrik.playground.innovation.exception.InnovationServiceException
;
import
com.altimetrik.playground.innovation.service.PgIdeaCategoryService
;
@RestController
public
class
PgIdeaCategoryContoller
extends
BaseController
{
@Autowired
private
PgIdeaCategoryService
pgIdeaCategoryService
;
@GetMapping
(
value
=
"/v1/categories"
)
public
ResponseEntity
<
PgIdeaCategoryListResponse
>
getCategories
()
throws
InnovationServiceException
{
return
ResponseEntity
.
ok
(
pgIdeaCategoryService
.
findAllCategories
());
}
@GetMapping
(
value
=
"/v1/categories/{id}"
)
public
ResponseEntity
<
PgIdeaCategoryResponse
>
getCategoriesById
(
@PathVariable
(
"id"
)
final
String
id
)
throws
InnovationServiceException
{
return
ResponseEntity
.
ok
(
pgIdeaCategoryService
.
findByCategoryId
(
id
));
}
@PostMapping
(
value
=
"/v1/categories"
)
public
ResponseEntity
<
PgIdeaCategoryResponse
>
createCategories
(
@RequestBody
PgIdeaCategoryRequest
req
)
throws
InnovationServiceException
{
return
ResponseEntity
.
ok
(
pgIdeaCategoryService
.
createCategory
(
req
));
}
}
src/main/java/com/altimetrik/playground/innovation/controller/PgIdeaController.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
controller
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PatchMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.altimetrik.playground.innovation.bean.BaseResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaArtifact
;
import
com.altimetrik.playground.innovation.bean.PgIdeaArtifactListResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaSearchRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaSearchResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaTeamInviteRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaTeamListResponse
;
import
com.altimetrik.playground.innovation.exception.PgApplicationException
;
import
com.altimetrik.playground.innovation.service.PgIdeaService
;
@RestController
public
class
PgIdeaController
extends
BaseController
{
@Autowired
private
PgIdeaService
pgIdeaService
;
@GetMapping
(
value
=
"/v1/ideas"
)
public
ResponseEntity
<
PgIdeaSearchResponse
>
listIdeas
(
@RequestParam
(
value
=
"search"
,
required
=
false
)
String
search
,
@RequestParam
(
"mine"
)
Boolean
mine
,
@RequestParam
(
value
=
"offset"
,
required
=
false
)
Integer
offset
,
@RequestParam
(
value
=
"limit"
,
required
=
false
)
Integer
limit
,
@RequestParam
(
value
=
"ids"
,
required
=
false
)
String
[]
ids
)
throws
PgApplicationException
{
PgIdeaSearchRequest
req
=
new
PgIdeaSearchRequest
();
if
(
search
!=
null
)
req
.
setSearch
(
search
);
if
(
mine
!=
null
)
req
.
setMine
(
mine
);
if
(
offset
!=
null
)
req
.
setOffset
(
offset
);
if
(
limit
!=
null
)
req
.
setLimit
(
limit
);
if
(
ids
!=
null
)
req
.
setIds
(
ids
);
return
new
ResponseEntity
<>(
pgIdeaService
.
getAllIdeas
(
req
),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/v1/ideas/{ideaId}"
)
public
ResponseEntity
<
PgIdeaResponse
>
getIdea
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
getIdea
(
ideaId
),
HttpStatus
.
OK
);
}
@PostMapping
(
value
=
"/v1/ideas"
)
public
ResponseEntity
<
PgIdeaResponse
>
createIdea
(
@Validated
@RequestBody
PgIdeaRequest
pgIdeaRequest
)
throws
PgApplicationException
,
URISyntaxException
{
PgIdeaResponse
createIdea
=
pgIdeaService
.
createIdea
(
pgIdeaRequest
);
return
ResponseEntity
.
created
(
new
URI
(
"/v1/ideas/"
+
createIdea
.
getIdeaId
())).
body
(
createIdea
);
}
@PatchMapping
(
value
=
"/v1/ideas/{ideaId}"
)
public
ResponseEntity
<
PgIdeaResponse
>
updateIdea
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
,
@RequestBody
PgIdeaRequest
pgIdeaRequest
)
throws
PgApplicationException
{
return
ResponseEntity
.
ok
(
pgIdeaService
.
updateIdea
(
ideaId
,
pgIdeaRequest
));
}
@GetMapping
(
value
=
"/v1/ideas/{ideaId}/artifacts"
)
public
ResponseEntity
<
PgIdeaArtifactListResponse
>
getIdeaArtifacts
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
getArtifact
(
ideaId
),
HttpStatus
.
OK
);
}
@PostMapping
(
value
=
"/v1/ideas/{ideaId}/artifacts"
)
public
ResponseEntity
<
PgIdeaArtifactListResponse
>
addArtifact
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
,
@Validated
@RequestBody
PgIdeaArtifact
req
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
addArtifact
(
ideaId
,
req
),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/v1/ideas/{ideaId}/team"
)
public
ResponseEntity
<
PgIdeaTeamListResponse
>
ideaTeamList
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
getTeamList
(
ideaId
),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/v1/ideas/{ideaId}/team/requests"
)
public
ResponseEntity
<
PgIdeaTeamListResponse
>
ideaTeamRequestList
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
listTeamRequests
(
ideaId
),
HttpStatus
.
OK
);
}
@PostMapping
(
value
=
"/v1/ideas/{ideaId}/team/requests/invite"
)
public
ResponseEntity
<
BaseResponse
>
ideaInviteRequest
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
,
@Validated
@RequestBody
PgIdeaTeamInviteRequest
request
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
inviteTeamRequests
(
ideaId
,
request
),
HttpStatus
.
OK
);
}
@PostMapping
(
value
=
"/v1/ideas/{ideaId}/team/invite/{requestId}/reject"
)
public
ResponseEntity
<
BaseResponse
>
ideaRejectInvite
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
,
@PathVariable
(
"requestId"
)
final
String
requestId
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
rejectTeamRequest
(
ideaId
,
requestId
),
HttpStatus
.
OK
);
}
@PostMapping
(
value
=
"/v1/ideas/{ideaId}/team/invite/{requestId}/accept"
)
public
ResponseEntity
<
BaseResponse
>
ideaAcceptInvite
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
,
@PathVariable
(
"requestId"
)
final
String
requestId
)
throws
PgApplicationException
{
return
new
ResponseEntity
<>(
pgIdeaService
.
acceptTeamRequest
(
ideaId
,
requestId
),
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/v1/ideas/{ideaId}/status", method =
// RequestMethod.POST)
// public ResponseEntity<BaseResponse>
// updateIdeaStatus(@PathVariable("ideaId")
// final long ideaId, @RequestBody PgIdeaStatusChangeRequest pgIdeaRequest)
// {
// return new ResponseEntity<BaseResponse>(new BaseResponse(),
// HttpStatus.OK);
// }
//
// @RequestMapping(value = "/v1/ideas/{ideaId}/status", method =
// RequestMethod.GET)
// public ResponseEntity<PgIdeaStatusChangeRequest>
// getIdeaStatus(@PathVariable("ideaId") final long ideaId) {
// return new ResponseEntity<PgIdeaStatusChangeRequest>(new
// PgIdeaStatusChangeRequest(), HttpStatus.OK);
// }
// @RequestMapping(value = "/v1/ideas/{ideaId}/share", method =
// RequestMethod.POST)
// public ResponseEntity<BaseResponse> shareIdea(@RequestBody
// PgIdeaShareRequest
// pgIdeaShareRequest) {
// return new ResponseEntity<BaseResponse>(new BaseResponse(),
// HttpStatus.OK);
// }
@PostMapping
(
value
=
"/v1/ideas/{ideaId}/team/requests/join"
)
public
ResponseEntity
<
BaseResponse
>
ideaJoinRequest
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
)
throws
PgApplicationException
{
return
ResponseEntity
.
ok
(
pgIdeaService
.
joinRequest
(
ideaId
));
}
@PostMapping
(
value
=
"/v1/ideas/{ideaId}/team/join/{requestId}/accept"
)
public
ResponseEntity
<
BaseResponse
>
ideaAcceptJoin
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
,
@PathVariable
(
"requestId"
)
final
String
requestId
)
throws
PgApplicationException
{
return
ResponseEntity
.
ok
(
pgIdeaService
.
acceptJoinRequests
(
ideaId
,
requestId
));
}
@PostMapping
(
value
=
"/v1/ideas/{ideaId}/team/join/{requestId}/reject"
)
public
ResponseEntity
<
BaseResponse
>
ideaRejectJoin
(
@PathVariable
(
"ideaId"
)
final
String
ideaId
,
@PathVariable
(
"requestId"
)
final
String
requestId
)
throws
PgApplicationException
{
return
ResponseEntity
.
ok
(
pgIdeaService
.
rejectJoinRequests
(
ideaId
,
requestId
));
}
// @RequestMapping(value = "/v1/ideas/artifacts/file/{fileName:.+}", method
// =
// RequestMethod.GET)
// public ResponseEntity<Resource> download(@PathVariable final String
// fileName,
// HttpServletRequest request) throws MalformedURLException {
// final Resource resource = new UrlResource("");
// ResponseEntity<Resource> response =
// ResponseEntity.ok().contentType(MediaType.parseMediaType("application/octet-stream"))
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" +
// resource.getFilename() + "\"").body(resource);
// return response;
// }
// @RequestMapping(value = "/v1/ideas/status/history/{ideaId}", method =
// RequestMethod.GET)
// public ResponseEntity<PgIdeaStatusHistoryListResponse>
// getIdeaStatusHistory(@PathVariable("ideaId") final Long ideaId) {
// return new ResponseEntity<PgIdeaStatusHistoryListResponse>(new
// PgIdeaStatusHistoryListResponse(), HttpStatus.OK);
// }
}
src/main/java/com/altimetrik/playground/innovation/controller/ServiceController.java
View file @
cfba9e81
...
...
@@ -25,6 +25,9 @@ import org.springframework.web.client.RestTemplate;
import
com.altimetrik.playground.innovation.rabbitmq.MessagePublisher
;
import
com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand
;
import
springfox.documentation.annotations.ApiIgnore
;
@ApiIgnore
@RestController
public
class
ServiceController
{
...
...
src/main/java/com/altimetrik/playground/innovation/entity/BaseEntity.java
View file @
cfba9e81
...
...
@@ -10,34 +10,42 @@ package com.altimetrik.playground.innovation.entity;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.UUID
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.annotation.CreatedBy
;
import
org.springframework.data.annotation.CreatedDate
;
import
org.springframework.data.annotation.LastModifiedBy
;
import
org.springframework.data.annotation.LastModifiedDate
;
@Setter
@Getter
public
class
BaseEntity
implements
Serializable
{
import
lombok.Data
;
private
static
final
long
serialVersionUID
=
331467586921967105L
;
@Data
public
class
BaseEntity
implements
Serializable
{
/** The guid. */
private
String
guid
=
UUID
.
randomUUID
().
toString
();
private
static
final
long
serialVersionUID
=
-
6450038133573391912L
;
/** The created date. */
private
Date
createdDate
;
private
String
id
=
new
ObjectId
().
toString
();
/** The created by. */
@CreatedBy
private
String
createdBy
;
/** The last modified date. */
private
Date
lastModifi
edDate
;
@CreatedDate
private
Date
creat
edDate
;
/** The last modified by. */
@LastModifiedBy
private
String
lastModifiedBy
;
@LastModifiedDate
private
Date
lastModifiedDate
;
public
BaseEntity
()
{
super
();
}
public
BaseEntity
(
String
loggedInUser
)
{
super
();
this
.
createdBy
=
loggedInUser
;
this
.
lastModifiedBy
=
loggedInUser
;
}
}
src/main/java/com/altimetrik/playground/innovation/entity/PgCategoryEntity.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
entity
;
import
java.util.List
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author Tushar Das
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Document
(
collection
=
"pgCategory"
)
public
class
PgCategoryEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
5048839337019789654L
;
private
String
categoryName
;
private
String
status
;
private
List
<
PgReviewersEntity
>
reviewers
;
}
src/main/java/com/altimetrik/playground/innovation/entity/PgIdeaArtifactEntity.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
entity
;
import
com.altimetrik.playground.innovation.constants.ArtifactTypeEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author Tushar Das
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgIdeaArtifactEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
-
9002413993210024093L
;
private
String
linkName
;
private
String
linkUrl
;
private
ArtifactTypeEnum
type
;
private
String
fileName
;
public
PgIdeaArtifactEntity
()
{
super
();
}
public
PgIdeaArtifactEntity
(
String
linkName
,
String
linkUrl
,
ArtifactTypeEnum
type
,
String
fileName
)
{
super
();
this
.
linkName
=
linkName
;
this
.
linkUrl
=
linkUrl
;
this
.
type
=
type
;
this
.
fileName
=
fileName
;
}
}
src/main/java/com/altimetrik/playground/innovation/entity/PgIdeaEntity.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
entity
;
import
java.util.List
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.altimetrik.playground.innovation.constants.IdeaStatusEnum
;
import
com.altimetrik.playground.innovation.constants.IdeaTypeEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author Tushar Das
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Document
(
collection
=
"pgIdea"
)
public
class
PgIdeaEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
-
3397851459471988688L
;
@Indexed
(
unique
=
true
)
private
String
title
;
private
String
description
;
private
String
businessRelevance
;
private
String
ideaCategoryId
;
private
Boolean
competenceCenter
;
private
IdeaTypeEnum
ideaType
;
private
IdeaStatusEnum
status
;
private
Boolean
published
;
private
Boolean
locked
;
private
String
businessDomain
;
private
String
technologyDomain
;
private
String
techStack
;
private
String
novelty
;
private
String
claims
;
private
String
completeness
;
private
String
l0ReviewerId
;
private
List
<
PgIdeaArtifactEntity
>
artifacts
;
private
List
<
PgReviewStatusEntity
>
reviews
;
private
List
<
PgTeamEntity
>
team
;
private
Boolean
disclosed
=
false
;
private
String
accessLevel
;
public
PgIdeaEntity
()
{
super
();
}
}
src/main/java/com/altimetrik/playground/innovation/entity/PgReviewStatusEntity.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
entity
;
import
com.altimetrik.playground.innovation.constants.ReviewLevelEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author Tushar Das
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgReviewStatusEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
4990543561287980181L
;
private
String
message
;
private
Boolean
approved
;
private
ReviewLevelEnum
level
;
}
src/main/java/com/altimetrik/playground/innovation/entity/PgReviewersEntity.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
entity
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.altimetrik.playground.innovation.constants.ReviewLevelEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author Tushar Das
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Document
(
collection
=
"pgReviewers"
)
public
class
PgReviewersEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
-
2092044372635489798L
;
private
String
name
;
private
String
userId
;
private
ReviewLevelEnum
level
;
public
PgReviewersEntity
(
String
userId
,
ReviewLevelEnum
level
)
{
super
();
this
.
userId
=
userId
;
this
.
level
=
level
;
}
}
src/main/java/com/altimetrik/playground/innovation/entity/PgTeamEntity.java
0 → 100644
View file @
cfba9e81
/**
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
*/
package
com
.
altimetrik
.
playground
.
innovation
.
entity
;
import
com.altimetrik.playground.innovation.constants.RoleTypeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestModeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestStatusEnum
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author Tushar Das
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PgTeamEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
5530187870956044558L
;
private
String
userId
;
private
RoleTypeEnum
role
;
private
TeamMemberRequestModeEnum
requestMode
;
private
TeamMemberRequestStatusEnum
requestStatus
;
}
src/main/java/com/altimetrik/playground/innovation/exception/InnovationServiceException.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
exception
;
import
java.util.Locale
;
public
class
InnovationServiceException
extends
PgApplicationException
{
private
static
final
long
serialVersionUID
=
473448373330820013L
;
@Override
public
String
getLocalizedMessage
(
String
errorCode
,
Locale
locale
,
Object
...
args
)
{
if
(
args
!=
null
&&
args
.
length
>
0
)
return
(
String
)
args
[
0
];
else
return
null
;
}
/**
* single argument constructor.
* @param errorCode - this argument receives error code instead of message.
* @param errorArgs - the arguments to be used to replace values within the
* message.
*/
public
InnovationServiceException
(
String
errorCode
,
Object
...
errorArgs
)
{
this
(
errorCode
,
null
,
errorArgs
);
}
/**
* Preferred constructor to be used to wrap the underlying exception within this
* exception object.
* @param errorCode - object encapsulating the error details(error code and
* message) with the predefined errorCode and message template.
* @param cause - the underlying cause of the exception
* @param errorArgs - the arguments to be used to replace values within the
* message.
*/
public
InnovationServiceException
(
String
errorCode
,
Throwable
cause
,
Object
...
errorArgs
)
{
super
(
errorCode
,
cause
,
errorArgs
);
}
}
src/main/java/com/altimetrik/playground/innovation/exception/InvalidRoleInfoException.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
exception
;
public
class
InvalidRoleInfoException
extends
AbstractServiceException
{
public
InvalidRoleInfoException
(
final
int
code
,
final
String
message
)
{
super
(
code
,
message
);
}
public
InvalidRoleInfoException
(
final
String
message
,
final
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
src/main/java/com/altimetrik/playground/innovation/exception/InvalidStatusTransitionException.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
exception
;
public
class
InvalidStatusTransitionException
extends
AbstractServiceException
{
public
InvalidStatusTransitionException
(
final
int
code
,
final
String
message
)
{
super
(
code
,
message
);
}
public
InvalidStatusTransitionException
(
final
String
message
,
final
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
src/main/java/com/altimetrik/playground/innovation/exception/PgApplicationException.java
View file @
cfba9e81
...
...
@@ -11,12 +11,14 @@ package com.altimetrik.playground.innovation.exception;
import
java.util.Locale
;
import
com.altimetrik.playground.innovation.util.PlatformErrorConstant
;
public
abstract
class
PgApplicationException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1186927232091885741L
;
private
static
final
String
ERR_PREFIX
=
"[Error Code: "
;
private
static
final
String
ERR_SUFFIX
=
"] "
;
private
final
Object
[]
errorArguments
;
public
PgApplicationException
()
{
this
(
PlatformErrorConstant
.
APPLICATION_ERROR
);
}
...
...
@@ -24,22 +26,27 @@ public abstract class PgApplicationException extends Exception {
/**
* single argument constructor.
* @param errorCode - this argument receives error code instead of message.
* @param errorArgs - the arguments to be used to replace values within the message.
* @param errorArgs - the arguments to be used to replace values within the
* message.
*/
public
PgApplicationException
(
String
errorCode
,
Object
...
errorArgs
)
{
public
PgApplicationException
(
String
errorCode
,
Object
...
errorArgs
)
{
this
(
errorCode
,
null
,
errorArgs
);
}
/**
* Preferred constructor to be used to wrap the underlying exception within this exception object.
* @param errorCode - object encapsulating the error details(error code and message) with the predefined errorCode and message template.
* Preferred constructor to be used to wrap the underlying exception within this
* exception object.
* @param errorCode - object encapsulating the error details(error code and
* message) with the predefined errorCode and message template.
* @param cause - the underlying cause of the exception
* @param errorArgs - the arguments to be used to replace values within the message.
* @param errorArgs - the arguments to be used to replace values within the
* message.
*/
public
PgApplicationException
(
String
errorCode
,
Throwable
cause
,
Object
...
errorArgs
)
{
public
PgApplicationException
(
String
errorCode
,
Throwable
cause
,
Object
...
errorArgs
)
{
super
(
errorCode
,
cause
);
this
.
errorArguments
=
errorArgs
;
}
/**
* Constructor with only exception argument.
* @param cause - passes exception instance.
...
...
@@ -54,15 +61,17 @@ public abstract class PgApplicationException extends Exception {
* @param cause - instance of any exception
* @param enableSuppression - enable suppression
* @param writableStackTrace - writable stack trace.
* @param errorArgs - the arguments to be used to replace values within the message.
* @param errorArgs - the arguments to be used to replace values within the
* message.
*/
public
PgApplicationException
(
String
errorCode
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
,
Object
...
errorArgs
)
{
public
PgApplicationException
(
String
errorCode
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
,
Object
...
errorArgs
)
{
super
(
errorCode
,
cause
,
enableSuppression
,
writableStackTrace
);
this
.
errorArguments
=
errorArgs
;
}
/**
* Subclasses to provide their implementation to get the localized message for the given error code.
* Subclasses to provide their implementation to get the localized message for
* the given error code.
* @param errorCode - to translate into localized message.
* @param locale - locale to identify the messages.
* @param args - to replace with the place holder if any.
...
...
@@ -72,7 +81,8 @@ public abstract class PgApplicationException extends Exception {
/**
* The component name for this exception.
* @return the component name of the module to which the exception is associated with.
* @return the component name of the module to which the exception is associated
* with.
*/
private
String
getComponent
()
{
return
this
.
getClass
().
getSimpleName
();
...
...
src/main/java/com/altimetrik/playground/innovation/repository/PgIdeaCategoryRepository.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
repository
;
import
java.util.List
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.stereotype.Repository
;
import
com.altimetrik.playground.innovation.entity.PgCategoryEntity
;
@Repository
public
interface
PgIdeaCategoryRepository
extends
MongoRepository
<
PgCategoryEntity
,
String
>
{
List
<
PgCategoryEntity
>
findAll
();
PgCategoryEntity
findByCategoryName
(
final
String
ideaCategoryName
);
}
src/main/java/com/altimetrik/playground/innovation/repository/PgIdeaRepository.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
repository
;
import
java.util.Optional
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.stereotype.Repository
;
import
com.altimetrik.playground.innovation.entity.PgIdeaEntity
;
@Repository
public
interface
PgIdeaRepository
extends
MongoRepository
<
PgIdeaEntity
,
String
>
{
Optional
<
PgIdeaEntity
>
findByTitle
(
String
title
);
}
src/main/java/com/altimetrik/playground/innovation/security/AuthValidatorUtil.java
View file @
cfba9e81
...
...
@@ -30,10 +30,8 @@ public final class AuthValidatorUtil {
/**
* Checks if is valid user.
*
* @param principal
* the principal
* @param userId
* the user id
* @param principal the principal
* @param userId the user id
* @return true, if is valid user
*/
public
static
boolean
isValidUser
(
Principal
principal
,
String
userId
)
{
...
...
@@ -46,10 +44,8 @@ public final class AuthValidatorUtil {
/**
* Checks if is valid user by user name.
*
* @param principal
* the principal
* @param userName
* the user name
* @param principal the principal
* @param userName the user name
* @return true, if is valid user by user name
*/
public
static
boolean
isValidUserByUserName
(
Principal
principal
,
String
userName
)
{
...
...
@@ -62,10 +58,8 @@ public final class AuthValidatorUtil {
/**
* Checks if is valid user.
*
* @param authentication
* the authentication
* @param userId
* the user id
* @param authentication the authentication
* @param userId the user id
* @return true, if is valid user
*/
public
static
boolean
isValidUser
(
Authentication
authentication
,
String
userId
)
{
...
...
@@ -75,10 +69,8 @@ public final class AuthValidatorUtil {
/**
* Checks if is valid user by user name.
*
* @param authentication
* the authentication
* @param userName
* the user name
* @param authentication the authentication
* @param userName the user name
* @return true, if is valid user by user name
*/
public
static
boolean
isValidUserByUserName
(
Authentication
authentication
,
String
userName
)
{
...
...
@@ -88,8 +80,7 @@ public final class AuthValidatorUtil {
/**
* Gets the principal.
*
* @param authentication
* the authentication
* @param authentication the authentication
* @return the principal
*/
public
static
Principal
getPrincipal
(
Authentication
authentication
)
{
...
...
src/main/java/com/altimetrik/playground/innovation/security/SecurityConfig.java
View file @
cfba9e81
...
...
@@ -63,6 +63,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
public
AnonymousAuthenticationFilter
gatewayAuthenticationFilter
()
{
return
new
GatewayAuthenticationFilter
(
strRegulus
);
}
/**
* Gateway authentication token filter.
*
...
...
src/main/java/com/altimetrik/playground/innovation/service/PgIdeaCategoryService.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
service
;
import
org.springframework.stereotype.Service
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryListResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponse
;
import
com.altimetrik.playground.innovation.exception.InnovationServiceException
;
@Service
public
interface
PgIdeaCategoryService
{
PgIdeaCategoryListResponse
findAllCategories
()
throws
InnovationServiceException
;
PgIdeaCategoryResponse
createCategory
(
PgIdeaCategoryRequest
req
)
throws
InnovationServiceException
;
PgIdeaCategoryResponse
findByCategoryId
(
String
id
)
throws
InnovationServiceException
;
}
src/main/java/com/altimetrik/playground/innovation/service/PgIdeaReviewerService.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
service
;
import
org.springframework.stereotype.Service
;
@Service
public
interface
PgIdeaReviewerService
{
}
src/main/java/com/altimetrik/playground/innovation/service/PgIdeaService.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
service
;
import
org.springframework.stereotype.Service
;
import
com.altimetrik.playground.innovation.bean.BaseResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaArtifact
;
import
com.altimetrik.playground.innovation.bean.PgIdeaArtifactListResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaSearchRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaSearchResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaTeamInviteRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaTeamListResponse
;
import
com.altimetrik.playground.innovation.exception.PgApplicationException
;
@Service
public
interface
PgIdeaService
{
PgIdeaSearchResponse
getAllIdeas
(
PgIdeaSearchRequest
req
)
throws
PgApplicationException
;
PgIdeaResponse
getIdea
(
String
req
)
throws
PgApplicationException
;
PgIdeaArtifactListResponse
addArtifact
(
String
ideaId
,
PgIdeaArtifact
req
)
throws
PgApplicationException
;
PgIdeaArtifactListResponse
getArtifact
(
String
ideaId
)
throws
PgApplicationException
;
PgIdeaResponse
createIdea
(
PgIdeaRequest
pgIdeaRequest
)
throws
PgApplicationException
;
PgIdeaResponse
updateIdea
(
String
ideaId
,
PgIdeaRequest
pgIdeaRequest
)
throws
PgApplicationException
;
PgIdeaTeamListResponse
getTeamList
(
String
ideaId
)
throws
PgApplicationException
;
PgIdeaTeamListResponse
listTeamRequests
(
String
ideaId
)
throws
PgApplicationException
;
BaseResponse
joinRequest
(
String
ideaId
)
throws
PgApplicationException
;
BaseResponse
acceptJoinRequests
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
;
BaseResponse
rejectJoinRequests
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
;
BaseResponse
inviteTeamRequests
(
String
ideaId
,
PgIdeaTeamInviteRequest
request
)
throws
PgApplicationException
;
BaseResponse
rejectTeamRequest
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
;
BaseResponse
acceptTeamRequest
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
;
}
src/main/java/com/altimetrik/playground/innovation/service/impl/PgIdeaCategoryServiceImpl.java
0 → 100644
View file @
cfba9e81
package
com
.
altimetrik
.
playground
.
innovation
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryListResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponse
;
import
com.altimetrik.playground.innovation.bean.PgReviewer
;
import
com.altimetrik.playground.innovation.bean.StatusDetails
;
import
com.altimetrik.playground.innovation.constants.ReviewLevelEnum
;
import
com.altimetrik.playground.innovation.entity.PgCategoryEntity
;
import
com.altimetrik.playground.innovation.entity.PgReviewersEntity
;
import
com.altimetrik.playground.innovation.exception.InnovationServiceException
;
import
com.altimetrik.playground.innovation.repository.PgIdeaCategoryRepository
;
import
com.altimetrik.playground.innovation.service.PgIdeaCategoryService
;
import
com.altimetrik.playground.innovation.util.UserUtil
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Component
public
class
PgIdeaCategoryServiceImpl
implements
PgIdeaCategoryService
{
private
static
final
String
NOT_FOUND
=
"not.found"
;
Map
<
Long
,
String
>
userMap
=
new
HashMap
<>();
@Autowired
private
PgIdeaCategoryRepository
pgIdeaCategoryRepository
;
@Autowired
private
UserUtil
userUtil
;
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaCategoryService#
* findAllCategories()
*/
@Override
public
PgIdeaCategoryListResponse
findAllCategories
()
throws
InnovationServiceException
{
PgIdeaCategoryListResponse
response
=
new
PgIdeaCategoryListResponse
();
List
<
PgIdeaCategoryResponse
>
result
=
new
ArrayList
<>();
final
List
<
PgCategoryEntity
>
pgIdeaCategories
=
this
.
pgIdeaCategoryRepository
.
findAll
();
if
(
pgIdeaCategories
!=
null
)
pgIdeaCategories
.
stream
().
forEach
(
pgCategoryEntity
->
result
.
add
(
prepareIdeaCategoryResponse
(
pgCategoryEntity
)));
response
.
setResult
(
result
);
response
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
response
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaCategoryService#
* createCategory(
* com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponse)
*/
@Override
public
PgIdeaCategoryResponse
createCategory
(
PgIdeaCategoryRequest
req
)
throws
InnovationServiceException
{
PgIdeaCategoryResponse
res
;
PgCategoryEntity
bom
=
new
PgCategoryEntity
();
List
<
PgReviewer
>
reviewers
=
req
.
getReviewers
();
List
<
PgReviewersEntity
>
rev
=
new
ArrayList
<>();
reviewers
.
stream
().
forEach
(
pgReviewer
->
{
PgReviewersEntity
reviewersEntity
=
new
PgReviewersEntity
(
pgReviewer
.
getReviewerId
(),
ReviewLevelEnum
.
LEVEL_0
);
reviewersEntity
.
setName
(
pgReviewer
.
getReviewerName
());
rev
.
add
(
reviewersEntity
);
});
if
(!
rev
.
isEmpty
())
bom
.
setReviewers
(
rev
);
bom
.
setCategoryName
(
req
.
getCategoryName
());
bom
=
pgIdeaCategoryRepository
.
save
(
bom
);
res
=
prepareIdeaCategoryResponse
(
bom
);
res
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
res
;
}
private
PgIdeaCategoryResponse
prepareIdeaCategoryResponse
(
PgCategoryEntity
bom
)
{
PgIdeaCategoryResponse
response
=
new
PgIdeaCategoryResponse
();
response
.
setCategoryId
(
bom
.
getId
());
response
.
setCategoryName
(
bom
.
getCategoryName
());
response
.
setCreatedBy
(
bom
.
getCreatedBy
());
response
.
setCreatedDate
(
bom
.
getCreatedDate
());
List
<
PgReviewer
>
reviewerList
=
new
ArrayList
<>();
List
<
PgReviewersEntity
>
reviewers
=
bom
.
getReviewers
();
if
(
reviewers
!=
null
)
reviewers
.
stream
().
forEach
(
pgReviewersEntity
->
{
PgReviewer
pgReviewer
=
new
PgReviewer
();
pgReviewer
.
setReviewerId
(
pgReviewersEntity
.
getUserId
());
pgReviewer
.
setReviewerName
(
pgReviewersEntity
.
getName
());
pgReviewer
.
setReviewLevel
(
pgReviewersEntity
.
getLevel
());
pgReviewer
.
setId
(
pgReviewersEntity
.
getId
());
reviewerList
.
add
(
pgReviewer
);
});
response
.
setReviewers
(
reviewerList
);
return
response
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaCategoryService#
* findByCategoryId(java. lang.String)
*/
@Override
public
PgIdeaCategoryResponse
findByCategoryId
(
String
id
)
throws
InnovationServiceException
{
PgIdeaCategoryResponse
res
;
Optional
<
PgCategoryEntity
>
categoryEntity
=
pgIdeaCategoryRepository
.
findById
(
id
);
if
(!
categoryEntity
.
isPresent
())
throw
new
InnovationServiceException
(
NOT_FOUND
,
"Idea Category not found"
);
PgCategoryEntity
cat
=
categoryEntity
.
get
();
res
=
prepareIdeaCategoryResponse
(
cat
);
res
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
res
;
}
}
src/main/java/com/altimetrik/playground/innovation/service/impl/PgIdeaReviewerServiceImpl.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
service
.
impl
;
import
org.springframework.stereotype.Service
;
import
com.altimetrik.playground.innovation.service.PgIdeaReviewerService
;
@Service
public
class
PgIdeaReviewerServiceImpl
implements
PgIdeaReviewerService
{
}
src/main/java/com/altimetrik/playground/innovation/service/impl/PgIdeaServiceImpl.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information of Altimetrik.
* You shall not disclose such Confidential Information and shall use it only in
* accordance with the terms and conditions entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Random
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
import
com.altimetrik.playground.innovation.bean.BaseResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaArtifact
;
import
com.altimetrik.playground.innovation.bean.PgIdeaArtifactListResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaSearchRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaSearchResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaTeamInviteRequest
;
import
com.altimetrik.playground.innovation.bean.PgIdeaTeamListResponse
;
import
com.altimetrik.playground.innovation.bean.PgIdeaTeamResponse
;
import
com.altimetrik.playground.innovation.bean.StatusDetails
;
import
com.altimetrik.playground.innovation.constants.ArtifactTypeEnum
;
import
com.altimetrik.playground.innovation.constants.IdeaStatusEnum
;
import
com.altimetrik.playground.innovation.constants.IdeaTypeEnum
;
import
com.altimetrik.playground.innovation.constants.ReviewLevelEnum
;
import
com.altimetrik.playground.innovation.constants.RoleTypeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestModeEnum
;
import
com.altimetrik.playground.innovation.constants.TeamMemberRequestStatusEnum
;
import
com.altimetrik.playground.innovation.entity.PgCategoryEntity
;
import
com.altimetrik.playground.innovation.entity.PgIdeaArtifactEntity
;
import
com.altimetrik.playground.innovation.entity.PgIdeaEntity
;
import
com.altimetrik.playground.innovation.entity.PgReviewersEntity
;
import
com.altimetrik.playground.innovation.entity.PgTeamEntity
;
import
com.altimetrik.playground.innovation.exception.InnovationServiceException
;
import
com.altimetrik.playground.innovation.exception.PgApplicationException
;
import
com.altimetrik.playground.innovation.repository.PgIdeaCategoryRepository
;
import
com.altimetrik.playground.innovation.repository.PgIdeaRepository
;
import
com.altimetrik.playground.innovation.service.PgIdeaService
;
import
com.altimetrik.playground.innovation.util.UserUtil
;
import
lombok.extern.slf4j.Slf4j
;
@Component
@Slf4j
public
class
PgIdeaServiceImpl
implements
PgIdeaService
{
private
static
final
String
IDEA_WITH_ID
=
"Idea with ID ("
;
private
static
final
String
NOT_FOUND
=
"not.found"
;
private
static
final
String
USER_NOT_AUTHORIZED
=
"user.not.authorized"
;
private
static
final
String
USER_NOT_AUTHORIZED_MSG
=
"Current user not authorized to perform this action on this request."
;
@Autowired
private
PgIdeaRepository
pgIdeaRepository
;
@Autowired
private
PgIdeaCategoryRepository
pgIdeaCategoryRepository
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
UserUtil
userUtil
;
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#getIdea(java.
* lang.String)
*/
@Override
public
PgIdeaResponse
getIdea
(
String
ideaId
)
throws
PgApplicationException
{
PgIdeaEntity
ideaEntity
=
getIdeaEntity
(
ideaId
);
try
{
validateUserAccessToIdea
(
ideaEntity
);
}
catch
(
InnovationServiceException
e
)
{
if
(!
ideaEntity
.
getPublished
()
||
ideaEntity
.
getIdeaType
().
equals
(
IdeaTypeEnum
.
PRIVATE
))
throw
e
;
}
PgIdeaResponse
response
=
prepareIdeaResponse
(
ideaEntity
);
response
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
response
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#getAllIdeas(
* com.altimetrik.playground.innovation.bean.PgIdeaSearchRequest)
*/
@Override
public
PgIdeaSearchResponse
getAllIdeas
(
PgIdeaSearchRequest
req
)
throws
PgApplicationException
{
PgIdeaSearchResponse
response
=
new
PgIdeaSearchResponse
();
List
<
PgIdeaResponse
>
result
=
new
ArrayList
<>();
List
<
Criteria
>
andCriterias
=
new
ArrayList
<>();
List
<
Criteria
>
orCriterias
=
new
ArrayList
<>();
Criteria
criteria
;
if
(
StringUtils
.
isNotBlank
(
req
.
getSearch
()))
{
Criteria
title
=
Criteria
.
where
(
"title"
).
regex
(
req
.
getSearch
().
trim
(),
"i"
);
Criteria
desc
=
Criteria
.
where
(
"description"
).
regex
(
req
.
getSearch
().
trim
(),
"i"
);
andCriterias
.
add
(
new
Criteria
().
orOperator
(
title
,
desc
));
}
if
(
req
.
getIds
()
!=
null
)
{
andCriterias
.
add
(
Criteria
.
where
(
"_id"
).
in
(
req
.
getIds
()));
}
if
(
req
.
getMine
())
{
andCriterias
.
add
(
Criteria
.
where
(
"team"
).
elemMatch
(
Criteria
.
where
(
"userId"
).
is
(
userUtil
.
getLoggedInUser
()).
andOperator
(
new
Criteria
()
.
orOperator
(
Criteria
.
where
(
"role"
).
is
(
RoleTypeEnum
.
INNOVATOR
),
Criteria
.
where
(
"role"
).
is
(
RoleTypeEnum
.
CO_INNOVATOR
),
Criteria
.
where
(
"role"
).
is
(
RoleTypeEnum
.
MEMBER
))
.
andOperator
(
new
Criteria
().
orOperator
(
Criteria
.
where
(
"requestStatus"
).
is
(
TeamMemberRequestStatusEnum
.
ACCEPTED
),
Criteria
.
where
(
"requestStatus"
).
exists
(
false
))))));
}
else
{
andCriterias
.
add
(
Criteria
.
where
(
"ideaType"
).
is
(
IdeaTypeEnum
.
PUBLIC
));
andCriterias
.
add
(
Criteria
.
where
(
"published"
).
is
(
true
));
andCriterias
.
add
(
Criteria
.
where
(
"team"
).
not
().
elemMatch
(
Criteria
.
where
(
"userId"
).
is
(
userUtil
.
getLoggedInUser
())));
}
if
(
andCriterias
.
isEmpty
()
&&
orCriterias
.
isEmpty
())
{
criteria
=
new
Criteria
();
}
else
if
(
andCriterias
.
isEmpty
()
&&
!
orCriterias
.
isEmpty
())
{
criteria
=
new
Criteria
().
orOperator
(
orCriterias
.
toArray
(
new
Criteria
[
orCriterias
.
size
()]));
}
else
if
(!
andCriterias
.
isEmpty
()
&&
orCriterias
.
isEmpty
())
{
criteria
=
new
Criteria
().
andOperator
(
andCriterias
.
toArray
(
new
Criteria
[
andCriterias
.
size
()]));
}
else
{
criteria
=
new
Criteria
().
andOperator
(
andCriterias
.
toArray
(
new
Criteria
[
andCriterias
.
size
()])).
orOperator
(
orCriterias
.
toArray
(
new
Criteria
[
orCriterias
.
size
()]));
}
Query
query
=
new
Query
(
criteria
);
if
(
req
.
getLimit
()
!=
null
)
query
.
limit
(
req
.
getLimit
());
if
(
req
.
getOffset
()
!=
null
)
query
.
skip
(
req
.
getOffset
());
List
<
PgIdeaEntity
>
entityList
=
mongoTemplate
.
find
(
query
,
PgIdeaEntity
.
class
);
entityList
.
forEach
(
e
->
{
PgIdeaResponse
ideaResponse
=
prepareIdeaResponse
(
e
);
result
.
add
(
ideaResponse
);
});
response
.
setResult
(
result
);
response
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
response
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#addArtifact(
* java.lang.String, com.altimetrik.playground.innovation.bean.PgIdeaArtifact)
*/
@Override
public
PgIdeaArtifactListResponse
addArtifact
(
String
ideaId
,
PgIdeaArtifact
req
)
throws
PgApplicationException
{
PgIdeaEntity
ideaEntity
=
getIdeaEntity
(
ideaId
);
validateUserAccessToIdea
(
ideaEntity
);
List
<
PgIdeaArtifactEntity
>
artifactList
=
ideaEntity
.
getArtifacts
();
if
(
artifactList
==
null
)
artifactList
=
new
ArrayList
<>();
PgIdeaArtifactEntity
artifact
=
new
PgIdeaArtifactEntity
(
req
.
getLinkName
(),
req
.
getLinkUrl
(),
ArtifactTypeEnum
.
LINK
,
req
.
getFileName
());
artifact
.
setCreatedBy
(
userUtil
.
getLoggedInUser
());
artifact
.
setCreatedDate
(
new
Date
());
artifactList
.
add
(
artifact
);
ideaEntity
.
setArtifacts
(
artifactList
);
ideaEntity
=
pgIdeaRepository
.
save
(
ideaEntity
);
return
prepareArtifactResponse
(
ideaEntity
);
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#getArtifact(
* java.lang.String)
*/
@Override
public
PgIdeaArtifactListResponse
getArtifact
(
String
ideaId
)
throws
PgApplicationException
{
PgIdeaEntity
ideaEntity
=
getIdeaEntity
(
ideaId
);
validateUserAccessToIdea
(
ideaEntity
);
return
prepareArtifactResponse
(
ideaEntity
);
}
/**
* @param ideaEntity
* @return
*/
private
PgIdeaArtifactListResponse
prepareArtifactResponse
(
PgIdeaEntity
ideaEntity
)
{
PgIdeaArtifactListResponse
resp
=
new
PgIdeaArtifactListResponse
();
List
<
PgIdeaArtifact
>
result
=
new
ArrayList
<>();
resp
.
setIdeaId
(
ideaEntity
.
getId
());
if
(
ideaEntity
.
getArtifacts
()
!=
null
)
{
ideaEntity
.
getArtifacts
().
forEach
(
entity
->
result
.
add
(
new
PgIdeaArtifact
(
entity
.
getId
(),
entity
.
getLinkName
(),
entity
.
getType
(),
entity
.
getLinkUrl
(),
entity
.
getFileName
(),
entity
.
getCreatedBy
(),
entity
.
getCreatedDate
())));
}
resp
.
setResult
(
result
);
resp
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
resp
;
}
/*
* (non-Javadoc)
*
* @see
* com.altimetrik.playground.innovation.service.PgIdeaService#createIdea(com
* .altimetrik.playground.innovation.bean.PgIdeaRequest)
*/
@Override
public
PgIdeaResponse
createIdea
(
PgIdeaRequest
pgIdeaRequest
)
throws
PgApplicationException
{
innitialCheckForIdeaCreation
(
pgIdeaRequest
);
String
loggedInUser
=
userUtil
.
getLoggedInUser
();
PgIdeaEntity
entity
=
new
PgIdeaEntity
();
entity
.
setTitle
(
pgIdeaRequest
.
getTitle
());
entity
.
setDescription
(
pgIdeaRequest
.
getDescription
());
entity
.
setBusinessRelevance
(
pgIdeaRequest
.
getBusinessRelevance
());
entity
.
setCompetenceCenter
(
pgIdeaRequest
.
getCompetenceCenter
()
==
null
?
Boolean
.
FALSE
:
pgIdeaRequest
.
getCompetenceCenter
());
entity
.
setIdeaType
(
pgIdeaRequest
.
getIdeaType
()
==
null
?
IdeaTypeEnum
.
PUBLIC
:
pgIdeaRequest
.
getIdeaType
());
entity
.
setStatus
(
pgIdeaRequest
.
getStatus
()
==
null
?
IdeaStatusEnum
.
NOT_SUBMITTED
:
pgIdeaRequest
.
getStatus
());
entity
.
setPublished
(
pgIdeaRequest
.
getPublished
()
==
null
?
Boolean
.
FALSE
:
pgIdeaRequest
.
getPublished
());
entity
.
setDisclosed
(
pgIdeaRequest
.
getDisclosed
()
==
null
?
Boolean
.
FALSE
:
pgIdeaRequest
.
getDisclosed
());
entity
.
setLocked
(
pgIdeaRequest
.
getLocked
()
==
null
?
Boolean
.
FALSE
:
pgIdeaRequest
.
getLocked
());
entity
.
setBusinessDomain
(
pgIdeaRequest
.
getBusinessDomain
());
entity
.
setTechnologyDomain
(
pgIdeaRequest
.
getTechnologyDomain
());
entity
.
setTechStack
(
pgIdeaRequest
.
getTechStack
());
entity
.
setNovelty
(
pgIdeaRequest
.
getNovelty
());
entity
.
setClaims
(
pgIdeaRequest
.
getClaims
());
entity
.
setCompleteness
(
pgIdeaRequest
.
getCompleteness
());
entity
.
setAccessLevel
(
pgIdeaRequest
.
getAccessLevel
());
if
(
pgIdeaRequest
.
getIdeaCategoryId
()
!=
null
)
{
entity
.
setIdeaCategoryId
(
pgIdeaRequest
.
getIdeaCategoryId
());
entity
.
setL0ReviewerId
(
getL0Reviwer
(
pgIdeaRequest
.
getIdeaCategoryId
()));
}
// Setting the creator for an idea
PgTeamEntity
creator
=
new
PgTeamEntity
();
creator
.
setRole
(
RoleTypeEnum
.
INNOVATOR
);
log
.
info
(
"Creator for idea : {}"
,
loggedInUser
);
creator
.
setUserId
(
loggedInUser
);
creator
.
setRequestStatus
(
TeamMemberRequestStatusEnum
.
ACCEPTED
);
creator
.
setCreatedBy
(
loggedInUser
);
creator
.
setCreatedDate
(
new
Date
());
List
<
PgTeamEntity
>
team
=
new
ArrayList
<>();
team
.
add
(
creator
);
entity
.
setTeam
(
team
);
entity
.
setCreatedBy
(
loggedInUser
);
entity
.
setCreatedDate
(
new
Date
());
entity
.
setLastModifiedBy
(
loggedInUser
);
entity
=
pgIdeaRepository
.
insert
(
entity
);
PgIdeaResponse
response
=
prepareIdeaResponse
(
entity
);
response
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
response
;
}
/**
* @param pgIdeaRequest
* @throws InnovationServiceException
*/
private
void
innitialCheckForIdeaCreation
(
PgIdeaRequest
pgIdeaRequest
)
throws
InnovationServiceException
{
if
(
pgIdeaRequest
.
getStatus
()
!=
null
&&
pgIdeaRequest
.
getStatus
().
equals
(
IdeaStatusEnum
.
APPROVED
))
throw
new
InnovationServiceException
(
"invalid"
,
"Idea cannot be created as an approved idea"
);
if
(
StringUtils
.
isBlank
(
pgIdeaRequest
.
getTitle
()))
throw
new
InnovationServiceException
(
"idea.not.found"
,
"Idea Title Not Found"
);
else
{
Optional
<
PgIdeaEntity
>
findByTitle
=
pgIdeaRepository
.
findByTitle
(
pgIdeaRequest
.
getTitle
());
if
(
findByTitle
.
isPresent
())
throw
new
InnovationServiceException
(
"idea.exist"
,
"Idea with given title already exist."
);
}
if
(
pgIdeaRequest
.
getStatus
()
!=
null
&&
pgIdeaRequest
.
getStatus
().
equals
(
IdeaStatusEnum
.
SUBMITTED
))
{
if
(
pgIdeaRequest
.
getPublished
()
==
null
||
!
pgIdeaRequest
.
getPublished
())
throw
new
InnovationServiceException
(
"not.published"
,
"Idea Not Published for Submission"
);
if
(
pgIdeaRequest
.
getIdeaCategoryId
()
!=
null
)
pgIdeaCategoryRepository
.
findById
(
pgIdeaRequest
.
getIdeaCategoryId
())
.
orElseThrow
(()
->
new
InnovationServiceException
(
"category.not.found"
,
"Category Not Found with ID : "
+
pgIdeaRequest
.
getIdeaCategoryId
()));
else
throw
new
InnovationServiceException
(
NOT_FOUND
,
"An idea has to part of a category before Submission."
);
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getNovelty
()))
throw
new
InnovationServiceException
(
NOT_FOUND
,
"An idea has to contain novelty before Submission."
);
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getClaims
()))
throw
new
InnovationServiceException
(
NOT_FOUND
,
"An idea has to contain claims before Submission."
);
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getCompleteness
()))
throw
new
InnovationServiceException
(
NOT_FOUND
,
"An idea has to contain completeness before Submission."
);
}
}
/**
* to create the response model.
* @param entity
* @return
*/
private
PgIdeaResponse
prepareIdeaResponse
(
PgIdeaEntity
entity
)
{
PgIdeaResponse
response
=
new
PgIdeaResponse
();
response
.
setIdeaId
(
entity
.
getId
());
response
.
setTitle
(
entity
.
getTitle
());
response
.
setDescription
(
entity
.
getDescription
());
response
.
setBusinessRelevance
(
entity
.
getBusinessRelevance
());
response
.
setIdeaCategoryId
(
entity
.
getIdeaCategoryId
());
response
.
setCompetenceCenter
(
entity
.
getCompetenceCenter
());
response
.
setIdeaType
(
entity
.
getIdeaType
());
response
.
setIdeaStatus
(
entity
.
getStatus
());
response
.
setPublished
(
entity
.
getPublished
());
response
.
setLocked
(
entity
.
getLocked
());
response
.
setBusinessDomain
(
entity
.
getBusinessDomain
());
response
.
setTechnologyDomain
(
entity
.
getTechnologyDomain
());
response
.
setTechStack
(
entity
.
getTechStack
());
response
.
setNovelty
(
entity
.
getNovelty
());
response
.
setClaims
(
entity
.
getClaims
());
response
.
setCompleteness
(
entity
.
getCompleteness
());
response
.
setL0ReviewerId
(
entity
.
getL0ReviewerId
());
response
.
setCreatedById
(
entity
.
getCreatedBy
());
response
.
setCreatedOn
(
entity
.
getCreatedDate
());
response
.
setDisclosed
(
entity
.
getDisclosed
());
response
.
setAccessLevel
(
entity
.
getAccessLevel
());
return
response
;
}
/**
* to retrieve level zero reviewer
* @param categoryId
* @return
* @throws InnovationServiceException
*/
private
String
getL0Reviwer
(
String
categoryId
)
throws
InnovationServiceException
{
String
reviewerId
=
null
;
Optional
<
PgCategoryEntity
>
entity
=
pgIdeaCategoryRepository
.
findById
(
categoryId
);
if
(
entity
.
isPresent
())
{
PgCategoryEntity
category
=
entity
.
get
();
List
<
PgReviewersEntity
>
reviewers
=
category
.
getReviewers
().
stream
().
filter
(
p
->
p
.
getLevel
().
equals
(
ReviewLevelEnum
.
LEVEL_0
)).
collect
(
Collectors
.
toList
());
int
index
=
new
Random
().
nextInt
(
reviewers
.
size
());
reviewerId
=
reviewers
.
get
(
index
).
getUserId
();
}
else
throw
new
InnovationServiceException
(
"category.not.found"
,
"Category Not Found with id : "
+
categoryId
);
return
reviewerId
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#updateIdea(
* java.lang.String, com.altimetrik.playground.innovation.bean.PgIdeaRequest)
*/
@Override
public
PgIdeaResponse
updateIdea
(
String
ideaId
,
PgIdeaRequest
pgIdeaRequest
)
throws
PgApplicationException
{
String
loggedInUser
=
userUtil
.
getLoggedInUser
();
PgIdeaEntity
idea
=
getIdeaEntity
(
ideaId
);
if
(
access
(
idea
.
getTeam
())
&&
!
idea
.
getStatus
().
equals
(
IdeaStatusEnum
.
APPROVED
))
{
if
(
pgIdeaRequest
.
getStatus
()
!=
null
)
{
if
(
pgIdeaRequest
.
getStatus
().
equals
(
IdeaStatusEnum
.
SUBMITTED
))
{
if
(!
idea
.
getPublished
())
throw
new
InnovationServiceException
(
"not.published"
,
"Idea Not Published for Submission for ID "
+
ideaId
);
if
(
idea
.
getIdeaCategoryId
()
!=
null
)
throw
new
InnovationServiceException
(
NOT_FOUND
,
IDEA_WITH_ID
+
ideaId
+
") is not a part of any category for ID. Please select a category before Submission."
);
if
(
StringUtils
.
isNotBlank
(
idea
.
getNovelty
()))
throw
new
InnovationServiceException
(
NOT_FOUND
,
IDEA_WITH_ID
+
ideaId
+
") does not have any novelty."
);
if
(
StringUtils
.
isNotBlank
(
idea
.
getClaims
()))
throw
new
InnovationServiceException
(
NOT_FOUND
,
IDEA_WITH_ID
+
ideaId
+
") does not have any Claims."
);
if
(
StringUtils
.
isNotBlank
(
idea
.
getCompleteness
()))
throw
new
InnovationServiceException
(
NOT_FOUND
,
IDEA_WITH_ID
+
ideaId
+
") does not have any Completeness."
);
}
idea
.
setStatus
(
pgIdeaRequest
.
getStatus
());
}
if
(
pgIdeaRequest
.
getTitle
()
!=
null
)
{
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getTitle
()))
{
if
(!
pgIdeaRequest
.
getTitle
().
equals
(
idea
.
getTitle
()))
{
Optional
<
PgIdeaEntity
>
findByTitle
=
pgIdeaRepository
.
findByTitle
(
pgIdeaRequest
.
getTitle
());
if
(
findByTitle
.
isPresent
())
throw
new
InnovationServiceException
(
"idea.exist"
,
"Idea with given title already exist."
);
idea
.
setTitle
(
pgIdeaRequest
.
getTitle
());
}
}
else
{
throw
new
InnovationServiceException
(
"not.blank"
,
"Idea Title cannot be blank."
);
}
}
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getDescription
()))
idea
.
setDescription
(
pgIdeaRequest
.
getDescription
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getBusinessRelevance
()))
idea
.
setBusinessRelevance
(
pgIdeaRequest
.
getBusinessRelevance
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getIdeaCategoryId
()))
{
PgCategoryEntity
category
=
pgIdeaCategoryRepository
.
findById
(
pgIdeaRequest
.
getIdeaCategoryId
())
.
orElseThrow
(()
->
new
InnovationServiceException
(
NOT_FOUND
,
"Please provide a valid category."
));
idea
.
setIdeaCategoryId
(
category
.
getId
());
idea
.
setL0ReviewerId
(
getL0Reviwer
(
pgIdeaRequest
.
getIdeaCategoryId
()));
}
if
(
pgIdeaRequest
.
getCompetenceCenter
()
!=
null
)
idea
.
setCompetenceCenter
(
pgIdeaRequest
.
getCompetenceCenter
());
if
(
pgIdeaRequest
.
getIdeaType
()
!=
null
)
idea
.
setIdeaType
(
pgIdeaRequest
.
getIdeaType
());
if
(
pgIdeaRequest
.
getPublished
()
!=
null
&&
idea
.
getStatus
().
equals
(
IdeaStatusEnum
.
NOT_SUBMITTED
))
{
if
(!
pgIdeaRequest
.
getPublished
()
&&
idea
.
getPublished
())
throw
new
InnovationServiceException
(
"restricted"
,
"Idea once published cannot be made draft."
);
else
idea
.
setPublished
(
pgIdeaRequest
.
getPublished
());
}
if
(
pgIdeaRequest
.
getLocked
()
!=
null
)
idea
.
setLocked
(
pgIdeaRequest
.
getLocked
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getBusinessDomain
()))
idea
.
setBusinessDomain
(
pgIdeaRequest
.
getBusinessDomain
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getTechnologyDomain
()))
idea
.
setTechnologyDomain
(
pgIdeaRequest
.
getTechnologyDomain
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getTechStack
()))
idea
.
setTechStack
(
pgIdeaRequest
.
getTechStack
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getNovelty
()))
idea
.
setNovelty
(
pgIdeaRequest
.
getNovelty
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getClaims
()))
idea
.
setClaims
(
pgIdeaRequest
.
getClaims
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getCompleteness
()))
idea
.
setCompleteness
(
pgIdeaRequest
.
getCompleteness
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getIdeaCategoryId
()))
idea
.
setL0ReviewerId
(
getL0Reviwer
(
pgIdeaRequest
.
getIdeaCategoryId
()));
if
(
pgIdeaRequest
.
getDisclosed
()
!=
null
)
idea
.
setDisclosed
(
pgIdeaRequest
.
getDisclosed
());
if
(
StringUtils
.
isNotBlank
(
pgIdeaRequest
.
getAccessLevel
()))
idea
.
setAccessLevel
(
pgIdeaRequest
.
getAccessLevel
());
idea
.
setLastModifiedBy
(
loggedInUser
);
idea
.
setLastModifiedDate
(
new
Date
());
idea
=
pgIdeaRepository
.
save
(
idea
);
}
else
{
throw
new
InnovationServiceException
(
USER_NOT_AUTHORIZED
,
"Current user not authorized to update the idea."
);
}
PgIdeaResponse
pgIdeaResponse
=
prepareIdeaResponse
(
idea
);
pgIdeaResponse
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
pgIdeaResponse
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#getTeamList(
* java.lang.String)
*/
@Override
public
PgIdeaTeamListResponse
getTeamList
(
String
ideaId
)
throws
PgApplicationException
{
Optional
<
PgIdeaEntity
>
entity
=
pgIdeaRepository
.
findById
(
ideaId
);
if
(!
entity
.
isPresent
())
{
throw
new
InnovationServiceException
(
NOT_FOUND
,
"Idea Not Found for ID "
+
ideaId
);
}
PgIdeaEntity
ideaEntity
=
entity
.
get
();
PgIdeaTeamListResponse
resp
=
new
PgIdeaTeamListResponse
();
final
List
<
PgTeamEntity
>
teamEntityList
=
ideaEntity
.
getTeam
();
AtomicBoolean
isLoggedInUserPartOfIdea
=
new
AtomicBoolean
(
false
);
List
<
PgIdeaTeamResponse
>
result
=
new
ArrayList
<>();
if
(
teamEntityList
!=
null
)
{
teamEntityList
.
forEach
(
teamEntity
->
{
PgIdeaTeamResponse
team
=
prepareTeamResponse
(
teamEntity
);
if
(
team
.
getUserId
().
equals
(
userUtil
.
getLoggedInUser
()))
isLoggedInUserPartOfIdea
.
set
(
true
);
result
.
add
(
team
);
});
if
(
isLoggedInUserPartOfIdea
.
get
())
{
resp
.
setResult
(
result
);
}
else
if
(
ideaEntity
.
getPublished
()
!=
null
&&
ideaEntity
.
getPublished
())
{
resp
.
setResult
(
result
.
stream
().
filter
(
p
->
p
.
getTeamMemberRequestStatus
()
!=
null
&&
p
.
getTeamMemberRequestStatus
().
equals
(
TeamMemberRequestStatusEnum
.
ACCEPTED
))
.
collect
(
Collectors
.
toList
()));
}
}
resp
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
resp
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#
* listTeamRequests(java.lang.String)
*/
@Override
public
PgIdeaTeamListResponse
listTeamRequests
(
String
ideaId
)
throws
PgApplicationException
{
PgIdeaEntity
ideaEntity
=
getIdeaEntity
(
ideaId
);
validateUserAccessToIdea
(
ideaEntity
);
PgIdeaTeamListResponse
resp
=
new
PgIdeaTeamListResponse
();
final
List
<
PgTeamEntity
>
teamEntityList
=
ideaEntity
.
getTeam
();
List
<
PgIdeaTeamResponse
>
result
=
new
ArrayList
<>();
if
(
teamEntityList
!=
null
)
{
teamEntityList
.
forEach
(
teamEntity
->
{
if
(
teamEntity
.
getRequestMode
()
!=
null
&&
(
teamEntity
.
getRequestMode
().
equals
(
TeamMemberRequestModeEnum
.
INVITE
)
||
teamEntity
.
getRequestMode
().
equals
(
TeamMemberRequestModeEnum
.
JOIN
)))
{
PgIdeaTeamResponse
team
=
prepareTeamResponse
(
teamEntity
);
result
.
add
(
team
);
}
});
}
resp
.
setResult
(
result
);
resp
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
resp
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#
* inviteTeamRequests(java.lang.String,
* com.altimetrik.playground.innovation.bean.PgIdeaTeamInviteRequest)
*/
@Override
public
BaseResponse
inviteTeamRequests
(
String
ideaId
,
PgIdeaTeamInviteRequest
request
)
throws
PgApplicationException
{
PgIdeaEntity
ideaEntity
=
getIdeaEntity
(
ideaId
);
validateUserAccessToIdea
(
ideaEntity
);
userUtil
.
isUserAnEmployee
(
request
.
getUserId
());
BaseResponse
res
=
new
BaseResponse
();
List
<
PgTeamEntity
>
teamEntityList
=
ideaEntity
.
getTeam
();
if
(
teamEntityList
!=
null
)
{
for
(
PgTeamEntity
teamEntity
:
teamEntityList
)
{
if
(
teamEntity
.
getUserId
().
equals
(
request
.
getUserId
()))
{
throw
new
InnovationServiceException
(
"user.exists"
,
request
.
getUserId
()
+
" is already invited/part of team for this Idea."
);
}
}
PgTeamEntity
entity
=
new
PgTeamEntity
();
entity
.
setRole
(
RoleTypeEnum
.
valueOf
(
request
.
getRole
()));
entity
.
setUserId
(
request
.
getUserId
());
entity
.
setRequestMode
(
TeamMemberRequestModeEnum
.
INVITE
);
entity
.
setRequestStatus
(
TeamMemberRequestStatusEnum
.
PENDING
);
entity
.
setCreatedBy
(
userUtil
.
getLoggedInUser
());
entity
.
setCreatedDate
(
new
Date
());
teamEntityList
.
add
(
entity
);
}
ideaEntity
.
setTeam
(
teamEntityList
);
pgIdeaRepository
.
save
(
ideaEntity
);
res
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
res
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#
* rejectTeamRequest(java.lang.String, java.lang.String)
*/
@Override
public
BaseResponse
rejectTeamRequest
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
{
return
teamRequestAction
(
ideaId
,
requestId
,
TeamMemberRequestStatusEnum
.
REJECTED
);
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#
* acceptTeamRequest(java.lang.String, java.lang.String)
*/
@Override
public
BaseResponse
acceptTeamRequest
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
{
return
teamRequestAction
(
ideaId
,
requestId
,
TeamMemberRequestStatusEnum
.
ACCEPTED
);
}
/**
* @param ideaId
* @param requestId
* @param status
* @return
* @throws InnovationServiceException
*/
private
BaseResponse
teamRequestAction
(
String
ideaId
,
String
requestId
,
TeamMemberRequestStatusEnum
status
)
throws
InnovationServiceException
{
PgIdeaEntity
ideaEntity
=
getIdeaEntity
(
ideaId
);
BaseResponse
res
=
new
BaseResponse
();
List
<
PgTeamEntity
>
teamEntityList
=
ideaEntity
.
getTeam
();
if
(
teamEntityList
!=
null
)
{
PgTeamEntity
teamEntity
=
teamEntityList
.
stream
().
filter
(
p
->
p
.
getId
().
equals
(
requestId
)).
findAny
()
.
orElseThrow
(()
->
new
InnovationServiceException
(
"request.not.found"
,
"Request ID not found."
));
if
(
teamEntity
.
getUserId
().
equals
(
userUtil
.
getLoggedInUser
()))
{
if
(!
teamEntity
.
getRequestStatus
().
equals
(
TeamMemberRequestStatusEnum
.
PENDING
))
{
throw
new
InnovationServiceException
(
"invalid.state"
,
"Team Request with PENDING status can only be updated."
);
}
teamEntity
.
setRequestStatus
(
status
);
teamEntity
.
setLastModifiedBy
(
userUtil
.
getLoggedInUser
());
teamEntity
.
setLastModifiedDate
(
new
Date
());
}
else
{
throw
new
InnovationServiceException
(
USER_NOT_AUTHORIZED
,
"Current user not authorized to perform this action on this team request."
);
}
}
ideaEntity
.
setTeam
(
teamEntityList
);
pgIdeaRepository
.
save
(
ideaEntity
);
res
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
res
;
}
/**
* @param ideaId
* @return
* @throws InnovationServiceException
*/
private
PgIdeaEntity
getIdeaEntity
(
String
ideaId
)
throws
InnovationServiceException
{
Optional
<
PgIdeaEntity
>
entity
=
pgIdeaRepository
.
findById
(
ideaId
);
if
(!
entity
.
isPresent
())
{
throw
new
InnovationServiceException
(
NOT_FOUND
,
"Idea Not Found for ID "
+
ideaId
);
}
return
entity
.
get
();
}
/**
* @param teamEntity
* @return
*/
private
PgIdeaTeamResponse
prepareTeamResponse
(
PgTeamEntity
teamEntity
)
{
PgIdeaTeamResponse
team
=
new
PgIdeaTeamResponse
();
team
.
setId
(
teamEntity
.
getId
());
team
.
setMode
(
teamEntity
.
getRequestMode
());
team
.
setRole
(
teamEntity
.
getRole
());
team
.
setTeamMemberRequestStatus
(
teamEntity
.
getRequestStatus
());
team
.
setUserId
(
teamEntity
.
getUserId
());
team
.
setCreatedBy
(
teamEntity
.
getCreatedBy
());
team
.
setCreatedDate
(
teamEntity
.
getCreatedDate
());
team
.
setLastModifiedBy
(
teamEntity
.
getLastModifiedBy
());
return
team
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#joinRequest(
* java.lang.String)
*/
@Override
public
BaseResponse
joinRequest
(
String
ideaId
)
throws
PgApplicationException
{
BaseResponse
response
=
new
BaseResponse
();
PgIdeaEntity
idea
=
getIdeaEntity
(
ideaId
);
isIdeaLocked
(
idea
);
String
loggedInUser
=
userUtil
.
getLoggedInUser
();
if
(
idea
.
getPublished
()
&&
idea
.
getIdeaType
().
equals
(
IdeaTypeEnum
.
PUBLIC
))
{
List
<
PgTeamEntity
>
teamEntityList
=
idea
.
getTeam
();
if
(
teamEntityList
!=
null
&&
teamEntityList
.
stream
().
anyMatch
(
teamEntity
->
teamEntity
.
getUserId
().
equals
(
loggedInUser
)))
throw
new
InnovationServiceException
(
"user.exists"
,
loggedInUser
+
" is already invited/joined the team for this Idea."
);
PgTeamEntity
member
=
new
PgTeamEntity
();
member
.
setUserId
(
loggedInUser
);
member
.
setRole
(
RoleTypeEnum
.
MEMBER
);
member
.
setRequestMode
(
TeamMemberRequestModeEnum
.
JOIN
);
member
.
setRequestStatus
(
TeamMemberRequestStatusEnum
.
PENDING
);
member
.
setCreatedBy
(
loggedInUser
);
member
.
setCreatedDate
(
new
Date
());
member
.
setLastModifiedBy
(
loggedInUser
);
idea
.
getTeam
().
add
(
member
);
pgIdeaRepository
.
save
(
idea
);
}
else
{
throw
new
InnovationServiceException
(
USER_NOT_AUTHORIZED
,
"Cannot join this idea("
+
ideaId
+
"), as it is either not published or is PRIVATE"
);
}
response
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
response
;
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#
* acceptJoinRequests(java.lang.String, java.lang.String)
*/
@Override
public
BaseResponse
acceptJoinRequests
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
{
return
handleJoinRequests
(
TeamMemberRequestStatusEnum
.
ACCEPTED
,
ideaId
,
requestId
);
}
/*
* (non-Javadoc)
*
* @see com.altimetrik.playground.innovation.service.PgIdeaService#
* rejectJoinRequests(java.lang.String, java.lang.String)
*/
@Override
public
BaseResponse
rejectJoinRequests
(
String
ideaId
,
String
requestId
)
throws
PgApplicationException
{
return
handleJoinRequests
(
TeamMemberRequestStatusEnum
.
REJECTED
,
ideaId
,
requestId
);
}
/**
* @param status
* @param ideaId
* @param requestId
* @return
* @throws PgApplicationException
*/
private
BaseResponse
handleJoinRequests
(
TeamMemberRequestStatusEnum
status
,
String
ideaId
,
String
requestId
)
throws
PgApplicationException
{
String
loggedInUser
=
userUtil
.
getLoggedInUser
();
PgIdeaEntity
ideaEntity
=
getIdeaEntity
(
ideaId
);
BaseResponse
res
=
new
BaseResponse
();
List
<
PgTeamEntity
>
teamEntityList
=
ideaEntity
.
getTeam
();
if
(
access
(
teamEntityList
))
{
PgTeamEntity
teamEntity
=
teamEntityList
.
stream
().
filter
(
p
->
p
.
getId
().
equals
(
requestId
)).
findAny
()
.
orElseThrow
(()
->
new
InnovationServiceException
(
"request.not.found"
,
"Request ID not found."
));
int
index
=
teamEntityList
.
indexOf
(
teamEntity
);
teamEntity
.
setRequestStatus
(
status
);
teamEntity
.
setLastModifiedBy
(
loggedInUser
);
teamEntity
.
setLastModifiedDate
(
new
Date
());
teamEntityList
.
set
(
index
,
teamEntity
);
}
else
{
throw
new
InnovationServiceException
(
USER_NOT_AUTHORIZED
,
"Current user not authorized to perform this action on this team request."
);
}
ideaEntity
.
setTeam
(
teamEntityList
);
pgIdeaRepository
.
save
(
ideaEntity
);
res
.
setStatus
(
new
StatusDetails
(
StatusDetails
.
SUCCESS
));
return
res
;
}
/**
* @param teamEntityList
* @return
* @throws InnovationServiceException
*/
private
Boolean
access
(
List
<
PgTeamEntity
>
teamEntityList
)
throws
InnovationServiceException
{
PgTeamEntity
admin
=
teamEntityList
.
stream
().
filter
(
p
->
p
.
getUserId
().
equals
(
userUtil
.
getLoggedInUser
())).
findAny
()
.
orElseThrow
(()
->
new
InnovationServiceException
(
USER_NOT_AUTHORIZED
,
USER_NOT_AUTHORIZED_MSG
));
return
admin
.
getRole
().
equals
(
RoleTypeEnum
.
INNOVATOR
)
||
admin
.
getRole
().
equals
(
RoleTypeEnum
.
CO_INNOVATOR
);
}
/**
* @param ideaEntity
* @throws InnovationServiceException
*/
private
void
validateUserAccessToIdea
(
PgIdeaEntity
ideaEntity
)
throws
InnovationServiceException
{
List
<
PgTeamEntity
>
teamEntityList
=
ideaEntity
.
getTeam
();
if
(
teamEntityList
!=
null
)
teamEntityList
.
stream
().
filter
(
p
->
p
.
getUserId
().
equals
(
userUtil
.
getLoggedInUser
())
&&
(
p
.
getRequestStatus
()
==
null
||
p
.
getRequestStatus
().
equals
(
TeamMemberRequestStatusEnum
.
ACCEPTED
)))
.
findAny
().
orElseThrow
(()
->
new
InnovationServiceException
(
USER_NOT_AUTHORIZED
,
USER_NOT_AUTHORIZED_MSG
));
else
throw
new
InnovationServiceException
(
USER_NOT_AUTHORIZED
,
USER_NOT_AUTHORIZED_MSG
);
}
private
void
isIdeaLocked
(
PgIdeaEntity
ideaEntity
)
throws
InnovationServiceException
{
if
(
ideaEntity
.
getLocked
())
throw
new
InnovationServiceException
(
"idea.locked"
,
"Idea Locked."
);
}
}
src/main/java/com/altimetrik/playground/innovation/util/MongoUtils.java
View file @
cfba9e81
...
...
@@ -9,7 +9,6 @@
package
com
.
altimetrik
.
playground
.
innovation
.
util
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -36,7 +35,7 @@ public class MongoUtils {
if
(
obj
==
null
)
{
return
null
;
}
List
<
String
>
itemIds
=
collectionGetter
.
apply
(
obj
).
stream
().
map
(
N:
:
get
Gui
d
).
collect
(
Collectors
.
toList
());
List
<
String
>
itemIds
=
collectionGetter
.
apply
(
obj
).
stream
().
map
(
N:
:
get
I
d
).
collect
(
Collectors
.
toList
());
int
index
=
itemIds
.
indexOf
(
innerId
);
if
(
index
==
-
1
)
{
return
null
;
...
...
@@ -52,7 +51,7 @@ public class MongoUtils {
return
collectionGetter
.
apply
(
obj2
).
get
(
0
);
}
public
void
removeNestedDocument
(
UUID
outerId
,
UUID
innerId
,
String
collectionName
,
Class
<?>
outerClass
)
{
public
void
removeNestedDocument
(
String
outerId
,
String
innerId
,
String
collectionName
,
Class
<?>
outerClass
)
{
Update
update
=
new
Update
();
update
.
pull
(
collectionName
,
new
Query
(
Criteria
.
where
(
"_id"
).
is
(
innerId
)));
mongo
.
updateFirst
(
new
Query
(
Criteria
.
where
(
"_id"
).
is
(
outerId
)),
update
,
outerClass
);
...
...
src/main/java/com/altimetrik/playground/innovation/util/PlatformErrorConstant.java
View file @
cfba9e81
...
...
@@ -3,7 +3,7 @@ package com.altimetrik.playground.innovation.util;
public
final
class
PlatformErrorConstant
{
private
PlatformErrorConstant
()
{
//private constructor to avoid instantiation.
//
private constructor to avoid instantiation.
}
/**
...
...
src/main/java/com/altimetrik/playground/innovation/util/UserUtil.java
View file @
cfba9e81
package
com
.
altimetrik
.
playground
.
innovation
.
util
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
com.altimetrik.playground.innovation.bean.Principal
;
import
com.altimetrik.playground.innovation.bean.usermanagement.UserResponseBean
;
import
com.altimetrik.playground.innovation.exception.InnovationServiceException
;
import
lombok.extern.slf4j.Slf4j
;
/**
* The Class UserUtil.
*/
@Component
(
"userUtil"
)
@Slf4j
public
class
UserUtil
{
@Value
(
"${playground.serviceUrl}"
)
private
String
baseUrl
;
/**
* Gets the logged in user.
...
...
@@ -22,4 +38,37 @@ public class UserUtil {
Principal
principal
=
(
Principal
)
authentication
.
getPrincipal
();
return
principal
.
getUserId
();
}
public
UserResponseBean
getUserDetailsByEmail
(
String
email
)
throws
InnovationServiceException
{
try
{
String
umCall
=
baseUrl
+
"api/common/getDetailsByEmail/"
+
email
+
"/"
;
log
.
info
(
"FINAL URL : "
+
umCall
);
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
<>(
httpHeaders
);
ResponseEntity
<
UserResponseBean
>
obj
=
restTemplate
.
exchange
(
umCall
,
HttpMethod
.
GET
,
httpEntity
,
UserResponseBean
.
class
);
UserResponseBean
body
=
obj
.
getBody
();
if
(
body
.
getInfoDetails
()
==
null
)
throw
new
InnovationServiceException
(
"user.not.found"
,
"User details not found in userManagement service for email "
+
email
);
return
body
;
}
catch
(
Exception
e
)
{
log
.
error
(
"ERROR from user mgmt :: "
,
e
);
throw
new
InnovationServiceException
(
"user.service"
,
"Exception in getting user details for email "
+
email
);
}
}
public
void
isUserAnEmployee
(
String
userId
)
throws
InnovationServiceException
{
UserResponseBean
userDetailsByEmail
=
getUserDetailsByEmail
(
userId
);
AtomicBoolean
isEmployee
=
new
AtomicBoolean
(
false
);
userDetailsByEmail
.
getInfoDetails
().
getPgUserInfoMstr
().
getPgRoleUser
().
stream
().
forEach
(
role
->
{
if
(
role
.
getPgRolePrivilege
()
!=
null
&&
role
.
getPgRolePrivilege
().
getPgRoleMstr
()
!=
null
&&
"EMPLOYEE"
.
equalsIgnoreCase
(
role
.
getPgRolePrivilege
().
getPgRoleMstr
().
getRoleName
()))
{
isEmployee
.
set
(
true
);
}
});
if
(!
isEmployee
.
get
())
throw
new
InnovationServiceException
(
"not.employee"
,
"Team member is not an employee."
);
}
}
src/main/java/com/altimetrik/playground/innovation/webmvc/RolesInterceptor.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
package
com
.
altimetrik
.
playground
.
innovation
.
webmvc
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
com.altimetrik.playground.innovation.annotation.RolesAllowed
;
import
com.altimetrik.playground.innovation.exception.InvalidRoleInfoException
;
import
com.altimetrik.playground.innovation.properties.ErrorProperties
;
import
com.altimetrik.playground.innovation.repository.PgIdeaRepository
;
import
com.sun.jersey.core.util.ReaderWriter
;
import
lombok.extern.slf4j.Slf4j
;
/**
* This Filter will intercept the incoming requests for web services which are
* tagged with EnableRole annotation.
*
* @author skondapalli.
*/
@Slf4j
@Component
public
class
RolesInterceptor
extends
HandlerInterceptorAdapter
{
@Autowired
private
ErrorProperties
errorProperties
;
@Autowired
private
PgIdeaRepository
pgIdeaRepository
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
final
RequestWrapper
servletRequest
=
new
RequestWrapper
(
request
);
if
(
handler
instanceof
HandlerMethod
)
{
final
HandlerMethod
handlerMethod
=
(
HandlerMethod
)
handler
;
final
RolesAllowed
rolesAllowed
=
this
.
getRolesAllowedAnnotation
(
handlerMethod
);
final
String
payload
=
this
.
getRequestBody
(
servletRequest
);
switch
(
rolesAllowed
.
action
())
{
case
UPDATE_IDEA:
// final PgIdeaRequestBean pgIdeaRequest = new
// Gson().fromJson(payload, PgIdeaRequestBean.class);
// this.updateIdeaActionValidator(pgIdeaRequest,
// Arrays.asList(rolesAllowed.roles()));
break
;
case
UPDATE_IDEA_STATUS:
// final PgIdeaStatusRequestBean pgIdeaStatusRequest = new
// Gson().fromJson(payload, PgIdeaStatusRequestBean.class);
// this.updateIdeaStatusActionValidator(pgIdeaStatusRequest);
break
;
}
}
return
true
;
}
private
RolesAllowed
getRolesAllowedAnnotation
(
final
HandlerMethod
handlerMethod
)
throws
InvalidRoleInfoException
{
final
RolesAllowed
rolesAllowed
=
handlerMethod
.
getMethod
().
getAnnotation
(
RolesAllowed
.
class
);
if
(
rolesAllowed
==
null
)
{
throw
new
InvalidRoleInfoException
(
this
.
errorProperties
.
getInvalidRoleInfoErrorCode
(),
this
.
errorProperties
.
getInvalidRoleInfoErrorMessage
());
}
return
rolesAllowed
;
}
// private void updateIdeaActionValidator(final PgIdeaRequestBean
// pgIdeaRequest, final List<RoleTypeEnum> allowedRoles) throws
// AuthorizationException {
// // No id meaning not update so skip the role validation.
// if (pgIdeaRequest.getIdeaId() != 0) {
// final RoleTypeEnum userRole =
// this.pgIdeaRepository.findTeamMemberRoleByIdeaIdAndEmailId(pgIdeaRequest.getIdeaId(),
// pgIdeaRequest.getLoggedInUser());
// if (!allowedRoles.contains(userRole)) {
// throw new
// AuthorizationException(this.errorProperties.getAuthorizationErrorCode(),
// this.errorProperties.getAuthorizationErrorMessage());
// }
// }
// }
//
// private void updateIdeaStatusActionValidator(final
// PgIdeaStatusRequestBean pgIdeaStatusRequest) throws
// AuthorizationException, InnovationServiceException {
// final boolean isTeamMember =
// (this.pgIdeaRepository.findByIdeaIdAndTeamMemberEmailId(pgIdeaStatusRequest.getIdeaId(),
// pgIdeaStatusRequest.getLoggedInUser()) != null) ? true
// : false;
// if
// (UserTypeEnum.TEAM_MEMBER.getAllowedIdeaStatusTransitions().contains(pgIdeaStatusRequest.getIdeaStatus())
// && !isTeamMember) {
// throw new
// AuthorizationException(this.errorProperties.getOperationNotAllowedErrorCode(),
// this.errorProperties.getOperationNotAllowedErrorMessage());
// }
// final boolean isReviewer =
// (this.pgIdeaRepository.findByIdeaIdAndIdeaReviewerEmailId(pgIdeaStatusRequest.getIdeaId(),
// pgIdeaStatusRequest.getLoggedInUser()) != null) ? true
// : false;
// if
// (UserTypeEnum.REVIEWER.getAllowedIdeaStatusTransitions().contains(pgIdeaStatusRequest.getIdeaStatus())
// && (!isReviewer || isTeamMember)) {
// throw new
// AuthorizationException(this.errorProperties.getOperationNotAllowedErrorCode(),
// this.errorProperties.getOperationNotAllowedErrorMessage());
// }
// }
private
String
getRequestBody
(
final
RequestWrapper
request
)
throws
IOException
{
final
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
final
InputStream
inputStream
=
request
.
getInputStream
();
final
StringBuilder
entityStream
=
new
StringBuilder
();
try
{
ReaderWriter
.
writeTo
(
inputStream
,
byteArrayOutputStream
);
final
byte
[]
entityBytes
=
byteArrayOutputStream
.
toByteArray
();
if
(
entityBytes
.
length
>
0
)
{
entityStream
.
append
(
new
String
(
entityBytes
));
}
}
catch
(
final
Exception
exception
)
{
log
.
error
(
"Exception occurred while executing getRequestBody"
,
exception
);
}
finally
{
// TODO: handle finally clause
// open resources will be closed by default.
if
(
inputStream
!=
null
)
inputStream
.
close
();
}
return
entityStream
.
toString
();
}
}
src/main/resources/application.properties
0 → 100644
View file @
cfba9e81
# Name of the service
spring.application.name
=
playground-innovation
server.servlet.context-path
=
/innovation
playground.serviceUrl
=
https://#PLAYGROUNDSERVICEURL#/
playground.microservice-admin-host
=
10.101.102.56
# spring.main.allow-bean-definition-overriding=true
# Url where Admin Server is running
spring.boot.admin.client.url
=
http://${playground.microservice-admin-host}:50207
# Use 0 for random port, so there is no collision on port 8080
server.port
=
${PORT:8080}
# Expose all the Actuator endpoints
management.endpoints.web.exposure.include
=
*
# Show details in Health check section
management.endpoint.health.show-details
=
always
# If you don't set this, username 'user' will be used by default and a password will be auto-generated
# each time your app starts such password is visible in the console during app startup
spring.security.user.name
=
user
spring.security.user.password
=
user
# Provide username and password for Spring Boot Admin Server to connect to the client
spring.boot.admin.client.instance.metadata.user.name
=
user
spring.boot.admin.client.instance.metadata.user.password
=
user
# Credentials to authenticate with the Admin Server
spring.boot.admin.client.username
=
admin
spring.boot.admin.client.password
=
admin
# Zipkin and Sleuth config for tracing
spring.zipkin.base-url
=
http://${playground.microservice-admin-host}:9411/
spring.zipkin.sender.type
=
web
spring.sleuth.sampler.probability
=
1
# Consul configuration
spring.cloud.consul.host
=
${playground.microservice-admin-host}
spring.cloud.consul.port
=
8500
spring.cloud.consul.discovery.enabled
=
true
spring.cloud.consul.discovery.instance-id
=
${spring.application.name}:${spring.application.instance_id:${random.value}}
spring.cloud.consul.discovery.health-check-path
=
${server.servlet.context-path}/health-check
spring.cloud.consul.discovery.health-check-interval
=
60s
# RabbitMQ configuration
spring.rabbitmq.host
=
${playground.microservice-admin-host}
spring.rabbitmq.port
=
5672
spring.rabbitmq.username
=
admin
spring.rabbitmq.password
=
admin
spring.rabbitmq.virtual-host
=
/
# disable togglz security - only for demonstration purposes
togglz.enabled
=
true
togglz.console.enabled
=
true
togglz.console.secured
=
false
togglz.console.use-management-port
=
false
logging.level.org.springframework.data.mongodb.core
=
DEBUG
src/main/resources/banner.txt
View file @
cfba9e81
,------. ,--. ,--.
| .--. ' | | ,--,--. ,--. ,--. ,---. ,--.--. ,---. ,--.,--. ,--,--, ,-| |
| '--' | | | ' ,-. | \ ' / | .-. | | .--' | .-. | | || | | \ ' .-. |
| | --' | | \ '-' | \ ' ' '-' ' | | ' '-' ' ' '' ' | || | \ `-' |
`--' `--' `--`--' .-' / .`- / `--' `---' `----' `--''--' `---'
____ ______ ____ __ _
/ __ \ / ____/ / _/ ____ ____ ____ _ __ ____ _ / /_ (_) ____ ____
/ /_/ / / / __ ______ / / / __ \ / __ \ / __ \| | / / / __ `/ / __/ / / / __ \ / __ \
/ ____/ / /_/ / /_____/ _/ / / / / / / / / // /_/ /| |/ / / /_/ / / /_ / / / /_/ / / / / /
/_/ \____/ /___/ /_/ /_/ /_/ /_/ \____/ |___/ \__,_/ \__/ /_/ \____/ /_/ /_/
/*******************************************************************************
...
...
src/test/java/com/altimetrik/playground/innovation/controller/PgIdeaCategoryContollerTests.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
/*package com.altimetrik.playground.innovation.controller;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.altimetrik.playground.innovation.bean.PgIdeaCategoryRequestBean;
import com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponseBean;
import com.altimetrik.playground.innovation.bean.PgUserRequestBean;
import com.altimetrik.playground.innovation.bean.PgUserResponseBean;
import com.altimetrik.playground.innovation.bean.ResponseDetailsBean;
import com.altimetrik.playground.innovation.constants.RequestStatusEnum;
import com.altimetrik.playground.innovation.constants.RoleTypeEnum;
import com.altimetrik.playground.innovation.service.impl.PgIdeaCategoryServiceImpl;
import com.altimetrik.playground.innovation.util.ResponseBuilderUtil;
import com.google.gson.Gson;
@SpringBootTest
@RunWith(SpringRunner.class)
public class PgIdeaCategoryContollerTests {
@Autowired
private Gson gson;
private MockMvc mockMvc;
@Spy
private ResponseBuilderUtil responseBuilderUtil;
@Mock
private PgIdeaCategoryServiceImpl pgIdeaCategoryService;
@InjectMocks
private PgIdeaCategoryContoller pgIdeaCategoryContoller;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
this.mockMvc = MockMvcBuilders.standaloneSetup(this.pgIdeaCategoryContoller).build();
}
private PgIdeaCategoryRequestBean mockPgIdeaCategoryRequest() {
return new PgIdeaCategoryRequestBean(Long.valueOf(1), "Category", this.mockPgIdeaReviewerRequest(RoleTypeEnum.REVIEWER), "admin@mail.com");
}
private List<PgUserRequestBean> mockPgIdeaReviewerRequest(RoleTypeEnum roleType) {
final List<PgUserRequestBean> pgIdeaReviewers = new ArrayList<PgUserRequestBean>();
pgIdeaReviewers.add(this.mockPgUserRequest(roleType));
return pgIdeaReviewers;
}
private PgUserRequestBean mockPgUserRequest(RoleTypeEnum roleType) {
PgUserRequestBean pgUserRequest = null;
switch (roleType) {
case REVIEWER:
pgUserRequest = new PgUserRequestBean("admin@mail.com", "Reviewer", "reviewer@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserRequest;
}
private PgIdeaCategoryResponseBean mockPgIdeaCategoryResponse() {
final Set<PgUserResponseBean> pgIdeaReviewerResponses = new HashSet<PgUserResponseBean>();
pgIdeaReviewerResponses.add(this.mockPgUserResponse(RoleTypeEnum.REVIEWER));
return new PgIdeaCategoryResponseBean(1, "Category", pgIdeaReviewerResponses);
}
private PgUserResponseBean mockPgUserResponse(RoleTypeEnum roleType) {
PgUserResponseBean pgUserResponse = null;
switch (roleType) {
case REVIEWER:
pgUserResponse = new PgUserResponseBean("Reviewer", "reviewer@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserResponse;
}
@Test
public void saveCategoryTest() throws Exception {
final String expectedResponse = this.gson.toJson(new ResponseDetailsBean(RequestStatusEnum.SUCCESS, true, null));
Mockito.when(this.pgIdeaCategoryService.saveCategory(Mockito.any())).thenReturn(true);
MockHttpServletResponse response = mockMvc.perform(MockMvcRequestBuilders.post("/v1/category").accept(MediaType.APPLICATION_JSON)
.content(this.gson.toJson(this.mockPgIdeaCategoryRequest())).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse();
JSONAssert.assertEquals(expectedResponse, response.getContentAsString(), true);
}
@Test
public void getAllCategoriesTest() throws Exception {
final List<PgIdeaCategoryResponseBean> pgIdeaCategoryResponses = new ArrayList<PgIdeaCategoryResponseBean>();
pgIdeaCategoryResponses.add(this.mockPgIdeaCategoryResponse());
final String expectedResponse = this.gson.toJson(new ResponseDetailsBean(RequestStatusEnum.SUCCESS, pgIdeaCategoryResponses, null));
Mockito.when(this.pgIdeaCategoryService.findAllCategories()).thenReturn(pgIdeaCategoryResponses);
MockHttpServletResponse response = mockMvc
.perform(MockMvcRequestBuilders.get("/v1/category/list").accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse();
JSONAssert.assertEquals(expectedResponse, response.getContentAsString(), true);
}
}
*/
src/test/java/com/altimetrik/playground/innovation/controller/PgIdeaContollerTests.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
/*package com.altimetrik.playground.innovation.controller;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponseBean;
import com.altimetrik.playground.innovation.bean.PgIdeaCollateralRequestBean;
import com.altimetrik.playground.innovation.bean.PgIdeaCollateralResponseBean;
import com.altimetrik.playground.innovation.bean.PgIdeaRequestBean;
import com.altimetrik.playground.innovation.bean.PgIdeaResponseBean;
import com.altimetrik.playground.innovation.bean.PgIdeaStatusRequestBean;
import com.altimetrik.playground.innovation.bean.PgUserRequestBean;
import com.altimetrik.playground.innovation.bean.PgUserResponseBean;
import com.altimetrik.playground.innovation.bean.ResponseDetailsBean;
import com.altimetrik.playground.innovation.constants.ArtifactModeEnum;
import com.altimetrik.playground.innovation.constants.ArtifactTypeEnum;
import com.altimetrik.playground.innovation.constants.IdeaStatusEnum;
import com.altimetrik.playground.innovation.constants.RequestStatusEnum;
import com.altimetrik.playground.innovation.constants.RoleTypeEnum;
import com.altimetrik.playground.innovation.constants.UserTypeEnum;
import com.altimetrik.playground.innovation.service.impl.PgIdeaServiceImpl;
import com.altimetrik.playground.innovation.util.ResponseBuilderUtil;
import com.google.gson.Gson;
@SpringBootTest
@RunWith(SpringRunner.class)
public class PgIdeaContollerTests {
@Autowired
private Gson gson;
private MockMvc mockMvc;
@Spy
private ResponseBuilderUtil responseBuilderUtil;
@Mock
private PgIdeaServiceImpl pgIdeaService;
@InjectMocks
private PgIdeaContoller pgIdeaContoller;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
this.mockMvc = MockMvcBuilders.standaloneSetup(this.pgIdeaContoller).build();
}
private PgIdeaRequestBean mockPgIdeaRequest() {
return new PgIdeaRequestBean("Idea", true, "Idea", true, "Idea", Long.valueOf(1), IdeaStatusEnum.DRAFTED, this.mockPgIdeaTeamMemberRequest(RoleTypeEnum.INNOVATOR),
this.mockPgIdeaCollateralRequest(), "admin@mail.com");
}
private Set<PgUserRequestBean> mockPgIdeaTeamMemberRequest(RoleTypeEnum roleType) {
final Set<PgUserRequestBean> pgIdeaTeamMembers = new HashSet<PgUserRequestBean>();
pgIdeaTeamMembers.add(this.mockPgUserRequest(roleType));
return pgIdeaTeamMembers;
}
private Set<PgIdeaCollateralRequestBean> mockPgIdeaCollateralRequest() {
final Set<PgIdeaCollateralRequestBean> pgIdeaCollaterals = new HashSet<PgIdeaCollateralRequestBean>();
pgIdeaCollaterals.add(new PgIdeaCollateralRequestBean("link", ArtifactTypeEnum.LINK, ArtifactModeEnum.IDEA));
return pgIdeaCollaterals;
}
private PgUserRequestBean mockPgUserRequest(RoleTypeEnum roleType) {
PgUserRequestBean pgUserRequest = null;
switch (roleType) {
case INNOVATOR:
pgUserRequest = new PgUserRequestBean("innovator@mail.com", "Innovator", "innovator@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserRequest;
}
private List<PgIdeaResponseBean> mockPgIdeaResponse() {
List<PgIdeaResponseBean> pgIdeaResponses = new ArrayList<PgIdeaResponseBean>();
pgIdeaResponses.add(new PgIdeaResponseBean(Long.valueOf(1), "Idea", true, "Idea", true, "Idea", IdeaStatusEnum.DRAFTED, this.mockPgIdeaCategoryResponse(),
this.mockPgIdeaTeamMemberResponse(RoleTypeEnum.INNOVATOR), this.mockPgIdeaCollateralResponse()));
return pgIdeaResponses;
}
private PgIdeaCategoryResponseBean mockPgIdeaCategoryResponse() {
final Set<PgUserResponseBean> pgIdeaReviewerResponses = new HashSet<PgUserResponseBean>();
pgIdeaReviewerResponses.add(this.mockPgUserResponse(RoleTypeEnum.REVIEWER));
return new PgIdeaCategoryResponseBean(1, "Category", pgIdeaReviewerResponses);
}
private Set<PgUserResponseBean> mockPgIdeaTeamMemberResponse(RoleTypeEnum roleType) {
final Set<PgUserResponseBean> pgIdeaTeamMemberResponses = new HashSet<PgUserResponseBean>();
pgIdeaTeamMemberResponses.add(this.mockPgUserResponse(roleType));
return pgIdeaTeamMemberResponses;
}
private Set<PgIdeaCollateralResponseBean> mockPgIdeaCollateralResponse() {
final Set<PgIdeaCollateralResponseBean> pgIdeaCollateralResponses = new HashSet<PgIdeaCollateralResponseBean>();
pgIdeaCollateralResponses.add(new PgIdeaCollateralResponseBean(Long.valueOf(1), "link", ArtifactTypeEnum.LINK, ArtifactModeEnum.IDEA));
return pgIdeaCollateralResponses;
}
private PgUserResponseBean mockPgUserResponse(RoleTypeEnum roleType) {
PgUserResponseBean pgUserResponse = null;
switch (roleType) {
case REVIEWER:
pgUserResponse = new PgUserResponseBean("Reviewer", "reviewer@mail.com", Long.valueOf(1), roleType);
break;
case INNOVATOR:
pgUserResponse = new PgUserResponseBean("Innovator", "innovator@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserResponse;
}
@Test
public void saveIdeaTest() throws Exception {
final String expectedResponse = this.gson.toJson(new ResponseDetailsBean(RequestStatusEnum.SUCCESS, true, null));
Mockito.when(this.pgIdeaService.saveIdea(Mockito.any())).thenReturn(true);
MockHttpServletResponse response = mockMvc.perform(MockMvcRequestBuilders.post("/v1/role/idea").accept(MediaType.APPLICATION_JSON)
.content(new Gson().toJson(this.mockPgIdeaRequest())).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse();
JSONAssert.assertEquals(expectedResponse, response.getContentAsString(), true);
}
@Test
public void getAllIdeasTest() throws Exception {
final String expectedResponse = this.gson.toJson(new ResponseDetailsBean(RequestStatusEnum.SUCCESS, this.mockPgIdeaResponse(), null));
Mockito.when(this.pgIdeaService.findAllIdeas(Mockito.any())).thenReturn(this.mockPgIdeaResponse());
MockHttpServletResponse response = mockMvc
.perform(MockMvcRequestBuilders.get("/v1/idea/list/DRAFTED").accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse();
JSONAssert.assertEquals(expectedResponse, response.getContentAsString(), true);
}
@Test
public void getAllUserIdeasTest() throws Exception {
final String expectedResponse = this.gson.toJson(new ResponseDetailsBean(RequestStatusEnum.SUCCESS, this.mockPgIdeaResponse(), null));
Mockito.when(this.pgIdeaService.findAllIdeas(UserTypeEnum.TEAM_MEMBER, Long.valueOf(1), IdeaStatusEnum.ALL)).thenReturn(this.mockPgIdeaResponse());
MockHttpServletResponse response = mockMvc
.perform(MockMvcRequestBuilders.get("/v1/idea/list/TEAM_MEMBER/1/ALL").accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andReturn()
.getResponse();
JSONAssert.assertEquals(expectedResponse, response.getContentAsString(), true);
}
@Test
public void updateIdeaStatusTest() throws Exception {
final PgIdeaStatusRequestBean pgIdeaStatusRequest = new PgIdeaStatusRequestBean(Long.valueOf(1), IdeaStatusEnum.SUBMITTED);
final String expectedResponse = this.gson.toJson(new ResponseDetailsBean(RequestStatusEnum.SUCCESS, true, null));
Mockito.when(this.pgIdeaService.updateIdeaStatus(Mockito.any())).thenReturn(true);
MockHttpServletResponse response = mockMvc.perform(MockMvcRequestBuilders.post("/v1/role/idea/status").accept(MediaType.APPLICATION_JSON)
.content(new Gson().toJson(pgIdeaStatusRequest)).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse();
JSONAssert.assertEquals(expectedResponse, response.getContentAsString(), true);
}
}
*/
src/test/java/com/altimetrik/playground/innovation/service/impl/PgIdeaCategoryServiceImplTests.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
/*package com.altimetrik.playground.innovation.service.impl;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.altimetrik.playground.innovation.bean.PgIdeaCategoryRequestBean;
import com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponseBean;
import com.altimetrik.playground.innovation.bean.PgUserRequestBean;
import com.altimetrik.playground.innovation.bean.PgUserResponseBean;
import com.altimetrik.playground.innovation.constants.RoleTypeEnum;
import com.altimetrik.playground.innovation.entity.PgIdeaCategoryEntity;
import com.altimetrik.playground.innovation.entity.PgIdeaReviewerEntity;
import com.altimetrik.playground.innovation.entity.PgIdeaReviewerId;
import com.altimetrik.playground.innovation.entity.PgUserEntity;
import com.altimetrik.playground.innovation.repository.PgIdeaCategoryRepository;
import com.google.gson.Gson;
@SpringBootTest
@RunWith(SpringRunner.class)
public class PgIdeaCategoryServiceImplTests {
@Autowired
private Gson gson;
@InjectMocks
private PgIdeaCategoryServiceImpl pgIdeaCategoryService;
@Mock
private PgIdeaCategoryRepository pgIdeaCategoryRepository;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}
private PgIdeaCategoryRequestBean mockPgIdeaCategoryRequest() {
return new PgIdeaCategoryRequestBean(Long.valueOf(1), "Category", this.mockPgIdeaReviewerRequest(RoleTypeEnum.REVIEWER), "admin@mail.com");
}
private List<PgUserRequestBean> mockPgIdeaReviewerRequest(RoleTypeEnum roleType) {
final List<PgUserRequestBean> pgIdeaReviewers = new ArrayList<PgUserRequestBean>();
pgIdeaReviewers.add(this.mockPgUserRequest(roleType));
return pgIdeaReviewers;
}
private PgUserRequestBean mockPgUserRequest(RoleTypeEnum roleType) {
PgUserRequestBean pgUserRequest = null;
switch (roleType) {
case REVIEWER:
pgUserRequest = new PgUserRequestBean("admin@mail.com", "Reviewer", "reviewer@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserRequest;
}
private PgIdeaCategoryEntity mockPgIdeaCategory() {
final Set<PgIdeaReviewerEntity> pgIdeaReviewers = new HashSet<PgIdeaReviewerEntity>();
pgIdeaReviewers.add(this.mockPgIdeaReviewer());
return new PgIdeaCategoryEntity("admin@mail.com", Long.valueOf(1), "Category", pgIdeaReviewers);
}
private PgIdeaReviewerEntity mockPgIdeaReviewer() {
return new PgIdeaReviewerEntity("admin@mail.com", new PgIdeaReviewerId(Long.valueOf(1), Long.valueOf(1)), this.mockPgUser(RoleTypeEnum.REVIEWER));
}
private PgUserEntity mockPgUser(RoleTypeEnum roleType) {
PgUserEntity pgUser = null;
switch (roleType) {
case REVIEWER:
pgUser = new PgUserEntity("admin@mail.com", Long.valueOf(1), "Reviewer", "reviewer@mail.com");
break;
}
return pgUser;
}
private PgIdeaCategoryResponseBean mockPgIdeaCategoryResponse() {
final Set<PgUserResponseBean> pgIdeaReviewerResponses = new HashSet<PgUserResponseBean>();
pgIdeaReviewerResponses.add(this.mockPgUserResponse(RoleTypeEnum.REVIEWER));
return new PgIdeaCategoryResponseBean(1, "Category", pgIdeaReviewerResponses);
}
private PgUserResponseBean mockPgUserResponse(RoleTypeEnum roleType) {
PgUserResponseBean pgUserResponse = null;
switch (roleType) {
case REVIEWER:
pgUserResponse = new PgUserResponseBean("Reviewer", "reviewer@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserResponse;
}
@Test
public void createCategoryTest() throws Exception {
Mockito.when(this.pgIdeaCategoryRepository.findByIdeaCategoryName(Mockito.any())).thenReturn(null);
Mockito.when(this.pgIdeaCategoryRepository.save(Mockito.any())).thenReturn(this.mockPgIdeaCategory());
JSONAssert.assertEquals(String.valueOf(true), String.valueOf(this.pgIdeaCategoryService.saveCategory(this.mockPgIdeaCategoryRequest())), true);
}
@Test
public void updateCategoryTest() throws Exception {
Mockito.when(this.pgIdeaCategoryRepository.findByIdeaCategoryName(Mockito.any())).thenReturn(this.mockPgIdeaCategory());
Mockito.when(this.pgIdeaCategoryRepository.save(Mockito.any())).thenReturn(this.mockPgIdeaCategory());
JSONAssert.assertEquals(String.valueOf(true), String.valueOf(this.pgIdeaCategoryService.saveCategory(this.mockPgIdeaCategoryRequest())), true);
}
@Test
public void findAllCategoriesTest() throws Exception {
final List<PgIdeaCategoryEntity> pgIdeaCategories = new ArrayList<PgIdeaCategoryEntity>();
pgIdeaCategories.add(this.mockPgIdeaCategory());
List<PgIdeaCategoryResponseBean> pgIdeaCategoryResponses = new ArrayList<PgIdeaCategoryResponseBean>();
pgIdeaCategoryResponses.add(this.mockPgIdeaCategoryResponse());
Mockito.when(this.pgIdeaCategoryRepository.findAll()).thenReturn(pgIdeaCategories);
JSONAssert.assertEquals(this.gson.toJson(pgIdeaCategoryResponses), this.gson.toJson(this.pgIdeaCategoryService.findAllCategories()), true);
}
@Test
public void findAllCategoriesNullCheckTest() throws Exception {
Mockito.when(this.pgIdeaCategoryRepository.findAll()).thenReturn(null);
JSONAssert.assertEquals(this.gson.toJson(new ArrayList<PgIdeaCategoryResponseBean>()), this.gson.toJson(this.pgIdeaCategoryService.findAllCategories()), true);
}
}
*/
src/test/java/com/altimetrik/playground/innovation/service/impl/PgIdeaServiceImplTests.java
0 → 100644
View file @
cfba9e81
/*******************************************************************************
* Copyright (C) Altimetrik 2018. All rights reserved.
*
* This software is the confidential and proprietary information
* of Altimetrik. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms and conditions
* entered into with Altimetrik.
******************************************************************************/
/*package com.altimetrik.playground.innovation.service.impl;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.altimetrik.playground.innovation.bean.PgIdeaCategoryResponseBean;
import com.altimetrik.playground.innovation.bean.PgIdeaCollateralRequestBean;
import com.altimetrik.playground.innovation.bean.PgIdeaCollateralResponseBean;
import com.altimetrik.playground.innovation.bean.PgIdeaRequestBean;
import com.altimetrik.playground.innovation.bean.PgIdeaResponseBean;
import com.altimetrik.playground.innovation.bean.PgIdeaStatusRequestBean;
import com.altimetrik.playground.innovation.bean.PgUserRequestBean;
import com.altimetrik.playground.innovation.bean.PgUserResponseBean;
import com.altimetrik.playground.innovation.constants.ArtifactModeEnum;
import com.altimetrik.playground.innovation.constants.ArtifactTypeEnum;
import com.altimetrik.playground.innovation.constants.IdeaStatusEnum;
import com.altimetrik.playground.innovation.constants.RoleTypeEnum;
import com.altimetrik.playground.innovation.constants.UserTypeEnum;
import com.altimetrik.playground.innovation.entity.PgIdeaCategoryEntity;
import com.altimetrik.playground.innovation.entity.PgIdeaArtifactEntity;
import com.altimetrik.playground.innovation.entity.PgIdeaEntity;
import com.altimetrik.playground.innovation.entity.PgIdeaReviewerEntity;
import com.altimetrik.playground.innovation.entity.PgIdeaReviewerId;
import com.altimetrik.playground.innovation.entity.PgIdeaTeamMemberEntity;
import com.altimetrik.playground.innovation.entity.PgIdeaTeamMemberId;
import com.altimetrik.playground.innovation.entity.PgUserEntity;
import com.altimetrik.playground.innovation.exception.AuthorizationException;
import com.altimetrik.playground.innovation.exception.InnovationServiceException;
import com.altimetrik.playground.innovation.exception.InvalidStatusTransitionException;
import com.altimetrik.playground.innovation.properties.ErrorProperties;
import com.altimetrik.playground.innovation.repository.PgIdeaCategoryRepository;
import com.altimetrik.playground.innovation.repository.PgIdeaRepository;
import com.google.gson.Gson;
@SpringBootTest
@RunWith(SpringRunner.class)
public class PgIdeaServiceImplTests {
@Autowired
private Gson gson;
@Spy
private ErrorProperties errorProperties;
@InjectMocks
private PgIdeaServiceImpl pgIdeaService;
@Mock
private PgIdeaRepository pgIdeaRepository;
@Mock
private PgIdeaCategoryRepository pgIdeaCategoryRepository;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}
private PgIdeaEntity mockPgIdea() {
return new PgIdeaEntity("innovator@mail.com", Long.valueOf(1), "Idea", "Idea", "Idea", true, true, IdeaStatusEnum.DRAFTED, "reviewer@mail.com", this.mockPgIdeaCategory(),
this.mockPgIdeaTeamMember(RoleTypeEnum.INNOVATOR), this.mockPgIdeaCollateral());
}
private PgIdeaCategoryEntity mockPgIdeaCategory() {
final Set<PgIdeaReviewerEntity> pgIdeaReviewers = new HashSet<PgIdeaReviewerEntity>();
pgIdeaReviewers.add(this.mockPgIdeaReviewer());
return new PgIdeaCategoryEntity("admin@mail.com", Long.valueOf(1), "Category", pgIdeaReviewers);
}
private Set<PgIdeaTeamMemberEntity> mockPgIdeaTeamMember(RoleTypeEnum roleType) {
final Set<PgIdeaTeamMemberEntity> pgIdeaTeamMembers = new HashSet<PgIdeaTeamMemberEntity>();
pgIdeaTeamMembers.add(new PgIdeaTeamMemberEntity("innovator@mail.com", new PgIdeaTeamMemberId(Long.valueOf(1), Long.valueOf(1)), RoleTypeEnum.INNOVATOR,
this.mockPgUser(RoleTypeEnum.INNOVATOR)));
return pgIdeaTeamMembers;
}
private Set<PgIdeaArtifactEntity> mockPgIdeaCollateral() {
final Set<PgIdeaArtifactEntity> pgIdeaCollaterals = new HashSet<PgIdeaArtifactEntity>();
pgIdeaCollaterals.add(new PgIdeaArtifactEntity("innovator@mail.com", Long.valueOf(1), "link", ArtifactTypeEnum.LINK, ArtifactModeEnum.IDEA));
return pgIdeaCollaterals;
}
private PgIdeaReviewerEntity mockPgIdeaReviewer() {
return new PgIdeaReviewerEntity("admin@mail.com", new PgIdeaReviewerId(Long.valueOf(1), Long.valueOf(1)), this.mockPgUser(RoleTypeEnum.REVIEWER));
}
private PgUserEntity mockPgUser(RoleTypeEnum roleType) {
PgUserEntity pgUser = null;
switch (roleType) {
case REVIEWER:
pgUser = new PgUserEntity("admin@mail.com", Long.valueOf(1), "Reviewer", "reviewer@mail.com");
break;
case INNOVATOR:
pgUser = new PgUserEntity("innovator@mail.com", Long.valueOf(1), "Innovator", "innovator@mail.com");
break;
}
return pgUser;
}
private PgIdeaRequestBean mockPgIdeaRequest() {
return new PgIdeaRequestBean("Idea", true, "Idea", true, "Idea", Long.valueOf(1), IdeaStatusEnum.DRAFTED, this.mockPgIdeaTeamMemberRequest(RoleTypeEnum.INNOVATOR),
this.mockPgIdeaCollateralRequest(), "admin@mail.com");
}
private Set<PgUserRequestBean> mockPgIdeaTeamMemberRequest(RoleTypeEnum roleType) {
final Set<PgUserRequestBean> pgIdeaTeamMembers = new HashSet<PgUserRequestBean>();
pgIdeaTeamMembers.add(this.mockPgUserRequest(roleType));
return pgIdeaTeamMembers;
}
private Set<PgIdeaCollateralRequestBean> mockPgIdeaCollateralRequest() {
final Set<PgIdeaCollateralRequestBean> pgIdeaCollaterals = new HashSet<PgIdeaCollateralRequestBean>();
pgIdeaCollaterals.add(new PgIdeaCollateralRequestBean("link", ArtifactTypeEnum.LINK, ArtifactModeEnum.IDEA));
return pgIdeaCollaterals;
}
private PgUserRequestBean mockPgUserRequest(RoleTypeEnum roleType) {
PgUserRequestBean pgUserRequest = null;
switch (roleType) {
case INNOVATOR:
pgUserRequest = new PgUserRequestBean("innovator@mail.com", "Innovator", "innovator@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserRequest;
}
private List<PgIdeaResponseBean> mockPgIdeaResponse() {
List<PgIdeaResponseBean> pgIdeaResponses = new ArrayList<PgIdeaResponseBean>();
pgIdeaResponses.add(new PgIdeaResponseBean(Long.valueOf(1), "Idea", true, "Idea", true, "Idea", IdeaStatusEnum.DRAFTED, this.mockPgIdeaCategoryResponse(),
this.mockPgIdeaTeamMemberResponse(RoleTypeEnum.INNOVATOR), this.mockPgIdeaCollateralResponse()));
return pgIdeaResponses;
}
private PgIdeaCategoryResponseBean mockPgIdeaCategoryResponse() {
final Set<PgUserResponseBean> pgIdeaReviewerResponses = new HashSet<PgUserResponseBean>();
pgIdeaReviewerResponses.add(this.mockPgUserResponse(RoleTypeEnum.REVIEWER));
return new PgIdeaCategoryResponseBean(1, "Category", pgIdeaReviewerResponses);
}
private Set<PgUserResponseBean> mockPgIdeaTeamMemberResponse(RoleTypeEnum roleType) {
final Set<PgUserResponseBean> pgIdeaTeamMemberResponses = new HashSet<PgUserResponseBean>();
pgIdeaTeamMemberResponses.add(this.mockPgUserResponse(roleType));
return pgIdeaTeamMemberResponses;
}
private Set<PgIdeaCollateralResponseBean> mockPgIdeaCollateralResponse() {
final Set<PgIdeaCollateralResponseBean> pgIdeaCollateralResponses = new HashSet<PgIdeaCollateralResponseBean>();
pgIdeaCollateralResponses.add(new PgIdeaCollateralResponseBean(Long.valueOf(1), "link", ArtifactTypeEnum.LINK, ArtifactModeEnum.IDEA));
return pgIdeaCollateralResponses;
}
private PgUserResponseBean mockPgUserResponse(RoleTypeEnum roleType) {
PgUserResponseBean pgUserResponse = null;
switch (roleType) {
case REVIEWER:
pgUserResponse = new PgUserResponseBean("Reviewer", "reviewer@mail.com", Long.valueOf(1), roleType);
break;
case INNOVATOR:
pgUserResponse = new PgUserResponseBean("Innovator", "innovator@mail.com", Long.valueOf(1), roleType);
break;
}
return pgUserResponse;
}
@Test
public void createIdeaTest() throws Exception {
Mockito.when(this.pgIdeaRepository.findByTitle(Mockito.any())).thenReturn(null);
Mockito.when(this.pgIdeaCategoryRepository.findByIdeaCategoryId(Mockito.any())).thenReturn(this.mockPgIdeaCategory());
Mockito.when(pgIdeaRepository.save(Mockito.any())).thenReturn(this.mockPgIdea());
JSONAssert.assertEquals(String.valueOf(true), String.valueOf(this.pgIdeaService.saveIdea(this.mockPgIdeaRequest())), true);
}
@Test
public void updateIdeaTest() throws Exception {
Mockito.when(this.pgIdeaRepository.findByTitle(Mockito.any())).thenReturn(this.mockPgIdea());
Mockito.when(this.pgIdeaCategoryRepository.findByIdeaCategoryId(Mockito.any())).thenReturn(this.mockPgIdeaCategory());
Mockito.when(this.pgIdeaRepository.save(Mockito.any())).thenReturn(this.mockPgIdea());
JSONAssert.assertEquals(String.valueOf(true), String.valueOf(this.pgIdeaService.saveIdea(this.mockPgIdeaRequest())), true);
}
@Test
public void populateCollateralsTest() throws Exception {
this.pgIdeaService.populateCollaterals(null, this.mockPgIdea(), "admin@mail.com");
}
@Test
public void populateIdeaCollateralResponsesTest() throws Exception {
this.pgIdeaService.populateIdeaCollateralResponses(null);
}
@Test
public void findAllIdeasTest() throws Exception {
final List<PgIdeaEntity> pgIdeas = new ArrayList<PgIdeaEntity>();
pgIdeas.add(this.mockPgIdea());
Mockito.when(this.pgIdeaRepository.findAll()).thenReturn(pgIdeas);
JSONAssert.assertEquals(this.gson.toJson(this.mockPgIdeaResponse()), this.gson.toJson(this.pgIdeaService.findAllIdeas(IdeaStatusEnum.ALL)), true);
}
@Test
public void findAllIdeasByIdeaStatusTest() throws Exception {
final List<PgIdeaEntity> pgIdeas = new ArrayList<PgIdeaEntity>();
pgIdeas.add(this.mockPgIdea());
Mockito.when(this.pgIdeaRepository.findByIdeaStatus(IdeaStatusEnum.DRAFTED)).thenReturn(pgIdeas);
JSONAssert.assertEquals(this.gson.toJson(this.mockPgIdeaResponse()), this.gson.toJson(this.pgIdeaService.findAllIdeas(IdeaStatusEnum.DRAFTED)), true);
}
@Test
public void findAllIdeasNullCheckTest() throws Exception {
Mockito.when(this.pgIdeaRepository.findAll()).thenReturn(null);
JSONAssert.assertEquals(this.gson.toJson(new ArrayList<PgIdeaResponseBean>()), this.gson.toJson(this.pgIdeaService.findAllIdeas(IdeaStatusEnum.ALL)), true);
}
@Test
public void findAllIdeasByUserTypeAndIdeaStatusTest() throws Exception {
final List<PgIdeaEntity> pgIdeas = new ArrayList<PgIdeaEntity>();
pgIdeas.add(this.mockPgIdea());
Mockito.when(this.pgIdeaService.findAllUserIdeas(UserTypeEnum.TEAM_MEMBER, Long.valueOf(1), IdeaStatusEnum.ALL)).thenReturn(pgIdeas);
JSONAssert.assertEquals(this.gson.toJson(this.mockPgIdeaResponse()),
this.gson.toJson(this.pgIdeaService.findAllIdeas(UserTypeEnum.TEAM_MEMBER, Long.valueOf(1), IdeaStatusEnum.ALL)), true);
}
@Test
public void findAllIdeasByUserTypeAndIdeaStatusNullCheckTest() throws Exception {
Mockito.when(this.pgIdeaService.findAllUserIdeas(UserTypeEnum.TEAM_MEMBER, Long.valueOf(1), IdeaStatusEnum.ALL)).thenReturn(null);
JSONAssert.assertEquals(this.gson.toJson(new ArrayList<PgIdeaResponseBean>()),
this.gson.toJson(this.pgIdeaService.findAllIdeas(UserTypeEnum.TEAM_MEMBER, Long.valueOf(1), IdeaStatusEnum.ALL)), true);
}
@Test
public void findAllReviewerIdeasTest() throws Exception {
final List<PgIdeaEntity> pgIdeas = new ArrayList<PgIdeaEntity>();
Mockito.when(this.pgIdeaRepository.findByIdeaReviewerId(Long.valueOf(1))).thenReturn(pgIdeas);
JSONAssert.assertEquals(this.gson.toJson(pgIdeas), this.gson.toJson(this.pgIdeaService.findAllUserIdeas(UserTypeEnum.REVIEWER, Long.valueOf(1), IdeaStatusEnum.ALL)), true);
}
@Test
public void findAllReviewerIdeasByIdeaStatusTest() throws Exception {
final List<PgIdeaEntity> pgIdeas = new ArrayList<PgIdeaEntity>();
Mockito.when(this.pgIdeaRepository.findByIdeaReviewerIdAndIdeaStatus(Long.valueOf(1), IdeaStatusEnum.SUBMITTED)).thenReturn(pgIdeas);
JSONAssert.assertEquals(this.gson.toJson(pgIdeas), this.gson.toJson(this.pgIdeaService.findAllUserIdeas(UserTypeEnum.REVIEWER, Long.valueOf(1), IdeaStatusEnum.SUBMITTED)),
true);
}
@Test
public void findAllTeamMemberIdeasTest() throws Exception {
final List<PgIdeaEntity> pgIdeas = new ArrayList<PgIdeaEntity>();
Mockito.when(this.pgIdeaRepository.findByIdeaTeamMemberId(Long.valueOf(1))).thenReturn(pgIdeas);
JSONAssert.assertEquals(this.gson.toJson(pgIdeas), this.gson.toJson(this.pgIdeaService.findAllUserIdeas(UserTypeEnum.TEAM_MEMBER, Long.valueOf(1), IdeaStatusEnum.ALL)),
true);
}
@Test
public void findAllTeamMemberIdeasByIdeaStatusTest() throws Exception {
final List<PgIdeaEntity> pgIdeas = new ArrayList<PgIdeaEntity>();
Mockito.when(this.pgIdeaRepository.findByIdeaTeamMemberIdAndIdeaStatus(Long.valueOf(1), IdeaStatusEnum.SUBMITTED)).thenReturn(pgIdeas);
JSONAssert.assertEquals(this.gson.toJson(pgIdeas),
this.gson.toJson(this.pgIdeaService.findAllUserIdeas(UserTypeEnum.TEAM_MEMBER, Long.valueOf(1), IdeaStatusEnum.SUBMITTED)), true);
}
@Test
public void updateIdeaStatusTest() throws Exception {
final PgIdeaStatusRequestBean pgIdeaStatusRequest = new PgIdeaStatusRequestBean(Long.valueOf(1), IdeaStatusEnum.SUBMITTED);
Mockito.when(this.pgIdeaRepository.findByIdeaId(Long.valueOf(1))).thenReturn(this.mockPgIdea());
Mockito.when(this.pgIdeaRepository.save(Mockito.any())).thenReturn(this.mockPgIdea());
JSONAssert.assertEquals(String.valueOf(true), String.valueOf(this.pgIdeaService.updateIdeaStatus(pgIdeaStatusRequest)), true);
}
@Test(expected = InvalidStatusTransitionException.class)
public void updateInvalidIdeaStatusTest() throws InvalidStatusTransitionException, InnovationServiceException, AuthorizationException {
final PgIdeaEntity pgIdea = this.mockPgIdea();
pgIdea.setIdeaStatus(IdeaStatusEnum.SUBMITTED);
final PgIdeaStatusRequestBean pgIdeaStatusRequest = new PgIdeaStatusRequestBean(Long.valueOf(1), IdeaStatusEnum.DRAFTED);
Mockito.when(this.pgIdeaRepository.findByIdeaId(Long.valueOf(1))).thenReturn(pgIdea);
this.pgIdeaService.updateIdeaStatus(pgIdeaStatusRequest);
}
}
*/
src/test/resources/application-test.properties
0 → 100644
View file @
cfba9e81
# Name of the service
spring.application.name
=
playground-innovation
server.servlet.context-path
=
/innovation
# spring.main.allow-bean-definition-overriding=true
# Url where Admin Server is running
spring.boot.admin.client.url
=
http://192.168.99.100:8090
# Use 0 for random port, so there is no collision on port 8080
server.port
=
${PORT:8092}
# Expose all the Actuator endpoints
management.endpoints.web.exposure.include
=
*
# Show details in Health check section
management.endpoint.health.show-details
=
always
# If you don't set this, username 'user' will be used by default and a password will be auto-generated
# each time your app starts such password is visible in the console during app startup
spring.security.user.name
=
user
spring.security.user.password
=
user
# Provide username and password for Spring Boot Admin Server to connect to the client
spring.boot.admin.client.instance.metadata.user.name
=
user
spring.boot.admin.client.instance.metadata.user.password
=
user
# Credentials to authenticate with the Admin Server
spring.boot.admin.client.username
=
admin
spring.boot.admin.client.password
=
admin
# Zipkin and Sleuth config for tracing
spring.zipkin.base-url
=
http://192.168.99.100:9411/
spring.zipkin.sender.type
=
web
spring.sleuth.sampler.probability
=
1
# Consul configuration
spring.cloud.consul.host
=
192.168.99.100
spring.cloud.consul.port
=
8500
spring.cloud.consul.discovery.enabled
=
true
spring.cloud.consul.discovery.instance-id
=
${spring.application.name}:${spring.application.instance_id:${random.value}}
spring.cloud.consul.discovery.health-check-path
=
${server.servlet.context-path}/health-check
spring.cloud.consul.discovery.health-check-interval
=
60s
# RabbitMQ configuration
spring.rabbitmq.host
=
192.168.99.100
spring.rabbitmq.port
=
5672
spring.rabbitmq.username
=
admin
spring.rabbitmq.password
=
admin
spring.rabbitmq.virtual-host
=
/
# disable togglz security - only for demonstration purposes
togglz.enabled
=
true
togglz.console.enabled
=
true
togglz.console.secured
=
false
togglz.console.use-management-port
=
false
src/test/resources/db-config.properties
View file @
cfba9e81
# Spring Boot automatically creates a JPA EntityManagerFactory using Hibernate
# but we need to override some defaults:
spring.jpa.show-sql
=
true
spring.jpa.open-in-view
=
true
# - Mongo DB Configurations
#spring.data.mongodb.field-naming-strategy= # Fully qualified name of the FieldNamingStrategy to use.
#spring.data.mongodb.grid-fs-database= # GridFS database name.
spring.data.mongodb.socketKeepAlive
=
true
spring.data.mongo.repositories.enabled
=
true
spring.data.mongodb.uri
=
mongodb://#DBUSR#:#DBPW#@#DBNODEPRIMARY#,#DBNODESECONDARY1#,#DBNODESECONDARY2#/#DBSCHEMA#?ssl=true&replicaSet=#DBREPLICASET#&authSource=admin&retryWrites=true&serverSelectionTimeoutMS=90000&connectTimeoutMS=60000&maxPoolSize=30
spring.jpa.database
=
H2
spring.jpa.show-sql
=
true
spring.jpa.open-in-view
=
true
spring.jpa.hibernate.ddl-auto
=
create-drop
spring.jpa.hibernate.naming_strategy
=
org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.hibernate.naming.physical-strategy
=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.format_sql
=
false
spring.jpa.properties.hibernate.dialect
=
org.hibernate.dialect.H2Dialect
spring.jpa.properties.javax.persistence.query.timeout
=
60000
spring.datasource.url
=
jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
spring.datasource.username
=
sa
spring.datasource.password
=
sa
spring.datasource.driver-class-name
=
org.h2.Driver
spring.datasource.testWhileIdle
=
true
spring.datasource.validationQuery
=
SELECT 1
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