Search in sources :

Example 16 with MetacardTypeImpl

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()));
}
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 17 with MetacardTypeImpl

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

Example 18 with MetacardTypeImpl

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

Example 19 with MetacardTypeImpl

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"));
}
Also used : Metacard(ddf.catalog.data.Metacard) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) URI(java.net.URI) ContentItem(ddf.catalog.content.data.ContentItem) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) ContentItemImpl(ddf.catalog.content.data.impl.ContentItemImpl) Test(org.junit.Test)

Example 20 with MetacardTypeImpl

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"));
}
Also used : Metacard(ddf.catalog.data.Metacard) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) URI(java.net.URI) ContentItem(ddf.catalog.content.data.ContentItem) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) ContentItemImpl(ddf.catalog.content.data.impl.ContentItemImpl) Test(org.junit.Test)

Aggregations

MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)40 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)21 Test (org.junit.Test)21 Metacard (ddf.catalog.data.Metacard)20 HashSet (java.util.HashSet)16 ArrayList (java.util.ArrayList)15 MetacardType (ddf.catalog.data.MetacardType)14 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)10 URI (java.net.URI)9 HashMap (java.util.HashMap)6 List (java.util.List)6 Metadata (org.apache.tika.metadata.Metadata)6 URISyntaxException (java.net.URISyntaxException)5 SourceResponse (ddf.catalog.operation.SourceResponse)4 QueryImpl (ddf.catalog.operation.impl.QueryImpl)3 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)3 MetacardTypeAdapter (ddf.catalog.transformer.xml.adapter.MetacardTypeAdapter)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ContentItem (ddf.catalog.content.data.ContentItem)2