示例#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();*/
  }
示例#2
0
  /* (non-Javadoc)
   * @see kiwi.api.fragment.FragmentService#getContentItemFragment(kiwi.model.content.ContentItemI, java.lang.String)
   */
  @Override
  public <C extends FragmentFacade> C getContentItemFragment(
      ContentItemI containing_ci, String fragment_id, Class<C> type) {

    if (fragment_id.startsWith("uri::")) {
      String uri = fragment_id.substring("uri::".length());
      C ff = kiwiEntityManager.find(type, uri);
      return ff;
    }

    return null;
  }