Search in sources :

Example 26 with AttributeDescriptorImpl

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;
}
Also used : MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 27 with AttributeDescriptorImpl

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;
}
Also used : MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 28 with AttributeDescriptorImpl

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));
}
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 29 with AttributeDescriptorImpl

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);
    }
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl)

Example 30 with AttributeDescriptorImpl

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));
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)44 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)34 HashSet (java.util.HashSet)26 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)24 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)19 Test (org.junit.Test)19 Metacard (ddf.catalog.data.Metacard)17 MetacardType (ddf.catalog.data.MetacardType)11 ArrayList (java.util.ArrayList)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 SourceResponse (ddf.catalog.operation.SourceResponse)6 QueryImpl (ddf.catalog.operation.impl.QueryImpl)6 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)6 Before (org.junit.Before)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Metadata (org.apache.tika.metadata.Metadata)5 Filter (org.opengis.filter.Filter)5 ByteSource (com.google.common.io.ByteSource)4