Fix history bug.

This commit is contained in:
Paulo Gustavo Veiga 2013-03-29 14:51:21 -03:00
parent 81d3d591fa
commit dce29eda19
5 changed files with 12 additions and 11 deletions

View File

@ -27,6 +27,7 @@ import org.hibernate.criterion.Junction;
import org.hibernate.criterion.Order;
import org.hibernate.Criteria;
import java.io.IOException;
import java.util.List;
import java.util.Calendar;
@ -234,10 +235,10 @@ public class MindmapManagerImpl
getHibernateTemplate().delete(mindMap);
}
private void saveHistory(@NotNull final Mindmap mindMap) {
private void saveHistory(@NotNull final Mindmap mindMap) throws IOException {
final MindMapHistory history = new MindMapHistory();
history.setXml(mindMap.getXml());
history.setZippedXml(mindMap.getZippedXml());
history.setCreationTime(Calendar.getInstance());
history.setEditor(mindMap.getLastEditor());
history.setMindmapId(mindMap.getId());

View File

@ -29,7 +29,7 @@ public class MindMapHistory {
private int id;
private Calendar creationTime;
private User editor;
private byte[] xml;
private byte[] zippedXml;
private int mindmapId;
public MindMapHistory() {
@ -69,15 +69,15 @@ public class MindMapHistory {
this.editor = editor;
}
public byte[] getXml() {
return xml;
public byte[] getZippedXml() {
return zippedXml;
}
public void setXml(byte[] value) {
xml = value;
public void setZippedXml(byte[] value) {
zippedXml = value;
}
public byte[] getUnzipXml() throws IOException {
return ZipUtils.zipToBytes(getXml());
return ZipUtils.zipToBytes(getZippedXml());
}
}

View File

@ -172,7 +172,7 @@ public class MindmapController extends BaseController {
List<MindMapHistory> mindmapHistory = mindmapService.findMindmapHistory(id);
if (mindmapHistory.size() > 0) {
final MindMapHistory mindMapHistory = mindmapHistory.get(0);
mindmap.setZippedXml(mindMapHistory.getXml());
mindmap.setZippedXml(mindMapHistory.getZippedXml());
saveMindmapDocument(true, mindmap, user);
}
} else {

View File

@ -263,7 +263,7 @@ public class MindmapServiceImpl
public void revertChange(@NotNull Mindmap mindmap, int historyId)
throws WiseMappingException, IOException {
final MindMapHistory history = mindmapManager.getHistory(historyId);
mindmap.setZippedXml(history.getXml());
mindmap.setZippedXml(history.getZippedXml());
updateMindmap(mindmap, true);
}

View File

@ -11,7 +11,7 @@
</id>
<property name="mindmapId" column="mindmap_id"/>
<property name="xml" column="xml"/>
<property name="getZippedXml" column="xml"/>
<property name="creationTime" column="creation_date"/>
<many-to-one name="editor" column="editor_id" unique="false" not-null="false" lazy="proxy"/>
</class>