Search in sources :

Example 51 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testCommentedJpeg.

@Test
public void testCommentedJpeg() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testJPEG_commented.jpg");
    /*
         * The dates in testJPEG_commented.jpg do not contain timezones. If no timezone is specified,
         * the Tika input transformer assumes the local time zone.  Set the system timezone to UTC
         * so we can do assertions.
         */
    TimeZone defaultTimeZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertThat(metacard.getTitle(), is("Tosteberga Ă„ngar"));
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("<meta name=\"Keywords\" content=\"bird watching\"/>"));
    assertThat(metacard.getContentTypeName(), is("image/jpeg"));
    assertThat(convertDate(metacard.getCreatedDate()), is("2010-07-28 11:02:00 UTC"));
    // Reset timezone back to local time zone.
    TimeZone.setDefault(defaultTimeZone);
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(IMAGE));
    assertThat(metacard.getContentTypeName(), is("image/jpeg"));
}
Also used : TimeZone(java.util.TimeZone) Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 52 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testPptx.

@Test
public void testPptx() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testPPT.pptx");
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertThat(metacard.getTitle(), is("Attachment Test"));
    assertThat(convertDate(metacard.getCreatedDate()), is("2010-05-04 06:43:54 UTC"));
    assertThat(convertDate(metacard.getModifiedDate()), is("2010-06-29 06:34:35 UTC"));
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("content as every other file being tested for tika content parsing"));
    assertThat(metacard.getContentTypeName(), is("application/vnd.openxmlformats-officedocument.presentationml.presentation"));
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(DOCUMENT));
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 53 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testAudioAu.

@Test
public void testAudioAu() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testAU.au");
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("PCM_SIGNED"));
    assertThat(metacard.getContentTypeName(), is("audio/basic"));
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(SOUND));
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 54 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testJavaSource.

@Test
public void testJavaSource() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testpackage/testJAVA.java");
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("HelloWorld"));
    assertThat(metacard.getContentTypeName(), containsString("text/plain"));
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(TEXT));
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 55 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class VideoInputTransformer method transform.

@Override
public Metacard transform(InputStream input, String id) throws IOException, CatalogTransformerException {
    Parser parser = new AutoDetectParser();
    ToXMLContentHandler handler = new ToXMLContentHandler();
    TikaMetadataExtractor tikaMetadataExtractor = new TikaMetadataExtractor(parser, handler);
    Metadata metadata = tikaMetadataExtractor.parseMetadata(input, new ParseContext());
    String metadataText = handler.toString();
    if (templates != null) {
        metadataText = transformToXml(metadataText);
    }
    Metacard metacard = MetacardCreator.createMetacard(metadata, id, metadataText, metacardType);
    metacard.setAttribute(new AttributeImpl(Core.DATATYPE, DataType.VIDEO.toString()));
    return metacard;
}
Also used : TikaMetadataExtractor(ddf.catalog.transformer.common.tika.TikaMetadataExtractor) ToXMLContentHandler(org.apache.tika.sax.ToXMLContentHandler) Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Metadata(org.apache.tika.metadata.Metadata) ParseContext(org.apache.tika.parser.ParseContext) AutoDetectParser(org.apache.tika.parser.AutoDetectParser) Parser(org.apache.tika.parser.Parser) AutoDetectParser(org.apache.tika.parser.AutoDetectParser)

Aggregations

Metacard (ddf.catalog.data.Metacard)746 Test (org.junit.Test)470 ArrayList (java.util.ArrayList)206 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)149 InputStream (java.io.InputStream)136 HashMap (java.util.HashMap)129 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)115 Result (ddf.catalog.data.Result)109 Serializable (java.io.Serializable)100 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)90 QueryRequest (ddf.catalog.operation.QueryRequest)84 QueryImpl (ddf.catalog.operation.impl.QueryImpl)80 QueryResponse (ddf.catalog.operation.QueryResponse)78 SourceResponse (ddf.catalog.operation.SourceResponse)76 IOException (java.io.IOException)75 List (java.util.List)74 Map (java.util.Map)67 Filter (org.opengis.filter.Filter)67 CreateResponse (ddf.catalog.operation.CreateResponse)66 HashSet (java.util.HashSet)65