Commit cfba9e81 authored by Vijay Sreenivas's avatar Vijay Sreenivas

Innovation Changes

parent 1b996ed5
Pipeline #3478 failed with stages
in 2 seconds
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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 "";
}
......@@ -11,7 +11,7 @@ package com.altimetrik.playground.innovation.bean;
import lombok.Data;
@Data
public class BaseRequestBean {
public class BaseRequestBean {
public BaseRequestBean() {
super();
......
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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;
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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();
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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();
}
}
......@@ -8,7 +8,6 @@
******************************************************************************/
package com.altimetrik.playground.innovation.bean;
import java.io.Serializable;
import lombok.Data;
......
......@@ -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;
......
/**
* 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() {
}
}
/**
* 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;
}
/**
* 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;
}
/**
* 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;
}
/**
* 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;
}
/**
* 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;
}
/**
* 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() {
}
}
/**
* 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;
}
/**
* 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;
}
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);
}
}
......@@ -19,7 +19,7 @@ import org.springframework.security.web.authentication.SavedRequestAwareAuthenti
*
* @author skondapalli
*/
//@Configuration
// @Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
......
......@@ -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/**");
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
/*******************************************************************************
* 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;
}
}
......@@ -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;
}
}
/*******************************************************************************
* 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));
}
}
/*******************************************************************************
* 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);
// }
}
......@@ -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 {
......
......@@ -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 lastModifiedDate;
@CreatedDate
private Date createdDate;
/** 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;
}
}
/**
* 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;
}
/**
* 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;
}
}
/**
* 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();
}
}
/**
* 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;
}
/**
* 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;
}
}
/**
* 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;
}
/*******************************************************************************
* 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);
}
}
/*******************************************************************************
* 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);
}
}
/*******************************************************************************
* 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);
}
}
......@@ -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();
......
/*******************************************************************************
* 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);
}
/*******************************************************************************
* 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);
}
......@@ -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) {
......
......@@ -63,6 +63,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
public AnonymousAuthenticationFilter gatewayAuthenticationFilter() {
return new GatewayAuthenticationFilter(strRegulus);
}
/**
* Gateway authentication token filter.
*
......
/*******************************************************************************
* 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;
}
/*******************************************************************************
* 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 {
}
/*******************************************************************************
* 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;
}
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;
}
}
/*******************************************************************************
* 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 {
}
......@@ -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::getGuid).collect(Collectors.toList());
List<String> itemIds = collectionGetter.apply(obj).stream().map(N::getId).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);
......
......@@ -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.
}
/**
......
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.");
}
}
/*******************************************************************************
* 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();
}
}
# 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
,------. ,--. ,--.
| .--. ' | | ,--,--. ,--. ,--. ,---. ,--.--. ,---. ,--.,--. ,--,--, ,-| |
| '--' | | | ' ,-. | \ ' / | .-. | | .--' | .-. | | || | | \ ' .-. |
| | --' | | \ '-' | \ ' ' '-' ' | | ' '-' ' ' '' ' | || | \ `-' |
`--' `--' `--`--' .-' / .`- / `--' `---' `----' `--''--' `---'
____ ______ ____ __ _
/ __ \ / ____/ / _/ ____ ____ ____ _ __ ____ _ / /_ (_) ____ ____
/ /_/ / / / __ ______ / / / __ \ / __ \ / __ \| | / / / __ `/ / __/ / / / __ \ / __ \
/ ____/ / /_/ / /_____/ _/ / / / / / / / / // /_/ /| |/ / / /_/ / / /_ / / / /_/ / / / / /
/_/ \____/ /___/ /_/ /_/ /_/ /_/ \____/ |___/ \__,_/ \__/ /_/ \____/ /_/ /_/
/*******************************************************************************
......
/*******************************************************************************
* 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);
}
}
*/
/*******************************************************************************
* 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);
}
}
*/
/*******************************************************************************
* 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);
}
}
*/
# 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
# 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment