use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.
the class FilterPluginTest method getNoRolesMetacard.
private Metacard getNoRolesMetacard() {
MetacardImpl metacard = new MetacardImpl();
metacard.setResourceSize("100");
try {
metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
} catch (URISyntaxException e) {
LOGGER.error("", e);
}
metacard.setContentTypeName("Resource");
metacard.setTitle("Metacard 1");
metacard.setContentTypeVersion("1");
metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
HashMap<String, List<String>> security = new HashMap<>();
metacard.setSecurity(security);
return metacard;
}
use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.
the class MetacardCreatorTest method testIntAttribute.
@Test
public void testIntAttribute() {
Set<AttributeDescriptor> extraAttributes = new HashSet<>();
extraAttributes.add(new AttributeDescriptorImpl(Media.DURATION, false, false, false, false, BasicTypes.INTEGER_TYPE));
final Metadata metadata = new Metadata();
String imageLength = "14";
metadata.add(TIFF.IMAGE_LENGTH, imageLength);
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.HEIGHT).getValue(), is(Integer.valueOf(imageLength)));
}
use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.
the class TestGeoJsonMetacardTransformer method testWithMultiValueAttributes.
@Test
public void testWithMultiValueAttributes() throws Exception {
Set<AttributeDescriptor> descriptors = new HashSet(BasicTypes.BASIC_METACARD.getAttributeDescriptors());
descriptors.add(new AttributeDescriptorImpl("multi-string", true, true, false, true, /* multivalued */
BasicTypes.STRING_TYPE));
MetacardType type = new MetacardTypeImpl("multi", descriptors);
MetacardImpl metacard = new MetacardImpl(type);
metacard.setAttribute("multi-string", (Serializable) Arrays.asList("foo", "bar"));
GeoJsonMetacardTransformer transformer = new GeoJsonMetacardTransformer();
BinaryContent content = transformer.transform(metacard, null);
String jsonText = new String(content.getByteArray());
JSONObject json = (JSONObject) PARSER.parse(jsonText);
Map properties = (Map) json.get("properties");
List<String> strings = (List<String>) properties.get("multi-string");
assertThat(strings.get(0), is("foo"));
assertThat(strings.get(1), is("bar"));
}
use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.
the class MetacardCreatorTest method createTestMetacard.
private Metacard createTestMetacard(Set<AttributeDescriptor> extraAttributes) {
final Metadata metadata = new Metadata();
final String title = "title";
final String contentType = "content type";
final String created = "2015-12-31T01:23:45Z";
final String modified = "2016-01-01T02:34:56Z";
final String latitude = "12.345";
final String longitude = "67.891";
metadata.add(TikaCoreProperties.TITLE, title);
metadata.add(Metadata.CONTENT_TYPE, contentType);
metadata.add(TikaCoreProperties.CREATED, created);
metadata.add(TikaCoreProperties.MODIFIED, modified);
metadata.add(Metadata.LATITUDE, latitude);
metadata.add(Metadata.LONGITUDE, longitude);
final String id = "id";
final String metadataXml = "<xml>test</xml>";
final Metacard metacard;
if (CollectionUtils.isEmpty(extraAttributes)) {
metacard = MetacardCreator.createMetacard(metadata, id, metadataXml, BasicTypes.BASIC_METACARD);
} else {
MetacardTypeImpl extendedMetacardType = new MetacardTypeImpl(BasicTypes.BASIC_METACARD.getName(), BasicTypes.BASIC_METACARD, extraAttributes);
metacard = MetacardCreator.createMetacard(metadata, id, metadataXml, extendedMetacardType);
}
assertThat(metacard, notNullValue());
assertThat(metacard.getTitle(), is(title));
assertThat(metacard.getContentTypeName(), is(contentType));
assertThat(convertDate(metacard.getCreatedDate()), is(created));
assertThat(convertDate(metacard.getModifiedDate()), is(modified));
assertThat(metacard.getLocation(), is(String.format("POINT(%s %s)", longitude, latitude)));
assertThat(metacard.getId(), is(id));
assertThat(metacard.getMetadata(), is(metadataXml));
return metacard;
}
use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.
the class MetacardCreatorTest method testValidDoubleAttribute.
@Test
public void testValidDoubleAttribute() {
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 = "14.88";
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).getValue(), is(Double.valueOf(durationValue)));
}
Aggregations