Migrate hibernate xml annotation to annotations

This commit is contained in:
Paulo Gustavo Veiga
2022-01-16 20:01:56 -08:00
parent 4668cba3bf
commit 7fc91abe59
105 changed files with 306 additions and 10790 deletions

View File

@@ -52,7 +52,7 @@ public class AdminController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "application/xml"})
@ResponseBody
public RestUser getUserById(@PathVariable long id) throws IOException {
public RestUser getUserById(@PathVariable int id) throws IOException {
final User userBy = userService.getUserBy(id);
if (userBy == null) {
throw new IllegalArgumentException("User could not be found");
@@ -109,7 +109,7 @@ public class AdminController extends BaseController {
@RequestMapping(method = RequestMethod.PUT, value = "admin/users/{id}/password", consumes = {"text/plain"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changePassword(@RequestBody String password, @PathVariable long id) throws WiseMappingException {
public void changePassword(@RequestBody String password, @PathVariable int id) throws WiseMappingException {
if (password == null) {
throw new IllegalArgumentException("Password can not be null");
}
@@ -124,7 +124,7 @@ public class AdminController extends BaseController {
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteUserByEmail(@PathVariable long id) throws WiseMappingException {
public void deleteUserByEmail(@PathVariable int id) throws WiseMappingException {
final User user = userService.getUserBy(id);
if (user == null) {
throw new IllegalArgumentException("User '" + id + "' could not be found");

View File

@@ -44,7 +44,7 @@ public class LabelController extends BaseController {
// Return the new created label ...
response.setHeader("Location", "/service/labels/" + label.getId());
response.setHeader("ResourceId", Integer.toString(label.getId()));
response.setHeader("ResourceId", Long.toString(label.getId()));
}
@RequestMapping(method = RequestMethod.GET, value = "/labels", produces = {"application/json", "application/xml"})

View File

@@ -18,7 +18,10 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.*;
import com.wisemapping.exceptions.LabelCouldNotFoundException;
import com.wisemapping.exceptions.MapCouldNotFoundException;
import com.wisemapping.exceptions.SessionExpiredException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.*;
import com.wisemapping.rest.model.*;
import com.wisemapping.security.Utils;
@@ -33,10 +36,8 @@ import org.springframework.stereotype.Controller;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
@@ -71,8 +72,9 @@ public class MindmapController extends BaseController {
final MindmapFilter filter = MindmapFilter.parse(q);
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
logger.debug("Collaborators list: " + collaborations.size());
final List<Mindmap> mindmaps = new ArrayList<Mindmap>();
final List<Mindmap> mindmaps = new ArrayList<>();
for (Collaboration collaboration : collaborations) {
final Mindmap mindmap = collaboration.getMindMap();
if (filter.accept(mindmap, user)) {
@@ -83,7 +85,7 @@ public class MindmapController extends BaseController {
}
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "application/xml"})
public RestMindmapHistoryList retrieveHistory(@PathVariable int id) throws IOException {
public RestMindmapHistoryList retrieveHistory(@PathVariable int id) {
final List<MindMapHistory> histories = mindmapService.findMindmapHistory(id);
final RestMindmapHistoryList result = new RestMindmapHistoryList();
for (MindMapHistory history : histories) {
@@ -301,7 +303,7 @@ public class MindmapController extends BaseController {
}
// Compare one by one if some of the elements has been changed ....
final Set<Collaboration> collabsToRemove = new HashSet<Collaboration>(mindMap.getCollaborations());
final Set<Collaboration> collabsToRemove = new HashSet<>(mindMap.getCollaborations());
for (RestCollaboration restCollab : restCollabs.getCollaborations()) {
final Collaboration collaboration = mindMap.findCollaboration(restCollab.getEmail());
// Validate role format ...
@@ -385,7 +387,7 @@ public class MindmapController extends BaseController {
final Mindmap mindMap = findMindmapById(id);
final Set<Collaboration> collaborations = mindMap.getCollaborations();
final List<RestCollaboration> collabs = new ArrayList<RestCollaboration>();
final List<RestCollaboration> collabs = new ArrayList<>();
for (Collaboration collaboration : collaborations) {
collabs.add(new RestCollaboration(collaboration));
}

View File

@@ -36,7 +36,7 @@ import javax.xml.bind.annotation.XmlRootElement;
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
public class RestCollaboration {
private long id;
private int id;
private String email;
private String role;
@@ -60,7 +60,7 @@ public class RestCollaboration {
}
public long getId() {
public int getId() {
return id;
}

View File

@@ -77,11 +77,11 @@ public class RestUser {
user.setLastname(lastname);
}
public long getId() {
public int getId() {
return user.getId();
}
public void setId(long id) {
public void setId(int id) {
user.setId(id);
}