mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Mindmap loading is lazy.
This commit is contained in:
parent
f5b4cc9ea7
commit
fd021de86d
@ -84,12 +84,13 @@ public class MindmapManagerImpl
|
|||||||
|
|
||||||
final List<MindMapHistory> historyList = hibernateCriteria.list();
|
final List<MindMapHistory> historyList = hibernateCriteria.list();
|
||||||
|
|
||||||
final Mindmap mindmapById = this.getMindmapById(mapId);
|
final Mindmap mindmap = this.getMindmapById(mapId);
|
||||||
|
if (mindmap != null) {
|
||||||
final Calendar yearAgo = Calendar.getInstance();
|
final Calendar yearAgo = Calendar.getInstance();
|
||||||
yearAgo.add(Calendar.MONTH, -12);
|
yearAgo.add(Calendar.MONTH, -12);
|
||||||
|
|
||||||
// If the map has not been modified in the last months, it means that I don't need to keep all the history ...
|
// If the map has not been modified in the last months, it means that I don't need to keep all the history ...
|
||||||
int max = mindmapById.getLastModificationTime().before(yearAgo) ? 10 : 25;
|
int max = mindmap.getLastModificationTime().before(yearAgo) ? 10 : 25;
|
||||||
|
|
||||||
for (MindMapHistory history : historyList) {
|
for (MindMapHistory history : historyList) {
|
||||||
byte[] zippedXml = history.getZippedXml();
|
byte[] zippedXml = history.getZippedXml();
|
||||||
@ -105,6 +106,7 @@ public class MindmapManagerImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Mindmap> search(MindMapCriteria criteria, int maxResult) {
|
public List<Mindmap> search(MindMapCriteria criteria, int maxResult) {
|
||||||
|
@ -57,7 +57,7 @@ public class FreemindExporter
|
|||||||
private Map<String, Node> nodesMap = null;
|
private Map<String, Node> nodesMap = null;
|
||||||
|
|
||||||
public void export(Mindmap map, OutputStream outputStream) throws ExportException {
|
public void export(Mindmap map, OutputStream outputStream) throws ExportException {
|
||||||
export(map.getXml(), outputStream);
|
export(map.getUnzipXml(), outputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void export(byte[] xml, @NotNull OutputStream outputStream) throws ExportException {
|
public void export(byte[] xml, @NotNull OutputStream outputStream) throws ExportException {
|
||||||
|
@ -48,7 +48,7 @@ public class Mindmap {
|
|||||||
private User creator;
|
private User creator;
|
||||||
private String tags;
|
private String tags;
|
||||||
private String title;
|
private String title;
|
||||||
private byte[] xml;
|
private byte[] zippedXml;
|
||||||
|
|
||||||
//~ Constructors .........................................................................................
|
//~ Constructors .........................................................................................
|
||||||
|
|
||||||
@ -57,32 +57,30 @@ public class Mindmap {
|
|||||||
|
|
||||||
//~ Methods ..............................................................................................
|
//~ Methods ..............................................................................................
|
||||||
|
|
||||||
public void setXml(byte[] xml) {
|
public void setUnzipXml(@NotNull byte[] value) {
|
||||||
this.xml = xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setXmlStr(@NotNull String xml)
|
|
||||||
throws IOException {
|
|
||||||
this.xml = xml.getBytes(UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getXml() {
|
|
||||||
return xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getXmlStr() throws UnsupportedEncodingException {
|
|
||||||
String result = null;
|
|
||||||
if (this.xml != null) {
|
|
||||||
result = new String(this.xml, UTF_8);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getZippedXml(){
|
|
||||||
byte[] result = this.xml;
|
|
||||||
if (result != null) {
|
|
||||||
try {
|
try {
|
||||||
result = ZipUtils.bytesToZip(result);
|
final byte[] zip = ZipUtils.bytesToZip(value);
|
||||||
|
this.setZippedXml(zip);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXmlStr(@NotNull String xml) {
|
||||||
|
try {
|
||||||
|
this.setUnzipXml(xml.getBytes(UTF_8));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public byte[] getUnzipXml() {
|
||||||
|
byte[] result = new byte[]{};
|
||||||
|
if (zippedXml != null) {
|
||||||
|
try {
|
||||||
|
final byte[] zip = this.getZippedXml();
|
||||||
|
result = ZipUtils.zipToBytes(zip);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
@ -90,9 +88,18 @@ public class Mindmap {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZippedXml(byte[] xml)
|
@NotNull
|
||||||
throws IOException {
|
public String getXmlStr() throws UnsupportedEncodingException {
|
||||||
this.xml = ZipUtils.zipToBytes(xml);
|
return new String(this.getUnzipXml(), UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public byte[] getZippedXml() {
|
||||||
|
return zippedXml;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZippedXml(@NotNull byte[] value) {
|
||||||
|
this.zippedXml = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Collaboration> getCollaborations() {
|
public Set<Collaboration> getCollaborations() {
|
||||||
@ -143,6 +150,7 @@ public class Mindmap {
|
|||||||
this.isPublic = isPublic;
|
this.isPublic = isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public Calendar getLastModificationTime() {
|
public Calendar getLastModificationTime() {
|
||||||
return lastModificationTime;
|
return lastModificationTime;
|
||||||
}
|
}
|
||||||
@ -282,7 +290,7 @@ public class Mindmap {
|
|||||||
final Mindmap result = new Mindmap();
|
final Mindmap result = new Mindmap();
|
||||||
result.setDescription(this.getDescription());
|
result.setDescription(this.getDescription());
|
||||||
result.setTitle(this.getTitle());
|
result.setTitle(this.getTitle());
|
||||||
result.setXml(this.getXml());
|
result.setUnzipXml(this.getUnzipXml());
|
||||||
result.setTags(this.getTags());
|
result.setTags(this.getTags());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -158,15 +158,10 @@ public class UserServiceImpl
|
|||||||
|
|
||||||
final String mapXml = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/samples/tutorial.vm", model);
|
final String mapXml = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/samples/tutorial.vm", model);
|
||||||
|
|
||||||
try {
|
|
||||||
result.setXmlStr(mapXml);
|
result.setXmlStr(mapXml);
|
||||||
result.setTitle(messageSource.getMessage("WELCOME", null, locale) + " " + firstName);
|
result.setTitle(messageSource.getMessage("WELCOME", null, locale) + " " + firstName);
|
||||||
result.setDescription("");
|
result.setDescription("");
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<property name="title"/>
|
<property name="title"/>
|
||||||
<property name="public"/>
|
<property name="public"/>
|
||||||
<property name="description"/>
|
<property name="description"/>
|
||||||
<property name="zippedXml" column="XML"/>
|
<property name="zippedXml" column="XML" lazy="true"/>
|
||||||
<property name="lastModificationTime" column="edition_date"/>
|
<property name="lastModificationTime" column="edition_date"/>
|
||||||
<property name="creationTime" column="creation_date"/>
|
<property name="creationTime" column="creation_date"/>
|
||||||
<property name="tags" column="tags"/>
|
<property name="tags" column="tags"/>
|
||||||
|
@ -47,7 +47,7 @@ public class ExportFreemindTest {
|
|||||||
private Mindmap load(@NotNull File wisemap) throws IOException {
|
private Mindmap load(@NotNull File wisemap) throws IOException {
|
||||||
final byte[] recContent = FileUtils.readFileToByteArray(wisemap);
|
final byte[] recContent = FileUtils.readFileToByteArray(wisemap);
|
||||||
final Mindmap result = new Mindmap();
|
final Mindmap result = new Mindmap();
|
||||||
result.setXml(recContent);
|
result.setUnzipXml(recContent);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class ExportXsltBasedTest {
|
|||||||
private Mindmap load(@NotNull File wisemap) throws IOException {
|
private Mindmap load(@NotNull File wisemap) throws IOException {
|
||||||
final byte[] recContent = FileUtils.readFileToByteArray(wisemap);
|
final byte[] recContent = FileUtils.readFileToByteArray(wisemap);
|
||||||
final Mindmap result = new Mindmap();
|
final Mindmap result = new Mindmap();
|
||||||
result.setXml(recContent);
|
result.setUnzipXml(recContent);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user