| 572 | | return findThingForOccurrence(informationElement, true, true, true, true); |
| 573 | | /*ClosableIterator<? extends Statement> iterator = null; |
| 574 | | Set<URI> result = new HashSet<URI>(); |
| 575 | | boolean open = mainRepository.isOpen(); |
| 576 | | if (!open) |
| 577 | | mainRepository.open(); |
| 578 | | iterator = mainRepository.findStatements(Variable.ANY,Variable.ANY, PIMO.occurrence, informationElement); |
| 579 | | try { |
| 580 | | while (iterator.hasNext()) { |
| 581 | | Node node = iterator.next().getSubject(); |
| 582 | | if (node instanceof URI) { |
| 583 | | result.add(node.asURI()); |
| 584 | | } else { |
| 585 | | log.finer(node+" is no instance of an URI"); |
| 586 | | } |
| 587 | | } |
| 588 | | } finally { |
| 589 | | iterator.close(); |
| 590 | | } |
| 591 | | iterator = mainRepository.findStatements(Variable.ANY,Variable.ANY, PIMO.groundingOccurrence, informationElement); |
| 592 | | try { |
| 593 | | while (iterator.hasNext()) { |
| 594 | | Node node = iterator.next().getSubject(); |
| 595 | | if (node instanceof URI) { |
| 596 | | result.add(node.asURI()); |
| 597 | | } else { |
| 598 | | log.finer(node+" is no instance of an URI"); |
| 599 | | } |
| 600 | | } |
| 601 | | } finally { |
| 602 | | iterator.close(); |
| 603 | | } |
| 604 | | // check if they are things |
| 605 | | for (Iterator<URI> i = result.iterator(); i.hasNext();) { |
| 606 | | URI u = i.next(); |
| 607 | | if (!mainRepository.containsStatements(Variable.ANY, u, PIMO.isDefinedBy, pimoClient.getPimoUri())) { |
| 608 | | i.remove(); |
| 609 | | } |
| 610 | | } |
| 611 | | // if (!open) |
| 612 | | // mainRepository.close(); |
| 613 | | if (result.size() > 1) log.severe("More then one thing: "+result.toString()+" found for the occurence "+informationElement); |
| 614 | | if (result.size() == 0) return null; |
| 615 | | return result.iterator().next();*/ |
| | 572 | URI result = findThingForOccurrence(informationElement, true, true, true, true); |
| | 573 | // the "folder" case is not handled by the other method, hence here. |
| | 574 | if (result == null) { |
| | 575 | ClosableIterator<Statement> it = mainRepository.findStatements(Variable.ANY, Variable.ANY, PIMO.hasFolder, informationElement); |
| | 576 | if (it.hasNext()) |
| | 577 | result=it.next().getSubject().asURI(); |
| | 578 | it.close(); |
| | 579 | } |
| | 580 | return result; |