Mercurial > hg > Database > jungle-network
view src/jungle/app/bbs/codesegment/LogUpdateCodeSegment.java @ 96:fcce7ca4adb9
Modified LogUpdateCodesegment
author | one |
---|---|
date | Mon, 18 Nov 2013 19:34:15 +0900 |
parents | 87ec5dd0dc27 |
children | 11ad00323206 |
line wrap: on
line source
package jungle.app.bbs.codesegment; import java.util.List; 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; import jungle.app.bbs.JungleManager; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.jungle.operations.NetworkTreeOperationLog; public class LogUpdateCodeSegment extends CodeSegment { Receiver log = ids.create(CommandType.PEEK); Receiver host = ids.create(CommandType.PEEK); Receiver clist = ids.create(CommandType.PEEK); public LogUpdateCodeSegment() { log.setKey("log"); host.setKey("host"); clist.setKey("_CLIST");; } public LogUpdateCodeSegment(int index) { log.setKey("log", index); host.setKey("host"); clist.setKey("_CLIST");; } public void run() { int index = log.index; NetworkTreeOperationLog netLog = log.asClass(NetworkTreeOperationLog.class); String hostName = host.asString(); @SuppressWarnings("unchecked") List<String> list = clist.asClass(List.class); if (!hostName.equals((log.from))) { Either<Error, JungleTreeEditor> either = JungleManager.update(netLog); if(either.isA()) { throw new IllegalStateException(); } } for (String node : list) { if (!node.equals(log.from)) { ods.update(node, log.key, log.getVal()); } } new LogUpdateCodeSegment(index); } }