Update to HSQLDB driver

Remove DWR
Remove native SVG tables
Add new REST services for persistence.
This commit is contained in:
Paulo Gustavo Veiga
2012-02-21 14:22:43 -03:00
parent 89f7fd8d3c
commit fb3f9946ae
58 changed files with 419 additions and 624 deletions

View File

@@ -23,15 +23,15 @@ import java.util.Set;
import java.util.HashSet;
public class Colaborator {
public class Collaborator {
private long id;
private String email;
private Calendar creationDate;
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
public Colaborator() {}
public Collaborator() {}
public Colaborator(Set<MindmapUser> mindmapUsers) {
public Collaborator(Set<MindmapUser> mindmapUsers) {
this.mindmapUsers = mindmapUsers;
}

View File

@@ -32,16 +32,17 @@ import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
public class MindMap {
private static final String UTF_8 = "UTF-8";
//~ Instance fields ......................................................................................
final Logger logger = Logger.getLogger(MindMap.class.getName());
private Calendar creationTime;
private String creator;
private String description;
@@ -52,24 +53,12 @@ public class MindMap {
private String lastModifierUser;
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
private MindMapNative nativeBrowser = new MindMapNative();
private User owner;
private String properties;
private String tags;
private String title;
private byte[] xml;
public static void main(String argv[]) {
String xml = "pepe\n hole";
xml = xml.replace("'", "\\'");
xml = xml.replace("\n", "");
xml = xml.trim();
System.out.println("xml:" + xml);
}
//~ Constructors .........................................................................................
public MindMap() {
@@ -85,13 +74,27 @@ public class MindMap {
this.xml = xml;
}
public void setXmlStr(@NotNull String xml)
throws IOException {
this.xml = xml.getBytes(UTF_8);
}
public byte[] getXml() {
return xml;
}
public String getUnzippedXml()
public String getXmlStr() throws UnsupportedEncodingException {
return new String(this.xml, UTF_8);
}
public byte[] getZippedXml()
throws IOException {
return ZipUtils.zipToString(xml);
return ZipUtils.stringToZip(new String(this.xml, UTF_8));
}
public void setZippedXml(byte[] xml)
throws IOException {
this.xml = ZipUtils.zipToString(xml).getBytes(UTF_8);
}
public void setProperties(String properties) {
@@ -117,8 +120,8 @@ public class MindMap {
this.mindmapUsers = mindmapUsers;
}
public void addMindmapUser(MindmapUser mindmaUser) {
mindmapUsers.add(mindmaUser);
public void addMindmapUser(MindmapUser mindmapUser) {
mindmapUsers.add(mindmapUser);
}
public boolean isPublic() {
@@ -173,15 +176,9 @@ public class MindMap {
this.title = title;
}
public String getNativeXml()
public String getXmlAsJsLiteral()
throws IOException {
return getUnzippedXml();
}
public String getNativeXmlAsJsLiteral()
throws IOException {
String xml = getNativeXml();
String xml = this.getXmlStr();
if (xml != null) {
xml = xml.replace("'", "\\'");
xml = xml.replaceAll("\\r|\\n", "");
@@ -190,10 +187,6 @@ public class MindMap {
return xml;
}
public void setNativeXml(@NotNull String nativeXml)
throws IOException {
this.xml = ZipUtils.stringToZip(nativeXml);
}
public void setTags(String tags) {
this.tags = tags;
@@ -226,12 +219,4 @@ public class MindMap {
public User getOwner() {
return owner;
}
public MindMapNative getNativeBrowser() {
return nativeBrowser;
}
public void setNativeBrowser(MindMapNative nativeBrowser) {
this.nativeBrowser = nativeBrowser;
}
}

View File

@@ -75,10 +75,4 @@ public class MindMapHistory {
public void setXml(byte[] xml) {
this.xml = xml;
}
public String getNativeXml()
throws IOException
{
return ZipUtils.zipToString(xml);
}
}

View File

@@ -1,79 +0,0 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.model;
import com.wisemapping.util.ZipUtils;
import java.io.IOException;
/**
* This class contains the SVG and VML representation of the MindMap
*/
public class MindMapNative {
private int id;
private byte[] svgXml;
private byte[] vmlXml;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public byte[] getSvgXml() {
return svgXml;
}
public void setSvgXml(byte[] svgXml) {
this.svgXml = svgXml;
}
public byte[] getVmlXml() {
return vmlXml;
}
public void setVmlXml(byte[] vmlXml) {
this.vmlXml = vmlXml;
}
public String getUnzippedVmlXml()
throws IOException
{
return ZipUtils.zipToString(vmlXml);
}
public String getUnzippedSvgXml()
throws IOException
{
return ZipUtils.zipToString(svgXml);
}
public void setVmlXml(String xml) throws IOException {
// compress and set
vmlXml = ZipUtils.stringToZip(xml);
}
public void setSvgXml(String xml) throws IOException {
// compress and set
svgXml = ZipUtils.stringToZip(xml);
}
}

View File

@@ -23,19 +23,19 @@ public class MindmapUser {
private int id;
private int roleId;
private MindMap mindMap;
private Colaborator colaborator;
private Collaborator collaborator;
public MindmapUser(){ }
public MindmapUser(int role, Colaborator colaborator , MindMap mindmap)
public MindmapUser(int role, Collaborator collaborator, MindMap mindmap)
{
this.roleId = role;
this.mindMap =mindmap;
this.colaborator = colaborator;
this.collaborator = collaborator;
// Guarantee referential integrity
mindmap.addMindmapUser(this);
colaborator.addMindmapUser(this);
collaborator.addMindmapUser(this);
}
public int getId() {
@@ -78,11 +78,11 @@ public class MindmapUser {
this.mindMap = mindMap;
}
public Colaborator getColaborator() {
return colaborator;
public Collaborator getCollaborator() {
return collaborator;
}
public void setColaborator(Colaborator colaborator) {
this.colaborator = colaborator;
public void setCollaborator(Collaborator collaborator) {
this.collaborator = collaborator;
}
}

View File

@@ -22,12 +22,12 @@ import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.*;
@XmlRootElement(name="user")
@XmlRootElement(name = "user")
public class User
extends Colaborator
implements Serializable
{
extends Collaborator
implements Serializable {
private static final String ADMIN_EMAIL = "test@wisemapping.org";
private String firstname;
private String lastname;
private String password;
@@ -40,13 +40,11 @@ public class User
public User() {
}
public void setTags(Set<String> tags)
{
public void setTags(Set<String> tags) {
this.tags = tags;
}
public Set<String> getTags()
{
public Set<String> getTags() {
return tags;
}
@@ -94,20 +92,17 @@ public class User
return activationDate;
}
public boolean isAllowSendEmail()
{
public boolean isAllowSendEmail() {
return allowSendEmail;
}
public void setAllowSendEmail(boolean allowSendEmail)
{
public void setAllowSendEmail(boolean allowSendEmail) {
this.allowSendEmail = allowSendEmail;
}
public boolean getAllowSendEmail()
{
public boolean getAllowSendEmail() {
return allowSendEmail;
}
}
public boolean equals(Object o) {
if (this == o) return true;
@@ -139,4 +134,8 @@ public class User
public void setUsername(String username) {
this.username = username;
}
public boolean isAdmin() {
return ADMIN_EMAIL.equals(this.getEmail());
}
}