Skip to content

Commit ae94e68

Browse files
committed
Added description to create method and calling updateAll on the status monitor
1 parent a6434c7 commit ae94e68

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import edu.tamu.app.model.Service;
1515
import edu.tamu.app.model.repo.ServiceRepo;
16+
import edu.tamu.app.service.SystemMonitorService;
1617
import edu.tamu.framework.aspect.annotation.ApiMapping;
1718
import edu.tamu.framework.aspect.annotation.ApiValidatedModel;
1819
import edu.tamu.framework.aspect.annotation.ApiValidation;
@@ -29,6 +30,9 @@ public class ServiceController {
2930

3031
@Autowired
3132
private ServiceRepo serviceRepo;
33+
34+
@Autowired
35+
private SystemMonitorService systemMonitorService;
3236

3337
@ApiMapping("/all")
3438
@Auth(role="ROLE_STAFF")
@@ -53,8 +57,9 @@ public ApiResponse getService(@ApiVariable Long id) {
5357
@Auth(role = "ROLE_SERVICE_MANAGER")
5458
@ApiValidation(business = { @ApiValidation.Business(value = CREATE), @ApiValidation.Business(value = EXISTS) })
5559
public ApiResponse createService(@ApiValidatedModel Service service) {
56-
service = serviceRepo.create(service.getName(), service.getStatus(), service.getIsAuto(), service.getIsPublic(), service.getOnShortList(), service.getServiceUrl());
60+
service = serviceRepo.create(service.getName(), service.getStatus(), service.getIsAuto(), service.getIsPublic(), service.getOnShortList(), service.getServiceUrl(), service.getDescription());
5761
simpMessagingTemplate.convertAndSend("/channel/service", new ApiResponse(SUCCESS, serviceRepo.findAll()));
62+
systemMonitorService.updateAll();
5863
return new ApiResponse(SUCCESS, service);
5964
}
6065

@@ -64,6 +69,7 @@ public ApiResponse createService(@ApiValidatedModel Service service) {
6469
public ApiResponse updateService(@ApiValidatedModel Service service) {
6570
service = serviceRepo.save(service);
6671
simpMessagingTemplate.convertAndSend("/channel/service/" + service.getId(), new ApiResponse(SUCCESS, service));
72+
systemMonitorService.updateAll();
6773
return new ApiResponse(SUCCESS, service);
6874
}
6975

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static javax.persistence.CascadeType.REMOVE;
55
import static javax.persistence.FetchType.EAGER;
66

7+
import java.io.UnsupportedEncodingException;
78
import java.util.ArrayList;
89
import java.util.HashSet;
910
import java.util.List;
@@ -14,6 +15,8 @@
1415
import javax.persistence.Entity;
1516
import javax.persistence.Lob;
1617
import javax.persistence.OneToMany;
18+
import javax.persistence.PrePersist;
19+
import javax.persistence.PreUpdate;
1720
import javax.validation.constraints.Size;
1821

1922
import org.hibernate.annotations.Fetch;
@@ -57,7 +60,7 @@ public class Service extends BaseEntity {
5760
@Column(nullable = false)
5861
private Boolean onShortList;
5962

60-
@Lob
63+
// @Lob
6164
@Column(nullable = true)
6265
private String description;
6366

@@ -72,14 +75,15 @@ public Service() {
7275
setAliases(new ArrayList<String>());
7376
}
7477

75-
public Service(String name, Status status, Boolean isAuto, Boolean isPublic, Boolean onShortList, String serviceUrl) {
78+
public Service(String name, Status status, Boolean isAuto, Boolean isPublic, Boolean onShortList, String serviceUrl, String description) {
7679
this();
7780
setName(name);
7881
setStatus(status);
7982
setIsAuto(isAuto);
8083
setIsPublic(isPublic);
8184
setOnShortList(onShortList);
8285
setServiceUrl(serviceUrl);
86+
setDescription(description);
8387
}
8488

8589
public String getName() {

src/main/java/edu/tamu/app/model/repo/custom/ServiceRepoCustom.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
public interface ServiceRepoCustom {
77

8-
public Service create(String name, Status status, Boolean isAuto, Boolean isPublic, Boolean onShortList, String serviceUrl);
8+
public Service create(String name, Status status, Boolean isAuto, Boolean isPublic, Boolean onShortList, String serviceUrl, String description);
99
}

src/main/java/edu/tamu/app/model/repo/impl/ServiceRepoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class ServiceRepoImpl implements ServiceRepoCustom {
1313
private ServiceRepo serviceRepo;
1414

1515
@Override
16-
public Service create(String name, Status status, Boolean isAuto, Boolean isPublic, Boolean onShortList, String serviceUrl) {
17-
return serviceRepo.save(new Service(name, status, isAuto, isPublic, onShortList, serviceUrl));
16+
public Service create(String name, Status status, Boolean isAuto, Boolean isPublic, Boolean onShortList, String serviceUrl, String description) {
17+
return serviceRepo.save(new Service(name, status, isAuto, isPublic, onShortList, serviceUrl, description));
1818
}
1919

2020
}

0 commit comments

Comments
 (0)