Search in sources :

Example 66 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class XmlInputTransformer method transform.

/**
     * Takes in an XML {@link InputStream} and an ID and returns a populated {@link Metacard}
     * The Metacard is populated with all attributes that have been parsed by the {@link SaxEventHandler}s
     * declared in {@link XmlInputTransformer#saxEventHandlerConfiguration}s and with the specific ID
     *
     * @param inputStream an XML input stream to be turned into a Metacard.
     * @param id          the attribute value for the {@link Metacard#ID} attribute that should be set in
     *                    the generated {@link Metacard}
     * @return a populated Metacard
     * @throws CatalogTransformerException
     * @throws IOException
     */
public Metacard transform(InputStream inputStream, String id) throws CatalogTransformerException, IOException {
    Metacard metacard = transform(inputStream);
    metacard.setAttribute(new AttributeImpl(Metacard.ID, id));
    return metacard;
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl)

Example 67 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class SaxEventHandlerUtilsTest method testValidMultiValue.

@Test
public void testValidMultiValue() {
    List<Attribute> attributes = getTestAttributes();
    attributes.add(new AttributeImpl(CoreAttributes.LANGUAGE, "Dothraki"));
    List<Attribute> combinedAttributes = saxEventHandlerUtils.getCombinedMultiValuedAttributes(descriptors, attributes);
    assertThat(combinedAttributes.size(), is(2));
    assertIdAttribute(combinedAttributes);
    assertLanguageAttribute(combinedAttributes, 2);
}
Also used : Attribute(ddf.catalog.data.Attribute) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Test(org.junit.Test)

Example 68 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class SaxEventHandlerUtilsTest method testInvalidMultiValue.

@Test
public void testInvalidMultiValue() {
    List<Attribute> attributes = getTestAttributes();
    attributes.add(new AttributeImpl(CoreAttributes.ID, "anotherId"));
    List<Attribute> combinedAttributes = saxEventHandlerUtils.getCombinedMultiValuedAttributes(descriptors, attributes);
    assertThat(combinedAttributes.size(), is(3));
    Attribute validationWarningAttr = getAttributeByName(combinedAttributes, ValidationAttributes.VALIDATION_WARNINGS);
    assertThat(validationWarningAttr, notNullValue());
    assertIdAttribute(combinedAttributes);
    assertLanguageAttribute(combinedAttributes, 1);
}
Also used : Attribute(ddf.catalog.data.Attribute) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Test(org.junit.Test)

Example 69 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl 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)

Example 70 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class HistorianTest method getMetacardUpdatePair.

private List<Metacard> getMetacardUpdatePair() {
    Metacard old = new MetacardImpl();
    old.setAttribute(new AttributeImpl(Metacard.ID, METACARD_ID));
    old.setAttribute(new AttributeImpl(Metacard.RESOURCE_URI, RESOURCE_URI));
    Metacard update = new MetacardImpl();
    update.setAttribute(new AttributeImpl(Metacard.ID, METACARD_ID));
    update.setAttribute(new AttributeImpl(Metacard.RESOURCE_URI, RESOURCE_URI));
    update.setAttribute(new AttributeImpl(Metacard.DESCRIPTION, UPDATE_DESCRIPTION));
    return Arrays.asList(old, update);
}
Also used : DeletedMetacard(ddf.catalog.core.versioning.DeletedMetacard) Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) DeletedMetacardImpl(ddf.catalog.core.versioning.impl.DeletedMetacardImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Aggregations

AttributeImpl (ddf.catalog.data.impl.AttributeImpl)181 Metacard (ddf.catalog.data.Metacard)109 Test (org.junit.Test)75 ArrayList (java.util.ArrayList)56 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)49 Serializable (java.io.Serializable)30 Date (java.util.Date)30 Attribute (ddf.catalog.data.Attribute)29 List (java.util.List)23 HashMap (java.util.HashMap)20 IOException (java.io.IOException)18 InputStream (java.io.InputStream)17 Result (ddf.catalog.data.Result)15 HashSet (java.util.HashSet)15 PolicyResponse (ddf.catalog.plugin.PolicyResponse)14 ResultImpl (ddf.catalog.data.impl.ResultImpl)11 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)11 Set (java.util.Set)11 ContentItem (ddf.catalog.content.data.ContentItem)10 QueryResponse (ddf.catalog.operation.QueryResponse)10