Examples of InMemoryContentItem


Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

    public static final String SINGLE_SENTENCE = "Dr. Patrick Marshall (1869 - November 1950) was a"
        + " geologist who lived in New Zealand and worked at the University of Otago.";
    public static final UriRef TEST_ENHANCEMENT_ENGINE_URI = new UriRef("urn:test:dummyEnhancementEngine");

    public static ContentItem wrapAsContentItem(final String id, final String text) {
      return new InMemoryContentItem(id, text, "text/plain");
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

    }

    @Test
    public void testEnhancementEngineHelper() throws Exception {
        ContentItem ci = new InMemoryContentItem(new UriRef("urn:test:contentItem"), "There is content", "text/plain");
        EnhancementEngine engine = new MyEngine();

        UriRef extraction = EnhancementEngineHelper.createNewExtraction(ci, engine);
        MGraph metadata = ci.getMetadata();

        assertTrue(metadata.contains(new TripleImpl(extraction,
                ENHANCER_RELATED_CONTENT_ITEM, new UriRef(ci.getUri().getUnicodeString()))));
        assertTrue(metadata.contains(new TripleImpl(extraction,
                RDF_TYPE, ENHANCER_EXTRACTION)));
        // and so on
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

                }
            } catch (FileUploadException e) {
                throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
            }
        } else { //normal content
            contentItem = new InMemoryContentItem(
                IOUtils.toByteArray(entityStream), mediaType.toString());
            //add the URI of the main content
            parsedContentIds.add(contentItem.getPartUri(0).getUnicodeString());
        }
        //set the parsed contentIDs to the EnhancementProperties
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

            while(contentPartIterator.hasNext()){
                FileItemStream fis = contentPartIterator.next();
                if(contentItem == null){
                    log.debug("create ContentItem {} for content (type:{})",
                        id,content.getContentType());
                    contentItem = new InMemoryContentItem(id,
                        IOUtils.toByteArray(fis.openStream()),
                        fis.getContentType(), metadata);
                } else {
                    Blob blob = new InMemoryBlob(fis.openStream(), fis.getContentType());
                    UriRef contentPartId = null;
                    if(fis.getFieldName() != null && !fis.getFieldName().isEmpty()){
                        contentPartId = new UriRef(fis.getFieldName());
                    } else {
                        //generating a random ID might break metadata
                        //TODO maybe we should throw an exception instead
                        contentPartId = new UriRef("urn:contentpart:"+ randomUUID());
                    }
                    log.debug("  ... add Blob {} to ContentItem {} with content (type:{})",
                        new Object[]{contentPartId, id, fis.getContentType()});
                    contentItem.addPart(contentPartId, blob);
                    parsedContentParts.add(contentPartId.getUnicodeString());
                }
            }
        } else {
            log.debug("create ContentItem {} for content (type:{})",
                id,content.getContentType());
            contentItem = new InMemoryContentItem(id,
                IOUtils.toByteArray(content.openStream()),
                content.getContentType(), metadata);
        }
        //add the URI of the main content to the parsed contentParts
        parsedContentParts.add(contentItem.getPartUri(0).getUnicodeString());
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

    public List<String> tokenizeEntities(String queryTerm) {
        // obtain entities about query term through Enhancer
        ContentItem ci = null;
        boolean error = false;
        try {
            ci = new InMemoryContentItem(queryTerm.getBytes(Constants.DEFAULT_ENCODING), "text/plain");
            enhancementJobManager.enhanceContent(ci);
        } catch (UnsupportedEncodingException e) {
            log.error("Failed to get bytes of query term: {}", queryTerm, e);
            error = true;
        } catch (EnhancementException e) {
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

    /**
     * @return
     */
    @BeforeClass
    public static void createTestContentItem() {
        contentItem = new InMemoryContentItem("urn:test",
            "<html>\n" +
            "  <body>\n" +
            "    This is a <b>ContentItem</b> to <i>Mime Multipart</i> test!\n" +
            "  </body>\n" +
            "</html>","text/html");
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

    @AfterClass
    public static void shutdownServices() {
    }

    public static ContentItem getContentItem(final String id, final String text) {
        return new InMemoryContentItem(id, text, "text/plain");
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

            "en",Collections.EMPTY_SET);
    }

    public static ContentItem wrapAsContentItem(final String id,
            final String text) {
      return new InMemoryContentItem(id, text, "text/plain");
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

      calaisExtractor.setLicenseKey(TEST_LICENSE_KEY);
    }
  }

  public static ContentItem wrapAsContentItem(final String text) {
    return new InMemoryContentItem((UriRef)null, text, "text/plain");
  }
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem

    @AfterClass
    public static void shutdownServices() {
    }

    public static ContentItem getContentItem(final String id, final String text) {
        return new InMemoryContentItem(id, text, "text/plain");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.