Skip to content

Commit 49cad2a

Browse files
authored
Merge pull request #77 from TAMULib/sprint6-staging
sprint 6
2 parents 8501ffe + 32257c3 commit 49cad2a

34 files changed

Lines changed: 713 additions & 271 deletions

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>edu.tamu.weaver</groupId>
1313
<artifactId>webservice-parent</artifactId>
14-
<version>2.0.0-RC3-SNAPSHOT</version>
14+
<version>2.0.0-RC5-SNAPSHOT</version>
1515
</parent>
1616

1717
<properties>
@@ -36,25 +36,25 @@
3636
<dependency>
3737
<groupId>edu.tamu.weaver</groupId>
3838
<artifactId>auth</artifactId>
39-
<version>2.0.0-RC3-SNAPSHOT</version>
39+
<version>2.0.0-RC5-SNAPSHOT</version>
4040
</dependency>
4141

4242
<dependency>
4343
<groupId>edu.tamu.weaver</groupId>
4444
<artifactId>token-provider</artifactId>
45-
<version>2.0.0-RC3-SNAPSHOT</version>
45+
<version>2.0.0-RC5-SNAPSHOT</version>
4646
</dependency>
4747

4848
<dependency>
4949
<groupId>edu.tamu.weaver</groupId>
5050
<artifactId>validation</artifactId>
51-
<version>2.0.0-RC3-SNAPSHOT</version>
51+
<version>2.0.0-RC5-SNAPSHOT</version>
5252
</dependency>
5353

5454
<dependency>
5555
<groupId>edu.tamu.weaver</groupId>
5656
<artifactId>reporting</artifactId>
57-
<version>2.0.0-RC3-SNAPSHOT</version>
57+
<version>2.0.0-RC5-SNAPSHOT</version>
5858
</dependency>
5959

6060
<dependency>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package edu.tamu.app.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.context.annotation.Profile;
5+
6+
import edu.tamu.weaver.email.config.WeaverEmailConfig;
7+
8+
@Configuration
9+
@Profile("!test")
10+
public class AppEmailConfig extends WeaverEmailConfig {
11+
12+
}

src/main/java/edu/tamu/app/controller/FeatureProposalController.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.tamu.app.controller;
22

3+
import static edu.tamu.weaver.response.ApiStatus.INVALID;
34
import static edu.tamu.weaver.response.ApiStatus.SUCCESS;
45
import static edu.tamu.weaver.validation.model.BusinessValidationType.CREATE;
56

@@ -62,6 +63,18 @@ public ApiResponse update(@WeaverValidatedModel FeatureProposal featureProposal)
6263
return new ApiResponse(SUCCESS, featureProposalRepo.update(featureProposal));
6364
}
6465

66+
@RequestMapping("/reject")
67+
@PreAuthorize("hasRole('SERVICE_MANAGER')")
68+
public ApiResponse reject(@WeaverValidatedModel FeatureProposal featureProposal) {
69+
ApiResponse response;
70+
if (featureProposal.getFeedback() == null || featureProposal.getFeedback().equals("")) {
71+
response = new ApiResponse(INVALID, "You must provide feedback to reject a feature proposal.");
72+
} else {
73+
response = new ApiResponse(SUCCESS, featureProposalRepo.reject(featureProposal));
74+
}
75+
return response;
76+
}
77+
6578
@Transactional
6679
@RequestMapping("/remove")
6780
@PreAuthorize("hasRole('SERVICE_MANAGER')")

src/main/java/edu/tamu/app/controller/IdeaController.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.tamu.app.controller;
22

3+
import static edu.tamu.weaver.response.ApiStatus.INVALID;
34
import static edu.tamu.weaver.response.ApiStatus.SUCCESS;
45
import static edu.tamu.weaver.validation.model.BusinessValidationType.CREATE;
56

@@ -11,10 +12,13 @@
1112
import org.springframework.web.bind.annotation.RequestMapping;
1213
import org.springframework.web.bind.annotation.RestController;
1314

