moving api methods to MindmapController
This commit is contained in:
committed by
Ezequiel Bergamaschi
parent
d089b471fc
commit
d555309c22
@@ -37,9 +37,6 @@ public class LabelController extends BaseController {
|
||||
@Qualifier("labelService")
|
||||
@Autowired
|
||||
private LabelService labelService;
|
||||
@Qualifier("mindmapService")
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels", consumes = {"application/json"})
|
||||
@@ -67,28 +64,6 @@ public class LabelController extends BaseController {
|
||||
return new RestLabelList(all);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.ACCEPTED)
|
||||
public void linkToMindMaps(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids, @NotNull HttpServletResponse response) throws WiseMappingException {
|
||||
int id = restLabel.getId();
|
||||
Label label = labelService.getLabelById(id);
|
||||
if (label == null) {
|
||||
// create label..
|
||||
validate(restLabel);
|
||||
createLabel(restLabel);
|
||||
label = restLabel.getDelegated();
|
||||
response.setHeader("ResourceId", Integer.toString(label.getId()));
|
||||
}
|
||||
for (String mindmapId : ids.split(",")) {
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(Integer.parseInt(mindmapId));
|
||||
if (mindmap == null) {
|
||||
throw new MapCouldNotFoundException("Map could not be found. Id:" + id);
|
||||
}
|
||||
mindmap.addLabel(label);
|
||||
mindmapService.updateMindmap(mindmap, false);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteLabelById(@PathVariable int id) throws WiseMappingException {
|
||||
|
||||
@@ -31,11 +31,13 @@ import com.wisemapping.importer.ImporterFactory;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.CollaborationProperties;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.MindMapHistory;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestCollaboration;
|
||||
import com.wisemapping.rest.model.RestCollaborationList;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestMindmap;
|
||||
import com.wisemapping.rest.model.RestMindmapHistory;
|
||||
import com.wisemapping.rest.model.RestMindmapHistoryList;
|
||||
@@ -617,4 +619,32 @@ public class MindmapController extends BaseController {
|
||||
result.rejectValue(fieldName, "error.not-specified", null, message);
|
||||
return new ValidationException(result);
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/maps/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void removeLabel(@RequestBody RestLabel restLabel, @PathVariable int id) throws WiseMappingException {
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User currentUser = Utils.getUser();
|
||||
final Label delegated = restLabel.getDelegated();
|
||||
assert currentUser != null;
|
||||
delegated.setCreator(currentUser);
|
||||
mindmapService.removeLabel(mindmap, delegated);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.ACCEPTED)
|
||||
public void addLabel(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids) throws WiseMappingException {
|
||||
int labelId = restLabel.getId();
|
||||
for (String id : ids.split(",")) {
|
||||
final int mindmapId = Integer.parseInt(id);
|
||||
final Mindmap mindmap = findMindmapById(mindmapId);
|
||||
final Label label = mindmap.findLabel(labelId);
|
||||
if (label == null) {
|
||||
final Label delegated = restLabel.getDelegated();
|
||||
delegated.setCreator(Utils.getUser());
|
||||
mindmapService.addLabel(mindmap, delegated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user