api for unlink mindmaps
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.wisemapping.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.LabelMindmapRelationshipNotFoundException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.LabelMindmap;
|
||||
import com.wisemapping.rest.model.RestLabelMindmap;
|
||||
import com.wisemapping.service.LabelMindmapService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@Controller
|
||||
public class LabelMindmapController extends BaseController {
|
||||
|
||||
@Qualifier("labelMindmapService")
|
||||
@Autowired
|
||||
private LabelMindmapService labelMindmapService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/maps")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void removeLabelFromMindmap(@RequestBody RestLabelMindmap restLabelMindmap) throws WiseMappingException {
|
||||
final int labelId = restLabelMindmap.getLabelId();
|
||||
final int mindmapId = restLabelMindmap.getMindmapId();
|
||||
final LabelMindmap relationship = labelMindmapService.getLabelMindmap(labelId, mindmapId);
|
||||
if (relationship == null) {
|
||||
throw new LabelMindmapRelationshipNotFoundException("Label Map relation could not be found. Label Id: " + labelId + ", Map Id: " + mindmapId);
|
||||
}
|
||||
labelMindmapService.removeLabelFromMindmap(relationship);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.wisemapping.rest.model;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.wisemapping.model.LabelMindmap;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
|
||||
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
|
||||
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = NONE,
|
||||
setterVisibility = PUBLIC_ONLY,
|
||||
isGetterVisibility = NONE,
|
||||
getterVisibility = PUBLIC_ONLY
|
||||
)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RestLabelMindmap {
|
||||
|
||||
@JsonIgnore
|
||||
private LabelMindmap labelMindmap;
|
||||
|
||||
public RestLabelMindmap() {
|
||||
this(new LabelMindmap());
|
||||
}
|
||||
|
||||
public RestLabelMindmap(@NotNull final LabelMindmap labelMindmap) {
|
||||
this.labelMindmap = labelMindmap;
|
||||
}
|
||||
|
||||
public void setLabelId(final int labelId) {
|
||||
this.labelMindmap.setLabelId(labelId);
|
||||
}
|
||||
|
||||
public int getLabelId() {
|
||||
return this.labelMindmap.getLabelId();
|
||||
}
|
||||
|
||||
public void setMindmapId(final int mindmapId) {
|
||||
labelMindmap.setMindmapId(mindmapId);
|
||||
}
|
||||
|
||||
public int getMindmapId() {
|
||||
return this.labelMindmap.getMindmapId();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user