15+
import edu.tamu.app.enums.IdeaState;
1416
import edu.tamu.app.exception.UserNotFoundException;
1517
import edu.tamu.app.model.Idea;
1618
import edu.tamu.app.model.repo.IdeaRepo;
1719
import edu.tamu.app.model.request.FilteredPageRequest;
20+
import edu.tamu.app.model.request.IssueRequest;
21+
import edu.tamu.app.service.ProjectService;
1822
import edu.tamu.weaver.auth.annotation.WeaverCredentials;
1923
import edu.tamu.weaver.auth.model.Credentials;
2024
import edu.tamu.weaver.response.ApiResponse;
@@ -28,6 +32,9 @@ public class IdeaController {
2832
@Autowired
2933
private IdeaRepo ideaRepo;
3034

35+
@Autowired
36+
private ProjectService projectService;
37+
3138
@RequestMapping("/page")
3239
@PreAuthorize("hasRole('SERVICE_MANAGER')")
3340
public ApiResponse page(@RequestBody FilteredPageRequest filteredPageRequest) {
@@ -52,6 +59,27 @@ public ApiResponse create(@WeaverValidatedModel Idea idea, @WeaverCredentials Cr
5259
public ApiResponse update(@WeaverValidatedModel Idea idea) {
5360
return new ApiResponse(SUCCESS, ideaRepo.update(idea));
5461
}
62+
63+
@RequestMapping("/reject")
64+
@PreAuthorize("hasRole('SERVICE_MANAGER')")
65+
public ApiResponse reject(@WeaverValidatedModel Idea idea) {
66+
ApiResponse response;
67+
if (idea.getFeedback() == null || idea.getFeedback().equals("")) {
68+
response = new ApiResponse(INVALID, "You must provide feedback to reject an idea.");
69+
} else {
70+
response = new ApiResponse(SUCCESS, ideaRepo.reject(idea));
71+
}
72+
return response;
73+
}
74+
75+
@RequestMapping("/helpdesk")
76+
@PreAuthorize("hasRole('SERVICE_MANAGER')")
77+
public ApiResponse helpdesk(@WeaverValidatedModel Idea idea, @WeaverCredentials Credentials credentials) {
78+
idea.setState(IdeaState.SENT_TO_HELPDESK);
79+
idea = ideaRepo.update(idea);
80+
IssueRequest request = new IssueRequest(idea, credentials);
81+
return projectService.submitIssueRequest(request);
82+
}
5583

5684
@Transactional
5785
@RequestMapping("/remove")

src/main/java/edu/tamu/app/controller/StatusController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import org.springframework.web.bind.annotation.RestController;
99

1010
import edu.tamu.app.service.MonitorService;
11-
import edu.tamu.weaver.auth.annotation.WeaverCredentials;
12-
import edu.tamu.weaver.auth.model.Credentials;
1311
import edu.tamu.weaver.response.ApiResponse;
1412

1513
@RestController
@@ -21,13 +19,13 @@ public class StatusController {
2119

2220
@RequestMapping("/overall-full")
2321
@PreAuthorize("hasRole('STAFF')")
24-
public ApiResponse overallFull(@WeaverCredentials Credentials credentials) {
22+
public ApiResponse overallFull() {
2523
return new ApiResponse(SUCCESS, monitorService.getOverallStatus());
2624
}
2725

2826
@RequestMapping("/overall-public")
2927
@PreAuthorize("hasRole('ANONYMOUS')")
30-
public ApiResponse overallPublic(@WeaverCredentials Credentials credentials) {
28+
public ApiResponse overallPublic() {
3129
return new ApiResponse(SUCCESS, monitorService.getOverallStatusPublic());
3230
}
3331

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package edu.tamu.app.enums;
2+
3+
public enum FeatureProposalState {
4+
IN_PROGRESS, ACTIVE, SUBMITTED, ON_HOLD, REJECTED;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package edu.tamu.app.enums;
2+
3+
public enum IdeaState {
4+
WAITING_ON_REVIEW, ELEVATED, SENT_TO_HELPDESK, REJECTED
5+
}

src/main/java/edu/tamu/app/enums/NotificationLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public enum NotificationLocation {
44

5-
MAIN, EVANS, CUSHING, MSL, WCL, PSEL, QATAR;
5+
MAIN, EVANS, CUSHING, MSL, WCL, PSEL, QATAR, SCHOLARS;
66

77
}

src/main/java/edu/tamu/app/model/AbstractIdea.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public abstract class AbstractIdea extends ValidatingBaseEntity {
2525
@Column(columnDefinition = "text", nullable = true)
2626
private String description;
2727

28+
@Column(nullable = true)
29+
private String feedback;
30+
2831
@Temporal(TemporalType.TIMESTAMP)
2932
@UpdateTimestamp
3033
private Calendar lastModified;
@@ -37,6 +40,7 @@ public abstract class AbstractIdea extends ValidatingBaseEntity {
3740

3841
public AbstractIdea() {
3942
super();
43+
this.feedback = "";
4044
}
4145

4246
public AbstractIdea(String title, String description) {
@@ -75,6 +79,14 @@ public void setDescription(String description) {
7579
this.description = description;
7680
}
7781

82+
public String getFeedback() {
83+
return feedback;
84+
}
85+
86+
public void setFeedback(String feedback) {
87+
this.feedback = feedback;
88+
}
89+
7890
public Calendar getLastModified() {
7991
return lastModified;
8092
}

src/main/java/edu/tamu/app/model/FeatureProposal.java

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,26 @@
1010
import javax.persistence.CascadeType;
1111
import javax.persistence.Column;
1212
import javax.persistence.Entity;
13+
import javax.persistence.EnumType;
14+
import javax.persistence.Enumerated;
1315
import javax.persistence.JoinTable;
1416
import javax.persistence.ManyToMany;
17+
import javax.persistence.OneToMany;
1518
import javax.persistence.UniqueConstraint;
1619

1720
import org.hibernate.annotations.Fetch;
1821

1922
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
2023
import com.fasterxml.jackson.annotation.JsonIdentityReference;
21-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2224
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
2325

26+
import edu.tamu.app.enums.FeatureProposalState;
2427
import edu.tamu.app.model.validation.FeatureProposalValidator;
2528

2629
@Entity
27-
@JsonIgnoreProperties(value = { "voters" }, allowGetters = true)
2830
public class FeatureProposal extends AbstractIdea {
2931

30-
@ManyToMany(fetch = EAGER, cascade = { CascadeType.REFRESH, CascadeType.DETACH, CascadeType.MERGE })
31-
@JoinTable(uniqueConstraints = @UniqueConstraint(columnNames = { "feature_proposal_id", "ideas_id" }))
32+
@OneToMany(fetch = EAGER, cascade = { CascadeType.REFRESH, CascadeType.DETACH, CascadeType.MERGE }, mappedBy = "featureProposal")
3233
@Fetch(value = SELECT)
3334
private List<Idea> ideas;
3435

@@ -39,12 +40,15 @@ public class FeatureProposal extends AbstractIdea {
3940
@Fetch(value = SELECT)
4041
private List<User> voters;
4142

43+
@Enumerated(EnumType.STRING)
44+
@Column(nullable = false)
45+
private FeatureProposalState state;
46+
4247
@Column(nullable = false)
43-
private boolean submitted;
48+
private Boolean isPrivate;
4449

4550
public FeatureProposal() {
4651
super();
47-
this.modelValidator = new FeatureProposalValidator();
4852
setup();
4953
}
5054

@@ -70,9 +74,11 @@ public FeatureProposal(Idea idea) {
7074
}
7175

7276
private void setup() {
77+
this.modelValidator = new FeatureProposalValidator();
7378
this.ideas = new ArrayList<Idea>();
7479
this.voters = new ArrayList<User>();
75-
this.submitted = false;
80+
this.state = FeatureProposalState.IN_PROGRESS;
81+
this.isPrivate = false;
7682
}
7783

7884
public List<Idea> getIdeas() {
@@ -126,12 +132,20 @@ public int getVotes() {
126132
return this.voters.size();
127133
}
128134

129-
public boolean isSubmitted() {
130-
return submitted;
135+
public FeatureProposalState getState() {
136+
return state;
137+
}
138+
139+
public void setState(FeatureProposalState state) {
140+
this.state = state;
141+
}
142+
143+
public Boolean getIsPrivate() {
144+
return isPrivate;
131145
}
132146

133-
public void setSubmitted(boolean submitted) {
134-
this.submitted = submitted;
147+
public void setIsPrivate(Boolean isPrivate) {
148+
this.isPrivate = isPrivate;
135149
}
136150

137151
}

0 commit comments

Comments
 (0)