Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Seq


    }
    Resource itemRes = model.getResource(itemURL.toString());
    if (logger.isDebugEnabled()) {
      logger.debug("Performing action on " + itemRes);
    }
    Seq itemsSeq = target.getProperty(RSS.items).getSeq();
    int oldPos = itemsSeq.indexOf(itemRes);
    itemsSeq.remove(oldPos);
    //TODO why does this throw an exception?
    //itemRes.removeProperties();
    Set statementsToRemove = new HashSet();
    StmtIterator stmtIterator = model.listStatements(null, null, itemRes);
    while (stmtIterator.hasNext()) {
View Full Code Here


     * @param resultModel
     */
    private void addConcept(Resource concept, Model resultModel) {
        resultModel.add(JenaUtil.getExpandedResource(concept, 2));
        if (concept.hasProperty(RDF.type, RDF.Seq)) {
            Seq seq = (Seq) concept.as(Seq.class);
            for (int i = 1; i <= seq.size(); i++) {
                addConcept(seq.getResource(i), resultModel);
            }
        }
    }
View Full Code Here

    throws MessagingException {
      List resultList = new ArrayList();
      StmtIterator attachments = mailItem.listProperties(ATTACH.attachments);
      while (attachments.hasNext()) {
        Statement currentAttachmentStmt = attachments.nextStatement();
        Seq attachmentSeq = currentAttachmentStmt.getSeq();
        for (int i = 1; i <= attachmentSeq.size(); i++) {
          Resource currentAttachment = attachmentSeq.getResource(i);
          if (currentAttachment.hasProperty(RDF.type,
              ATTACH.InlineAttachment)) {
            continue;
          }
          String label = getBestLabel(currentAttachment, acceptedLocales);
View Full Code Here

          .getLocaleRange().getLocale().getLanguage());
    }
    StmtIterator attachments = resultModel.listStatements(null,
        ATTACH.attachments, (Resource) null);
    while (attachments.hasNext()) {
      Seq currentSeq = attachments.nextStatement().getSeq();
      for (int i = 1; i <= currentSeq.size(); i++) {
        Resource currentAttachment;
        try {
          currentAttachment = currentSeq.getResource(i);
        } catch (PropertyNotFoundException ex) {
          log.warn("inconsisten seq");
          continue;
        }
        Statement langStmt = currentAttachment.getProperty(DC.language);
        if (langStmt == null) {
          continue;
        }
        String lang = langStmt.getString();
        if (!acceptedLang.contains(lang)) {
          // remove
          currentSeq.remove(i--);
          currentAttachment.removeProperties();
        }
      }
    }
    // listSubjectsWithProperty(RDF.type, ATTACH.Attachment);
View Full Code Here

         * titleStmt.getObject()); } //linkSeq.add(containerLink); }
         */
        Statement attachmentsStmt = itemInResult
                .getProperty(ATTACH.attachments);
        if (attachmentsStmt != null) {
            Seq attachmentsSeq = attachmentsStmt.getSeq();
            ATTACHMENTS: for (int i = 1; i <= attachmentsSeq.size(); i++) {
                Resource attachment;
                try {
                    attachment = attachmentsSeq.getResource(i);
                } catch (PropertyNotFoundException ex) {
                    log.warn("sequence with missing elements");
                    continue;
                }
                if (attachment.hasProperty(DC.language)) {
                    //check if one of supportedLanguages matches
                    StmtIterator languageStmts = attachment
                            .listProperties(DC.language);
                    while (languageStmts.hasNext()) {
                        String currentLang = languageStmts.nextStatement()
                                .getString();
                        if (acceptLanguagesStringList.contains(currentLang)) {
                            continue ATTACHMENTS;
                        }
                    }
                    attachment.removeProperties();
                    try {
                        attachmentsSeq.remove(i--);
                    } catch (PropertyNotFoundException ex) {
                        log
                                .warn("sequence with missing elements, faled removing "
                                        + i);
                    }
View Full Code Here

          .getLocaleRange().getLocale().getLanguage());
    }*/
    StmtIterator attachments = resultModel.listStatements(null,
        ATTACH.attachments, (Resource) null);
    while (attachments.hasNext()) {
      Seq currentSeq = attachments.nextStatement().getSeq();
      for (int i = 1; i <= currentSeq.size(); i++) {
        Resource currentAttachment;
        try {
          currentAttachment = currentSeq.getResource(i);
        } catch (PropertyNotFoundException ex) {
          log.warn("inconsisten seq");
          continue;
        }
        Statement langStmt = currentAttachment.getProperty(DC.language);
        if (langStmt == null) {
          continue;
        }
        String lang = langStmt.getString();
        Locale locale = new Locale(lang);
        boolean matches = false;
        while (langIter.hasNext()) {
          if (langIter.nextAcceptLanguageHeader()
              .getLocaleRange().match(locale)) {
            matches = true;
          }
        }
        if (!matches) {
          // remove
          currentSeq.remove(i--);
          currentAttachment.removeProperties();
        }
      }
    }
    // listSubjectsWithProperty(RDF.type, ATTACH.Attachment);
View Full Code Here

    final Resource subject = VirtuserHandler.getSubject();
    final Statement personalHistoryStmt = subject
        .getProperty(HISTORY.personalHistory);
    Model result = JenaUtil.getExpandedResource(subject, 2);
    if (personalHistoryStmt != null) {
      Seq personalHistory = personalHistoryStmt.getSeq();
      addTitles(personalHistory, result);
    }

    // it would be nice if this could be writte to the model
    // before the next page is requested, respectively before the
    // CookieSetResponse checks
    // if a new cookie should be set
    // TODO think if CookieSetResponse could/should check in the queue for
    // actions affecting subject or if have a subject-used threadlocale
    // would be useful
    new Thread() {
      public void run() {
        Model model = subject.getModel();
        model.enterCriticalSection(ModelLock.WRITE);
        try {
          Set allreadyInSeq = new HashSet();
          Seq personalHistory = subject.getModel().createSeq();
          allreadyInSeq.add(currentPage);
          personalHistory.add(currentPage);
          if (personalHistoryStmt != null) {
            Seq oldPersonalHistory = personalHistoryStmt.getSeq();
            for (int i = 1; i <= oldPersonalHistory.size(); i++) {
              if (i == 7) {
                break;
              }
              Resource current = oldPersonalHistory
                  .getResource(i);
              if (!allreadyInSeq.contains(current)) {
                personalHistory.add(current);
                allreadyInSeq.add(current);
              }
            }
            oldPersonalHistory.removeProperties();
          }
          StmtIterator phStmts = subject
              .listProperties(HISTORY.personalHistory);
          Set stmtsToRemove = new HashSet();
          while (phStmts.hasNext()) {
View Full Code Here

            String defaultLanguage) throws IOException,
            AggregatingToOwnInstanceException {
        Model model = aggregated.getModel();

        Resource feedURL = null;
        Seq itemSeq = null;
        model.enterCriticalSection(ModelLock.READ);
        try {
            try {
                feedURL = aggregated.getProperty(AGGREGATOR.feed).getResource();
            } catch (Exception ex) {
View Full Code Here

  }

  public void testMoreIndexing()
  {
    final int num = 10;
    final Seq seq = model.createSeq();
    for (int i = 0; i < num; i += 1)
    {
      seq.add(i);
    }

    try
    {
      seq.add(0, false);
      Assert.fail("cannot at at position 0");
    }
    catch (final SeqIndexBoundsException e)
    {
      JenaTestBase.pass();
    }

    seq.add(num + 1, false);
    Assert.assertEquals(num + 1, seq.size());

    seq.remove(num + 1);
    try
    {
      seq.add(num + 2, false);
      Assert.fail("cannot add past the end");
    }
    catch (final SeqIndexBoundsException e)
    {
      JenaTestBase.pass();
    }

    final int size = seq.size();
    for (int i = 1; i <= (num - 1); i += 1)
    {
      seq.add(i, 1000 + i);
      Assert.assertEquals(1000 + i, seq.getInt(i));
      Assert.assertEquals(0, seq.getInt(i + 1));
      Assert.assertEquals(size + i, seq.size());
      Assert.assertEquals(num - i - 1, seq.getInt(size));
    }
  }
View Full Code Here

  }

  protected void testRemove( final boolean[] retain )
  {
    final int num = retain.length;
    final Seq seq = model.createSeq();
    for (int i = 0; i < num; i += 1)
    {
      seq.add(i);
    }
    //
    final List<RDFNode> retained = new ArrayList<RDFNode>();
    //
    final NodeIterator nIter = seq.iterator();
    for (int i = 0; i < num; i += 1)
    {
      final RDFNode x = nIter.nextNode();
      if (retain[i])
      {
        retained.add(x);
      }
      else
      {
        nIter.remove();
      }
    }
    //
    Assert.assertFalse(nIter.hasNext());
    Assert.assertEquals(retained, seq.iterator().toList());
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Seq

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.