annotate src/alice/jungle/codesegment/LogUpdateCodeSegment.java @ 40:7e94de2d6bc0

add PutAnotherLogCodeSegment, PutHostLogCodeSegment
author one
date Tue, 09 Jul 2013 17:32:06 +0900
parents 10359a815068
children 4419ac56cbfd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
34
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
1 package alice.jungle.codesegment;
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
2
40
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
3 import java.io.IOException;
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
4
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree;
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor;
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog;
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
10 import jungle.test.bbs.JungleManager;
34
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
11 import alice.codesegment.CodeSegment;
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
12 import alice.datasegment.CommandType;
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
13 import alice.datasegment.Receiver;
40
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
14 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer;
34
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
15
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
16 public class LogUpdateCodeSegment extends CodeSegment {
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
17
39
10359a815068 add alice.jungle.codesegment.remote
one
parents: 34
diff changeset
18 public Receiver arg1 = ids.create(CommandType.TAKE);
10359a815068 add alice.jungle.codesegment.remote
one
parents: 34
diff changeset
19
10359a815068 add alice.jungle.codesegment.remote
one
parents: 34
diff changeset
20 public LogUpdateCodeSegment() {
10359a815068 add alice.jungle.codesegment.remote
one
parents: 34
diff changeset
21
10359a815068 add alice.jungle.codesegment.remote
one
parents: 34
diff changeset
22 }
10359a815068 add alice.jungle.codesegment.remote
one
parents: 34
diff changeset
23
34
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
24 public void run() {
40
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
25 DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class);
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
26 DefaultTreeOperationLog log = null;
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
27 try {
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
28 log = container.convert();
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
29 } catch (IOException e) {
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
30 e.printStackTrace();
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
31 }
34
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
32
40
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
33 JungleManager jm = new JungleManager();
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
34 JungleTree tree = jm.getJungle().getTreeByName("boards");
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
35 JungleTreeEditor editor = tree.getTreeEditor();
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
36 Either<Error, JungleTreeEditor> either = jm.edit(editor, log);
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
37 if(either.isA()) {
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
38 throw new IllegalStateException();
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
39 }
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
40 editor = either.b();
7e94de2d6bc0 add PutAnotherLogCodeSegment, PutHostLogCodeSegment
one
parents: 39
diff changeset
41 editor.success();
34
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
42 }
bf696a6334b2 add LogUpdateCodeSegment
one
parents:
diff changeset
43 }