2
|
1 package jungle.test.codesegment.practice;
|
|
2
|
9
|
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 jungle.test.datasegment.store.operations.DefaultTreeOperationLogContainer;
|
2
|
17 import alice.codesegment.CodeSegment;
|
|
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();
|
9
|
26 cs.arg1.setKey("log");
|
2
|
27 System.out.println("create TestCodeSegment");
|
9
|
28
|
|
29 String key = "hoge";
|
|
30 ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes());
|
|
31 DefaultNodePath nodePath1 = new DefaultNodePath();
|
|
32 nodePath1 = nodePath1.add(1);
|
|
33 DefaultNodePath nodePath2 = nodePath1.add(2);
|
|
34 AppendChildAtOperation appendChildOp = new AppendChildAtOperation(1);
|
|
35 PutAttributeOperation putOp = new PutAttributeOperation(key, b);
|
|
36 DeleteAttributeOperation deleteOp = new DeleteAttributeOperation("hoge");
|
|
37 DeleteChildAtOperation deleteChild = new DeleteChildAtOperation(2);
|
|
38 List<TreeOperation> list = new LinkedList<TreeOperation>();
|
|
39 list.add(new DefaultTreeOperation(nodePath1, appendChildOp));
|
|
40 list.add(new DefaultTreeOperation(nodePath2, appendChildOp));
|
|
41 list.add(new DefaultTreeOperation(nodePath2, putOp));
|
|
42 list.add(new DefaultTreeOperation(nodePath2, deleteOp));
|
|
43 list.add(new DefaultTreeOperation(nodePath1, deleteChild));
|
|
44 DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size());
|
2
|
45
|
9
|
46 DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer();
|
|
47 try {
|
|
48 logContainer.unconvert(log);
|
|
49 ods.update("local", "log", logContainer);
|
|
50 } catch (IOException e) {
|
|
51 e.printStackTrace();
|
|
52 }
|
2
|
53 }
|
|
54
|
|
55 }
|