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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations