Mercurial > hg > Members > tatsuki > JungleXMLReader
changeset 39:22edfb7f47ad
bbs show all node attribute
author | one |
---|---|
date | Tue, 11 Nov 2014 19:01:36 +0900 |
parents | 7e6f1f9b40a8 |
children | 59a7d2cffc86 |
files | src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/GetAttributeImp.java src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JuGrix.java src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JungleBulletinBoard.java src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/MatrixApp.java src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/ShowMatrix.java |
diffstat | 5 files changed, 88 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/GetAttributeImp.java Sun Nov 09 23:10:03 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/GetAttributeImp.java Tue Nov 11 19:01:36 2014 +0900 @@ -1,22 +1,21 @@ package jp.ac.u_ryukyu.cr.ie.tatsuki.bbs; +import fj.data.List; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; +public class GetAttributeImp { + private final TreeNode node; - + public GetAttributeImp(TreeNode _node) { + node = _node; + } -public class GetAttributeImp -{ - private final TreeNode node; - - public GetAttributeImp(TreeNode _node) - { - node = _node; - } + public String getMessage(String key) { + return node.getAttributes().getString(key); + } + + public List<String> getKeys() { + return node.getAttributes().getKeys(); + } - public String getMessage() { - return node.getAttributes().getString("text"); - } - } -
--- a/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JuGrix.java Sun Nov 09 23:10:03 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JuGrix.java Tue Nov 11 19:01:36 2014 +0900 @@ -45,7 +45,6 @@ e.printStackTrace(); } } - public boolean isActive(String id) { InterfaceTraverser personTraverser = personTree.getTraverser(); @@ -63,6 +62,7 @@ return false; } + public Iterator<String> personIds(String orgId, LinkedList<String> roleIds) { @@ -97,6 +97,7 @@ }; } + public Iterator<String> personIds(LinkedList<String> orgIds, LinkedList<String> roleIds) { TreeMap<String, String> personIds = TreeMap.empty(Ord.stringOrd); @@ -129,7 +130,7 @@ }; } - + private TreeMap<String, String> personIdsSearch(String orgId, TreeMap<String, String> orgIdsTreeMap) { InterfaceTraverser personTraverser = personTree.getTraverser(); @@ -165,7 +166,11 @@ return orgIdsTreeMap; } + + + public boolean filter(String orgId, LinkedList<String> roleIds) { + if (roleIds == null) return true; @@ -174,7 +179,7 @@ InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> orgNodeIterator = orgTraverser.find((TreeNode node) -> { + Iterator<Pair<TreeNode, NodePath>> orgIdPairIterator = orgTraverser.find((TreeNode node) -> { String personId = node.getAttributes().getString("element"); if (personId == null) return false; @@ -188,33 +193,34 @@ return false; }, "Organization-id", orgId); - if (!orgNodeIterator.hasNext()) + if (!orgIdPairIterator.hasNext()) return false; - Pair<TreeNode, NodePath> searchNodePair = orgNodeIterator.next(); + Pair<TreeNode, NodePath> orgIdPair = orgIdPairIterator.next(); for (String id : roleIds) { Pattern personPattern = Pattern.compile("r:"); Matcher personMacher = personPattern.matcher(id); if (personMacher.find()) { - if (roleFilter(id, searchNodePair)) + if (roleFilter(id, orgIdPair)) return false; } Pattern organizationPattern = Pattern.compile("rde:"); Matcher organizationMacher = organizationPattern.matcher(id); if (organizationMacher.find()) { - if (!rdeFilter(id, searchNodePair)) + if (!rdeFilter(id, orgIdPair)) return false; } } return true; } - - private boolean rdeFilter(String id, Pair<TreeNode, NodePath> searchNodePair) { + + private boolean rdeFilter(String filterRdeId, Pair<TreeNode, NodePath> searchNodePair) { InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> pairIdIterator = orgTraverser.findInSubTreeAllValue((TreeNode node) -> { + + Iterator<Pair<TreeNode, NodePath>> orgRoleIdPairIterator = orgTraverser.findInSubTreeAllValue((TreeNode node) -> { String element = node.getAttributes().getString("element"); if (element == null) return false; @@ -226,18 +232,20 @@ return false; }, searchNodePair, "text-roleRefId"); - TreeMap<String, String> idMap = TreeMap.empty(Ord.stringOrd); - for (; pairIdIterator.hasNext();) { - String roleId = pairIdIterator.next().left().getAttributes().getString("text-roleRefId"); - idMap = idMap.set(roleId, roleId); + TreeMap<String, String> orgRoleIdMap = TreeMap.empty(Ord.stringOrd); + + for (; orgRoleIdPairIterator.hasNext();) { + String roleId = orgRoleIdPairIterator.next().left().getAttributes().getString("text-roleRefId"); + orgRoleIdMap = orgRoleIdMap.set(roleId, roleId); } - Iterator<P2<String, String>> ids = idMap.iterator(); + Iterator<P2<String, String>> orgRoleIdP2Iterator = orgRoleIdMap.iterator(); InterfaceTraverser roleTraverser = roleTree.getTraverser(); - for (; ids.hasNext();) { - String roleId = ids.next()._1(); - Iterator<Pair<TreeNode, NodePath>> roleNodeIterator = roleTraverser.find((TreeNode node) -> { + for (; orgRoleIdP2Iterator.hasNext();) { + String orgRoleId = orgRoleIdP2Iterator.next()._1(); + + Iterator<Pair<TreeNode, NodePath>> roleIdPairIterator = roleTraverser.find((TreeNode node) -> { String element = node.getAttributes().getString("element"); if (element == null) return false; @@ -246,14 +254,15 @@ String compareRoleId = node.getAttributes().getString("Role-id"); if (compareRoleId == null) return false; - if (compareRoleId.equals(roleId)) + if (compareRoleId.equals(orgRoleId)) return true; return false; - }, "Role-id", roleId); + }, "Role-id", orgRoleId); - for (; roleNodeIterator.hasNext();) { - Pair<TreeNode, NodePath> rolePair = roleNodeIterator.next(); - Iterator<Pair<TreeNode, NodePath>> rdeNodeIterator = roleTraverser.findInSubTree((TreeNode node) -> { + for (; roleIdPairIterator.hasNext();) { + + Pair<TreeNode, NodePath> rolePair = roleIdPairIterator.next(); + Iterator<Pair<TreeNode, NodePath>> rdeIdPairIterator = roleTraverser.findInSubTree((TreeNode node) -> { String elementName = node.getAttributes().getString("element"); if (elementName == null) return false; @@ -262,26 +271,24 @@ String rdeId = node.getAttributes().getString("text-roleDescriptionElementRefIds"); if (rdeId == null) return false; - Pattern personPattern = Pattern.compile(id); - Matcher personMacher = personPattern.matcher(rdeId); - if (personMacher.find()) + if (rdeId.equals(filterRdeId)) return true; return false; - }, rolePair, "text-roleDescriptionElementRefIds", id); + }, rolePair, "text-roleDescriptionElementRefIds", filterRdeId); - if (!rdeNodeIterator.hasNext()) + if (!rdeIdPairIterator.hasNext()) return false; } } return true; } - + public boolean roleFilter(String id, Pair<TreeNode, NodePath> searchNodePair) { // System.out.println(searchNodePair.getAttributes().getString("id")); InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> pairIdIterator = orgTraverser.findInSubTree((TreeNode node) -> { + Iterator<Pair<TreeNode, NodePath>> roleIdPairIterator = orgTraverser.findInSubTree((TreeNode node) -> { String elementName = node.getAttributes().getString("element"); if (elementName == null) return false; @@ -295,13 +302,12 @@ return false; }, searchNodePair, "text-roleRefIds", id); - if (pairIdIterator.hasNext()) { - System.out.println(pairIdIterator.next().left().getAttributes().getString("text-roleRefIds")); + if (roleIdPairIterator.hasNext()) { return false; } return true; } - + public Iterator<String> roleIds(String id) { Pattern personPattern = Pattern.compile("p:"); Matcher personMacher = personPattern.matcher(id); @@ -317,6 +323,7 @@ return new NullIterator(); } + public Iterator<String> searchRoleIds(JungleTree tree, String id, String element) { @@ -383,6 +390,7 @@ }; } + public Iterator<String> competentRoleId(String personId) { InterfaceTraverser personTraverser = personTree.getTraverser(); @@ -447,7 +455,7 @@ } }; } - + public Iterator<String> concurrentRoleIds(String personId) { InterfaceTraverser personTraverser = personTree.getTraverser(); @@ -515,7 +523,7 @@ } }; } - + public Iterator<String> deepPersonIds(String orgId, LinkedList<String> filterIds) { TreeMap<String, String> personIdsTreeMap = TreeMap.empty(Ord.stringOrd); @@ -549,6 +557,7 @@ } }; } + public Iterator<String> deepChildOrganizationIdsPlus(String orgId, LinkedList<String> filterIds) { TreeMap<String, String> orgIdsTreeMap = TreeMap.empty(Ord.stringOrd); @@ -580,7 +589,7 @@ } }; } - + public Iterator<String> deepChildOrganizationIds(String orgId, LinkedList<String> filterIds) { TreeMap<String, String> orgIdsTreeMap = TreeMap.empty(Ord.stringOrd); @@ -609,7 +618,7 @@ } }; } - + public TreeMap<String, String> _deepChildOrganizationIds(String orgId, TreeMap<String, String> orgIdsTreeMap) { TreeMap<String, String> childrenIdTreeMap = _childOrganizationIds(orgId, TreeMap.empty(Ord.stringOrd)); @@ -719,26 +728,6 @@ return childOrgIdsTreeMap; } - public TreeNode getTarget(TreeNode node, NodePath path) { - TreeNode target; - Pair<Integer, NodePath> pathNode = path.pop(); - int num = pathNode.left(); - NodePath newPath = pathNode.right(); - if (num == -1 && newPath.size() != 0) - return getTarget(node, newPath); - - Either<Error, TreeNode> either = node.getChildren().at(num); - if (either.isA()) - return node; - - TreeNode child = either.b(); - if (pathNode.right().size() == 0) - return child; - - target = getTarget(child, pathNode.right()); - return target; - } - class NullIterator implements Iterator<String> { @Override @@ -1110,5 +1099,27 @@ }; } + + public TreeNode getTarget(TreeNode node, NodePath path) { + TreeNode target; + Pair<Integer, NodePath> popPath = path.pop(); + int num = popPath.left(); + NodePath newPath = popPath.right(); + if (num == -1 && newPath.size() != 0) + return getTarget(node, newPath); + + Either<Error, TreeNode> either = node.getChildren().at(num); + if (either.isA()) + return node; + + TreeNode child = either.b(); + if (popPath.right().size() == 0) + return child; + + target = getTarget(child, popPath.right()); + return target; + } + + }
--- a/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JungleBulletinBoard.java Sun Nov 09 23:10:03 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JungleBulletinBoard.java Tue Nov 11 19:01:36 2014 +0900 @@ -590,8 +590,6 @@ @Override public void createBoards(String _name, String _author, String _initMessage, String _editKey) { - // TODO Auto-generated method stub - } }
--- a/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/MatrixApp.java Sun Nov 09 23:10:03 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/MatrixApp.java Tue Nov 11 19:01:36 2014 +0900 @@ -39,7 +39,6 @@ Servlet createBoard = new ReadXml(BBS); Servlet editBoardMessage = new EditMessageServlet(BBS); Servlet index = new ShowBoardsServletMatrix(BBS,createBoardPath,showMatrixPath); - // Servlet board = new ShowBoardMessageServlet(BBS,createBoardMessagePath,editMessagePath); Servlet matrix = new ShowMatrix(BBS,createFolderPath,editNodePath, showMatrixPath, createAttributePath, editAttributePath,deleteAttributePath,deleteNodePath,thp); ServletHandler context = new ServletHandler(); context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath);
--- a/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/ShowMatrix.java Sun Nov 09 23:10:03 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/ShowMatrix.java Tue Nov 11 19:01:36 2014 +0900 @@ -8,6 +8,7 @@ import org.eclipse.jetty.util.thread.ThreadPool; +import fj.data.List; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage; public class ShowMatrix extends HttpServlet { @@ -85,9 +86,12 @@ _pw.write("<br><hr/><p>Value</p>"); GetAttributeImp attribute = (bbs.getAttribute(_bname, path)); - - _pw.write(bbs.sanitize(attribute.getMessage())); - + List<String> keys = attribute.getKeys(); + + for (String key : keys) { + _pw.write(key + " : " + bbs.sanitize(attribute.getMessage(key)) + "<br>"); + + } _pw.write("</body></html>"); _pw.flush();