use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.
the class SolrProviderExtensibleMetacards method createAuthor.
private Metacard createAuthor() {
MetacardImpl customMetacard;
authorDescriptors.add(new AttributeDescriptorImpl(Metacard.ID, true, true, true, false, BasicTypes.STRING_TYPE));
authorDescriptors.add(new AttributeDescriptorImpl(AUTHOR_FIELD, true, true, true, false, BasicTypes.XML_TYPE));
MetacardTypeImpl newType = new MetacardTypeImpl("34ga$^TGHfg:/", authorDescriptors);
customMetacard = new MetacardImpl(newType);
customMetacard.setAttribute(AUTHOR_FIELD, AUTHOR_VALUE);
return customMetacard;
}
use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.
the class SolrProviderExtensibleMetacards method createDescriptionMetacard.
private Metacard createDescriptionMetacard() {
descriptionDescriptors.add(new AttributeDescriptorImpl(Metacard.ID, true, true, true, false, BasicTypes.STRING_TYPE));
descriptionDescriptors.add(new AttributeDescriptorImpl(DESCRIPTION_FIELD, true, true, true, false, BasicTypes.STRING_TYPE));
MetacardTypeImpl mType = new MetacardTypeImpl("custom1", descriptionDescriptors);
MetacardImpl customMetacard = new MetacardImpl(mType);
customMetacard.setAttribute(DESCRIPTION_FIELD, DESCRIPTION_VALUE);
return customMetacard;
}
use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.
the class MetacardCreatorTest method testAdditionalKeyMappings.
@Test
public void testAdditionalKeyMappings() {
Metadata metadata = new Metadata();
String imageLength = "14";
String imageWidth = "18";
String duration = "12.5 s";
String durationHms = "00:01:30.5";
String customImageWidthKey = "Width_Of_Image";
String customDurationKey = "Media_Duration";
String customDurationMetacardKey = "ext.media.duration";
String shortMetacardKey = "ext.short";
String shortMetadataKey = "Short Value";
String shortValue = "3";
String longMetacardKey = "ext.long";
String longMetadataKey = "Long Value";
String longValue = "4";
String booleanMetacardKey = "ext.boolean";
String booleanMetadataKey = "Boolean Value";
String booleanValue = "true";
String floatMetacardKey = "ext.float";
String floatMetadataKey = "Float Value";
String floatValue = "1.2";
metadata.add(TIFF.IMAGE_LENGTH, imageLength);
metadata.add(customImageWidthKey, imageWidth);
metadata.add("Duration", duration);
metadata.add(customDurationKey, durationHms);
metadata.add(shortMetadataKey, shortValue);
metadata.add(longMetadataKey, longValue);
metadata.add(booleanMetadataKey, booleanValue);
metadata.add(floatMetadataKey, floatValue);
MetacardCreator.ALTERNATE_METADATA_KEY_MAPPING.put(Media.WIDTH, Arrays.asList("Image Width", customImageWidthKey));
MetacardCreator.ALTERNATE_METADATA_KEY_MAPPING.put(customDurationMetacardKey, Arrays.asList(customDurationKey));
MetacardCreator.ALTERNATE_METADATA_KEY_MAPPING.put(shortMetacardKey, Arrays.asList(shortMetadataKey));
MetacardCreator.ALTERNATE_METADATA_KEY_MAPPING.put(longMetacardKey, Arrays.asList(longMetadataKey));
MetacardCreator.ALTERNATE_METADATA_KEY_MAPPING.put(booleanMetacardKey, Arrays.asList(booleanMetadataKey));
MetacardCreator.ALTERNATE_METADATA_KEY_MAPPING.put(floatMetacardKey, Arrays.asList(floatMetadataKey));
final String id = "id";
final String metadataXml = "<xml>test</xml>";
Set<AttributeDescriptor> extraAttributes = new HashSet<>();
extraAttributes.add(new AttributeDescriptorImpl(Media.HEIGHT, false, false, false, false, BasicTypes.INTEGER_TYPE));
extraAttributes.add(new AttributeDescriptorImpl(Media.WIDTH, false, false, false, false, BasicTypes.INTEGER_TYPE));
extraAttributes.add(new AttributeDescriptorImpl(Media.DURATION, false, false, false, false, BasicTypes.DOUBLE_TYPE));
extraAttributes.add(new AttributeDescriptorImpl(customDurationMetacardKey, false, false, false, false, BasicTypes.DOUBLE_TYPE));
extraAttributes.add(new AttributeDescriptorImpl(shortMetacardKey, false, false, false, false, BasicTypes.SHORT_TYPE));
extraAttributes.add(new AttributeDescriptorImpl(longMetacardKey, false, false, false, false, BasicTypes.LONG_TYPE));
extraAttributes.add(new AttributeDescriptorImpl(booleanMetacardKey, false, false, false, false, BasicTypes.BOOLEAN_TYPE));
extraAttributes.add(new AttributeDescriptorImpl(floatMetacardKey, false, false, false, false, BasicTypes.FLOAT_TYPE));
MetacardTypeImpl extendedMetacardType = new MetacardTypeImpl(MetacardImpl.BASIC_METACARD.getName(), MetacardImpl.BASIC_METACARD, extraAttributes);
final Metacard metacard = MetacardCreator.createMetacard(metadata, id, metadataXml, extendedMetacardType);
assertThat(metacard.getAttribute(Media.HEIGHT).getValue(), is(Integer.valueOf(imageLength)));
assertThat(metacard.getAttribute(Media.WIDTH).getValue(), is(Integer.valueOf(imageWidth)));
assertThat(metacard.getAttribute(Media.DURATION).getValue(), is(12.5));
assertThat(metacard.getAttribute(customDurationMetacardKey).getValue(), is(90.5));
assertThat(metacard.getAttribute(shortMetacardKey).getValue(), is((short) 3));
assertThat(metacard.getAttribute(longMetacardKey).getValue(), is(4l));
assertThat(metacard.getAttribute(booleanMetacardKey).getValue(), is(true));
assertThat(metacard.getAttribute(floatMetacardKey).getValue(), is(1.2f));
}
use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.
the class FeatureMetacardType method addDescriptors.
/**
* we don't want to expose these in a query interface ie wfs endpoint, so we need to create new
* attributes for each and set them to stored = false note: indexed is being used to determine
* whether or not to query certain wfs fields so it did not seem appropriate to hide those fields
* from the endpoint schema
*/
private void addDescriptors(Set<AttributeDescriptor> attrDescriptors) {
for (AttributeDescriptor descriptor : attrDescriptors) {
AttributeDescriptorImpl basicAttributeDescriptor = (AttributeDescriptorImpl) descriptor;
AttributeDescriptor attributeDescriptor = new AttributeDescriptorImpl(basicAttributeDescriptor.getName(), false, false, basicAttributeDescriptor.isTokenized(), basicAttributeDescriptor.isMultiValued(), basicAttributeDescriptor.getType());
add(attributeDescriptor);
}
}
use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.
the class GenericXmlLibTest 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));
}
Aggregations