# HG changeset patch # User shoshi # Date 1296545329 -32400 # Node ID a72718a0bccf6888e1df6c7ae95eec1d4fdd7f48 # Parent d12e1f578c9ae23338a3a8b1aaab3a60ef711415 added demo tree builder diff -r d12e1f578c9a -r a72718a0bccf contents/cat.jpeg Binary file contents/cat.jpeg has changed diff -r d12e1f578c9a -r a72718a0bccf src/treecms/demo/ContentsTreeBuilder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/demo/ContentsTreeBuilder.java Tue Feb 01 16:28:49 2011 +0900 @@ -0,0 +1,108 @@ +package treecms.demo; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.nio.ByteBuffer; +import java.util.Calendar; + +import org.apache.commons.codec.binary.Base64; + +import treecms.proto.api.Node; +import treecms.proto.simple.SimpleBrowser; + +public class ContentsTreeBuilder +{ + public static Node blogSite() throws Exception + { + Node root = SimpleBrowser.getSingleton().useContents(); + root.setTitle("ブログ形式サイト"); + + //contents + Node contents = root.createNode(); + root.addChild(contents); + contents.setTitle("contents"); + + //contents - 2009年12月 + Node y09m12 = root.createNode(); + contents.addChild(y09m12); + y09m12.setTitle("2009年12月"); + + //contents - 2009年12月 - 今日はレクチャの日です + Node lecture = root.createNode(); + y09m12.addChild(lecture); + lecture.setTitle("今日はレクチャの日です"); + lecture.setAttribute("layout","Blog/Main/BlogPage"); + lecture.setAttribute("publish_date","2009-12-22-00-00-00"); + + //contents - 2009年12月 - 今日はレクチャの日です - 本文 + Node body = root.createNode(); + lecture.addChild(body); + body.setTitle("本文"); + body.setAttribute("data","今日は二子玉川のオフィスでレイアウトの練習をしています。\n難しそうです。\nたいへんです。\n困ったです。"); + + //contents - 2009年12月 - 今日はレクチャの日です - 画像 + File picFile = new File("contents/cat.jpeg"); + byte buf[] = new byte[(int)picFile.length()]; + FileInputStream in = new FileInputStream(picFile); + in.read(buf); + in.close(); + + String base64 = new String(Base64.encodeBase64(buf)); + + Node pic = root.createNode(); + lecture.addChild(pic); + pic.setTitle("画像"); + pic.setAttribute("data",base64); + + //contents - 2010年01月 + Node y10m01 = root.createNode(); + contents.addChild(y10m01); + y10m01.setTitle("2010年1月"); + + //contents - 2010年01月 - 整体 + Node seitai = root.createNode(); + y10m01.addChild(seitai); + seitai.setTitle("整体"); + seitai.setAttribute("layout","Blog/Main/BlogPage"); + seitai.setAttribute("publish_date","2009-01-05-00-00-00"); + + //contents - 2010年01月 - 整体 - 本文 + Node bSeitai = root.createNode(); + seitai.addChild(bSeitai); + bSeitai.setTitle("本文"); + bSeitai.setAttribute("data","今日は整体の先生のところへ行きました。昨年 11 月に腰を痛めてから、ずっと通っています。歩けなくなったのが 3 日で一応歩けるようになりました。でも朝とか痛いし、重い物もてないし、台所にずっと立ってるのがつらいんです。"); + + //contents - 2010年01月 - 仕事始め + Node hajime = root.createNode(); + y10m01.addChild(hajime); + hajime.setTitle("仕事始め"); + hajime.setAttribute("layout","Blog/Main/BlogPage"); + lecture.setAttribute("publish_date","2009-01-07-00-00-00"); + + //contents - 2010年01月 - 仕事始め - 本文 + Node bHajime = root.createNode(); + hajime.addChild(bHajime); + bHajime.setTitle("本文"); + bHajime.setAttribute("data","なんかひどい一日でした。\n佐野厄除け大師の電車広告によると、今年はなんとか厄みたいなんで、ちょっといやだなぁ。"); + + + //comments + Node comments = root.createNode(); + root.addChild(comments); + comments.setTitle("comments"); + + //application + Node application = root.createNode(); + root.addChild(application); + application.setTitle("#APPLICATION"); + + //application - css + Node css = root.createNode(); + application.addChild(css); + css.setTitle("css"); + css.setAttribute("data","#header {background-image: url(/cgi-bin/WebObjects/Atropos_TRAIN.woa/wa/imageP/12606f53c0b);}"); + + return root; + } +} diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/CassBrowser.java --- a/src/treecms/proto/cassandra/CassBrowser.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/cassandra/CassBrowser.java Tue Feb 01 16:28:49 2011 +0900 @@ -14,7 +14,6 @@ import treecms.proto.api.NodeID; import org.apache.thrift.transport.TTransport; -import org.apache.thrift.transport.TFramedTransport; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransportException; import org.apache.thrift.protocol.TProtocol; @@ -25,6 +24,7 @@ import org.apache.cassandra.thrift.ColumnPath; import org.apache.cassandra.thrift.ConsistencyLevel; import org.apache.cassandra.thrift.KeySlice; +import org.apache.cassandra.thrift.NotFoundException; import org.apache.cassandra.thrift.SlicePredicate; import org.apache.cassandra.thrift.SliceRange; @@ -36,14 +36,52 @@ public static final String TREEINFO = "TreeInfo"; public static final String ROOTNODE = "RootNode"; - + public static final String MARKER = "Marker"; // because of can't create null row entry. public static final String CLASSNAME = "ClassName"; public static final String TITLE = "Title"; public static final String CHILDREN = "Children"; + public static final String LINKUUID = "LinkUUID"; public static final String CHILDREN_DELIM = ","; private static final String ATTR_PREFIX = "_"; + public static void main(String _args[]) + { + CassBrowser cass = CassBrowser.createInstance("localhost","9160","TreeCMSKS","TreeCMSCF03"); + Node node = cass.useContents(); + node.setTitle("fugafuga"); + node.setClassName("hogehoge"); + + node.setAttribute("fuga","higa"); + node.setAttribute("Title","higa"); + + System.out.println(node.getTitle()); + + for(String key : node.getAttributeKeys()){ + System.out.println(key); + System.out.println(node.getAttribute(key)); + } + + Node clone = node.cloneNode(); + System.out.println(clone.getID().toString()); + clone.setTitle("cloned1"); + + LinkedList children = new LinkedList(); + Node child1 = clone.createNode(); + child1.setTitle("fugafuga"); + children.add(child1); + Node child2 = clone.createNode(); + child1.setTitle("hugahuga"); + children.add(child2); + + clone.addChildren(children); + + Node child3 = clone.createNode(); + child3.setTitle("xfgafuga"); + + clone.addChild(child3); + } + private CassBrowser(String _host,String _port) throws TTransportException { m_host = _host; @@ -53,6 +91,37 @@ connect(); } + private boolean initialize() + { + try{ + ColumnPath column = new ColumnPath(); + column.column_family = m_colFamily; + column.column = ROOTNODE.getBytes(); + + m_cassandra.get(m_keySpace,TREEINFO,column,ConsistencyLevel.ALL); + + }catch(NotFoundException _e){ + _e.printStackTrace(); + System.out.println("Initializing ColumFamily["+m_colFamily+"]"); + + Node root = createNode(); + ColumnPath path = new ColumnPath(); + path.column = ROOTNODE.getBytes(); + path.column_family = m_colFamily; + + try { + m_cassandra.insert(m_keySpace,TREEINFO,path,root.getID().getUUID().getBytes(),System.currentTimeMillis()/1000,ConsistencyLevel.ALL); + }catch(Exception _e2){ + _e2.printStackTrace(); + return false; + } + }catch(Exception _e){ + _e.printStackTrace(); + } + + return true; + } + public Cassandra.Client getClient() { return m_cassandra; @@ -68,17 +137,18 @@ return m_colFamily; } - public synchronized void connect() throws TTransportException + public synchronized void connect() throws TTransportException { if(m_cassandra != null && m_cassandra.getOutputProtocol().getTransport().isOpen()){ return; } - TTransport tr = new TFramedTransport(new TSocket(m_host,Integer.parseInt(m_port))); + TTransport tr = new TSocket(m_host,Integer.parseInt(m_port)); TProtocol proto = new TBinaryProtocol(tr); m_cassandra = new Cassandra.Client(proto); tr.open(); + } public static CassBrowser createInstance(String _host,String _port,String _ks,String _cf) @@ -88,6 +158,9 @@ browser = new CassBrowser(_host,_port); browser.m_keySpace = _ks; browser.m_colFamily = _cf; + if(!browser.initialize()){ + return null; + } }catch(Exception _err){ _err.printStackTrace(); } @@ -113,26 +186,21 @@ StringBuffer buf = new StringBuffer(children); - if(!set.isEmpty()){ + if(buf.length() != 0){ buf.append(CHILDREN_DELIM); } - for(int i = 0;i < _children.size() - 1;i ++){ + String prefix = ""; + for(int i = 0;i < _children.size();i ++){ String key = _children.get(i).getID().toString(); if(set.get(key) != null){ return; } - buf.append(key).append(CHILDREN_DELIM); + buf.append(prefix).append(key); + prefix = CHILDREN_DELIM; } - String key = _children.get(_children.size() - 1).getID().toString(); - if(set.get(key) != null){ - return; - } - - buf.append(key); - setColumn(_id.toString(),CHILDREN,buf.toString()); } @@ -146,7 +214,8 @@ String raw = getChildrenRaw(_id); StringTokenizer token = new StringTokenizer(raw,CHILDREN_DELIM); - CharBuffer buf = CharBuffer.allocate(raw.length()); + //CharBuffer buf = CharBuffer.allocate(raw.length()); + StringBuffer buf = new StringBuffer(); boolean changed = false; @@ -181,26 +250,25 @@ public void replace(NodeID _id,Node _child1,Node _child2) { String children = getChildrenRaw(_id); - CharBuffer buf = CharBuffer.allocate(children.length()); + //CharBuffer buf = CharBuffer.allocate(children.length()); + StringBuffer buf = new StringBuffer(); StringTokenizer tokens = new StringTokenizer(children,CHILDREN_DELIM); - int flagSuccess = 0; + boolean flag = false; String id1 = _child1.getID().toString(); String id2 = _child2.getID().toString(); for(String prefix = "";tokens.hasMoreElements();prefix = CHILDREN_DELIM){ String token = tokens.nextToken(); if(token.equals(id1)){ buf.append(prefix+id2); - flagSuccess++; - }else if(token.equals(id2)){ - buf.append(prefix+id1); - flagSuccess++; + flag = true; }else{ buf.append(prefix+token); } } - if(flagSuccess == 2){ + if(flag){ +// setColumn(_id.toString(),CHILDREN,new String(buf.array())); setColumn(_id.toString(),CHILDREN,buf.toString()); } } @@ -209,20 +277,27 @@ { String children = getChildrenRaw(_id); String id = _child.getID().toString(); - CharBuffer buf = CharBuffer.allocate(children.length()); + //CharBuffer buf = CharBuffer.allocate(children.length()); + StringBuffer buf = new StringBuffer(); StringTokenizer tokens = new StringTokenizer(children,CHILDREN_DELIM); for(String prefix = "";tokens.hasMoreElements();prefix = CHILDREN_DELIM){ String token = tokens.nextToken(); if(token.equals(id)){ if(tokens.hasMoreElements()){ - buf.append(prefix+tokens.nextToken()); - prefix = CHILDREN_DELIM; + String next = tokens.nextToken(); + buf.append(prefix+next); + buf.append(CHILDREN_DELIM+_child.getID().toString()); + }else{ + buf.append(prefix+_child.getID().toString()); } + continue; } + buf.append(prefix+token); } + //setColumn(_id.toString(),CHILDREN,new String(buf.array())); setColumn(_id.toString(),CHILDREN,buf.toString()); } @@ -230,27 +305,25 @@ { String children = getChildrenRaw(_id); String id = _child.getID().toString(); - CharBuffer buf = CharBuffer.allocate(children.length()); + //CharBuffer buf = CharBuffer.allocate(children.length()); + StringBuffer buf = new StringBuffer(); StringTokenizer tokens = new StringTokenizer(children,CHILDREN_DELIM); - String prev = null; - String prefix = ""; + int diff = 0; while(tokens.hasMoreElements()){ - if(prev == null){ - prev = tokens.nextToken(); - continue; + String token = tokens.nextToken(); + if(token.equals(id)){ + int size = buf.length(); + buf.insert(size - diff,CHILDREN_DELIM+token); + }else{ + buf.append(CHILDREN_DELIM+token); } - String token = tokens.nextToken(); - if(token.equals(id)){ - buf.append(prefix+prev); - prev = token; - }else{ - buf.append(prefix+prev); - } + diff = buf.length() - diff; + } - prefix = CHILDREN_DELIM; - } + String result = buf.toString().substring(1); + setColumn(_id.toString(),CHILDREN,result); } public void setClassName(NodeID _id,String _className) @@ -260,7 +333,19 @@ public Node createNode() { - return new CassNode(this,new CassDecNodeID(this)); + NodeID newID = new CassDecNodeID(this); + + try{ + ColumnPath path = new ColumnPath(); + path.column_family = m_colFamily; + path.column = MARKER.getBytes(); + + m_cassandra.insert(m_keySpace,newID.toString(),path,"null".getBytes(),System.currentTimeMillis()/1000,ConsistencyLevel.ALL); + }catch(Exception _e){ + _e.printStackTrace(); + } + + return new CassNode(this,newID); } public List getChildren(NodeID _id) @@ -294,11 +379,11 @@ sp.setSlice_range(sr); try{ - List columns = m_cassandra.get_slice(m_keySpace,_id.toString(),new ColumnParent(m_colFamily),sp,ConsistencyLevel.ONE); + List columns = m_cassandra.get_slice(m_keySpace,_id.toString(),new ColumnParent(m_colFamily),sp,ConsistencyLevel.ALL); Map> cfmap = new HashMap>(); cfmap.put(m_colFamily,columns); - m_cassandra.batch_insert(m_keySpace,newID.toString(),cfmap,ConsistencyLevel.ONE); + m_cassandra.batch_insert(m_keySpace,newID.toString(),cfmap,ConsistencyLevel.ALL); }catch(Exception _e){ _e.printStackTrace(); } @@ -308,7 +393,10 @@ public CassLink createLink(NodeID _id) { - return new CassLink(new CassDecNodeID(this),_id,this); + //must create link entries on cassandra + Node link = createNode(); + setNode(link.getID(),_id); + return new CassLink(link.getID(),this); } public boolean isChild(NodeID _id,Node _child) @@ -327,7 +415,11 @@ public String getChildrenRaw(NodeID _id) { - return getColumn(_id.toString(),CHILDREN); + String res = getColumn(_id.toString(),CHILDREN); + if(res == null){ + return ""; + } + return res; } public String getTitle(NodeID _id) @@ -362,11 +454,11 @@ sp.setSlice_range(sr); try{ - List columns = m_cassandra.get_slice(m_keySpace,_id.toString(),new ColumnParent(m_colFamily),sp,ConsistencyLevel.ONE); + List columns = m_cassandra.get_slice(m_keySpace,_id.toString(),new ColumnParent(m_colFamily),sp,ConsistencyLevel.ALL); for(ColumnOrSuperColumn column : columns){ String key = new String(column.column.name); if(key.startsWith(ATTR_PREFIX)){ - attrs.add(key); + attrs.add(key.replace(ATTR_PREFIX,"")); } } }catch(Exception _e){ @@ -386,7 +478,7 @@ slicePredicate.setSlice_range(sliceRange); try { - List values = m_cassandra.get_range_slice(m_keySpace,new ColumnParent(m_colFamily),slicePredicate,"","",1,ConsistencyLevel.ONE); + List values = m_cassandra.get_range_slice(m_keySpace,new ColumnParent(m_colFamily),slicePredicate,_uuid,"",1,ConsistencyLevel.ALL); String key = values.get(0).getKey(); String tip = key.replaceFirst((_uuid+"@").intern(),""); @@ -404,11 +496,11 @@ path.column_family = m_colFamily; path.column = _colName.getBytes(); - String value = null; + String value = ""; try{ ColumnOrSuperColumn column; - column = m_cassandra.get(m_keySpace,_row,path,ConsistencyLevel.ONE); - value = column.column.toString(); + column = m_cassandra.get(m_keySpace,_row,path,ConsistencyLevel.ALL); + value = new String(column.column.value); }catch(Exception _e){ _e.printStackTrace(); } @@ -423,7 +515,7 @@ path.column = _colName.getBytes(); try{ - m_cassandra.insert(m_keySpace,_row,path,_value.getBytes(),System.currentTimeMillis()/1000,ConsistencyLevel.ONE); + m_cassandra.insert(m_keySpace,_row,path,_value.getBytes(),System.currentTimeMillis()/1000,ConsistencyLevel.ALL); return true; }catch(Exception _e){ _e.printStackTrace(); @@ -444,4 +536,16 @@ NodeID rootID = getTipIDFromUUID(uuid); return new CassNode(this,rootID); } + + public Node getNode(NodeID m_id) + { + String uuid = getColumn(m_id.toString(),LINKUUID); + NodeID id = getTipIDFromUUID(uuid); + return new CassNode(this,id); + } + + public void setNode(NodeID m_id,NodeID _link) + { + setColumn(m_id.toString(),LINKUUID,_link.getUUID()); + } } diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/CassDecNodeID.java --- a/src/treecms/proto/cassandra/CassDecNodeID.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/cassandra/CassDecNodeID.java Tue Feb 01 16:28:49 2011 +0900 @@ -1,7 +1,6 @@ package treecms.proto.cassandra; import java.util.UUID; - import treecms.proto.api.NodeID; import treecms.proto.id.DecrementalNodeID; @@ -35,7 +34,11 @@ @Override public NodeID getTip() { - return m_cassandra.getTipIDFromUUID(m_uuid); + NodeID tip = m_cassandra.getTipIDFromUUID(m_uuid); + if(tip == null){ + return this; + } + return tip; } @Override @@ -53,6 +56,6 @@ @Override public NodeID update() { - return null; + return new CassDecNodeID(m_cassandra,m_uuid,m_version - 1); } } diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/CassEditor.java --- a/src/treecms/proto/cassandra/CassEditor.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/cassandra/CassEditor.java Tue Feb 01 16:28:49 2011 +0900 @@ -20,6 +20,7 @@ public CassEditor(Browser _browser) { + m_browser = _browser; update(); } diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/CassLink.java --- a/src/treecms/proto/cassandra/CassLink.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/cassandra/CassLink.java Tue Feb 01 16:28:49 2011 +0900 @@ -11,14 +11,12 @@ public class CassLink implements Link { private NodeID m_id; - private NodeID m_target; private CassBrowser m_browser; - public CassLink(NodeID _id,NodeID _target,CassBrowser _browser) + public CassLink(NodeID _id,CassBrowser _browser) { m_id = _id; - m_target = _target; m_browser = _browser; } @@ -26,13 +24,13 @@ @Override public Node getNode() { - return m_browser.getNodeByID(m_target.getTip()); + return m_browser.getNode(m_id); } @Override public void setNode(Node _link) { - m_target = _link.getID(); + m_browser.setNode(m_id,_link.getID()); } @Override diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/CassNode.java --- a/src/treecms/proto/cassandra/CassNode.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/cassandra/CassNode.java Tue Feb 01 16:28:49 2011 +0900 @@ -40,6 +40,11 @@ getBrowser().addChildren(m_id,_children); } + public String toString() + { + return getTitle()+"["+getID().toString()+"]"; + } + @Override public void clearChildren() { diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/test/CassGetSliceTest.java --- a/src/treecms/proto/cassandra/test/CassGetSliceTest.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/cassandra/test/CassGetSliceTest.java Tue Feb 01 16:28:49 2011 +0900 @@ -46,8 +46,8 @@ tr.open(); System.out.println("ClusterName = "+client.describe_cluster_name()); - //testGetRangeSlice(client); - testBatchInsert(client); + testGetRangeSlice(client); + //testBatchInsert(client); tr.close(); } @@ -118,7 +118,7 @@ SlicePredicate slicePredicate = new SlicePredicate(); slicePredicate.setSlice_range(sliceRange); - List values = _client.get_slice("TreeCMSKS","uuid@01",new ColumnParent("TreeCMSCF01"),slicePredicate,ConsistencyLevel.ONE); + List values = _client.get_slice("TreeCMSKS","",new ColumnParent("TreeCMSCF03"),slicePredicate,ConsistencyLevel.ONE); for(ColumnOrSuperColumn value : values){ System.out.println(new String(value.column.getName())+":"+new String(value.column.getValue())); @@ -134,7 +134,7 @@ SlicePredicate slicePredicate = new SlicePredicate(); slicePredicate.setSlice_range(sliceRange); - List values = _client.get_range_slice("TreeCMSKS",new ColumnParent("TreeCMSCF02"),slicePredicate,"hogehoge","hogehogea",100,ConsistencyLevel.ONE); + List values = _client.get_range_slice("TreeCMSKS",new ColumnParent("TreeCMSCF03"),slicePredicate,"","",100,ConsistencyLevel.ONE); for(KeySlice key : values){ System.out.println(new String(key.getKey())); diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/test/CassLinkTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/cassandra/test/CassLinkTest.java Tue Feb 01 16:28:49 2011 +0900 @@ -0,0 +1,19 @@ +package treecms.proto.cassandra.test; + +import org.junit.runner.JUnitCore; + +import treecms.proto.cassandra.CassBrowser; +import treecms.proto.test.LinkTest; + +public class CassLinkTest extends LinkTest +{ + public static void main(String _arg[]) + { + JUnitCore.main(CassLinkTest.class.getName()); + } + + public CassLinkTest() + { + super(CassBrowser.createInstance("localhost","9160","TreeCMSKS","TreeCMSCF03").useContents()); + } +} diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/cassandra/test/CassNodeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/cassandra/test/CassNodeTest.java Tue Feb 01 16:28:49 2011 +0900 @@ -0,0 +1,20 @@ +package treecms.proto.cassandra.test; + + +import org.junit.runner.JUnitCore; + +import treecms.proto.cassandra.CassBrowser; +import treecms.proto.test.NodeTest; + +public class CassNodeTest extends NodeTest +{ + public static void main(String _args[]) + { + JUnitCore.main(CassNodeTest.class.getName()); + } + + public CassNodeTest() + { + super(CassBrowser.createInstance("localhost","9160","TreeCMSKS","TreeCMSCF03").useContents()); + } +} \ No newline at end of file diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/gui/GraphicalMonotonicTreeEditor.java --- a/src/treecms/proto/gui/GraphicalMonotonicTreeEditor.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/gui/GraphicalMonotonicTreeEditor.java Tue Feb 01 16:28:49 2011 +0900 @@ -21,18 +21,21 @@ import javax.swing.table.DefaultTableModel; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; - import treecms.proto.api.Editor; import treecms.proto.api.Node; -import treecms.proto.simple.SimpleEditor; +import treecms.proto.cassandra.CassBrowser; +import treecms.proto.cassandra.CassEditor; public class GraphicalMonotonicTreeEditor extends JFrame { private static final long serialVersionUID = 1095393471116557554L; - public static void main(String _args[]) + public static void main(String _args[]) throws Exception { - new GraphicalMonotonicTreeEditor(new SimpleEditor()); + CassBrowser browser = CassBrowser.createInstance("localhost","9160","TreeCMSKS","TreeCMSCF03"); + new GraphicalMonotonicTreeEditor(new CassEditor(browser)); + //ContentsTreeBuilder.blogSite(); + //new GraphicalMonotonicTreeEditor(new SimpleEditor()); } private static final String WINDOW_TITLE = "Monotonic-Tree Editor"; diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/id/DecrementalNodeID.java --- a/src/treecms/proto/id/DecrementalNodeID.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/id/DecrementalNodeID.java Tue Feb 01 16:28:49 2011 +0900 @@ -24,7 +24,7 @@ @Override public String toString() { - return getUUID()+"@"+getVersion(); + return getUUID()+"@"+String.format("%06d",Long.parseLong(getVersion())); } @Override diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/test/LinkTest.java --- a/src/treecms/proto/test/LinkTest.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/test/LinkTest.java Tue Feb 01 16:28:49 2011 +0900 @@ -13,7 +13,7 @@ public LinkTest(Node _node) { - m_node = _node; + m_node = _node.createNode(); } @Test diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/test/NodeTest.java --- a/src/treecms/proto/test/NodeTest.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/test/NodeTest.java Tue Feb 01 16:28:49 2011 +0900 @@ -14,7 +14,7 @@ protected NodeTest(Node _node) { - m_node = _node; + m_node = _node.createNode(); } @Test @@ -62,9 +62,9 @@ List children = m_node.getChildren(); Assert.assertEquals(children.size(),3); - Assert.assertEquals(children.get(0),child1); - Assert.assertEquals(children.get(1),child2); - Assert.assertEquals(children.get(2),child3); + Assert.assertEquals(children.get(0).getID().equals(child1.getID()),true); + Assert.assertEquals(children.get(1).getID().equals(child2.getID()),true); + Assert.assertEquals(children.get(2).getID().equals(child3.getID()),true); } @Test @@ -81,8 +81,8 @@ m_node.removeChild(child2); List children = m_node.getChildren(); - Assert.assertEquals(children.get(0),child1); - Assert.assertEquals(children.get(1),child3); + Assert.assertEquals(children.get(0).getID().equals(child1.getID()),true); + Assert.assertEquals(children.get(1).getID().equals(child3.getID()),true); } @Test @@ -98,9 +98,9 @@ m_node.up(child2); List children = m_node.getChildren(); - Assert.assertEquals(children.get(0),child2); - Assert.assertEquals(children.get(1),child1); - Assert.assertEquals(children.get(2),child3); + Assert.assertEquals(children.get(0).getID().equals(child2.getID()),true); + Assert.assertEquals(children.get(1).getID().equals(child1.getID()),true); + Assert.assertEquals(children.get(2).getID().equals(child3.getID()),true); } @Test @@ -115,9 +115,9 @@ m_node.down(child2); List children = m_node.getChildren(); - Assert.assertEquals(children.get(0),child1); - Assert.assertEquals(children.get(1),child3); - Assert.assertEquals(children.get(2),child2); + Assert.assertEquals(children.get(0).getID().equals(child1.getID()),true); + Assert.assertEquals(children.get(1).getID().equals(child3.getID()),true); + Assert.assertEquals(children.get(2).getID().equals(child2.getID()),true); } @Test @@ -134,9 +134,9 @@ m_node.replace(child2,node); List children = m_node.getChildren(); - Assert.assertEquals(children.get(0),child1); - Assert.assertEquals(children.get(1),node); - Assert.assertEquals(children.get(2),child3); + Assert.assertEquals(children.get(0).getID().equals(child1.getID()),true); + Assert.assertEquals(children.get(1).getID().equals(node.getID()),true); + Assert.assertEquals(children.get(2).getID().equals(child3.getID()),true); } @Test diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/test/StringConcatTest.java --- a/src/treecms/proto/test/StringConcatTest.java Sun Jan 30 21:22:27 2011 +0900 +++ b/src/treecms/proto/test/StringConcatTest.java Tue Feb 01 16:28:49 2011 +0900 @@ -23,6 +23,7 @@ for(int i = 0;i < 1000;i ++){ buffer.append(m_str); } + System.out.println(new String(buffer.array())); } } diff -r d12e1f578c9a -r a72718a0bccf src/treecms/proto/util/NodeUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/util/NodeUtil.java Tue Feb 01 16:28:49 2011 +0900 @@ -0,0 +1,11 @@ +package treecms.proto.util; + +import treecms.proto.api.Node; + +public class NodeUtil +{ + public static boolean compareNode(Node node1,Node node2) + { + return true; + } +}