comparison src/test/java/alice/jungle/log/example/StartCodeSegment.java @ 82:60d28fedcbf2

Remove unnecessary files and move some files
author one
date Wed, 16 Oct 2013 20:53:44 +0900
parents src/jungle/test/codesegment/log/practice/StartCodeSegment.java@87ec5dd0dc27
children f9e29a52efd3
comparison
equal deleted inserted replaced
81:b9dd8ec0e66e 82:60d28fedcbf2
1 package test.java.alice.jungle.log.example;
2
3 import java.io.IOException;
4 import java.nio.ByteBuffer;
5 import java.util.LinkedList;
6 import java.util.List;
7
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath;
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog;
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation;
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DefaultTreeOperation;
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation;
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation;
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
16 import alice.codesegment.CodeSegment;
17 import alice.jungle.datasegment.store.container.DefaultTreeOperationLogContainer;
18
19 public class StartCodeSegment extends CodeSegment {
20
21 @Override
22 public void run() {
23 System.out.println("run StartCodeSegment");
24
25 TestCodeSegment cs = new TestCodeSegment();
26 cs.arg1.setKey("log");
27 System.out.println("create TestCodeSegment");
28
29 DefaultTreeOperationLog log = getSampleOperationLog();
30 DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer();
31 try {
32 logContainer.unconvert(log);
33 ods.update("local", "log", logContainer);
34 } catch (IOException e) {
35 e.printStackTrace();
36 }
37 }
38
39 public DefaultTreeOperationLog getSampleOperationLog() {
40 String key = "hoge";
41 ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes());
42 DefaultNodePath nodePath1 = new DefaultNodePath();
43 nodePath1 = nodePath1.add(1);
44 DefaultNodePath nodePath2 = nodePath1.add(2);
45 AppendChildAtOperation appendChildOp1 = new AppendChildAtOperation(1);
46 AppendChildAtOperation appendChildOp2 = new AppendChildAtOperation(2);
47 PutAttributeOperation putOp = new PutAttributeOperation(key, b);
48 DeleteAttributeOperation deleteOp = new DeleteAttributeOperation("hoge");
49 DeleteChildAtOperation deleteChild = new DeleteChildAtOperation(2);
50 List<TreeOperation> list = new LinkedList<TreeOperation>();
51 list.add(new DefaultTreeOperation(new DefaultNodePath(), appendChildOp1));
52 list.add(new DefaultTreeOperation(nodePath1, appendChildOp2));
53 list.add(new DefaultTreeOperation(nodePath2, putOp));
54 list.add(new DefaultTreeOperation(nodePath2, deleteOp));
55 list.add(new DefaultTreeOperation(nodePath1, deleteChild));
56 DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size());
57 return log;
58 }
59
60 }