mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
api for unlink mindmaps
This commit is contained in:
parent
734463d233
commit
8db7f5015f
@ -0,0 +1,14 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.LabelMindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface LabelMindmapManager {
|
||||
|
||||
@Nullable
|
||||
LabelMindmap getLabelMindmap(final int labelId, final int mindmapId);
|
||||
|
||||
void removeLabelMindmap(@NotNull LabelMindmap labelMindmap);
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.LabelMindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class LabelMindmapManagerImpl extends HibernateDaoSupport
|
||||
implements LabelMindmapManager {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LabelMindmap getLabelMindmap(int labelId, int mindmapId) {
|
||||
LabelMindmap result = null;
|
||||
List<LabelMindmap> list = getHibernateTemplate().find("from com.wisemapping.model.LabelMindmap wisemapping where mindmap_id=? and label_id=? ", new Object[]{mindmapId, labelId});
|
||||
assert list.size() <= 1;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
result = list.get(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabelMindmap(@NotNull LabelMindmap labelMindmap) {
|
||||
getHibernateTemplate().delete(labelMindmap);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LabelMindmapRelationshipNotFoundException extends ClientException {
|
||||
|
||||
private static final String MSG_KEY = "LABEL_MINDMAP_RELATION_NOT_BE_FOUND";
|
||||
|
||||
public LabelMindmapRelationshipNotFoundException(@NotNull String msg)
|
||||
{
|
||||
super(msg,Severity.WARNING);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class LabelMindmap implements Serializable{
|
||||
|
||||
private int mindmapId;
|
||||
private int labelId;
|
||||
|
||||
public int getMindmapId() {
|
||||
return mindmapId;
|
||||
}
|
||||
|
||||
public void setMindmapId(int mindmapId) {
|
||||
this.mindmapId = mindmapId;
|
||||
}
|
||||
|
||||
public int getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public void setLabelId(int labelId) {
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof LabelMindmap)) return false;
|
||||
|
||||
LabelMindmap that = (LabelMindmap) o;
|
||||
|
||||
return labelId == that.labelId && mindmapId == that.mindmapId;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = mindmapId;
|
||||
result = 31 * result + labelId;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.LabelMindmap;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public interface LabelMindmapService {
|
||||
|
||||
void removeLabelFromMindmap(@NotNull final LabelMindmap labelMindmap) throws WiseMappingException;
|
||||
|
||||
LabelMindmap getLabelMindmap(int labelId, int mindmapId);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.dao.LabelMindmapManager;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.LabelMindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LabelMindmapServiceImpl implements LabelMindmapService {
|
||||
|
||||
private LabelMindmapManager labelMindmapManager;
|
||||
|
||||
public void setLabelMindmapManager(LabelMindmapManager labelMindmapManager) {
|
||||
this.labelMindmapManager = labelMindmapManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabelFromMindmap(@NotNull LabelMindmap labelMindmap) throws WiseMappingException {
|
||||
this.labelMindmapManager.removeLabelMindmap(labelMindmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LabelMindmap getLabelMindmap(int labelId, int mindmapId) {
|
||||
return this.labelMindmapManager.getLabelMindmap(labelId, mindmapId);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
|
||||
<class name="com.wisemapping.model.LabelMindmap" table="R_LABEL_MINDMAP">
|
||||
<composite-id>
|
||||
<key-property name="mindmapId" type="int" column="mindmap_id"/>
|
||||
<key-property name="labelId" type="int" column="label_id" />
|
||||
</composite-id>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
@ -255,6 +255,7 @@ CAPTCHA_LOADING_ERROR=ReCaptcha could not be loaded. You must have access to Goo
|
||||
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.
|
||||
LABEL_MINDMAP_RELATION_NOT_BE_FOUND= Upps. The label can not be found on map. It must have already 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>.
|
||||
|
@ -34,6 +34,7 @@
|
||||
<value>com/wisemapping/model/AccessAuditory.hbm.xml</value>
|
||||
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
|
||||
<value>com/wisemapping/model/Label.hbm.xml</value>
|
||||
<value>com/wisemapping/model/LabelMindmap.hbm.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="hibernateProperties">
|
||||
|
@ -17,5 +17,9 @@
|
||||
<bean id="labelManager" class="com.wisemapping.dao.LabelManagerImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate"/>
|
||||
</bean>
|
||||
|
||||
<bean id="labelMindmapManager" class="com.wisemapping.dao.LabelMindmapManagerImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate"/>
|
||||
</bean>
|
||||
</beans>
|
||||
</beans>
|
@ -45,6 +45,7 @@
|
||||
<value>com.wisemapping.rest.model.RestLogItem</value>
|
||||
<value>com.wisemapping.rest.model.RestLockInfo</value>
|
||||
<value>com.wisemapping.rest.model.RestLabel</value>
|
||||
<value>com.wisemapping.rest.model.RestLabelMindmap</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
@ -72,6 +72,22 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="labelMindmapServiceTarget" class="com.wisemapping.service.LabelMindmapServiceImpl">
|
||||
<property name="labelMindmapManager" ref="labelMindmapManager"/>
|
||||
</bean>
|
||||
|
||||
<bean id="labelMindmapService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
<property name="target">
|
||||
<ref local="labelMindmapServiceTarget"/>
|
||||
</property>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRED</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<property name="host" value="${mail.smtp.host}"/>
|
||||
<property name="port" value="${mail.smtp.port}"/>
|
||||
|
Loading…
Reference in New Issue
Block a user