Search in sources :

Example 11 with AttributeDescriptorImpl

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

the class TestGeoJsonExtensible method sampleMetacardTypeB.

private MetacardType sampleMetacardTypeB() {
    Set<AttributeDescriptor> descriptors = new HashSet<AttributeDescriptor>();
    descriptors.add(new AttributeDescriptorImpl(COLUMNS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl(ROWS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl(DESCRIPTION_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.ID, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.TITLE, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(REVIEWED_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.BOOLEAN_TYPE));
    descriptors.add(new AttributeDescriptorImpl(PRECISE_LENGTH_METERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.DOUBLE_TYPE));
    descriptors.add(new AttributeDescriptorImpl(PRECISE_HEIGHT_METERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.FLOAT_TYPE));
    descriptors.add(new AttributeDescriptorImpl(NUMBER_REVIEWERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.SHORT_TYPE));
    return new MetacardTypeImpl("MetacardTypeB", descriptors);
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet)

Example 12 with AttributeDescriptorImpl

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

the class MetacardCreatorTest method testIntAttribute.

@Test
public void testIntAttribute() {
    Set<AttributeDescriptor> extraAttributes = new HashSet<>();
    extraAttributes.add(new AttributeDescriptorImpl(Media.DURATION, false, false, false, false, BasicTypes.INTEGER_TYPE));
    final Metadata metadata = new Metadata();
    String imageLength = "14";
    metadata.add(TIFF.IMAGE_LENGTH, imageLength);
    MetacardTypeImpl extendedMetacardType = new MetacardTypeImpl(BasicTypes.BASIC_METACARD.getName(), BasicTypes.BASIC_METACARD, extraAttributes);
    final String id = "id";
    final String metadataXml = "<xml>test</xml>";
    Metacard metacard = MetacardCreator.createMetacard(metadata, id, metadataXml, extendedMetacardType);
    assertThat(metacard.getMetadata(), is(metadataXml));
    assertThat(metacard.getAttribute(Media.HEIGHT).getValue(), is(Integer.valueOf(imageLength)));
}
Also used : Metacard(ddf.catalog.data.Metacard) Metadata(org.apache.tika.metadata.Metadata) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with AttributeDescriptorImpl

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

the class TestGeoJsonMetacardTransformer method testWithMultiValueAttributes.

@Test
public void testWithMultiValueAttributes() throws Exception {
    Set<AttributeDescriptor> descriptors = new HashSet(BasicTypes.BASIC_METACARD.getAttributeDescriptors());
    descriptors.add(new AttributeDescriptorImpl("multi-string", true, true, false, true, /* multivalued */
    BasicTypes.STRING_TYPE));
    MetacardType type = new MetacardTypeImpl("multi", descriptors);
    MetacardImpl metacard = new MetacardImpl(type);
    metacard.setAttribute("multi-string", (Serializable) Arrays.asList("foo", "bar"));
    GeoJsonMetacardTransformer transformer = new GeoJsonMetacardTransformer();
    BinaryContent content = transformer.transform(metacard, null);
    String jsonText = new String(content.getByteArray());
    JSONObject json = (JSONObject) PARSER.parse(jsonText);
    Map properties = (Map) json.get("properties");
    List<String> strings = (List<String>) properties.get("multi-string");
    assertThat(strings.get(0), is("foo"));
    assertThat(strings.get(1), is("bar"));
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) LineString(ddf.geo.formatter.LineString) MultiLineString(ddf.geo.formatter.MultiLineString) BinaryContent(ddf.catalog.data.BinaryContent) MetacardType(ddf.catalog.data.MetacardType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) JSONObject(org.json.simple.JSONObject) List(java.util.List) Map(java.util.Map) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with AttributeDescriptorImpl

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

the class MetacardCreatorTest method testValidDoubleAttribute.

@Test
public void testValidDoubleAttribute() {
    Set<AttributeDescriptor> extraAttributes = new HashSet<>();
    extraAttributes.add(new AttributeDescriptorImpl(Media.DURATION, false, false, false, false, BasicTypes.DOUBLE_TYPE));
    final Metadata metadata = new Metadata();
    String durationValue = "14.88";
    metadata.add(MetacardCreator.DURATION_METDATA_KEY, durationValue);
    MetacardTypeImpl extendedMetacardType = new MetacardTypeImpl(BasicTypes.BASIC_METACARD.getName(), BasicTypes.BASIC_METACARD, extraAttributes);
    final String id = "id";
    final String metadataXml = "<xml>test</xml>";
    Metacard metacard = MetacardCreator.createMetacard(metadata, id, metadataXml, extendedMetacardType);
    assertThat(metacard.getMetadata(), is(metadataXml));
    assertThat(metacard.getAttribute(Media.DURATION).getValue(), is(Double.valueOf(durationValue)));
}
Also used : Metacard(ddf.catalog.data.Metacard) Metadata(org.apache.tika.metadata.Metadata) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with AttributeDescriptorImpl

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

the class TestGeoJsonExtensible method setUp.

@Before
public void setUp() {
    transformer = new GeoJsonInputTransformer();
    transformer.setMetacardTypes(prepareMetacardTypes());
    AttributeRegistry attributeRegistry = new AttributeRegistryImpl();
    attributeRegistry.register(new AttributeDescriptorImpl(TEMPERATURE_KEY, true, true, true, true, DOUBLE_TYPE));
    transformer.setAttributeRegistry(attributeRegistry);
}
Also used : AttributeRegistry(ddf.catalog.data.AttributeRegistry) AttributeRegistryImpl(ddf.catalog.data.impl.AttributeRegistryImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) Before(org.junit.Before)

Aggregations

AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)25 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)23 HashSet (java.util.HashSet)18 Metacard (ddf.catalog.data.Metacard)13 Test (org.junit.Test)13 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)12 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)10 MetacardType (ddf.catalog.data.MetacardType)7 QueryImpl (ddf.catalog.operation.impl.QueryImpl)5 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)5 Matchers.anyString (org.mockito.Matchers.anyString)5 ByteSource (com.google.common.io.ByteSource)4 ContentItem (ddf.catalog.content.data.ContentItem)4 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)4 CreateStorageRequestImpl (ddf.catalog.content.operation.impl.CreateStorageRequestImpl)4 CreateResponse (ddf.catalog.operation.CreateResponse)4 SourceResponse (ddf.catalog.operation.SourceResponse)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Metadata (org.apache.tika.metadata.Metadata)4