Mercurial > hg > Database > jungle-network
comparison src/main/java/jungle/app/bbs/codesegment/LogUpdateCodeSegment.java @ 105:f9e29a52efd3
Move some files
author | one |
---|---|
date | Tue, 26 Nov 2013 06:43:10 +0900 |
parents | src/jungle/app/bbs/codesegment/LogUpdateCodeSegment.java@55a4f2bb44a8 |
children | f42f2e6b31de |
comparison
equal
deleted
inserted
replaced
104:03bf62bb699e | 105:f9e29a52efd3 |
---|---|
1 package jungle.app.bbs.codesegment; | |
2 | |
3 | |
4 | |
5 import java.util.List; | |
6 | |
7 import alice.jungle.operations.NetworkTreeOperationLog; | |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | |
11 import jungle.app.bbs.JungleManager; | |
12 import alice.codesegment.CodeSegment; | |
13 import alice.datasegment.CommandType; | |
14 import alice.datasegment.Receiver; | |
15 | |
16 public class LogUpdateCodeSegment extends CodeSegment { | |
17 | |
18 Receiver log = ids.create(CommandType.PEEK); | |
19 Receiver clist = ids.create(CommandType.PEEK); | |
20 | |
21 | |
22 public LogUpdateCodeSegment() { | |
23 log.setKey("log"); | |
24 clist.setKey("_CLIST");; | |
25 } | |
26 | |
27 public LogUpdateCodeSegment(int index) { | |
28 log.setKey("log", index); | |
29 clist.setKey("_CLIST");; | |
30 } | |
31 | |
32 public void run() { | |
33 int index = log.index; | |
34 NetworkTreeOperationLog netLog = log.asClass(NetworkTreeOperationLog.class); | |
35 @SuppressWarnings("unchecked") | |
36 List<String> list = clist.asClass(List.class); | |
37 if (!log.from.equals("local")) { | |
38 Either<Error, JungleTreeEditor> either = JungleManager.update(netLog); | |
39 if(either.isA()) { | |
40 /* Should throw after new LogUpdateCodeSegment */ | |
41 throw new IllegalStateException(); | |
42 } | |
43 } | |
44 for (String node : list) { | |
45 if (!node.equals(log.from)) { | |
46 ods.put(node, log.key, log.getVal()); | |
47 } | |
48 } | |
49 new LogUpdateCodeSegment(index); | |
50 } | |
51 } |