Mercurial > hg > Members > tatsuki > JungleXMLReader
comparison src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/JuGrix.java @ 29:626e56f749a9
use index competentRoleIdTest and concurrentRoleIdsTest
author | one |
---|---|
date | Fri, 07 Nov 2014 03:22:11 +0900 |
parents | ed831b2fc156 |
children | f45b1c839753 |
comparison
equal
deleted
inserted
replaced
28:ed831b2fc156 | 29:626e56f749a9 |
---|---|
38 personTree = reader.loadTestData("Person.xml"); | 38 personTree = reader.loadTestData("Person.xml"); |
39 organizationTree = reader.loadTestData("Organization.xml"); | 39 organizationTree = reader.loadTestData("Organization.xml"); |
40 roleTree = reader.loadTestData("Role.xml"); | 40 roleTree = reader.loadTestData("Role.xml"); |
41 rdeTree = reader.loadTestData("RoleDescriptionElement.xml"); | 41 rdeTree = reader.loadTestData("RoleDescriptionElement.xml"); |
42 } | 42 } |
43 | 43 |
44 } catch (Exception e) { | 44 } catch (Exception e) { |
45 e.printStackTrace(); | 45 e.printStackTrace(); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
120 } | 120 } |
121 | 121 |
122 public boolean filter(String orgId, LinkedList<String> roleIds) { | 122 public boolean filter(String orgId, LinkedList<String> roleIds) { |
123 if (roleIds == null) | 123 if (roleIds == null) |
124 return true; | 124 return true; |
125 | 125 |
126 if (roleIds.isEmpty()) | 126 if (roleIds.isEmpty()) |
127 return true; | 127 return true; |
128 | 128 |
129 InterfaceTraverser orgTraverser = organizationTree.getTraverser(); | 129 InterfaceTraverser orgTraverser = organizationTree.getTraverser(); |
130 | 130 |
230 } | 230 } |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 public boolean roleFilter(String id, Pair<TreeNode, NodePath> searchNodePair) { | 234 public boolean roleFilter(String id, Pair<TreeNode, NodePath> searchNodePair) { |
235 //System.out.println(searchNodePair.getAttributes().getString("id")); | 235 // System.out.println(searchNodePair.getAttributes().getString("id")); |
236 InterfaceTraverser orgTraverser = organizationTree.getTraverser(); | 236 InterfaceTraverser orgTraverser = organizationTree.getTraverser(); |
237 | 237 |
238 Iterator<Pair<TreeNode, NodePath>> pairIdIterator = orgTraverser.findInSubTree((TreeNode node) -> { | 238 Iterator<Pair<TreeNode, NodePath>> pairIdIterator = orgTraverser.findInSubTree((TreeNode node) -> { |
239 String elementName = node.getAttributes().getString("element"); | 239 String elementName = node.getAttributes().getString("element"); |
240 if (elementName == null) | 240 if (elementName == null) |
375 } | 375 } |
376 | 376 |
377 public Iterator<String> concurrentRoleIds(String personId) { | 377 public Iterator<String> concurrentRoleIds(String personId) { |
378 | 378 |
379 InterfaceTraverser ifTraverser = personTree.getTraverser(); | 379 InterfaceTraverser ifTraverser = personTree.getTraverser(); |
380 Iterator<Pair<TreeNode, NodePath>> pairPersonIterator = searchPerson(personId, ifTraverser); | 380 Iterator<Pair<TreeNode, NodePath>> pairPersonIterator = ifTraverser.find((TreeNode node) -> { |
381 String nodeElement = node.getAttributes().getString("element"); | |
382 if (nodeElement == null) | |
383 return false; | |
384 if (!nodeElement.equals("Person")) | |
385 return false; | |
386 String nodeId = node.getAttributes().getString("Person-id"); | |
387 if (nodeId == null) | |
388 return false; | |
389 if (nodeId.equals(personId)) | |
390 return true; | |
391 return false; | |
392 }, "Person-id", personId); | |
381 | 393 |
382 if (!pairPersonIterator.hasNext()) | 394 if (!pairPersonIterator.hasNext()) |
383 return new NullIterator(); | 395 return new NullIterator(); |
384 Pair<TreeNode, NodePath> person = pairPersonIterator.next(); | 396 Pair<TreeNode, NodePath> person = pairPersonIterator.next(); |
385 | 397 |
386 Iterator<Pair<TreeNode, NodePath>> targetPairIterator = ifTraverser.findInSubTree((TreeNode node) -> { | 398 Iterator<Pair<TreeNode, NodePath>> targetPairIterator = ifTraverser.findInSubTreeAllValue((TreeNode node) -> { |
387 String nodeElement = node.getAttributes().getString("element"); | 399 String nodeElement = node.getAttributes().getString("element"); |
388 if (nodeElement == null) | 400 if (nodeElement == null) |
389 return false; | 401 return false; |
390 if (!nodeElement.equals("priority")) | 402 if (!nodeElement.equals("priority")) |
391 return false; | 403 return false; |
392 String priority = node.getAttributes().getString("text"); | 404 String priority = node.getAttributes().getString("text-priority"); |
393 if (priority == null) | 405 if (priority != null) |
394 return false; | 406 return true; |
395 if (!priority.equals("0")) | 407 return false; |
396 return true; | 408 }, person, "text-priority"); |
397 return false; | |
398 }, person, "text", "0"); | |
399 | 409 |
400 LinkedList<String> idList = new LinkedList<String>(); | 410 LinkedList<String> idList = new LinkedList<String>(); |
401 for (; targetPairIterator.hasNext();) { | 411 for (; targetPairIterator.hasNext();) { |
402 NodePath searchPath = targetPairIterator.next().right(); | 412 Pair<TreeNode,NodePath> targetPair = targetPairIterator.next(); |
403 Pair<Integer, NodePath> searchPair = searchPath.last(); | 413 TreeNode targetNode = targetPair.left(); |
404 NodePath targetPath = searchPair.right().add(searchPair.left() + 1); | 414 int priority = Integer.parseInt(targetNode.getAttributes().getString("text-priority")); |
405 TreeNode targetNode = getTarget(person.left(), targetPath); | 415 if (priority > 0) { |
406 String id = targetNode.getAttributes().getString("text"); | 416 NodePath targetPath = targetPair.right(); |
407 idList.add(id); | 417 Pair<Integer, NodePath> searchPair = targetPath.last(); |
418 NodePath roleIdNodePath = searchPair.right().add(searchPair.left() + 1); | |
419 TreeNode roleIdNode = getTarget(personTree.getRootNode(), roleIdNodePath); | |
420 String id = roleIdNode.getAttributes().getString("text-roleRefId"); | |
421 idList.add(id); | |
422 } | |
408 } | 423 } |
409 | 424 |
410 return idList.iterator(); | 425 return idList.iterator(); |
411 } | 426 } |
412 | |
413 | 427 |
414 public Iterator<String> deepPersonIds(String orgId, LinkedList<String> filterIds) { | 428 public Iterator<String> deepPersonIds(String orgId, LinkedList<String> filterIds) { |
415 | 429 |
416 Iterator<String> childrensIterator = deepChildOrganizationIds(orgId, new LinkedList<String>()); | 430 Iterator<String> childrensIterator = deepChildOrganizationIds(orgId, new LinkedList<String>()); |
417 if (!childrensIterator.hasNext()) | 431 if (!childrensIterator.hasNext()) |
491 if (!chilrenOrgIdsIterator.hasNext()) | 505 if (!chilrenOrgIdsIterator.hasNext()) |
492 return new NullIterator(); | 506 return new NullIterator(); |
493 | 507 |
494 Pair<TreeNode, NodePath> chilerenOrgIds = chilrenOrgIdsIterator.next(); | 508 Pair<TreeNode, NodePath> chilerenOrgIds = chilrenOrgIdsIterator.next(); |
495 | 509 |
496 Iterator<Pair<TreeNode, NodePath>> chilrenOrgIdIterator = orgTraverser.findInSubTree((TreeNode node) -> { | 510 Iterator<Pair<TreeNode, NodePath>> chilrenOrgIdIterator = orgTraverser.findInSubTreeAllValue((TreeNode node) -> { |
497 String nodeElement = node.getAttributes().getString("element"); | 511 String nodeElement = node.getAttributes().getString("element"); |
498 if (nodeElement == null) | 512 if (nodeElement == null) |
499 return false; | 513 return false; |
500 if (!nodeElement.equals("organizationRefIds")) | 514 if (!nodeElement.equals("organizationRefIds")) |
501 return false; | 515 return false; |
502 nodeElement = node.getAttributes().getString("text-organizationRefIds"); | 516 nodeElement = node.getAttributes().getString("text-organizationRefIds"); |
503 if (nodeElement != null) | 517 if (nodeElement != null) |
504 return true; | 518 return true; |
505 return false; | 519 return false; |
506 }, chilerenOrgIds, "text-organizationRefIds", null); | 520 }, chilerenOrgIds, "text-organizationRefIds"); |
507 | 521 |
508 LinkedList<String> ids = new LinkedList<String>(); | 522 LinkedList<String> ids = new LinkedList<String>(); |
509 | 523 |
510 for (; chilrenOrgIdIterator.hasNext();) { | 524 for (; chilrenOrgIdIterator.hasNext();) { |
511 String childrenOrgId = chilrenOrgIdIterator.next().left().getAttributes().getString("text-organizationRefIds"); | 525 String childrenOrgId = chilrenOrgIdIterator.next().left().getAttributes().getString("text-organizationRefIds"); |