Mercurial > hg > Members > nobuyasu > jungle-network
diff src/jungle/test/bbs/codesegment/ChildLogCheckCodeSegment.java @ 50:459b50f1a6ee
add ChildLogCheckCodeSegment.
author | one |
---|---|
date | Fri, 12 Jul 2013 20:39:02 +0900 |
parents | |
children | 9e782b4eb06e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jungle/test/bbs/codesegment/ChildLogCheckCodeSegment.java Fri Jul 12 20:39:02 2013 +0900 @@ -0,0 +1,48 @@ +package jungle.test.bbs.codesegment; + +import java.io.IOException; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; +import jungle.test.bbs.JungleManager; +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; +import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; + +public class ChildLogCheckCodeSegment extends CodeSegment { + + Receiver childLog = ids.create(CommandType.TAKE); + + public ChildLogCheckCodeSegment() { + childLog.setKey("childLog"); + } + + public void run() { + DefaultTreeOperationLogContainer container = childLog.asClass(DefaultTreeOperationLogContainer.class); + DefaultTreeOperationLog log = null; + try { + log = container.convert(); + } catch (IOException e) { + e.printStackTrace(); + } + JungleTree tree = JungleManager.getJungle().getTreeByName("boards"); + JungleTreeEditor editor = tree.getTreeEditor(); + Either<Error, JungleTreeEditor> either = JungleManager.edit(editor, log); + if(either.isA()) { + throw new IllegalStateException(); + } + editor = either.b(); + either = editor.success(); + if(either.isA()) { + throw new IllegalStateException(); + } + ods.put("log", container); + new ChildLogCheckCodeSegment(); + } + + +}