mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-11 23:00:06 +02:00
link label to mindmaps
This commit is contained in:
parent
72a46367d6
commit
2ec941e1a0
@ -3,6 +3,7 @@ package com.wisemapping.dao;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -14,6 +15,10 @@ public interface LabelManager {
|
||||
|
||||
@NotNull
|
||||
List<Label> getAllLabels(@NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelById(int id);
|
||||
|
||||
@Nullable
|
||||
Label getLabelByTitle(@NotNull final String title, @NotNull final User user);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.wisemapping.dao;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import java.util.List;
|
||||
@ -25,6 +26,13 @@ public class LabelManagerImpl extends HibernateDaoSupport
|
||||
public List<Label> getAllLabels(@NotNull final User user) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where creator_id=?", user.getId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelById(int id) {
|
||||
return getHibernateTemplate().get(Label.class, id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||
@ -35,4 +43,6 @@ public class LabelManagerImpl extends HibernateDaoSupport
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LabelCouldNotFoundException extends ClientException {
|
||||
|
||||
private static final String MSG_KEY = "LABEL_CAN_NOT_BE_FOUND";
|
||||
|
||||
public LabelCouldNotFoundException(@NotNull String msg)
|
||||
{
|
||||
super(msg,Severity.FATAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@ public class Mindmap {
|
||||
private User lastEditor;
|
||||
|
||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
private Set<Label> labels = new HashSet<Label>();
|
||||
|
||||
private User creator;
|
||||
private String tags;
|
||||
@ -118,6 +119,18 @@ public class Mindmap {
|
||||
collaborations.add(collaboration);
|
||||
}
|
||||
|
||||
@NotNull public Set<Label> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void setLabels(@NotNull final Set<Label> labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
public void addLabel(@NotNull final Label label) {
|
||||
this.labels.add(label);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Collaboration findCollaboration(@NotNull Collaborator collaborator) {
|
||||
Collaboration result = null;
|
||||
|
@ -1,12 +1,18 @@
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MapCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestLabelList;
|
||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.validator.LabelValidator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -15,6 +21,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@ -22,7 +29,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@ -31,6 +37,9 @@ 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"})
|
||||
@ -45,7 +54,7 @@ public class LabelController extends BaseController {
|
||||
|
||||
// Validate ...
|
||||
final BindingResult result = new BeanPropertyBindingResult(restLabel, "");
|
||||
new LabelValidator().validate(label, result);
|
||||
new LabelValidator(labelService).validate(label, result);
|
||||
if (result.hasErrors()) {
|
||||
throw new ValidationException(result);
|
||||
}
|
||||
@ -67,4 +76,20 @@ public class LabelController extends BaseController {
|
||||
return new RestLabelList(all);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/labels/{id}/maps", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void linkToMindMaps(@PathVariable int id, @RequestBody String ids) throws WiseMappingException {
|
||||
final Label label = labelService.getLabelById(id);
|
||||
if (label == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + id);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class RestMindmapList {
|
||||
}
|
||||
|
||||
public RestMindmapList(@NotNull List<Mindmap> mindmaps, @NotNull Collaborator collaborator) {
|
||||
this.mindmapsInfo = new ArrayList<RestMindmapInfo>();
|
||||
this.mindmapsInfo = new ArrayList<>(mindmaps.size());
|
||||
for (Mindmap mindMap : mindmaps) {
|
||||
this.mindmapsInfo.add(new RestMindmapInfo(mindMap, collaborator));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -12,5 +13,9 @@ public interface LabelService {
|
||||
void addLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException;
|
||||
|
||||
@NotNull List<Label> getAll(@NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelById(int id);
|
||||
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -29,6 +30,11 @@ public class LabelServiceImpl implements LabelService {
|
||||
return labelManager.getAllLabels(user);
|
||||
}
|
||||
|
||||
@Override @Nullable
|
||||
public Label getLabelById(int id) {
|
||||
return labelManager.getLabelById(id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||
|
@ -25,6 +25,13 @@
|
||||
<key column="mindmap_id" not-null="true"/>
|
||||
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
||||
</set>
|
||||
|
||||
<set name = "labels"
|
||||
table="R_LABEL_MINDMAP"
|
||||
cascade="all,delete-orphan,save-update">
|
||||
<key column="mindmap_id" not-null="true"/>
|
||||
<many-to-many column="label_id" class="com.wisemapping.model.Label"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
@ -252,6 +252,7 @@ CONTACT_US=Contact Us
|
||||
CAPTCHA_LOADING_ERROR=ReCaptcha could not be loaded. You must have access to Google ReCaptcha service.
|
||||
ACCESS_HAS_BEEN_REVOKED= Upps. your access permissions to this map has been revoked. Contact map owner.
|
||||
MAP_CAN_NOT_BE_FOUND= Upps. The map can not be found. It must have been deleted.
|
||||
LABEL_CAN_NOT_BE_FOUND= Upps. The label can not be found. It must have been deleted.
|
||||
LICENSE=License
|
||||
WELCOME_TO_WISEMAPPING=Welcome to WiseMapping
|
||||
WELCOME_DETAILS=WiseMapping will enable you to create and read your mind maps everywhere. With WiseMapping you can: <ul><li>Embed mind map it in web pages and blogs</li><li>Link mind map and documents</li><li>Share your maps with friend and colleagues</li><li>Export your maps SVG,PNG,JPG and FreeMind</li></ul>.
|
||||
|
Loading…
Reference in New Issue
Block a user