Ejemplo n.º 1
0
  /* (non-Javadoc)
   * @see kiwi.api.fragment.FragmentService#getContentItemFragments(kiwi.model.content.ContentItemI)
   */
  @Override
  public <C extends FragmentFacade> Collection<C> getContentItemFragments(
      ContentItemI containing_ci, Class<C> type) {

    Collection<C> ret = new LinkedList<C>();
    Collection<KiWiTriple> triples;
    try {
      triples =
          containing_ci
              .getResource()
              .listIncoming("http://www.kiwi-project.eu/kiwi/special/fragmentOf");

      for (KiWiTriple triple : triples) {
        KiWiResource subject = triple.getSubject();
        if (subject.isUriResource()) {
          KiWiUriResource subject_uri = (KiWiUriResource) triple.getSubject();
          C ff = kiwiEntityManager.find(type, subject_uri.getUri());
          if (ff != null) {
            ret.add(ff);
          }
        }
      }
    } catch (NamespaceResolvingException e) {
      e.printStackTrace();
    }

    return ret;

    /*Query query = kiwiEntityManager.createQuery("SELECT ?B WHERE { ?B <http://www.kiwi-project.eu/kiwi/special/fragmentOf> <" + ((KiWiUriResource)containing_ci.getResource()).getUri() + "> . }", KiWiQueryLanguage.SPARQL, type);
    return query.getResultList();*/
  }
Ejemplo n.º 2
0
  public List<ReferencesNode> getIncoming() {
    if (incoming == null) {
      incoming = new ArrayList<ReferencesNode>();

      // get incoming triples up to limit
      Collection<KiWiTriple> incomingTriples;
      try {
        incomingTriples = currentContentItem.getResource().listIncoming(null, limit);
      } catch (NamespaceResolvingException e) {
        e.printStackTrace();
        incomingTriples = Collections.emptySet();
      }
      incomingCount = incomingTriples.size();

      Map<KiWiResource, List<KiWiTriple>> groupings = calculateGrouping(incomingTriples);

      for (KiWiResource prop : groupings.keySet()) {
        // create new node for property
        ReferencesNode node = new ReferencesNode(prop);
        incoming.add(node);

        // add all objects reachable by this property to the children of the node
        for (KiWiTriple t : groupings.get(prop)) {
          ReferencesNode child = new ReferencesNode((KiWiResource) t.getSubject());
          if (t.isInferred()) {
            child.setInferred(true);
          }
          child.setTripleId(t.getId());
          node.getChildren().add(child);
        }
      }
    }
    return incoming;
  }