Mercurial > hg > Database > jungle-network
annotate src/jungle/test/bbs/codesegment/LogUpdateCodeSegment.java @ 59:8a532ca5df80
refactoring LogUpdateCodeSegment and ChildLogCheckCodeSegment
author | one |
---|---|
date | Mon, 15 Jul 2013 10:59:53 +0900 |
parents | src/alice/jungle/codesegment/LogUpdateCodeSegment.java@4851344e120e |
children | ebf42371454b |
rev | line source |
---|---|
59
8a532ca5df80
refactoring LogUpdateCodeSegment and ChildLogCheckCodeSegment
one
parents:
58
diff
changeset
|
1 package jungle.test.bbs.codesegment; |
34 | 2 |
40 | 3 |
59
8a532ca5df80
refactoring LogUpdateCodeSegment and ChildLogCheckCodeSegment
one
parents:
58
diff
changeset
|
4 |
40 | 5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | |
8 import jungle.test.bbs.JungleManager; | |
34 | 9 import alice.codesegment.CodeSegment; |
10 import alice.datasegment.CommandType; | |
11 import alice.datasegment.Receiver; | |
52 | 12 import alice.jungle.datasegment.HashSetDataSegment; |
40 | 13 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; |
34 | 14 |
15 public class LogUpdateCodeSegment extends CodeSegment { | |
16 | |
52 | 17 Receiver parentLog = ids.create(CommandType.PEEK); |
18 Receiver host = ids.create(CommandType.PEEK); | |
19 Receiver hashLog = ids.create(CommandType.PEEK); | |
39 | 20 |
47 | 21 public LogUpdateCodeSegment() { |
52 | 22 parentLog.setKey("parent", "log"); |
50 | 23 host.setKey("host"); |
52 | 24 hashLog.setKey("hashLog"); |
39 | 25 } |
26 | |
50 | 27 public LogUpdateCodeSegment(int index) { |
52 | 28 parentLog.setKey("parent", "log", index); |
50 | 29 host.setKey("host"); |
58
4851344e120e
fix bug LogUpdateCodeSegment and ChildLogCheckCodeSegment
one
parents:
57
diff
changeset
|
30 hashLog.setKey("hashLog"); |
49 | 31 } |
32 | |
34 | 33 public void run() { |
52 | 34 int index = parentLog.index; |
59
8a532ca5df80
refactoring LogUpdateCodeSegment and ChildLogCheckCodeSegment
one
parents:
58
diff
changeset
|
35 String hostName = host.asString(); |
52 | 36 DefaultTreeOperationLogContainer container = parentLog.asClass(DefaultTreeOperationLogContainer.class); |
37 HashSetDataSegment ds = hashLog.asClass(HashSetDataSegment.class); | |
38 if(ds.hash.contains(container.getHashLogString())) { | |
39 ods.update("hashLog", ds); | |
51 | 40 new LogUpdateCodeSegment(index); |
42 | 41 return; |
42 } | |
59
8a532ca5df80
refactoring LogUpdateCodeSegment and ChildLogCheckCodeSegment
one
parents:
58
diff
changeset
|
43 Either<Error, JungleTreeEditor> either = JungleManager.update(container); |
46 | 44 if(either.isA()) { |
45 throw new IllegalStateException(); | |
46 } | |
52 | 47 ds.hash.add(container.getHashLogString()); |
48 ods.update("hashLog", ds); | |
49 | 49 ods.put("log", container); |
51 | 50 new LogUpdateCodeSegment(index); |
34 | 51 } |
52 } |