use of ddf.catalog.data.impl.MetacardTypeImpl 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.MetacardTypeImpl 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);
}
use of ddf.catalog.data.impl.MetacardTypeImpl 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);
}
use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.
the class OverrideAttributesSupportTest method testOverrideAttributesBasic.
@Test
public void testOverrideAttributesBasic() throws URISyntaxException {
List<ContentItem> contentItems = new ArrayList<>();
Map<String, Metacard> metacardMap = new HashMap<>();
MetacardImpl overrideMetacard = new MetacardImpl();
MetacardImpl metacard = new MetacardImpl(new MetacardTypeImpl("special", overrideMetacard.getMetacardType().getAttributeDescriptors()));
metacard.setMetadata("original");
metacard.setTitle("original");
metacard.setId("original");
metacard.setResourceURI(new URI("content:stuff"));
overrideMetacard.setTitle("updated");
overrideMetacard.setId("updated");
overrideMetacard.setResourceURI(new URI("content:newstuff"));
overrideMetacard.setMetadata("updated");
metacardMap.put(metacard.getId(), metacard);
contentItems.add(new ContentItemImpl("original", null, "txt/plain", overrideMetacard));
OverrideAttributesSupport.overrideAttributes(contentItems, metacardMap);
assertNotNull(metacardMap.get("original"));
assertThat(metacardMap.get("original").getMetadata(), is("updated"));
assertThat(metacardMap.get("original").getTitle(), is("updated"));
assertThat(metacardMap.get("original").getResourceURI().toString(), is("content:newstuff"));
assertThat(metacardMap.get("original").getId(), is("original"));
assertThat(metacardMap.get("original").getMetacardType().getName(), is("special"));
}
use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.
the class OverrideAttributesSupportTest method testOverrideAttributesOther.
@Test
public void testOverrideAttributesOther() throws URISyntaxException {
List<ContentItem> contentItems = new ArrayList<>();
Map<String, Metacard> metacardMap = new HashMap<>();
MetacardImpl metacard = new MetacardImpl();
metacard.setMetadata("original");
metacard.setTitle("original");
metacard.setId("original");
metacard.setResourceURI(new URI("content:stuff"));
MetacardImpl overrideMetacard = new MetacardImpl(new MetacardTypeImpl("other", metacard.getMetacardType().getAttributeDescriptors()));
overrideMetacard.setTitle("updated");
overrideMetacard.setId("updated");
overrideMetacard.setMetadata("updated");
overrideMetacard.setResourceURI(new URI("content:newstuff"));
metacardMap.put(metacard.getId(), metacard);
contentItems.add(new ContentItemImpl("original", null, "txt/plain", overrideMetacard));
OverrideAttributesSupport.overrideAttributes(contentItems, metacardMap);
assertNotNull(metacardMap.get("original"));
assertThat(metacardMap.get("original").getMetadata(), is("updated"));
assertThat(metacardMap.get("original").getTitle(), is("updated"));
assertThat(metacardMap.get("original").getResourceURI().toString(), is("content:newstuff"));
assertThat(metacardMap.get("original").getId(), is("original"));
assertThat(metacardMap.get("original").getMetacardType().getName(), is("other"));
}
Aggregations