Search in sources :

Example 6 with AttributeDescriptorImpl

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

the class TestGetRecordsResponseConverter method createMetacardList.

private List<Metacard> createMetacardList(int start, int finish) {
    List<Metacard> list = new LinkedList<>();
    for (int i = start; i <= finish; i++) {
        MetacardImpl metacard = new MetacardImpl();
        metacard.setId(ID_PREFIX + i);
        metacard.setSourceId(SOURCE_PREFIX + i);
        metacard.setTitle(TITLE_PREFIX + i);
        // for testing an attribute with multiple values
        AttributeDescriptor ad = new AttributeDescriptorImpl(FORMAT, true, true, true, true, BasicTypes.STRING_TYPE);
        Set<AttributeDescriptor> ads = new HashSet<>(metacard.getMetacardType().getAttributeDescriptors());
        ads.add(ad);
        metacard.setType(new MetacardTypeImpl("test", ads));
        metacard.setLocation(WKT);
        AttributeImpl attr = new AttributeImpl(FORMAT, FORMAT);
        attr.addValue(FORMAT);
        metacard.setAttribute(attr);
        // for testing an attribute with no attribute descriptor
        metacard.setAttribute(RELATION, RELATION);
        list.add(metacard);
    }
    return list;
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) LinkedList(java.util.LinkedList) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 7 with AttributeDescriptorImpl

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

the class TestGenericXmlLib method testDynamicMetacardType.

@Test
public void testDynamicMetacardType() {
    Set<AttributeDescriptor> attributeDescriptors = new HashSet<>();
    attributeDescriptors.add(new AttributeDescriptorImpl(Metacard.TITLE, false, false, false, false, BasicTypes.STRING_TYPE));
    DynamicMetacardType dynamicMetacardType = new DynamicMetacardType(attributeDescriptors, "Foo");
    assertThat(dynamicMetacardType.getName(), is("Foo.metacard"));
    assertThat(dynamicMetacardType.getAttributeDescriptor(Metacard.TITLE), notNullValue());
    assertThat(dynamicMetacardType.getAttributeDescriptors().equals(attributeDescriptors), is(true));
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with AttributeDescriptorImpl

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

the class MetacardCreatorTest method testNullIntAttribute.

@Test
public void testNullIntAttribute() {
    Set<AttributeDescriptor> extraAttributes = new HashSet<>();
    extraAttributes.add(new AttributeDescriptorImpl(Media.DURATION, false, false, false, false, BasicTypes.INTEGER_TYPE));
    final Metadata metadata = new Metadata();
    metadata.add(MetacardCreator.COMPRESSION_TYPE_METADATA_KEY, null);
    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.COMPRESSION), is(nullValue()));
}
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 9 with AttributeDescriptorImpl

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

the class MetacardCreatorTest method testDoubleAttributeWithNumberFormatException.

@Test
public void testDoubleAttributeWithNumberFormatException() {
    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 = "Not actually a double";
    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), is(nullValue()));
}
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 10 with AttributeDescriptorImpl

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

the class TestGeoJsonExtensible method sampleMetacardTypeA.

private MetacardType sampleMetacardTypeA() {
    Set<AttributeDescriptor> descriptors = new HashSet<AttributeDescriptor>();
    descriptors.add(new AttributeDescriptorImpl("frequency", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.LONG_TYPE));
    descriptors.add(new AttributeDescriptorImpl("min-frequency", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.LONG_TYPE));
    descriptors.add(new AttributeDescriptorImpl("max-frequency", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.LONG_TYPE));
    descriptors.add(new AttributeDescriptorImpl("angle", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl("multi-string", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    true, /* 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));
    return new MetacardTypeImpl(SAMPLE_A_METACARD_TYPE_NAME, descriptors);
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet)

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