Mercurial > hg > Members > tatsuki > JungleXMLReader
changeset 42:c036d36c33af
function refactor
line wrap: on
line diff
--- a/src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/time/TimeMeasurementJuGrix.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/time/TimeMeasurementJuGrix.java Tue Nov 25 11:57:17 2014 +0900 @@ -7,21 +7,21 @@ public class TimeMeasurementJuGrix { - static int roopCount = 1000; + static int roopCount = 3; public static void main(String args[]) { - JuGrix jugrix = new JuGrix(false); - System.out.println("start : no index"); + System.out.println("start : "); String orgId = "o:2"; String personId = "p:1"; LinkedList<String> filterIds = new LinkedList<String>(); filterIds.add("r:5"); - functions(jugrix, orgId, personId, filterIds); long sumTime = 0; for (int count = 0; count < roopCount; count++) { + + JuGrix jugrix = new JuGrix(); Random random = new Random(); int ran = random.nextInt(30); orgId = "o:" + String.valueOf(ran); @@ -34,25 +34,6 @@ } System.out.println("合計 = " + sumTime + "s"); System.out.println("end"); - - jugrix = new JuGrix(true); - functions(jugrix, orgId, personId, filterIds); - System.out.println("start : use index"); - sumTime = 0; - - for (int count = 0; count < roopCount; count++) { - Random random = new Random(); - int ran = random.nextInt(30); - orgId = "o:" + String.valueOf(ran); - personId = "p:" + String.valueOf(ran); - long t1 = System.currentTimeMillis(); - functions(jugrix, orgId, personId, filterIds); - long t2 = System.currentTimeMillis(); - //System.out.println(count + "回目=" + (t2 - t1) + "s"); - sumTime = sumTime + t2 - t1; - } - System.out.println("合計 = " + sumTime + "s"); - System.out.println("end"); } private static void functions(JuGrix jugrix, String orgId, String personId, LinkedList<String> filterIds) {
--- a/src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/xmlReader/LoadXml.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/xmlReader/LoadXml.java Tue Nov 25 11:57:17 2014 +0900 @@ -26,32 +26,6 @@ jungle = new DefaultJungle(null, "jungle", new DefaultTreeEditor(new DefaultTraverser())); } - private JungleTree putTestDataCreate(String xmlName, JungleTree tree) throws FileNotFoundException, - SAXException, IOException, ParserConfigurationException { - SAXParser saxParser = saxParserFactory.newSAXParser(); - ReadXmlPutAttributeCreateIndex readXmlHandler = new ReadXmlPutAttributeCreateIndex(tree); - saxParser.parse(new FileInputStream("xml/" + xmlName), readXmlHandler); - JungleTree newTree = readXmlHandler.getTree(); - - return newTree; - - } - - private JungleTree createNodeTestData(String xmlName) throws FileNotFoundException, SAXException, - IOException, ParserConfigurationException { - SAXParser saxParser = saxParserFactory.newSAXParser(); - JungleTree tree = jungle.createNewTree(xmlName); - ReadXmlNodeCreateIndexHandler readXmlHandler = new ReadXmlNodeCreateIndexHandler(tree); - saxParser.parse(new FileInputStream("xml/" + xmlName), readXmlHandler); - JungleTree nodeTree = readXmlHandler.getTree(); - JungleTree newTree = putTestDataCreate(xmlName, nodeTree); - return newTree; - } - - public JungleTree loadTestDataCreateIndex(String xmlName) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException{ - JungleTree newTree = createNodeTestData(xmlName); - return newTree; - } public JungleTree loadTestData(String xmlName) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
--- a/src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/xmlReader/ReadXmlNodeCreateIndexHandler.java Thu Nov 13 23:34:41 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -package ac.jp.u_ryukyu.cr.ie.tatsuki.xmlReader; - -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.NodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; - -import org.xml.sax.*; -import org.xml.sax.helpers.*; - -public class ReadXmlNodeCreateIndexHandler extends DefaultHandler { - private JungleTree tree; - private JungleTreeEditor editor; - private NodePath path; - - public ReadXmlNodeCreateIndexHandler(JungleTree tree) { - this.tree = tree; - this.editor = tree.getTreeEditor(); - this.path = new DefaultNodePath().add(-1); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) { - Pair<Integer, NodePath> nodePair = path.last(); - path = nodePair.right(); - int num = nodePair.left() + 1; - - Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, num); - if (either.isA()) { - // error - } - this.editor = either.b(); - - path = path.add(num); - path = path.add(-1); - } - - - @Override - public void endElement(String namespaceURI, String localName, String qName) { - path = path.tail(); - if (namespaceURI != "") { - // System.out.println("namespaceURI= " + namespaceURI); - } - if (localName != "") { - // System.out.println("localName= " + localName); - } - - if (qName != "") { - // System.out.println("qName= " + qName); - } - } - - - @Override - public void endDocument() { - Either<Error, JungleTreeEditor> either = editor.success(); - if (either.isA()) { - // error - } - // System.out.println("end"); - } - - public JungleTree getTree() { - return tree; - } - -}
--- a/src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/xmlReader/ReadXmlPutAttributeCreateIndex.java Thu Nov 13 23:34:41 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -package ac.jp.u_ryukyu.cr.ie.tatsuki.xmlReader; - -import java.nio.ByteBuffer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -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.NodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; - -import org.xml.sax.*; -import org.xml.sax.helpers.*; - -public class ReadXmlPutAttributeCreateIndex extends DefaultHandler { - private JungleTree tree; - private JungleTreeEditor editor; - private NodePath path; - private String elementName; - - public ReadXmlPutAttributeCreateIndex(JungleTree tree) { - this.tree = tree; - this.editor = tree.getIndexTreeEditor(); - this.path = new DefaultNodePath().add(-1); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) { - Pair<Integer, NodePath> nodePair = path.last(); - path = nodePair.right(); - int num = nodePair.left() + 1; - path = path.add(num); - // System.out.println(path.toString()); - - if (uri != "") { - // System.out.println("namespaceURI= " + uri); - } - - if (localName != "") { - // System.out.println("localName= " + localName); - } - - if (qName != "") { - // System.out.println("qName= " + qName); - elementName = qName; - Either<Error, JungleTreeEditor> newEither = editor.putAttribute(path, "element", - ByteBuffer.wrap(qName.getBytes())); - if (newEither.isA()) { - // error - } - this.editor = newEither.b(); - } - - if (attributes.getLength() != 0) { - for (int count = 0; attributes.getLength() > count; count++) { - // System.out.println(attributes.getLocalName(count) + " = " + - // attributes.getValue(count)); - String key = elementName + "-" + attributes.getLocalName(count); - String value = attributes.getValue(count); - ByteBuffer bValue = ByteBuffer.wrap(value.getBytes()); - Either<Error, JungleTreeEditor> newEither = editor.putAttribute(path, key, bValue); - if (newEither.isA()) { - // error - } - this.editor = newEither.b(); - } - } - path = path.add(-1); - } - - @Override - public void characters(char[] ch, int start, int length) { - String str = new String(ch, start, length); - Pattern pattern = Pattern.compile("\n"); - Matcher macher = pattern.matcher(str); - - if (!macher.find()) { - String[] splitStrs = str.split(" "); - for (String splitStr : splitStrs) { - Pair<Integer, NodePath> nodePair = path.last(); - NodePath onePath = nodePair.right(); - Either<Error, JungleTreeEditor> newEither = editor.putAttribute(onePath, "text-" + elementName, - ByteBuffer.wrap(splitStr.getBytes())); - if (newEither.isA()) { - // error - } - this.editor = newEither.b(); - } - } - } - - @Override - public void endElement(String namespaceURI, String localName, String qName) { - path = path.tail(); - if (namespaceURI != "") { - // System.out.println("namespaceURI= " + namespaceURI); - } - if (localName != "") { - // System.out.println("localName= " + localName); - } - - if (qName != "") { - // System.out.println("qName= " + qName); - } - } - - @Override - public void startDocument() { - // System.out.println("start"); - } - - @Override - public void endDocument() { - Either<Error, JungleTreeEditor> either = editor.success(); - if (either.isA()) { - // error - } - // System.out.println("end"); - } - - public JungleTree getTree() { - return tree; - } - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/xmlReader/UpdateXmlHundler.java Tue Nov 25 11:57:17 2014 +0900 @@ -0,0 +1,125 @@ +package ac.jp.u_ryukyu.cr.ie.tatsuki.xmlReader; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.xml.sax.*; +import org.xml.sax.helpers.*; + +public class UpdateXmlHundler extends DefaultHandler { + private String elementName; + private boolean flag = false; + private PrintWriter pw; + private int count = 0; + String xmlStr = ""; + + public UpdateXmlHundler(String xml) throws IOException { + File file = new File("./XML/" + xml + ".xml"); + pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); + + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) { + pw.print(xmlStr); + xmlStr = "<"; + if (qName != "") { + // System.out.print("qName= " + qName); + elementName = qName; + + if (elementName.equals("roleRefIds") || elementName.equals("organizationRefIds") + || elementName.equals("personRefIds") || elementName.equals("childrenRoleRefIds") + || elementName.equals("roleDescriptionElementRefIds")) + flag = true; + xmlStr = xmlStr + elementName; + } + + if (attributes.getLength() != 0) { + for (int count = 0; attributes.getLength() > count; count++) { + String value = attributes.getValue(count); + xmlStr = xmlStr + " " + attributes.getLocalName(count) + "=\"" + value + "\""; + } + } + xmlStr = xmlStr + ">"; + String tab = tab(); + pw.print(tab + xmlStr); + count++; + xmlStr = "\n"; + } + + @Override + public void characters(char[] ch, int start, int length) { + String str = new String(ch, start, length); + Pattern pattern = Pattern.compile("\n"); + Matcher macher = pattern.matcher(str); + String[] split = str.split(" "); + if (!macher.find()) { + if (flag == true) { + flag = false; + for (String text : split) { + pw.println(); + if (elementName.equals("roleRefIds")) + pw.print(tab() + "<roleRefId>" + text + "</roleRefId>"); + if (elementName.equals("organizationRefIds")) + pw.print(tab() + "<organizationRefId>" + text + "</organizationRefId>"); + if (elementName.equals("personRefIds")) + pw.print(tab() + "<personRefId>" + text + "</personRefId>"); + if (elementName.equals("childrenRoleRefIds")) + pw.print(tab() + "<childrenRoleRefId>" + text + "</childrenRoleRefId>"); + if (elementName.equals("roleDescriptionElementRefIds")) + pw.print(tab() + "<roleDescriptionElementRefId>" + text + "</roleDescriptionElementRefId>"); + } + count--; + xmlStr = "\n" + tab(); + count++; + return; + } else { + if (str.equals("松田賢一")) + System.out.println("aaaa"); + pw.print(str); + } + xmlStr = ""; + return; + } + if (flag == true) { + xmlStr = ""; + flag = false; + } + + } + + @Override + public void endElement(String namespaceURI, String localName, String qName) { + count--; + if (xmlStr == "\n") + xmlStr = xmlStr + tab(); + pw.print(xmlStr); + pw.print("</" + qName + ">"); + xmlStr = "\n"; + } + + @Override + public void startDocument() { + // System.out.print("start"); + } + + @Override + public void endDocument() { + pw.close(); + System.out.print("end"); + } + + private String tab() { + String tab = ""; + for (int tabCount = 0; tabCount < count; tabCount++) { + tab = tab + " "; + } + return tab; + } + +}
--- a/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JuGrix.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JuGrix.java Tue Nov 25 11:57:17 2014 +0900 @@ -2,6 +2,7 @@ import java.util.Iterator; import java.util.LinkedList; +import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -10,12 +11,11 @@ import fj.P2; import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; +import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex; public class JuGrix { @@ -24,31 +24,24 @@ JungleTree roleTree; JungleTree rdeTree; - public JuGrix(boolean index) { + public JuGrix() { try { LoadXml reader = new LoadXml(); - - if (index == true) { - personTree = reader.loadTestDataCreateIndex("Person.xml"); - organizationTree = reader.loadTestDataCreateIndex("Organization.xml"); - roleTree = reader.loadTestDataCreateIndex("Role.xml"); - rdeTree = reader.loadTestDataCreateIndex("RoleDescriptionElement.xml"); - } else { - personTree = reader.loadTestData("Person.xml"); - organizationTree = reader.loadTestData("Organization.xml"); - roleTree = reader.loadTestData("Role.xml"); - rdeTree = reader.loadTestData("RoleDescriptionElement.xml"); - } + personTree = reader.loadTestData("Person.xml"); + organizationTree = reader.loadTestData("Organization.xml"); + roleTree = reader.loadTestData("Role.xml"); + rdeTree = reader.loadTestData("RoleDescriptionElement.xml"); } catch (Exception e) { e.printStackTrace(); } } + public boolean isActive(String id) { InterfaceTraverser personTraverser = personTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> personIdpairIterator = personTraverser.find((TreeNode node) -> { + Iterator<TreeNode> personIdpairIterator = personTraverser.find((TreeNode node) -> { String personId = node.getAttributes().getString("Person-id"); if (personId == null) return false; @@ -62,563 +55,474 @@ return false; } - - public Iterator<String> personIds(String orgId, LinkedList<String> roleIds) { + public Iterator<String> personIds(String orgId, LinkedList<String> filterIds) { + + InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - Iterator<String> parentOrgIdIterator = parentOrganizationIds(orgId, roleIds); - TreeMap<String, String> personIdsTreeMap = TreeMap.empty(Ord.stringOrd); - - if (filter(orgId, roleIds)) - personIdsTreeMap = personIdsSearch(orgId, personIdsTreeMap); + Iterator<TreeNode> orgIdNodeIterator = orgTraverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("Organization")) + return false; + String targetOrgId = node.getAttributes().getString("Organization-id"); + if (targetOrgId == null) + return false; + if (targetOrgId.equals(orgId)) + return true; + return false; + }, "Organization-id", orgId); + + if (!orgIdNodeIterator.hasNext()) + return new NullIterator<String>(); - for (; parentOrgIdIterator.hasNext();) { - personIdsTreeMap = personIdsSearch(parentOrgIdIterator.next(), personIdsTreeMap); - } + TreeNode orgIdNode = orgIdNodeIterator.next(); + TreeNode orgRoleIdNodes = orgIdNode.getChildren().at(2).b(); + TreeNode orgRoleIdNode = orgRoleIdNodes.getChildren().at(0).b(); + String orgRoleId = orgRoleIdNode.getAttributes().getString("text-roleRefId"); + if (!filter(filterIds, orgRoleId)) + return new NullIterator<String>(); + + InterfaceTraverser traverser = personTree.getTraverser(); - if (personIdsTreeMap.isEmpty()) - return new NullIterator(); + return new Iterator<String>() { + Iterator<TreeNode> orgIdNodeIterator = traverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("organizationRefId")) + return false; + String targetOrgId = node.getAttributes().getString("text-organizationRefId"); + if (targetOrgId == null) + return false; + if (targetOrgId.equals(orgId)) + return true; + return false; + }, "text-organizationRefId", orgId); - Iterator<P2<String, String>> personIdsIterator = personIdsTreeMap.iterator(); - return new Iterator<String>() { + String targetPersonId; @Override public boolean hasNext() { - if (personIdsIterator.hasNext()) + for (; orgIdNodeIterator.hasNext();) { + TreeNode orgIdNode = orgIdNodeIterator.next(); + ParentIndex parentIndex = traverser.getParentIndex(); + TreeNode OrganizationMappedByRoleNode = parentIndex.get(orgIdNode); + TreeNode parentOrganizations = parentIndex.get(OrganizationMappedByRoleNode); + TreeNode targetPersonIdNode = parentIndex.get(parentOrganizations); + targetPersonId = targetPersonIdNode.getAttributes().getString("Person-id"); return true; - return false; - } - - @Override - public String next() { - return personIdsIterator.next()._1(); - } - - }; - } - - - public Iterator<String> personIds(LinkedList<String> orgIds, LinkedList<String> roleIds) { - - TreeMap<String, String> personIds = TreeMap.empty(Ord.stringOrd); - for (String orgId : orgIds) { - personIds = personIdsSearch(orgId, personIds); - } - - if (personIds.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> personIdsIterator = personIds.iterator(); - - return new Iterator<String>() { - String personId; - - @Override - public boolean hasNext() { - for (; personIdsIterator.hasNext();) { - personId = personIdsIterator.next()._1(); - if (filter(personId, roleIds)) - return true; } return false; } @Override public String next() { - return personId; + return targetPersonId; } }; } - - private TreeMap<String, String> personIdsSearch(String orgId, TreeMap<String, String> orgIdsTreeMap) { - InterfaceTraverser personTraverser = personTree.getTraverser(); - - Iterator<Pair<TreeNode, NodePath>> personIdPairIterator = personTraverser.findAll((TreeNode node) -> { - String personId = node.getAttributes().getString("element"); - if (personId == null) - return false; - if (personId.equals("Person")) - return true; - return false; - }, "Person-id"); - - for (; personIdPairIterator.hasNext();) { - - Pair<TreeNode, NodePath> personIdPair = personIdPairIterator.next(); - - Iterator<Pair<TreeNode, NodePath>> orgIdPairIterator = personTraverser.findInSubTree((TreeNode node) -> { - String personId = node.getAttributes().getString("text-organizationRefId"); - if (personId == null) - return false; - if (personId.equals(orgId)) - return true; - return false; - }, personIdPair, "text-organizationRefId", orgId); - - if (orgIdPairIterator.hasNext()) { - String personId = personIdPair.left().getAttributes().getString("Person-id"); - if (personId != null) - orgIdsTreeMap = orgIdsTreeMap.set(personId, personId); - } - } - return orgIdsTreeMap; - } - - - - - public boolean filter(String orgId, LinkedList<String> roleIds) { - - if (roleIds == null) - return true; - - if (roleIds.isEmpty()) - return true; - - InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - - Iterator<Pair<TreeNode, NodePath>> orgIdPairIterator = orgTraverser.find((TreeNode node) -> { - String personId = node.getAttributes().getString("element"); - if (personId == null) - return false; - if (!personId.equals("Organization")) - return false; - String compareOrgId = node.getAttributes().getString("Organization-id"); - if (compareOrgId == null) - return false; - if (compareOrgId.equals(orgId)) - return true; - return false; - }, "Organization-id", orgId); - - if (!orgIdPairIterator.hasNext()) - return false; - - 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, orgIdPair)) - return false; - } - - Pattern organizationPattern = Pattern.compile("rde:"); - Matcher organizationMacher = organizationPattern.matcher(id); - if (organizationMacher.find()) { - if (!rdeFilter(id, orgIdPair)) - return false; - } - } - return true; - } - - private boolean rdeFilter(String filterRdeId, Pair<TreeNode, NodePath> searchNodePair) { - - InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - - Iterator<Pair<TreeNode, NodePath>> orgRoleIdPairIterator = orgTraverser.findInSubTreeAllValue((TreeNode node) -> { - String element = node.getAttributes().getString("element"); - if (element == null) - return false; - if (!element.equals("roleRefId")) - return false; - String roleId = node.getAttributes().getString("text-roleRefId"); - if (roleId != null) - return true; - return false; - }, searchNodePair, "text-roleRefId"); - - 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>> orgRoleIdP2Iterator = orgRoleIdMap.iterator(); - InterfaceTraverser roleTraverser = roleTree.getTraverser(); - - 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; - if (!element.equals("Role")) - return false; - String compareRoleId = node.getAttributes().getString("Role-id"); - if (compareRoleId == null) - return false; - if (compareRoleId.equals(orgRoleId)) - return true; - return false; - }, "Role-id", orgRoleId); - - 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; - if (!elementName.equals("roleDescriptionElementRefIds")) - return false; - String rdeId = node.getAttributes().getString("text-roleDescriptionElementRefIds"); - if (rdeId == null) - return false; - if (rdeId.equals(filterRdeId)) - return true; - return false; - }, rolePair, "text-roleDescriptionElementRefIds", filterRdeId); - - 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>> roleIdPairIterator = orgTraverser.findInSubTree((TreeNode node) -> { - String elementName = node.getAttributes().getString("element"); - if (elementName == null) - return false; - if (!elementName.equals("roleRefIds")) - return false; - String roleId = node.getAttributes().getString("text-roleRefIds"); - if (roleId == null) - return false; - if (roleId.equals(id)) - return true; - return false; - }, searchNodePair, "text-roleRefIds", id); - - if (roleIdPairIterator.hasNext()) { - return false; - } - return true; - } - - public Iterator<String> roleIds(String id) { + public Iterator<String> roleIds(String id, LinkedList<String> filterIds) { Pattern personPattern = Pattern.compile("p:"); Matcher personMacher = personPattern.matcher(id); if (personMacher.find()) { - return searchRoleIds(personTree, id, "Person"); + return searchPersonRoleIds(personTree, id, "Person", filterIds); } Pattern organizationPattern = Pattern.compile("o:"); Matcher organizationMacher = organizationPattern.matcher(id); if (organizationMacher.find()) { - return searchRoleIds(organizationTree, id, "Organization"); + return searchOrgRoleIds(organizationTree, id, "Organization", filterIds); } - return new NullIterator(); + return new NullIterator<String>(); } - - public Iterator<String> searchRoleIds(JungleTree tree, String id, String element) { + public Iterator<String> searchPersonRoleIds(JungleTree tree, String id, String element, LinkedList<String> filterIds) { InterfaceTraverser traverser = tree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> idPairIterator = traverser.find((TreeNode node) -> { - String nodeElement = node.getAttributes().getString("element"); - if (nodeElement == null) - return false; - if (!nodeElement.equals(element)) - return false; - String nodeId = node.getAttributes().getString(element + "-id"); - if (nodeId == null) - return false; - if (nodeId.equals(id)) - return true; - return false; - }, element + "-id", id); + return new Iterator<String>() { - TreeMap<String, String> idsTreeMap = TreeMap.empty(Ord.stringOrd); - ; - - for (; idPairIterator.hasNext();) { - - Pair<TreeNode, NodePath> targetPair = idPairIterator.next(); - - Iterator<Pair<TreeNode, NodePath>> roleIdPairIterator = traverser.findInSubTreeAllValue((TreeNode node) -> { + String roleRefId = ""; + Iterator<TreeNode> idNodeIterator = traverser.find((TreeNode node) -> { String nodeElement = node.getAttributes().getString("element"); if (nodeElement == null) return false; - if (!nodeElement.equals("roleRefId")) + if (!nodeElement.equals(element)) return false; - String nodeId = node.getAttributes().getString("text-roleRefId"); - if (nodeId != null) + String nodeId = node.getAttributes().getString(element + "-id"); + if (nodeId == null) + return false; + if (nodeId.equals(id)) return true; return false; - }, targetPair, "text-roleRefId"); + }, element + "-id", id); - for (; roleIdPairIterator.hasNext();) { - Pair<TreeNode, NodePath> roleIdPair = roleIdPairIterator.next(); - String roleId = roleIdPair.left().getAttributes().getString("text-roleRefId"); - idsTreeMap = idsTreeMap.set(roleId, roleId); - } - } - - if (idsTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> ids = idsTreeMap.iterator(); - return new Iterator<String>() { + Iterator<TreeNode> OrganizationMappedByRoleIterator = getParentOrgs(); @Override public boolean hasNext() { - if (ids.hasNext()) + + if (OrganizationMappedByRoleIterator == null) + return false; + + if (OrganizationMappedByRoleIterator.hasNext()) + roleRefId = search(); + else + roleRefId = null; + + if (roleRefId != null) + return true; + + OrganizationMappedByRoleIterator = getParentOrgs(); + if (OrganizationMappedByRoleIterator != null) + roleRefId = search(); + + if (roleRefId != null) return true; - return false; + + return this.hasNext(); + } + + private String search() { + for (; OrganizationMappedByRoleIterator.hasNext();) { + TreeNode OrganizationMappedByRole = OrganizationMappedByRoleIterator.next(); + TreeNode organizationRefIdNode = OrganizationMappedByRole.getChildren().at(0).b(); + System.out.println(organizationRefIdNode.getAttributes().getString("element")); + String organizationRefId = organizationRefIdNode.getAttributes().getString("text-organizationRefId"); + if (!filterIds.contains(organizationRefId)) + continue; + + TreeNode roleRefIdNode = OrganizationMappedByRole.getChildren().at(1).b(); + return roleRefIdNode.getAttributes().getString("text-roleRefId"); + } + OrganizationMappedByRoleIterator = getParentOrgs(); + + return null; + } + + private Iterator<TreeNode> getParentOrgs() { + for (; idNodeIterator.hasNext();) { + TreeNode targetPersonNode = idNodeIterator.next(); + TreeNode parentOrganizations = targetPersonNode.getChildren().at(5).b(); + return parentOrganizations.getChildren().iterator(); + } + return null; } @Override public String next() { - return ids.next()._1(); + return roleRefId; } }; } - - public Iterator<String> competentRoleId(String personId) { + public Iterator<String> searchOrgRoleIds(JungleTree tree, String id, String element, LinkedList<String> filterIds) { - InterfaceTraverser personTraverser = personTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> personIdPairIterator = personTraverser.find((TreeNode node) -> { - String nodeElement = node.getAttributes().getString("element"); - if (nodeElement == null) - return false; - if (!nodeElement.equals("Person")) - return false; - String nodeId = node.getAttributes().getString("Person-id"); - if (nodeId == null) - return false; - if (nodeId.equals(personId)) - return true; - return false; - }, "Person-id", personId); + InterfaceTraverser traverser = tree.getTraverser(); - if (!personIdPairIterator.hasNext()) - return new NullIterator(); - - Pair<TreeNode, NodePath> personIdPair = personIdPairIterator.next(); + return new Iterator<String>() { - Iterator<Pair<TreeNode, NodePath>> priorityPairIterator = personTraverser.findInSubTree((TreeNode node) -> { - String nodeElement = node.getAttributes().getString("element"); - if (nodeElement == null) - return false; - if (!nodeElement.equals("priority")) - return false; - String priority = node.getAttributes().getString("text-priority"); - if (priority == null) + String roleRefId = ""; + Iterator<TreeNode> idNodeIterator = traverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals(element)) + return false; + String nodeId = node.getAttributes().getString(element + "-id"); + if (nodeId == null) + return false; + if (nodeId.equals(id)) + return true; return false; - if (priority.equals("0")) - return true; - return false; - }, personIdPair, "text-priority", "0"); - - TreeMap<String, String> roleIdTreeMap = TreeMap.empty(Ord.stringOrd); - - for (; priorityPairIterator.hasNext();) { - - Pair<TreeNode, NodePath> priorityPair = priorityPairIterator.next(); - NodePath priorityPath = priorityPair.right(); - Pair<Integer, NodePath> removeLastPair = priorityPath.last(); - NodePath roleIdNodePath = removeLastPair.right().add(removeLastPair.left() + 1); - TreeNode roleIdNode = getTarget(personTree.getRootNode(), roleIdNodePath); - String roleId = roleIdNode.getAttributes().getString("text-roleRefId"); - roleIdTreeMap = roleIdTreeMap.set(roleId, roleId); - } - Iterator<P2<String, String>> roleIdP2Iterator = roleIdTreeMap.iterator(); - return new Iterator<String>() { + }, element + "-id", id); + Iterator<TreeNode> OrganizationMappedByRoleIterator = getParentOrgs(); @Override public boolean hasNext() { - if (roleIdP2Iterator.hasNext()) + + if (OrganizationMappedByRoleIterator == null) + return false; + if (OrganizationMappedByRoleIterator.hasNext()) + roleRefId = search(); + else + roleRefId = null; + if (roleRefId != null) + return true; + + OrganizationMappedByRoleIterator = getParentOrgs(); + if (OrganizationMappedByRoleIterator != null) + roleRefId = search(); + + if (roleRefId != null) return true; + return false; } + private String search() { + for (; OrganizationMappedByRoleIterator.hasNext();) { + TreeNode OrganizationMappedByRole = OrganizationMappedByRoleIterator.next(); + TreeNode organizationRefIdNode = OrganizationMappedByRole.getChildren().at(0).b(); + String organizationRefId = organizationRefIdNode.getAttributes().getString("text-organizationRefId"); + if (!filterIds.contains(organizationRefId)) + continue; + + TreeNode roleRefIdNode = OrganizationMappedByRole.getChildren().at(1).b(); + return roleRefIdNode.getAttributes().getString("text-roleRefId"); + } + OrganizationMappedByRoleIterator = getParentOrgs(); + + return null; + } + + private Iterator<TreeNode> getParentOrgs() { + for (; idNodeIterator.hasNext();) { + TreeNode targetPersonNode = idNodeIterator.next(); + TreeNode parentOrganizations = targetPersonNode.getChildren().at(4).b(); + return parentOrganizations.getChildren().iterator(); + } + return null; + } + @Override public String next() { - return roleIdP2Iterator.next()._1(); + return roleRefId; } + }; } - - public Iterator<String> concurrentRoleIds(String personId) { + + public Iterator<String> competentRoleId(String personId) { InterfaceTraverser personTraverser = personTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> personIdPairIterator = personTraverser.find((TreeNode node) -> { - String nodeElement = node.getAttributes().getString("element"); - if (nodeElement == null) - return false; - if (!nodeElement.equals("Person")) - return false; - String nodeId = node.getAttributes().getString("Person-id"); - if (nodeId == null) - return false; - if (nodeId.equals(personId)) - return true; - return false; - }, "Person-id", personId); - if (!personIdPairIterator.hasNext()) - return new NullIterator(); - - Pair<TreeNode, NodePath> personidPair = personIdPairIterator.next(); + return new Iterator<String>() { - Iterator<Pair<TreeNode, NodePath>> priorityPairIterator = personTraverser.findInSubTreeAllValue( - (TreeNode node) -> { - String nodeElement = node.getAttributes().getString("element"); - if (nodeElement == null) - return false; - if (!nodeElement.equals("priority")) - return false; - String priority = node.getAttributes().getString("text-priority"); - if (priority != null) - return true; + String roleId = ""; + Iterator<TreeNode> personNodeIterator = personTraverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("Person")) return false; - }, personidPair, "text-priority"); - - TreeMap<String, String> roleIdTreeMap = TreeMap.empty(Ord.stringOrd); - - for (; priorityPairIterator.hasNext();) { - - Pair<TreeNode, NodePath> priorityPair = priorityPairIterator.next(); - TreeNode priorityNode = priorityPair.left(); - int priority = Integer.parseInt(priorityNode.getAttributes().getString("text-priority")); - if (priority > 0) { - NodePath priorityPath = priorityPair.right(); - Pair<Integer, NodePath> removeLastPair = priorityPath.last(); - NodePath roleIdNodePath = removeLastPair.right().add(removeLastPair.left() + 1); - TreeNode roleIdNode = getTarget(personTree.getRootNode(), roleIdNodePath); - String roleId = roleIdNode.getAttributes().getString("text-roleRefId"); - roleIdTreeMap = roleIdTreeMap.set(roleId, roleId); - } - } - Iterator<P2<String, String>> roleIdP2Iterator = roleIdTreeMap.iterator(); - return new Iterator<String>() { + String targetPersonId = node.getAttributes().getString("Person-id"); + if (targetPersonId == null) + return false; + if (targetPersonId.equals(personId)) + return true; + return false; + }, "PersonId", personId); + Iterator<TreeNode> PriorityMappedByRoleIterator = new NullIterator<TreeNode>(); @Override public boolean hasNext() { - if (roleIdP2Iterator.hasNext()) - return true; + + for (; PriorityMappedByRoleIterator.hasNext();) { + if (search()) + return true; + } + + for (; personNodeIterator.hasNext();) { + TreeNode personNode = personNodeIterator.next(); + TreeNode prioritiesNode = personNode.getChildren().at(6).b(); + PriorityMappedByRoleIterator = prioritiesNode.getChildren().iterator(); + for (; PriorityMappedByRoleIterator.hasNext();) { + if (search()) + return true; + } + } return false; } - @Override - public String next() { - return roleIdP2Iterator.next()._1(); - } - }; - } - - public Iterator<String> deepPersonIds(String orgId, LinkedList<String> filterIds) { - - TreeMap<String, String> personIdsTreeMap = TreeMap.empty(Ord.stringOrd); - Iterator<String> childrensIterator = deepChildOrganizationIdsPlus(orgId, filterIds); - - - if (!childrensIterator.hasNext()) - return new NullIterator(); - - for (; childrensIterator.hasNext();) { - String id = childrensIterator.next(); - personIdsTreeMap = personIdsSearch(id, personIdsTreeMap); - } - - if (personIdsTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> personIds = personIdsTreeMap.iterator(); - return new Iterator<String>() { - - @Override - public boolean hasNext() { - if (personIds.hasNext()) + private boolean search() { + TreeNode priorityMappedByRole = PriorityMappedByRoleIterator.next(); + TreeNode priorityNode = priorityMappedByRole.getChildren().at(0).b(); + String priority = priorityNode.getAttributes().getString("text-priority"); + if (priority.equals("0")) { + TreeNode roleIdNode = priorityMappedByRole.getChildren().at(1).b(); + roleId = roleIdNode.getAttributes().getString("text-roleRefId"); return true; - return false; - } - - @Override - public String next() { - return personIds.next()._1(); - } - }; - } - - - public Iterator<String> deepChildOrganizationIdsPlus(String orgId, LinkedList<String> filterIds) { - TreeMap<String, String> orgIdsTreeMap = TreeMap.empty(Ord.stringOrd); - - orgIdsTreeMap = orgIdsTreeMap.set(orgId, orgId); - orgIdsTreeMap = _deepChildOrganizationIds(orgId, orgIdsTreeMap); - - if (orgIdsTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> orgIdsP2Iterator = orgIdsTreeMap.iterator(); - return new Iterator<String>() { - - String childOrgId; - - @Override - public boolean hasNext() { - for (; orgIdsP2Iterator.hasNext();) { - childOrgId = orgIdsP2Iterator.next()._1(); - if (filter(childOrgId, filterIds)) - return true; } return false; } @Override public String next() { - return childOrgId; + return roleId; + } + }; + } + + public Iterator<String> concurrentRoleIds(String personId) { + + InterfaceTraverser personTraverser = personTree.getTraverser(); + + return new Iterator<String>() { + + String roleId = ""; + Iterator<TreeNode> personNodeIterator = personTraverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("Person")) + return false; + String targetPersonId = node.getAttributes().getString("Person-id"); + if (targetPersonId == null) + return false; + if (targetPersonId.equals(personId)) + return true; + return false; + }, "PersonId", personId); + Iterator<TreeNode> PriorityMappedByRoleIterator = new NullIterator<TreeNode>(); + + @Override + public boolean hasNext() { + + for (; PriorityMappedByRoleIterator.hasNext();) { + if (search()) + return true; + } + + for (; personNodeIterator.hasNext();) { + TreeNode personNode = personNodeIterator.next(); + TreeNode prioritiesNode = personNode.getChildren().at(6).b(); + PriorityMappedByRoleIterator = prioritiesNode.getChildren().iterator(); + for (; PriorityMappedByRoleIterator.hasNext();) { + if (search()) + return true; + } + } + return false; + } + + private boolean search() { + TreeNode priorityMappedByRole = PriorityMappedByRoleIterator.next(); + TreeNode priorityNode = priorityMappedByRole.getChildren().at(0).b(); + int priority = Integer.parseInt(priorityNode.getAttributes().getString("text-priority")); + + if (priority > 0) { + TreeNode roleIdNode = priorityMappedByRole.getChildren().at(1).b(); + roleId = roleIdNode.getAttributes().getString("text-roleRefId"); + return true; + } + return false; + + } + + @Override + public String next() { + return roleId; } }; } - + + public Iterator<String> deepPersonIds(String orgId, LinkedList<String> filterIds) { + + return new Iterator<String>() { + Iterator<String> orgIdIterator = deepParentOrganizationIdsPlus(orgId, filterIds); + private Iterator<String> personIterator = new NullIterator<String>(); + String personId = ""; + + @Override + public boolean hasNext() { + for (; orgIdIterator.hasNext();) { + if (personIterator.hasNext()) { + personId = personIterator.next(); + return true; + } + + String targetOrgId = orgIdIterator.next(); + personIterator = personIds(targetOrgId, new LinkedList<>()); + if (personIterator.hasNext()) { + personId = personIterator.next(); + return true; + } + } + return false; + } + + @Override + public String next() { + // TODO Auto-generated method stub + return personId; + } + + }; + } + + public Iterator<String> deepChildOrganizationIdsPlus(String orgId, LinkedList<String> filterIds) { + + return new Iterator<String>() { + Iterator<String> childOrgIdIterator = deepChildOrganizationIds(orgId, filterIds); + String childOrgId = initOrgId(); + + @Override + public boolean hasNext() { + return childOrgId != null; + } + + private String initOrgId() { + if (filter(filterIds, orgId)) + return orgId; + if (childOrgIdIterator.hasNext()) + return childOrgIdIterator.next(); + return null; + } + + @Override + public String next() { + String str = childOrgId; + if (childOrgIdIterator.hasNext()) + childOrgId = childOrgIdIterator.next(); + else + childOrgId = null; + return str; + } + + }; + } + public Iterator<String> deepChildOrganizationIds(String orgId, LinkedList<String> filterIds) { - TreeMap<String, String> orgIdsTreeMap = TreeMap.empty(Ord.stringOrd); - TreeMap<String, String> newOrgIdsTreeMap = _deepChildOrganizationIds(orgId, orgIdsTreeMap); - if (newOrgIdsTreeMap.isEmpty()) - return new NullIterator(); + return new Iterator<String>() { + + Iterator<TreeNode> childOrgnizationIdsIterator = childOrganizationIdsNode(orgId); + Stack<String> orgIdStack = new Stack<String>(); + + String childOrgId; + + @Override + public boolean hasNext() { - Iterator<P2<String, String>> orgIdP2Iterator = newOrgIdsTreeMap.iterator(); + for (; childOrgnizationIdsIterator.hasNext();) { + TreeNode parentOrgIdNode = childOrgnizationIdsIterator.next(); + childOrgId = parentOrgIdNode.getAttributes().getString("text-organizationRefId"); + orgIdStack.push(childOrgId); + if (orgNodefilter(filterIds, parentOrgIdNode)) + return true; + } + if (orgIdStack.isEmpty()) + return false; - return new Iterator<String>() { - String childOrgId; + childOrgnizationIdsIterator = childOrganizationIdsNode(orgIdStack.pop()); + return this.hasNext(); + } @Override public String next() { return childOrgId; } - @Override - public boolean hasNext() { - for (; orgIdP2Iterator.hasNext();) { - childOrgId = orgIdP2Iterator.next()._1(); - if (filter(childOrgId, filterIds)) - return true; - } - return false; - } }; } - + public TreeMap<String, String> _deepChildOrganizationIds(String orgId, TreeMap<String, String> orgIdsTreeMap) { TreeMap<String, String> childrenIdTreeMap = _childOrganizationIds(orgId, TreeMap.empty(Ord.stringOrd)); @@ -638,41 +542,201 @@ } public Iterator<String> childOrganizationIds(String orgId, LinkedList<String> filterIds) { - TreeMap<String, String> childrenOrgIdTreeMap = TreeMap.empty(Ord.stringOrd); - TreeMap<String, String> newChildrenOrgIdTreeMap = _childOrganizationIds(orgId, childrenOrgIdTreeMap); - - if (newChildrenOrgIdTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> childrenOrgIdIterator = newChildrenOrgIdTreeMap.iterator(); return new Iterator<String>() { - String childOrgId; + Iterator<TreeNode> orgNodeIterator = childOrganizationIdsNode(orgId); + String organizationRefId; @Override public boolean hasNext() { - - if (childrenOrgIdIterator.hasNext()) { - childOrgId = childrenOrgIdIterator.next()._1(); - if (filter(childOrgId, filterIds)) - return true; + for (; orgNodeIterator.hasNext();) { + TreeNode organizationRefIdNode = orgNodeIterator.next(); + organizationRefId = organizationRefIdNode.getAttributes().getString("text-organizationRefId"); + return true; } return false; } @Override public String next() { - return childOrgId; + return organizationRefId; + } + + }; + } + + public Iterator<TreeNode> childOrganizationIdsNode(String orgId) { + + InterfaceTraverser orgTraverser = organizationTree.getTraverser(); + + return new Iterator<TreeNode>() { + TreeNode childOrgNode; + + Iterator<TreeNode> orgIdNodeIterator = orgTraverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("Organization")) + return false; + String nodeId = node.getAttributes().getString("Organization-id"); + if (nodeId == null) + return false; + if (nodeId.equals(orgId)) + return true; + return false; + }, "Organization-id", orgId); + + Iterator<TreeNode> childOrganizations = getParentOrgs(); + + @Override + public boolean hasNext() { + + if (childOrganizations == null) + return false; + if (childOrganizations.hasNext()) + childOrgNode = search(); + else + childOrgNode = null; + if (childOrgNode != null) + return true; + + childOrganizations = getParentOrgs(); + if (childOrganizations != null) + childOrgNode = search(); + + if (childOrgNode != null) + return true; + + return this.hasNext(); + } + + @Override + public TreeNode next() { + return childOrgNode; + } + + private TreeNode search() { + for (; childOrganizations.hasNext();) { + TreeNode OrganizationMappedByRole = childOrganizations.next(); + TreeNode organizationRefIdsNode = OrganizationMappedByRole.getChildren().at(0).b(); + TreeNode organizationRefIdNode = organizationRefIdsNode.getChildren().at(0).b(); + return organizationRefIdNode; + + } + childOrganizations = getParentOrgs(); + + return null; + } + + private Iterator<TreeNode> getParentOrgs() { + for (; orgIdNodeIterator.hasNext();) { + TreeNode targetPersonNode = orgIdNodeIterator.next(); + TreeNode parentOrganizations = targetPersonNode.getChildren().at(3).b(); + return parentOrganizations.getChildren().iterator(); + } + return null; } }; } + private boolean orgNodefilter(LinkedList<String> filterIds, TreeNode orgNode) { + System.out.println(orgNode.getAttributes().getString("element")); + String orgId = orgNode.getAttributes().getString("text-organizationRefId"); + + return filter(filterIds, orgId); + } + + private boolean filter(LinkedList<String> filterIds, String id) { + + Pattern orgPattern = Pattern.compile("o:"); + Matcher orgMacher = orgPattern.matcher(id); + if (orgMacher.find()) { + id = getRole(id); + } + + for (String filterId : filterIds) { + Pattern rolePattern = Pattern.compile("r:"); + Matcher roleMacher = rolePattern.matcher(filterId); + if (roleMacher.find()) { + if (!filterId.equals(id)) { + return false; + } + } else { + Pattern rdePattern = Pattern.compile("rde:"); + Matcher rdeMacher = rdePattern.matcher(filterId); + if (rdeMacher.find()) { + if (!getRde(id, filterId)) + return false; + } + } + } + return true; + } + + private String getRole(String orgId) { + InterfaceTraverser orgTraverser = organizationTree.getTraverser(); + Iterator<TreeNode> orgNodeIterator = orgTraverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("Organization")) + return false; + String nodeId = node.getAttributes().getString("Organization"); + if (nodeId == null) + return false; + if (nodeId.equals(orgId)) + return true; + return false; + }, "Organization-id", orgId); + + if (!orgNodeIterator.hasNext()) + return ""; + + TreeNode orgNode = orgNodeIterator.next(); + TreeNode roleRefIds = orgNode.getChildren().at(2).b(); + TreeNode roleRefId = roleRefIds.getChildren().at(0).b(); + String roleId = roleRefId.getAttributes().getString("text-roleRefId"); + return roleId; + } + + private boolean getRde(String roleId, String filterId) { + + InterfaceTraverser roleTraverser = roleTree.getTraverser(); + Iterator<TreeNode> rdeIdNodeIterator = roleTraverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("Role")) + return false; + String nodeId = node.getAttributes().getString("Role-id"); + if (nodeId == null) + return false; + if (nodeId.equals(roleId)) + return true; + return false; + }, "Role-id", roleId); + + for (; rdeIdNodeIterator.hasNext();) { + TreeNode rdeIdNode = rdeIdNodeIterator.next(); + TreeNode roleDescriptionElementRefIds = rdeIdNode.getChildren().at(6).b(); + Iterator<TreeNode> roleDescriptionElementRefIdIterator = roleDescriptionElementRefIds.getChildren().iterator(); + for (; roleDescriptionElementRefIdIterator.hasNext();) { + String roleDescriptionElementRefId = roleDescriptionElementRefIdIterator.next().getAttributes() + .getString("text-roleDescriptionElementRefId"); + System.out.println(roleDescriptionElementRefId); + if (roleDescriptionElementRefId.equals(filterId)) + return true; + } + } + return false; + } + public TreeMap<String, String> _childOrganizationIds(String orgId, TreeMap<String, String> childOrgIdsTreeMap) { InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> orgIdPairIterator = orgTraverser.find((TreeNode node) -> { + Iterator<TreeNode> orgIdNodeIterator = orgTraverser.find((TreeNode node) -> { String nodeElement = node.getAttributes().getString("element"); if (nodeElement == null) return false; @@ -686,41 +750,39 @@ return false; }, "Organization-id", orgId); - if (!orgIdPairIterator.hasNext()) + if (!orgIdNodeIterator.hasNext()) return childOrgIdsTreeMap; - Pair<TreeNode, NodePath> orgIdPair = orgIdPairIterator.next(); + TreeNode orgIdNode = orgIdNodeIterator.next(); - Iterator<Pair<TreeNode, NodePath>> chilrenOrgPairIterator = orgTraverser.findInSubTree((TreeNode node) -> { + Iterator<TreeNode> chilrenOrgNodeIterator = orgTraverser.findInSubTree((TreeNode node) -> { String nodeElement = node.getAttributes().getString("element"); if (nodeElement == null) return false; if (nodeElement.equals("childOrganizations")) return true; return false; - }, orgIdPair, "element", "childOrganizations"); + }, orgIdNode, "element", "childOrganizations"); - if (!chilrenOrgPairIterator.hasNext()) + if (!chilrenOrgNodeIterator.hasNext()) return childOrgIdsTreeMap; - Pair<TreeNode, NodePath> chilerenOrg = chilrenOrgPairIterator.next(); + TreeNode chilerenOrg = chilrenOrgNodeIterator.next(); - Iterator<Pair<TreeNode, NodePath>> chilrenOrgIdPairIterator = orgTraverser.findInSubTreeAllValue( - (TreeNode node) -> { - String nodeElement = node.getAttributes().getString("element"); - if (nodeElement == null) - return false; - if (!nodeElement.equals("organizationRefIds")) - return false; - nodeElement = node.getAttributes().getString("text-organizationRefIds"); - if (nodeElement != null) - return true; - return false; - }, chilerenOrg, "text-organizationRefIds"); + Iterator<TreeNode> chilrenOrgIdNodeIterator = orgTraverser.findInSubTreeAllValue((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals("organizationRefIds")) + return false; + nodeElement = node.getAttributes().getString("text-organizationRefIds"); + if (nodeElement != null) + return true; + return false; + }, chilerenOrg, "text-organizationRefIds"); - for (; chilrenOrgIdPairIterator.hasNext();) { - String childrenOrgId = chilrenOrgIdPairIterator.next().left().getAttributes() - .getString("text-organizationRefIds"); + for (; chilrenOrgIdNodeIterator.hasNext();) { + String childrenOrgId = chilrenOrgIdNodeIterator.next().getAttributes().getString("text-organizationRefIds"); childOrgIdsTreeMap = childOrgIdsTreeMap.set(childrenOrgId, childrenOrgId); } @@ -728,7 +790,7 @@ return childOrgIdsTreeMap; } - class NullIterator implements Iterator<String> { + class NullIterator<T> implements Iterator<T> { @Override public boolean hasNext() { @@ -736,7 +798,7 @@ } @Override - public String next() { + public T next() { return null; } @@ -746,26 +808,7 @@ InterfaceTraverser personTraverser = personTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> personIdPairIterator = personTraverser.find((TreeNode node) -> { - String element = node.getAttributes().getString("element"); - if (element == null) - return false; - if (!element.equals("Person")) - return false; - String nodePersonId = node.getAttributes().getString("Person-id"); - if (nodePersonId == null) - return false; - if (nodePersonId.equals(personId)) - return true; - return false; - }, "Person-id", personId); - - if (!personIdPairIterator.hasNext()) - return ""; - - Pair<TreeNode, NodePath> targetPersonIdPair = personIdPairIterator.next(); - - Iterator<Pair<TreeNode, NodePath>> roleIdPairIterator = personTraverser.findInSubTree((TreeNode node) -> { + Iterator<TreeNode> roleIdNodeIterator = personTraverser.find((TreeNode node) -> { String element = node.getAttributes().getString("element"); if (element == null) return false; @@ -777,128 +820,167 @@ if (compareRoleId.equals(roleId)) return true; return false; - }, targetPersonIdPair, "text-roleRefId", roleId); + }, "text-roleRefId", roleId); - for (; roleIdPairIterator.hasNext();) { - Pair<TreeNode, NodePath> roleIdPair = roleIdPairIterator.next(); - NodePath roleIdNodePath = roleIdPair.right(); - Pair<Integer, NodePath> removeLastPath = roleIdNodePath.last(); - NodePath priorityNodePath = removeLastPath.right().add(removeLastPath.left() - 1); - TreeNode priorityNode = getTarget(personTree.getRootNode(), priorityNodePath); + for (; roleIdNodeIterator.hasNext();) { + TreeNode roleIdNode = roleIdNodeIterator.next(); + ParentIndex parentIndex = personTraverser.getParentIndex(); + TreeNode roleIdParentNode = parentIndex.get(roleIdNode); + TreeNode parent = parentIndex.get(roleIdParentNode); + parent = parentIndex.get(parent); + String nodePersonId = parent.getAttributes().getString("Person-Id"); + if (nodePersonId != null && !nodePersonId.equals(personId)) + continue; + TreeNode priorityNode = roleIdParentNode.getChildren().at(0).b(); if (priorityNode.getAttributes().getString("element").equals("priority")) return priorityNode.getAttributes().getString("text-priority"); } return ""; } - public Iterator<String> parentOrganizationIds(String orgId, LinkedList<String> filterIds) { + public Iterator<String> parentOrganizationIds(String id, LinkedList<String> filterIds) { - TreeMap<String, String> parentIdsTreeMap = _parentOrganizationIds(orgId); - if (parentIdsTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> parentIdP2Iterator = parentIdsTreeMap.iterator(); return new Iterator<String>() { - String parentId; + Iterator<TreeNode> orgNodeIterator = parentOrganizationIdsNode(id); + String organizationRefId; @Override public boolean hasNext() { - for (; parentIdP2Iterator.hasNext();) { - parentId = parentIdP2Iterator.next()._1(); - if (filter(parentId, filterIds)) - return true; + for (; orgNodeIterator.hasNext();) { + TreeNode organizationRefIdNode = orgNodeIterator.next(); + String orgId = organizationRefIdNode.getAttributes().getString("text-organizationRefId"); + if (!filter(filterIds, orgId)) + continue; + organizationRefId = orgId; + return true; } return false; } @Override public String next() { - return parentId; + return organizationRefId; } }; } - public TreeMap<String, String> _parentOrganizationIds(String orgId) { + public Iterator<TreeNode> parentOrganizationIdsNode(String id) { + + return new Iterator<TreeNode>() { + InterfaceTraverser traverser = getTraverser(id); + String element; + int pos; - InterfaceTraverser orgTraverser = organizationTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> orgIdPairIterator = orgTraverser.find((TreeNode node) -> { - String element = node.getAttributes().getString("element"); - if (element == null) - return false; - if (!element.equals("Organization")) - return false; - String nodeId = node.getAttributes().getString("Organization-id"); - if (nodeId == null) - return false; - if (nodeId.equals(orgId)) - return true; - return false; - }, "Organization-id", orgId); - - if (!orgIdPairIterator.hasNext()) - return TreeMap.empty(Ord.stringOrd); - - Pair<TreeNode, NodePath> orgNode = orgIdPairIterator.next(); - - Iterator<Pair<TreeNode, NodePath>> parentOrgPairIterator = orgTraverser.findInSubTree((TreeNode node) -> { - String element = node.getAttributes().getString("element"); - if (element == null) + Iterator<TreeNode> idNodeIterator = traverser.find((TreeNode node) -> { + String nodeElement = node.getAttributes().getString("element"); + if (nodeElement == null) + return false; + if (!nodeElement.equals(element)) + return false; + String nodeId = node.getAttributes().getString(element + "-id"); + if (nodeId == null) + return false; + if (nodeId.equals(id)) + return true; return false; - if (element.equals("parentOrganizations")) - return true; - return false; - }, orgNode, "element", "parentOrganizations"); + }, element + "-id", id); - TreeMap<String, String> parentIdsTreeMap = TreeMap.empty(Ord.stringOrd); - - for (; parentOrgPairIterator.hasNext();) { - Pair<TreeNode, NodePath> parentOrgNode = parentOrgPairIterator.next(); + TreeNode orgId; + Iterator<TreeNode> parentOrganizationsIterator = getparentOrganizations(); - Iterator<Pair<TreeNode, NodePath>> parentOrgIdPairIterator = orgTraverser.findInSubTreeAllValue( - (TreeNode node) -> { - String element = node.getAttributes().getString("element"); - if (element == null) - return false; - if (!element.equals("organizationRefId")) - return false; - String parentId = node.getAttributes().getString("text-organizationRefId"); - if (parentId != null) - return true; - return false; - }, parentOrgNode, "text-organizationRefId"); - - for (; parentOrgIdPairIterator.hasNext();) { - String parentId = parentOrgIdPairIterator.next().left().getAttributes().getString("text-organizationRefId"); - parentIdsTreeMap = parentIdsTreeMap.set(parentId, parentId); + private Iterator<TreeNode> getparentOrganizations() { + for (; idNodeIterator.hasNext();) { + TreeNode targetPersonNode = idNodeIterator.next(); + TreeNode parentOrganizations = targetPersonNode.getChildren().at(pos).b(); + return parentOrganizations.getChildren().iterator(); + } + return null; } - } + @Override + public boolean hasNext() { + if (parentOrganizationsIterator == null) + return false; + if (parentOrganizationsIterator.hasNext()) + orgId = search(); + else + orgId = null; + if (orgId != null) + return true; + + for (; parentOrganizationsIterator != null;) { + parentOrganizationsIterator = getparentOrganizations(); + if (parentOrganizationsIterator != null) + orgId = search(); + + if (orgId != null) + return true; + } + return false; + } + + @Override + public TreeNode next() { + return orgId; + } - return parentIdsTreeMap; + private TreeNode search() { + for (; parentOrganizationsIterator.hasNext();) { + TreeNode OrganizationMappedByRole = parentOrganizationsIterator.next(); + TreeNode organizationRefIdNode = OrganizationMappedByRole.getChildren().at(0).b(); + return organizationRefIdNode; + } + parentOrganizationsIterator = getparentOrganizations(); + + return null; + } + private InterfaceTraverser getTraverser(String id) { + Pattern rolePattern = Pattern.compile("p:"); + Matcher roleMacher = rolePattern.matcher(id); + if (roleMacher.find()) { + element = "Person"; + pos = 5; + return personTree.getTraverser(); + } + + Pattern rdePattern = Pattern.compile("o:"); + Matcher rdeMacher = rdePattern.matcher(id); + if (rdeMacher.find()) { + element = "Organization"; + pos = 4; + return organizationTree.getTraverser(); + } + return null; + } + + }; } public Iterator<String> deepParentOrganizationIds(String orgId, LinkedList<String> filterIds) { - TreeMap<String, String> parentIdsTreeMap = TreeMap.empty(Ord.stringOrd); - TreeMap<String, String> newParentIdsTreeMap = _deepParentOrganizationIds(orgId, parentIdsTreeMap); - - if (newParentIdsTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> parentIds = newParentIdsTreeMap.iterator(); return new Iterator<String>() { + Iterator<TreeNode> parentOrgnizationIdsIterator = parentOrganizationIdsNode(orgId); + Stack<String> orgIdStack = new Stack<String>(); + String parentOrgId; @Override public boolean hasNext() { - for (; parentIds.hasNext();) { - parentOrgId = parentIds.next()._1(); - if (filter(parentOrgId, filterIds)) + + for (; parentOrgnizationIdsIterator.hasNext();) { + TreeNode parentOrgIdNode = parentOrgnizationIdsIterator.next(); + parentOrgId = parentOrgIdNode.getAttributes().getString("text-organizationRefId"); + orgIdStack.push(parentOrgId); + if (orgNodefilter(filterIds, parentOrgIdNode)) return true; } - return false; + if (orgIdStack.isEmpty()) + return false; + + parentOrgnizationIdsIterator = parentOrganizationIdsNode(orgIdStack.pop()); + return this.hasNext(); } @Override @@ -909,49 +991,33 @@ }; } - public TreeMap<String, String> _deepParentOrganizationIds(String orgId, TreeMap<String, String> orgIds) { - - TreeMap<String, String> parentIdsTreeMap = _parentOrganizationIds(orgId); - - if (parentIdsTreeMap.isEmpty()) - return orgIds; - - Iterator<P2<String, String>> parentIdsIterator = parentIdsTreeMap.iterator(); - for (; parentIdsIterator.hasNext();) { - String parentId = parentIdsIterator.next()._1(); - orgIds = orgIds.set(parentId, parentId); - orgIds = _deepParentOrganizationIds(parentId, orgIds); - } - return orgIds; - } - public Iterator<String> deepParentOrganizationIdsPlus(String id, LinkedList<String> filterIds) { - TreeMap<String, String> parentIdsTreeMap = TreeMap.empty(Ord.stringOrd); - - parentIdsTreeMap = parentIdsTreeMap.set(id, id); - parentIdsTreeMap = _deepParentOrganizationIds(id, parentIdsTreeMap); - - if (parentIdsTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> personIds = parentIdsTreeMap.iterator(); return new Iterator<String>() { - String parentOrgId; + String parentOrgId = initOrgId(); + Iterator<String> parentOrgIdIterator = deepParentOrganizationIds(id, filterIds); @Override public boolean hasNext() { - for (; personIds.hasNext();) { - parentOrgId = personIds.next()._1(); - if (filter(parentOrgId, filterIds)) - return true; - } - return false; + return parentOrgId != null; + } + + private String initOrgId() { + if (filter(filterIds, id)) + return id; + + if (parentOrgIdIterator.hasNext()) + return parentOrgIdIterator.next(); + return null; } @Override public String next() { - return parentOrgId; + String str = parentOrgId; + parentOrgId = null; + if (parentOrgIdIterator.hasNext()) + parentOrgId = parentOrgIdIterator.next(); + return str; } }; @@ -968,20 +1034,17 @@ final String StrPath = str; InterfaceTraverser traverser = null; - TreeNode root = null; String elementName = null; if (splitPath[0].equals("r")) { traverser = roleTree.getTraverser(); - root = roleTree.getRootNode(); elementName = "Role"; } if (splitPath[0].equals("rde")) { traverser = rdeTree.getTraverser(); - root = rdeTree.getRootNode(); elementName = "RoleDescriptionElement"; } - Iterator<Pair<TreeNode, NodePath>> PathNameIterator = traverser.find((TreeNode node) -> { + Iterator<TreeNode> PathNameIterator = traverser.find((TreeNode node) -> { String element = node.getAttributes().getString("element"); if (element == null) return false; @@ -998,49 +1061,39 @@ if (!PathNameIterator.hasNext()) return ""; - Pair<TreeNode, NodePath> pathNamePair = PathNameIterator.next(); - NodePath pathNamePath = pathNamePair.right(); - NodePath pathNameIdPath = pathNamePath.last().right(); - - TreeNode pathNameIdNode = getTarget(root, pathNameIdPath); + TreeNode pathNameNode = PathNameIterator.next(); + ParentIndex parentIndex = traverser.getParentIndex(); + TreeNode pathNameIdNode = parentIndex.get(pathNameNode); String pathNameId = pathNameIdNode.getAttributes().getString(elementName + "-id"); return pathNameId; } public Iterator<String> roleDescriptionElementIds(String id, LinkedList<String> filterIds) { - Iterator<String> orgIdsIterator = deepParentOrganizationIdsPlus(id, filterIds); - - TreeMap<String, String> rdeIdsTreeMap = TreeMap.empty(Ord.stringOrd); - - for (; orgIdsIterator.hasNext();) { - String orgId = orgIdsIterator.next(); - Iterator<String> roleIdIteraotr = roleIds(orgId); - for (; roleIdIteraotr.hasNext();) { - String roleId = roleIdIteraotr.next(); - Iterator<String> rdeIdIterator = getRde(roleId); - for (; rdeIdIterator.hasNext();) { - String rdeId = rdeIdIterator.next(); - rdeIdsTreeMap = rdeIdsTreeMap.set(rdeId, rdeId); - } - } - } - if (rdeIdsTreeMap.isEmpty()) - return new NullIterator(); - - Iterator<P2<String, String>> rdeIds = rdeIdsTreeMap.iterator(); return new Iterator<String>() { + Iterator<String> parentOrgIdIterator = deepParentOrganizationIdsPlus(id, filterIds); + Iterator<String> rdeIdIterator = new NullIterator<String>(); @Override public boolean hasNext() { - if (rdeIds.hasNext()) + + if (rdeIdIterator.hasNext()) return true; - return false; + + if (parentOrgIdIterator.hasNext()) { + String orgId = parentOrgIdIterator.next(); + String roleId = getRole(orgId); + rdeIdIterator = getRde(roleId); + } else { + return false; + } + + return this.hasNext(); } @Override public String next() { - return rdeIds.next()._1(); + return rdeIdIterator.next(); } }; } @@ -1049,77 +1102,53 @@ InterfaceTraverser traverser = roleTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> roleIdPairIterator = traverser.find((TreeNode node) -> { - String element = node.getAttributes().getString("element"); - if (element == null) - return false; - if (!element.equals("Role")) - return false; - String id = node.getAttributes().getString("Role-id"); - if (id == null) - return false; - if (id.equals(roleId)) - return true; - return false; - }, "Role-id", roleId); - - if (!roleIdPairIterator.hasNext()) - return new NullIterator(); + return new Iterator<String>() { - Pair<TreeNode, NodePath> roleIdPair = roleIdPairIterator.next(); - - Iterator<Pair<TreeNode, NodePath>> rdeIdPairIterator = traverser.findInSubTreeAllValue((TreeNode node) -> { - String element = node.getAttributes().getString("element"); - if (element == null) - return false; - if (!element.equals("roleDescriptionElementRefIds")) + Iterator<TreeNode> roleIdNodeIterator = traverser.find((TreeNode node) -> { + String element = node.getAttributes().getString("element"); + if (element == null) + return false; + if (!element.equals("Role")) + return false; + String id = node.getAttributes().getString("Role-id"); + if (id == null) + return false; + if (id.equals(roleId)) + return true; return false; - String rde = node.getAttributes().getString("text-roleDescriptionElementRefIds"); - if (rde != null) - return true; - return false; - }, roleIdPair, "text-roleDescriptionElementRefIds"); - - if (!rdeIdPairIterator.hasNext()) - return new NullIterator(); - - return new Iterator<String>() { + }, "Role-id", roleId); + String rdeId; + Iterator<TreeNode> roleDescriptionElementRefIdIterator = new NullIterator<TreeNode>(); @Override public boolean hasNext() { - if (rdeIdPairIterator.hasNext()) - return true; + for (; roleIdNodeIterator.hasNext();) { + + if (roleDescriptionElementRefIdIterator.hasNext()) { + rdeId = roleDescriptionElementRefIdIterator.next().getAttributes() + .getString("text-roleDescriptionElementRefId"); + return true; + } + + TreeNode roleId = roleIdNodeIterator.next(); + TreeNode roleDescriptionElementRefIds = roleId.getChildren().at(6).b(); + roleDescriptionElementRefIdIterator = roleDescriptionElementRefIds.getChildren().iterator(); + if (roleDescriptionElementRefIdIterator.hasNext()) { + rdeId = roleDescriptionElementRefIdIterator.next().getAttributes() + .getString("text-roleDescriptionElementRefId"); + return true; + } + + } return false; } @Override public String next() { - return rdeIdPairIterator.next().left().getAttributes().getString("text-roleDescriptionElementRefIds"); + return rdeId; } }; } - - 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 Thu Nov 13 23:34:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JungleBulletinBoard.java Tue Nov 25 11:57:17 2014 +0900 @@ -42,7 +42,7 @@ - public Iterable<String> getBoards() { + public IterableConverter<String, TreeNode> getBoards() { JungleTree tree = jungle.getTreeByName("boards"); TreeNode node = tree.getRootNode(); Children chs = node.getChildren();
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/ChildOrganizationIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/ChildOrganizationIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -10,23 +10,22 @@ public class ChildOrganizationIdsTest { - @Test - public void childOrganizationIdsTest(){ - JuGrix jugrix = new JuGrix(false); - LinkedList<String> list = new LinkedList<String>(); - Iterator<String> ids = jugrix.childOrganizationIds("o:2", list); - - Assert.assertTrue(ids.hasNext()); - Assert.assertEquals(ids.next(),"o:9"); + @Test + public void childOrganizationIdsTest() { + JuGrix jugrix = new JuGrix(); + LinkedList<String> list = new LinkedList<String>(); + list.add("r:11"); + Iterator<String> ids = jugrix.childOrganizationIds("o:2", list); + Assert.assertTrue(ids.hasNext()); - Assert.assertEquals(ids.next(),"o:3"); - - JuGrix indexJugrix = new JuGrix(true); - ids = indexJugrix.childOrganizationIds("o:2", list); - + Assert.assertEquals(ids.next(), "o:3"); + + list = new LinkedList<String>(); + list.add("rde:4"); + ids = jugrix.childOrganizationIds("o:2", list); + Assert.assertTrue(ids.hasNext()); - Assert.assertEquals(ids.next(),"o:9"); - Assert.assertTrue(ids.hasNext()); - Assert.assertEquals(ids.next(),"o:3"); - } + Assert.assertEquals(ids.next(), "o:3"); + } + }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/CompetentRoleIdTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/CompetentRoleIdTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -11,14 +11,11 @@ @Test public void testCompetentRoleIdTest(){ - JuGrix jugrix = new JuGrix(false); + + JuGrix jugrix = new JuGrix(); Iterator<String> roleIds = jugrix.competentRoleId("p:1"); Assert.assertTrue(roleIds.hasNext()); Assert.assertEquals(roleIds.next(), "r:10"); - jugrix = new JuGrix(true); - roleIds = jugrix.competentRoleId("p:1"); - Assert.assertTrue(roleIds.hasNext()); - Assert.assertEquals(roleIds.next(), "r:10"); } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/ConcurrentRoleIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/ConcurrentRoleIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -8,20 +8,12 @@ import junit.framework.Assert; public class ConcurrentRoleIdsTest { - - @Test - public void testConcurrentRoleId(){ - JuGrix jugrix = new JuGrix(false); - Iterator<String> roleIds = jugrix.concurrentRoleIds("p:1"); - Assert.assertTrue(roleIds.hasNext()); - Assert.assertEquals(roleIds.next(), "r:34"); - - jugrix = new JuGrix(true); - roleIds = jugrix.concurrentRoleIds("p:1"); + + @Test + public void testConcurrentRoleId() { + JuGrix jugrix = new JuGrix(); + Iterator<String> roleIds = jugrix.concurrentRoleIds("p:1"); Assert.assertTrue(roleIds.hasNext()); Assert.assertEquals(roleIds.next(), "r:34"); - - roleIds = jugrix.concurrentRoleIds("p:48"); - Assert.assertFalse(roleIds.hasNext()); - } + } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepChildOrganizationIdsPlusTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepChildOrganizationIdsPlusTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -11,31 +11,30 @@ public class DeepChildOrganizationIdsPlusTest { @Test - public void TestDeepChildOrganizationIdsPlus(){ - JuGrix jugrix = new JuGrix(false); - LinkedList<String> filterIds = new LinkedList<String>(); - filterIds.add("r:9"); - Iterator<String> childrenIds = jugrix.deepChildOrganizationIdsPlus("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:2"); - - filterIds = new LinkedList<String>(); - filterIds.add("r:5"); - childrenIds = jugrix.deepChildOrganizationIdsPlus("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:4"); - - jugrix = new JuGrix(true); - filterIds = new LinkedList<String>(); - filterIds.add("r:9"); - childrenIds = jugrix.deepChildOrganizationIdsPlus("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:2"); - - filterIds = new LinkedList<String>(); - filterIds.add("r:5"); - childrenIds = jugrix.deepChildOrganizationIdsPlus("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:4"); + public void TestDeepChildOrganizationIdsPlus() { + + JuGrix jugrix = new JuGrix(); + LinkedList<String> filterIds = new LinkedList<String>(); + Iterator<String> childrenIds = jugrix.deepChildOrganizationIdsPlus("o:2", filterIds); + Assert.assertTrue(childrenIds.hasNext()); + String orgId = childrenIds.next(); + Assert.assertEquals(orgId, "o:2"); + Assert.assertTrue(childrenIds.hasNext()); + orgId = childrenIds.next(); + Assert.assertEquals(orgId, "o:3"); + + filterIds.add("r:9"); + childrenIds = jugrix.deepChildOrganizationIdsPlus("o:2", filterIds); + Assert.assertTrue(childrenIds.hasNext()); + orgId = childrenIds.next(); + Assert.assertEquals(orgId, "o:2"); + + filterIds.add("rde:3"); + childrenIds = jugrix.deepChildOrganizationIdsPlus("o:2", filterIds); + Assert.assertTrue(childrenIds.hasNext()); + orgId = childrenIds.next(); + Assert.assertEquals(orgId, "o:2"); + + } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepChildOrganizationIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepChildOrganizationIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -12,37 +12,23 @@ @Test public void TestDeepChildOrganizationIds() { - JuGrix jugrix = new JuGrix(false); + + JuGrix jugrix = new JuGrix(); LinkedList<String> filterIds = new LinkedList<String>(); - filterIds.add("r:5"); + filterIds.add("r:11"); Iterator<String> childrenIds = jugrix.deepChildOrganizationIds("o:2", filterIds); Assert.assertTrue(childrenIds.hasNext()); String childrenId = childrenIds.next(); - Assert.assertEquals(childrenId, "o:4"); + Assert.assertEquals(childrenId, "o:3"); filterIds.add("rde:4"); childrenIds = jugrix.deepChildOrganizationIds("o:2", filterIds); Assert.assertTrue(childrenIds.hasNext()); childrenId = childrenIds.next(); - Assert.assertEquals(childrenId, "o:4"); + Assert.assertEquals(childrenId, "o:3"); Assert.assertFalse(childrenIds.hasNext()); - jugrix = new JuGrix(true); - filterIds = new LinkedList<String>(); - filterIds.add("r:5"); - childrenIds = jugrix.deepChildOrganizationIds("o:2", filterIds); - - Assert.assertTrue(childrenIds.hasNext()); - childrenId = childrenIds.next(); - Assert.assertEquals(childrenId, "o:4"); - - filterIds.add("rde:4"); - childrenIds = jugrix.deepChildOrganizationIds("o:2", filterIds); - - Assert.assertTrue(childrenIds.hasNext()); - childrenId = childrenIds.next(); - Assert.assertEquals(childrenId, "o:4"); } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepParentOrganizationIdsPlusTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepParentOrganizationIdsPlusTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -11,37 +11,20 @@ public class DeepParentOrganizationIdsPlusTest { @Test public void deepParentOrganizationIdsPlus(){ - JuGrix jugrix = new JuGrix(false); + JuGrix jugrix = new JuGrix(); LinkedList<String> filterIds = new LinkedList<String>(); - //filterIds.add("r:2"); Iterator<String> childrenIds = jugrix.deepParentOrganizationIdsPlus("o:2", filterIds); + + Assert.assertTrue(childrenIds.hasNext()); + Assert.assertEquals(childrenIds.next(),"o:2"); Assert.assertTrue(childrenIds.hasNext()); Assert.assertEquals(childrenIds.next(),"o:23"); Assert.assertTrue(childrenIds.hasNext()); Assert.assertEquals(childrenIds.next(),"o:22"); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:2"); - filterIds.add("r:2"); childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); Assert.assertTrue(childrenIds.hasNext()); Assert.assertEquals(childrenIds.next(),"o:23"); - - jugrix = new JuGrix(true); - filterIds = new LinkedList<String>(); - //filterIds.add("r:2"); - childrenIds = jugrix.deepParentOrganizationIdsPlus("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:23"); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:22"); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:2"); - - filterIds.add("r:2"); - childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:23"); } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepParentOrganizationIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepParentOrganizationIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -9,34 +9,26 @@ import org.junit.Test; public class DeepParentOrganizationIdsTest { - - @Test - public void deepParentOrganizationIds(){ - JuGrix jugrix = new JuGrix(false); - LinkedList<String> filterIds = new LinkedList<String>(); - Iterator<String> childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:23"); + + @Test + public void deepParentOrganizationIds() { + JuGrix jugrix = new JuGrix(); + LinkedList<String> filterIds = new LinkedList<String>(); + Iterator<String> childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:22"); - - filterIds.add("r:2"); - childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); + Assert.assertEquals(childrenIds.next(), "o:23"); Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:23"); + Assert.assertEquals(childrenIds.next(), "o:22"); - jugrix = new JuGrix(true); - filterIds = new LinkedList<String>(); - childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:23"); - Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:22"); - - filterIds.add("r:2"); childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); Assert.assertTrue(childrenIds.hasNext()); - Assert.assertEquals(childrenIds.next(),"o:23"); - } + Assert.assertEquals(childrenIds.next(), "o:23"); + + filterIds.add("rde:2"); + childrenIds = jugrix.deepParentOrganizationIds("o:2", filterIds); + Assert.assertTrue(childrenIds.hasNext()); + Assert.assertEquals(childrenIds.next(), "o:23"); + + } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepPersonIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/DeepPersonIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -10,7 +10,7 @@ public class DeepPersonIdsTest { @Test public void TestDeepPersonIds(){ - JuGrix jugrix = new JuGrix(false); + JuGrix jugrix = new JuGrix(); LinkedList<String> filterIds = new LinkedList<String>(); //filterIds.add("r:9"); Iterator<String> ids = jugrix.deepPersonIds("o:2",filterIds); @@ -18,17 +18,5 @@ for (;ids.hasNext();) { System.out.println(ids.next()); } - - - jugrix = new JuGrix(true); - filterIds = new LinkedList<String>(); - //filterIds.add("r:9"); - ids = jugrix.deepPersonIds("o:3",filterIds); - System.out.println("------------------------------------------------"); - for (;ids.hasNext();) { - System.out.println(ids.next()); - } } - - }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/IsActiveTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/IsActiveTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -11,7 +11,7 @@ @Test public void TestIsActive(){ - JuGrix jugrix = new JuGrix(false); + JuGrix jugrix = new JuGrix(); String personId = "p:1"; Assert.assertTrue(jugrix.isActive(personId)); @@ -19,12 +19,6 @@ personId = "p:100"; Assert.assertFalse(jugrix.isActive(personId)); - jugrix = new JuGrix(true); - personId = "p:1"; - Assert.assertTrue(jugrix.isActive(personId)); - - personId = "p:100"; - Assert.assertFalse(jugrix.isActive(personId)); } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/ParentOrganizationIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/ParentOrganizationIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -11,7 +11,7 @@ public class ParentOrganizationIdsTest { @Test public void testParentOrganizationIds() { - JuGrix jugrix = new JuGrix(false); + JuGrix jugrix = new JuGrix(); LinkedList<String> filterIds = new LinkedList<String>(); filterIds.add("r:2"); Iterator<String> childrenIds = jugrix.parentOrganizationIds("o:2", filterIds); @@ -22,15 +22,11 @@ childrenIds = jugrix.parentOrganizationIds("o:2", filterIds); Assert.assertFalse(childrenIds.hasNext()); - jugrix = new JuGrix(true); - filterIds = new LinkedList<String>(); - filterIds.add("r:2"); + filterIds = new LinkedList<String>(); + filterIds.add("rde:2"); childrenIds = jugrix.parentOrganizationIds("o:2", filterIds); Assert.assertTrue(childrenIds.hasNext()); Assert.assertEquals(childrenIds.next(), "o:23"); - - filterIds.add("r:2a"); - childrenIds = jugrix.parentOrganizationIds("o:2", filterIds); - Assert.assertFalse(childrenIds.hasNext()); + } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/PersonIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/PersonIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -14,44 +14,37 @@ @Test public void testPersonIds() { - JuGrix jugrix = new JuGrix(false); + JuGrix jugrix = new JuGrix(); LinkedList<String> filterIds = new LinkedList<String>(); + + Iterator<String> ids = jugrix.personIds("o:2", filterIds); + Assert.assertTrue(ids.hasNext()); + Assert.assertEquals(ids.next(), "p:1"); + Assert.assertTrue(ids.hasNext()); + Assert.assertEquals(ids.next(), "p:45"); + filterIds.add("r:9"); - Iterator<String> ids = jugrix.personIds("o:2", filterIds); + ids = jugrix.personIds("o:2", filterIds); Assert.assertTrue(ids.hasNext()); Assert.assertEquals(ids.next(), "p:45"); + Assert.assertTrue(ids.hasNext()); Assert.assertEquals(ids.next(), "p:1"); + filterIds.add("rde:3"); ids = jugrix.personIds("o:2", filterIds); ids.hasNext(); Assert.assertEquals(ids.next(), "p:45"); + ids.hasNext(); Assert.assertEquals(ids.next(), "p:1"); + + filterIds.add("rde:322"); ids = jugrix.personIds("o:2", filterIds); Assert.assertFalse(ids.hasNext()); - jugrix = new JuGrix(true); - filterIds = new LinkedList<String>(); - filterIds.add("r:9"); - ids = jugrix.personIds("o:2", filterIds); - - ids.hasNext(); - Assert.assertEquals(ids.next(), "p:45"); - Assert.assertEquals(ids.next(), "p:1"); - - filterIds.add("rde:3"); - ids = jugrix.personIds("o:2", filterIds); - - ids.hasNext(); - Assert.assertEquals(ids.next(), "p:45"); - Assert.assertEquals(ids.next(), "p:1"); - - filterIds.add("rde:322"); - ids = jugrix.personIds("o:2", filterIds); - Assert.assertFalse(ids.hasNext()); - } + } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/RoleDescriptionElementIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/RoleDescriptionElementIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -12,23 +12,22 @@ @Test public void testRoleDescriptionElementIds(){ - JuGrix jugrix = new JuGrix(true - ); + JuGrix jugrix = new JuGrix(); LinkedList<String> ids = new LinkedList<String>(); //ids.add("o:34"); Iterator<String> rdeIds = jugrix.roleDescriptionElementIds("o:2",ids); - Assert.assertEquals(rdeIds.next(),"rde:3"); - Assert.assertEquals(rdeIds.next(),"rde:2"); - Assert.assertEquals(rdeIds.next(),"rde:10"); - Assert.assertEquals(rdeIds.next(),"rde:1"); - - jugrix = new JuGrix(true); - ids = new LinkedList<String>(); - //ids.add("o:34"); + Assert.assertTrue(rdeIds.hasNext()); + String rdeId = rdeIds.next(); + Assert.assertEquals(rdeId,"rde:3"); + Assert.assertTrue(rdeIds.hasNext()); + rdeId = rdeIds.next(); + Assert.assertEquals(rdeId,"rde:2"); + + ids.add("r:9"); rdeIds = jugrix.roleDescriptionElementIds("o:2",ids); - Assert.assertEquals(rdeIds.next(),"rde:3"); - Assert.assertEquals(rdeIds.next(),"rde:2"); - Assert.assertEquals(rdeIds.next(),"rde:10"); - Assert.assertEquals(rdeIds.next(),"rde:1"); + Assert.assertTrue(rdeIds.hasNext()); + rdeId = rdeIds.next(); + Assert.assertEquals(rdeId,"rde:3"); + Assert.assertFalse(rdeIds.hasNext()); } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/RoleIdsTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/RoleIdsTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -1,6 +1,7 @@ package jp.ac.u_ryukyu.cr.ie.tatsuki.functionTest; import java.util.Iterator; +import java.util.LinkedList; import jp.ac.u_ryukyu.cr.ie.tatsuki.bbs.JuGrix; import junit.framework.Assert; @@ -11,29 +12,23 @@ @Test public void testRoleIds() { - JuGrix jugrix = new JuGrix(false); - Iterator<String> orgIds = jugrix.roleIds("o:6"); + JuGrix jugrix = new JuGrix(); + LinkedList<String> filterIds = new LinkedList<String>(); + filterIds.add("o:5"); + Iterator<String> orgIds = jugrix.roleIds("o:6",filterIds); orgIds.hasNext(); Assert.assertEquals(orgIds.next(), "r:18"); Assert.assertFalse(orgIds.hasNext()); - Iterator<String> personIds = jugrix.roleIds("p:1"); - personIds.hasNext(); - Assert.assertEquals(personIds.next(), "r:34"); - personIds.hasNext(); - Assert.assertEquals(personIds.next(), "r:10"); - jugrix = new JuGrix(true); - orgIds = jugrix.roleIds("o:6"); - orgIds.hasNext(); - Assert.assertEquals(orgIds.next(), "r:18"); - Assert.assertFalse(orgIds.hasNext()); - - personIds = jugrix.roleIds("p:1"); - personIds.hasNext(); - Assert.assertEquals(personIds.next(), "r:34"); + filterIds = new LinkedList<String>(); + filterIds.add("o:2"); + + Iterator<String> personIds = jugrix.roleIds("p:1",filterIds); personIds.hasNext(); Assert.assertEquals(personIds.next(), "r:10"); + + } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/RolePriorityTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/RolePriorityTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -9,12 +9,8 @@ @Test public void testRolePriority(){ - JuGrix jugrix = new JuGrix(false); + JuGrix jugrix = new JuGrix(); String priority = jugrix.rolePriority("p:1", "r:34"); Assert.assertEquals(priority,"1"); - - jugrix = new JuGrix(true); - priority = jugrix.rolePriority("p:1", "r:34"); - Assert.assertEquals(priority,"1"); } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/StringPathToIdTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/functionTest/StringPathToIdTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -8,16 +8,10 @@ public class StringPathToIdTest { @Test public void testStringPathToId() { - JuGrix jugrix = new JuGrix(false); + JuGrix jugrix = new JuGrix(); String id = jugrix.stringPathToId("r:path:エスアールエルテクノシステム/臨検システム部/業務システムグループ"); Assert.assertEquals(id, "r:43"); id = jugrix.stringPathToId("rde:path:システム開発申請書/組織的役割/起票部署"); Assert.assertEquals(id, "rde:10"); - - jugrix = new JuGrix(true); - id = jugrix.stringPathToId("r:path:エスアールエルテクノシステム/臨検システム部/業務システムグループ"); - Assert.assertEquals(id, "r:43"); - id = jugrix.stringPathToId("rde:path:システム開発申請書/組織的役割/起票部署"); - Assert.assertEquals(id, "rde:10"); } }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/xmlReadTest/ReadXmlTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/xmlReadTest/ReadXmlTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -11,7 +11,7 @@ @Test public void Readml(){ long t1 = System.currentTimeMillis(); - new JuGrix(true); + new JuGrix(); long t2 = System.currentTimeMillis(); System.out.println(t2 - t1 + "s"); }
--- a/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/xmlReadTest/SaxTest.java Thu Nov 13 23:34:41 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/cr/ie/tatsuki/xmlReadTest/SaxTest.java Tue Nov 25 11:57:17 2014 +0900 @@ -29,7 +29,7 @@ JungleTree newTree = testHandler.getTree(); InterfaceTraverser ifTraverser = newTree.getTraverser(); - Iterator<Pair<TreeNode, NodePath>> searchNode = ifTraverser.find(( + Iterator<TreeNode> searchNodeIterator = ifTraverser.find(( TreeNode node) -> { ByteBuffer attribute = node.getAttributes().get("element"); if (attribute != null) { @@ -40,12 +40,11 @@ } return false; }, "element", "Person"); - Pair<TreeNode, NodePath> nodePair = searchNode.next(); - Assert.assertEquals(nodePair.left().getAttributes().getString("element"),"Person"); - Assert.assertEquals(nodePair.right().toString(), "<-1,0>"); + TreeNode searchNode = searchNodeIterator.next(); + Assert.assertEquals(searchNode.getAttributes().getString("element"),"Person"); - searchNode = ifTraverser.find((TreeNode node) -> { + searchNodeIterator = ifTraverser.find((TreeNode node) -> { ByteBuffer attribute = node.getAttributes().get("element"); if (attribute != null) { byte[] byteAttribute = attribute.array(); @@ -56,11 +55,10 @@ return false; }, "element", "name"); - nodePair = searchNode.next(); - Assert.assertEquals(nodePair.left().getAttributes().getString("text"),"tatsuki"); - Assert.assertEquals(nodePair.right().toString(), "<-1,0,0>"); + searchNode = searchNodeIterator.next(); + Assert.assertEquals(searchNode.getAttributes().getString("text"),"tatsuki"); - searchNode = ifTraverser.find((TreeNode node) -> { + searchNodeIterator = ifTraverser.find((TreeNode node) -> { ByteBuffer attribute = node.getAttributes().get("text"); if (attribute != null) { byte[] byteAttribute = attribute.array(); @@ -71,11 +69,10 @@ return false; }, "text", "tatsuki"); - nodePair = searchNode.next(); - Assert.assertEquals(nodePair.left().getAttributes().getString("id"),"10"); - Assert.assertEquals(nodePair.right().toString(), "<-1,0,0>"); + searchNode = searchNodeIterator.next(); + Assert.assertEquals(searchNode.getAttributes().getString("id"),"10"); - searchNode = ifTraverser.find((TreeNode node) -> { + searchNodeIterator = ifTraverser.find((TreeNode node) -> { ByteBuffer attribute = node.getAttributes().get("id"); if (attribute != null) { byte[] byteAttribute = attribute.array(); @@ -86,9 +83,8 @@ return false; }, "id", "10"); - nodePair = searchNode.next(); - Assert.assertEquals(nodePair.left().getAttributes().getString("id"),"10"); - Assert.assertEquals(nodePair.right().toString(), "<-1,0,0>"); + searchNode = searchNodeIterator.next(); + Assert.assertEquals(searchNode.getAttributes().getString("id"),"10"); } catch (Exception e) { e.printStackTrace();