This commit is contained in:
Ezequiel Bergamaschi 2014-01-29 02:56:09 -03:00 committed by Ezequiel Bergamaschi
parent 9edea47dbd
commit b4c69133f5
3 changed files with 14 additions and 3 deletions

View File

@ -76,9 +76,10 @@ public class LabelController extends BaseController {
return new RestLabelList(all); return new RestLabelList(all);
} }
@RequestMapping(method = RequestMethod.PUT, value = "/labels/{id}/maps", consumes = {"text/plain"}) @RequestMapping(method = RequestMethod.PUT, value = "/labels/maps", consumes = {"application/json"})
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void linkToMindMaps(@PathVariable int id, @RequestBody String ids) throws WiseMappingException { public void linkToMindMaps(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids) throws WiseMappingException {
int id = restLabel.getId();
final Label label = labelService.getLabelById(id); final Label label = labelService.getLabelById(id);
if (label == null) { if (label == null) {
throw new LabelCouldNotFoundException("Label could not be found. Id: " + id); throw new LabelCouldNotFoundException("Label could not be found. Id: " + id);

View File

@ -21,6 +21,7 @@ package com.wisemapping.rest.model;
import com.wisemapping.model.Collaboration; import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Collaborator; import com.wisemapping.model.Collaborator;
import com.wisemapping.model.Label;
import com.wisemapping.model.Mindmap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.security.Utils; import com.wisemapping.security.Utils;
@ -35,6 +36,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;
@XmlRootElement(name = "map") @XmlRootElement(name = "map")
@XmlAccessorType(XmlAccessType.PROPERTY) @XmlAccessorType(XmlAccessType.PROPERTY)
@ -93,6 +96,13 @@ public class RestMindmapInfo {
public void setTitle(String title) { public void setTitle(String title) {
mindmap.setTitle(title); mindmap.setTitle(title);
} }
public Set<RestLabel> getLabels() {
final Set<RestLabel> result = new HashSet<>();
for (Label label : mindmap.getLabels()) {
result.add(new RestLabel(label));
}
return result;
}
public int getId() { public int getId() {
return mindmap.getId(); return mindmap.getId();

View File

@ -28,7 +28,7 @@
<set name = "labels" <set name = "labels"
table="R_LABEL_MINDMAP" table="R_LABEL_MINDMAP"
cascade="all,delete-orphan,save-update"> cascade="all">
<key column="mindmap_id" not-null="true"/> <key column="mindmap_id" not-null="true"/>
<many-to-many column="label_id" class="com.wisemapping.model.Label"/> <many-to-many column="label_id" class="com.wisemapping.model.Label"/>
</set> </set>