Mercurial > hg > Database > jungle-network
view src/main/java/app/bbs/codesegment/LogUpdateCodeSegment.java @ 128:48d342e72dd7
Modified to TAKE in LogUpdateCodeSegment
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 11 Jan 2014 08:55:29 +0900 |
parents | 495ac60d7f5f |
children | 00fcb468de27 |
line wrap: on
line source
package app.bbs.codesegment; import java.util.List; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.jungle.operations.NetworkTreeOperationLog; import app.bbs.BullentInBoardJungleManager; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; public class LogUpdateCodeSegment extends CodeSegment { Receiver log = ids.create(CommandType.TAKE); Receiver clist = ids.create(CommandType.PEEK); public LogUpdateCodeSegment() { log.setKey("log"); clist.setKey("_CLIST");; } public LogUpdateCodeSegment(int index) { log.setKey("log", index); clist.setKey("_CLIST");; } public void run() { int index = log.index; NetworkTreeOperationLog netLog = log.asClass(NetworkTreeOperationLog.class); @SuppressWarnings("unchecked") List<String> list = clist.asClass(List.class); if (!log.from.equals("local")) { Either<Error, JungleTreeEditor> either = BullentInBoardJungleManager.update(netLog); if(either.isA()) { /* Should throw after new LogUpdateCodeSegment */ throw new IllegalStateException(); } } for (String node : list) { if (!node.equals(log.from)) { ods.put(node, log.key, log.getVal()); } } new LogUpdateCodeSegment(index); } }