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