forgot the project had to be compiled for 1.7

parent f838e018
package no.nsd.websurvey.tromso.controller;
import no.nsd.websurvey.tromso.domain.ResponseObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -15,43 +16,16 @@ import java.util.List;
import java.util.Map;
/**
* Replaces the Spring Boot standard error page with a simple, less
* detailed error message specifying where to get the resource.
* Replaces the Spring Boot standard error page with a default
* return value for unknown entities.
*/
@RestController
@RequestMapping
public class WSTErrorController implements ErrorController {
@Autowired
private RequestMappingHandlerMapping requestMappingHandlerMapping;
private List<String> urlMappings = new ArrayList<>();
/**
* Simple implementation to provide a list of registered controller
* mappings and resources from all {@link org.springframework.web.bind.annotation.RestController}
*/
@PostConstruct
public void getAvailableUrls() {
Map<RequestMappingInfo, HandlerMethod> handlerMethodMap =
this.requestMappingHandlerMapping.getHandlerMethods();
urlMappings.add("Available resources:");
for(Map.Entry<RequestMappingInfo, HandlerMethod> item : handlerMethodMap.entrySet()) {
RequestMappingInfo mapping = item.getKey();
HandlerMethod method = item.getValue();
for(String urlMapping : mapping.getPatternsCondition().getPatterns()) {
urlMappings.add(urlMapping);
}
}
}
@RequestMapping(value = "error", method = RequestMethod.GET)
public List<String> error() {
return urlMappings;
public ResponseObject error() {
return new ResponseObject(0, 0);
}
/**
......
......@@ -5,12 +5,11 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface SurveyUsersRepository extends CrudRepository<SurveyUsers, Integer> {
public Optional<SurveyUsers> findByIdAndSid(int id, int sid);
public SurveyUsers findByIdAndSid(int id, int sid);
public List<SurveyUsers> findBySid(int sid);
......
......@@ -23,34 +23,27 @@ public class SurveyUsersServiceImpl implements SurveyUsersService {
@Override
public ResponseObject findById(int id, int sid) {
SurveyUsers surveyUsers = surveyUsersRepository.findByIdAndSid(id, sid).orElse(null);
SurveyUsers surveyUsers = surveyUsersRepository.findByIdAndSid(id, sid);
ResponseObject responseObject = new ResponseObject();
responseObject.setId(surveyUsers.getId());
if(surveyUsers != null) {
responseObject.setId(surveyUsers.getId());
if(surveyUsers.getUserAgent() == null &&surveyUsers.getCompleted() == 0) {
responseObject.setStatus(1);
}
else if(surveyUsers.getUserAgent() != null && surveyUsers.getCompleted() == 0) {
responseObject.setStatus(2);
}
else {
responseObject.setStatus(3);
}
if(surveyUsers.getUserAgent() == null &&surveyUsers.getCompleted() == 0) {
responseObject.setStatus(1);
}
return responseObject;
else if(surveyUsers.getUserAgent() != null && surveyUsers.getCompleted() == 0) {
responseObject.setStatus(2);
}
else {
responseObject.setStatus(0);
return responseObject;
responseObject.setStatus(3);
}
return responseObject;
}
@Override
public List<ResponseObject> findBySid(int sid) {
return null;
......
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