use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.
the class MetacardTypeRegistryTest method setupMetacardTypeRegistry.
@BeforeClass
public static void setupMetacardTypeRegistry() throws Exception {
mtr = MetacardTypeRegistryImpl.getInstance();
qmtAttributes = new HashSet<AttributeDescriptor>();
AttributeDescriptor ad1 = new AttributeDescriptorImpl(GEO_ATTRIBUTE_DESCRIPTOR_NAME, true, true, false, false, BasicTypes.GEO_TYPE);
qmtAttributes.add(ad1);
AttributeDescriptor ad2 = new AttributeDescriptorImpl(METADATA_ATTRIBUTE_DESCRIPTOR_NAME, true, true, false, false, BasicTypes.XML_TYPE);
qmtAttributes.add(ad2);
QualifiedMetacardTypeImpl qmt1 = new QualifiedMetacardTypeImpl(QUALIFIED_METACARD_TYPE_NAMESPACE_1, QUALIFIED_METACARD_TYPE_NAME_1, qmtAttributes);
mtr.register(qmt1);
QualifiedMetacardTypeImpl qmt2 = new QualifiedMetacardTypeImpl(QUALIFIED_METACARD_TYPE_NAMESPACE_1, QUALIFIED_METACARD_TYPE_NAME_2, qmtAttributes);
mtr.register(qmt2);
QualifiedMetacardTypeImpl qmt3 = new QualifiedMetacardTypeImpl(QualifiedMetacardType.DEFAULT_METACARD_TYPE_NAMESPACE, QUALIFIED_METACARD_TYPE_NAME_3, qmtAttributes);
mtr.register(qmt3);
}
use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.
the class CswMarshallHelper method writeBoundingBox.
static void writeBoundingBox(HierarchicalStreamWriter writer, MarshallingContext context, Metacard metacard) {
Set<AttributeDescriptor> attrDescs = metacard.getMetacardType().getAttributeDescriptors();
List<Geometry> geometries = new LinkedList<>();
for (AttributeDescriptor ad : attrDescs) {
if (ad.getType() != null && AttributeType.AttributeFormat.GEOMETRY.equals(ad.getType().getAttributeFormat())) {
Attribute attr = metacard.getAttribute(ad.getName());
if (attr != null) {
if (ad.isMultiValued()) {
for (Serializable value : attr.getValues()) {
geometries.add(XmlNode.readGeometry((String) value));
}
} else {
geometries.add(XmlNode.readGeometry((String) attr.getValue()));
}
}
}
}
Geometry allGeometry = new GeometryCollection(geometries.toArray(new Geometry[geometries.size()]), new GeometryFactory());
Envelope bounds = allGeometry.getEnvelopeInternal();
if (!bounds.isNull()) {
String bbox = CswConstants.OWS_NAMESPACE_PREFIX + CswConstants.NAMESPACE_DELIMITER + CswConstants.OWS_BOUNDING_BOX;
String lower = CswConstants.OWS_NAMESPACE_PREFIX + CswConstants.NAMESPACE_DELIMITER + CswConstants.OWS_LOWER_CORNER;
String upper = CswConstants.OWS_NAMESPACE_PREFIX + CswConstants.NAMESPACE_DELIMITER + CswConstants.OWS_UPPER_CORNER;
writer.startNode(bbox);
writer.addAttribute(CswConstants.CRS, CswConstants.SRS_URL);
writer.startNode(lower);
writer.setValue(bounds.getMinX() + " " + bounds.getMinY());
writer.endNode();
writer.startNode(upper);
writer.setValue(bounds.getMaxX() + " " + bounds.getMaxY());
writer.endNode();
writer.endNode();
}
}
use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.
the class CswMarshallHelper method writeFields.
static void writeFields(HierarchicalStreamWriter writer, MarshallingContext context, MetacardImpl metacard, List<QName> fieldsToWrite) {
for (QName qName : fieldsToWrite) {
if (qName != null && !qName.equals(CswConstants.OWS_BOUNDING_BOX_QNAME)) {
String attrName = DefaultCswRecordMap.getDefaultCswRecordMap().getDefaultMetacardFieldFor(qName);
AttributeDescriptor ad = metacard.getMetacardType().getAttributeDescriptor(attrName);
/* Backwards Compatibility */
if (ad == null) {
ad = BasicTypes.BASIC_METACARD.getAttributeDescriptor(attrName);
}
writeAttribute(writer, context, metacard, ad, qName);
}
}
}
use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.
the class CqlResult method metacardToMap.
private Map<String, Object> metacardToMap(Result result) {
Map<String, Object> geoJson = null;
MetacardImpl resultMetacard = new MetacardImpl(result.getMetacard(), result.getMetacard().getMetacardType());
try {
for (AttributeDescriptor descriptor : resultMetacard.getMetacardType().getAttributeDescriptors()) {
switch(descriptor.getType().getAttributeFormat()) {
case BINARY:
case XML:
case OBJECT:
resultMetacard.setAttribute(descriptor.getName(), null);
default:
break;
}
}
geoJson = PropertyJsonMetacardTransformer.convertToJSON(resultMetacard, ImmutableList.of(AttributeType.AttributeFormat.BINARY, AttributeType.AttributeFormat.XML, AttributeType.AttributeFormat.OBJECT));
addCachedDate(resultMetacard, geoJson);
} catch (CatalogTransformerException e) {
LOGGER.debug("Unable to convert metacard to GeoJSON", e);
}
return geoJson;
}
use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.
the class TestXmlResponseQueueTransformer method givenMetacardTypeName.
private SourceResponse givenMetacardTypeName(String metacardTypeName) {
MetacardType type = getMetacardTypeStub(metacardTypeName, new HashSet<AttributeDescriptor>());
Metacard metacard = new MetacardImpl(type);
SourceResponse response = new SourceResponseImpl(null, Arrays.asList((Result) new ResultImpl(metacard)));
return response;
}
Aggregations