Skip to content

Commit 6d47cc9

Browse files
authored
Merge pull request #90 from TAMULib/products-sprint5-staging
Products sprint5 staging
2 parents ed9e6a5 + c031cf5 commit 6d47cc9

17 files changed

Lines changed: 120 additions & 120 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import edu.tamu.app.model.repo.IdeaRepo;
1919
import edu.tamu.app.model.request.FilteredPageRequest;
2020
import edu.tamu.app.model.request.IssueRequest;
21-
import edu.tamu.app.service.ProjectService;
21+
import edu.tamu.app.service.ProductService;
2222
import edu.tamu.weaver.auth.annotation.WeaverCredentials;
2323
import edu.tamu.weaver.auth.model.Credentials;
2424
import edu.tamu.weaver.response.ApiResponse;
@@ -33,7 +33,7 @@ public class IdeaController {
3333
private IdeaRepo ideaRepo;
3434

3535
@Autowired
36-
private ProjectService projectService;
36+
private ProductService productService;
3737

3838
@RequestMapping("/page")
3939
@PreAuthorize("hasRole('SERVICE_MANAGER')")
@@ -78,7 +78,7 @@ public ApiResponse helpdesk(@WeaverValidatedModel Idea idea, @WeaverCredentials
7878
idea.setState(IdeaState.SENT_TO_HELPDESK);
7979
idea = ideaRepo.update(idea);
8080
IssueRequest request = new IssueRequest(idea, credentials);
81-
return projectService.submitIssueRequest(request);
81+
return productService.submitIssueRequest(request);
8282
}
8383

8484
@Transactional

src/main/java/edu/tamu/app/controller/ProjectController.java renamed to src/main/java/edu/tamu/app/controller/ProductController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414

1515
import edu.tamu.app.exception.UserNotFoundException;
1616
import edu.tamu.app.model.FeatureProposal;
17-
import edu.tamu.app.service.ProjectService;
17+
import edu.tamu.app.service.ProductService;
1818
import edu.tamu.weaver.response.ApiResponse;
1919
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel;
2020

2121
@RestController
22-
@RequestMapping("/projects")
23-
public class ProjectController {
22+
@RequestMapping("/products")
23+
public class ProductController {
2424

2525
@Autowired
26-
private ProjectService projectService;
26+
private ProductService productService;
2727

2828
@RequestMapping
2929
@PreAuthorize("hasRole('USER')")
3030
public ApiResponse getAll() throws JsonParseException, JsonMappingException, MalformedURLException, IOException {
31-
return projectService.getAll();
31+
return productService.getAll();
3232
}
3333

3434
@RequestMapping("/{id}")
3535
@PreAuthorize("hasRole('ANONYMOUS')")
3636
public ApiResponse getById(@PathVariable Long id) throws JsonParseException, JsonMappingException, MalformedURLException, IOException {
37-
return projectService.getById(id);
37+
return productService.getById(id);
3838
}
3939

4040
@RequestMapping("/feature")
4141
@PreAuthorize("hasRole('SERVICE_MANAGER')")
4242
public ApiResponse submitFeatureRequest(@WeaverValidatedModel FeatureProposal proposal) throws UserNotFoundException {
43-
return projectService.submitFeatureRequest(proposal);
43+
return productService.submitFeatureRequest(proposal);
4444
}
4545

4646
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import edu.tamu.app.model.request.FilteredPageRequest;
2121
import edu.tamu.app.model.request.IssueRequest;
2222
import edu.tamu.app.model.request.ServiceRequest;
23-
import edu.tamu.app.service.ProjectService;
23+
import edu.tamu.app.service.ProductService;
2424
import edu.tamu.weaver.auth.annotation.WeaverCredentials;
2525
import edu.tamu.weaver.auth.model.Credentials;
2626
import edu.tamu.weaver.response.ApiResponse;
@@ -39,7 +39,7 @@ public class ServiceController {
3939
private IdeaRepo ideaRepo;
4040

4141
@Autowired
42-
private ProjectService projectService;
42+
private ProductService productService;
4343

4444
@RequestMapping
4545
@PreAuthorize("hasRole('ANONYMOUS')")
@@ -94,7 +94,7 @@ public ApiResponse submitIssueRequest(@RequestBody ServiceRequest request, @Weav
9494
Service service = serviceRepo.findOne(request.getService());
9595
issueRequest.setService(service.getName());
9696
issueRequest.setCredentials(credentials);
97-
return projectService.submitIssueRequest(issueRequest);
97+
return productService.submitIssueRequest(issueRequest);
9898
}
9999

100100
@RequestMapping("/feature")

src/main/java/edu/tamu/app/mock/controller/MockProjectManagementController.java renamed to src/main/java/edu/tamu/app/mock/controller/MockProductManagementController.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@
99
import org.springframework.web.bind.annotation.RequestMapping;
1010
import org.springframework.web.bind.annotation.RestController;
1111

12-
import edu.tamu.app.mock.projects.MockProjects;
12+
import edu.tamu.app.mock.products.MockProducts;
1313
import edu.tamu.app.model.request.FeatureRequest;
1414
import edu.tamu.weaver.response.ApiResponse;
1515

1616
@RestController
1717
@Profile("test")
18-
@RequestMapping("/mock/projects")
19-
public class MockProjectManagementController {
18+
@RequestMapping("/mock/products")
19+
public class MockProductManagementController {
2020

2121
@Autowired
22-
private MockProjects mockProjects;
22+
private MockProducts mockProducts;
2323

2424
@RequestMapping
2525
public ApiResponse getAll() {
26-
return new ApiResponse(SUCCESS, mockProjects.getAllProjects());
26+
return new ApiResponse(SUCCESS, mockProducts.getAllProducts());
2727
}
2828

2929
@RequestMapping("/{id}")
3030
public ApiResponse getById(@PathVariable Long id) {
31-
return new ApiResponse(SUCCESS, mockProjects.getProjectById(id));
31+
return new ApiResponse(SUCCESS, mockProducts.getProductById(id));
3232
}
3333

3434
@RequestMapping("/issue")
3535
public ApiResponse submitIssue(@RequestBody FeatureRequest request) {
36-
return new ApiResponse(SUCCESS, mockProjects.submitRequest(request));
36+
return new ApiResponse(SUCCESS, mockProducts.submitRequest(request));
3737
}
3838

3939
@RequestMapping("/feature")
4040
public ApiResponse submitFeature(@RequestBody FeatureRequest request) {
41-
return new ApiResponse(SUCCESS, mockProjects.submitRequest(request));
41+
return new ApiResponse(SUCCESS, mockProducts.submitRequest(request));
4242
}
4343

4444
}

src/main/java/edu/tamu/app/mock/projects/MockProjects.java renamed to src/main/java/edu/tamu/app/mock/products/MockProducts.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package edu.tamu.app.mock.projects;
1+
package edu.tamu.app.mock.products;
22

33
import java.io.IOException;
44
import java.util.ArrayList;
@@ -19,41 +19,41 @@
1919
import com.fasterxml.jackson.databind.ObjectMapper;
2020

2121
import edu.tamu.app.model.request.FeatureRequest;
22-
import edu.tamu.app.model.response.Project;
22+
import edu.tamu.app.model.response.Product;
2323

2424
@Service
2525
@Profile("test")
26-
public class MockProjects {
26+
public class MockProducts {
2727

28-
private static List<Project> projects = new ArrayList<Project>();
28+
private static List<Product> products = new ArrayList<Product>();
2929

30-
@Value("classpath:mock/projects.json")
30+
@Value("classpath:mock/products.json")
3131
private Resource resource;
3232

3333
@Autowired
3434
private ObjectMapper objectMapper;
3535

3636
@PostConstruct
37-
private void loadProjects() throws JsonParseException, JsonMappingException, IOException {
38-
projects = objectMapper.readValue(resource.getFile(), new TypeReference<List<Project>>() {});
37+
private void loadProducts() throws JsonParseException, JsonMappingException, IOException {
38+
products = objectMapper.readValue(resource.getFile(), new TypeReference<List<Product>>() {});
3939
}
4040

41-
public List<Project> getAllProjects() {
42-
return projects;
41+
public List<Product> getAllProducts() {
42+
return products;
4343
}
4444

45-
public Project getProjectById(Long id) {
46-
Project project = null;
47-
for (Project currentProject : projects) {
48-
Optional<Long> currentId = Optional.ofNullable(Long.valueOf(currentProject.getId()));
45+
public Product getProductById(Long id) {
46+
Product product = null;
47+
for (Product currentProduct : products) {
48+
Optional<Long> currentId = Optional.ofNullable(Long.valueOf(currentProduct.getId()));
4949
if (currentId.isPresent()) {
5050
if (currentId.get().equals(id)) {
51-
project = currentProject;
51+
product = currentProduct;
5252
break;
5353
}
5454
}
5555
}
56-
return project;
56+
return product;
5757
}
5858

5959
public String submitRequest(FeatureRequest request) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class Service extends AbstractScheduler {
5151
private String software;
5252

5353
@Column(nullable = true)
54-
private Long projectId;
54+
private Long productId;
5555

5656
public Service() {
5757
super();
@@ -150,12 +150,12 @@ public void setSoftware(String software) {
150150
this.software = software;
151151
}
152152

153-
public Long getProjectId() {
154-
return projectId;
153+
public Long getProductId() {
154+
return productId;
155155
}
156156

157-
public void setProjectId(Long projectId) {
158-
this.projectId = projectId;
157+
public void setProductId(Long productId) {
158+
this.productId = productId;
159159
}
160160

161161
@Override

src/main/java/edu/tamu/app/model/request/FeatureRequest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class FeatureRequest extends AbstractRequest {
66

77
private static final long serialVersionUID = -6953745180846929244L;
88

9-
private Long projectId;
9+
private Long productId;
1010

1111
public FeatureRequest() {
1212
super();
@@ -20,21 +20,21 @@ public FeatureRequest(RequestType type, String title, String description) {
2020
super(type, title, description);
2121
}
2222

23-
public FeatureRequest(RequestType type, String title, String description, Long projectId) {
23+
public FeatureRequest(RequestType type, String title, String description, Long productId) {
2424
this(type, title, description);
25-
this.projectId = projectId;
25+
this.productId = productId;
2626
}
2727

2828
public FeatureRequest(FeatureProposal proposal) {
29-
this(RequestType.FEATURE, proposal.getTitle(), proposal.getDescription(), proposal.getService().getProjectId());
29+
this(RequestType.FEATURE, proposal.getTitle(), proposal.getDescription(), proposal.getService().getProductId());
3030
}
3131

32-
public Long getProjectId() {
33-
return projectId;
32+
public Long getProductId() {
33+
return productId;
3434
}
3535

36-
public void setProjectId(Long projectId) {
37-
this.projectId = projectId;
36+
public void setProductId(Long productId) {
37+
this.productId = productId;
3838
}
3939

4040
}

src/main/java/edu/tamu/app/model/response/Project.java renamed to src/main/java/edu/tamu/app/model/response/Product.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
import java.io.Serializable;
44

5-
public class Project implements Serializable {
5+
public class Product implements Serializable {
66

77
private static final long serialVersionUID = -6339048161691523620L;
88

99
private Long id;
1010

1111
private String name;
1212

13-
public Project() {
13+
public Product() {
1414
super();
1515
}
1616

17-
public Project(Long id, String name) {
17+
public Product(Long id, String name) {
1818
this();
1919
this.id = id;
2020
this.name = name;

src/main/java/edu/tamu/app/service/ProjectService.java renamed to src/main/java/edu/tamu/app/service/ProductService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import edu.tamu.weaver.response.ApiStatus;;
2626

2727
@Service
28-
public class ProjectService {
28+
public class ProductService {
2929

30-
@Value("${app.projects.url}")
31-
private String projectsUrl;
30+
@Value("${app.products.url}")
31+
private String productsUrl;
3232

3333
@Autowired
3434
private ObjectMapper objectMapper;
@@ -43,15 +43,15 @@ public class ProjectService {
4343
private SimpMessagingTemplate simpMessagingTemplate;
4444

4545
public ApiResponse getAll() throws JsonParseException, JsonMappingException, MalformedURLException, IOException {
46-
return objectMapper.readValue(new URL(projectsUrl), ApiResponse.class);
46+
return objectMapper.readValue(new URL(productsUrl), ApiResponse.class);
4747
}
4848

4949
public ApiResponse getById(Long id) throws JsonParseException, JsonMappingException, MalformedURLException, IOException {
50-
return objectMapper.readValue(new URL(projectsUrl + "/" + id), ApiResponse.class);
50+
return objectMapper.readValue(new URL(productsUrl + "/" + id), ApiResponse.class);
5151
}
5252

5353
public ApiResponse submitFeatureRequest(FeatureProposal proposal) {
54-
ApiResponse response = restTemplate.postForObject(projectsUrl + "/feature", new FeatureRequest(proposal), ApiResponse.class);
54+
ApiResponse response = restTemplate.postForObject(productsUrl + "/feature", new FeatureRequest(proposal), ApiResponse.class);
5555
if (response.getMeta().getStatus().equals(ApiStatus.SUCCESS)) {
5656
proposal.setState(FeatureProposalState.SUBMITTED);
5757
proposal = featureProposalRepo.save(proposal);
@@ -61,7 +61,7 @@ public ApiResponse submitFeatureRequest(FeatureProposal proposal) {
6161
}
6262

6363
public ApiResponse submitIssueRequest(IssueRequest request) {
64-
return restTemplate.postForObject(projectsUrl + "/issue", request, ApiResponse.class);
64+
return restTemplate.postForObject(productsUrl + "/issue", request, ApiResponse.class);
6565

6666
}
6767

src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spring:
4646

4747
---
4848
app:
49-
projects.url: http://localhost:9001/projects
49+
products.url: http://localhost:9001/products
5050

5151
whitelist: 127.0.0.1
5252

0 commit comments

Comments
 (0)