private ObjectNode encodeSweTextField(SweField field) { ObjectNode jfield = createField(field); jfield.put(JSONConstants.TYPE, JSONConstants.TEXT_TYPE); SweText sweText = (SweText) field.getElement(); if (sweText.isSetValue()) { jfield.put(JSONConstants.VALUE, sweText.getValue()); } return jfield; }
/** * Process standard formatted capabilities insertion metadata into a map (key=identifier, * value=name) * * @param dataRecord The DataRecord to examine * @param xbCapabilities The original capabilites xml object, used for exception throwing * @return Map of insertion metadata (key=identifier, value=name) * @throws CodedException thrown if the DataRecord fields are in an incorrect format */ private Map<String, String> parseCapabilitiesMetadata( final SmlCapabilities caps, final Capabilities xbCapabilities) throws OwsExceptionReport { final Map<String, String> map = Maps.newHashMapWithExpectedSize(caps.getDataRecord().getFields().size()); for (final SweField sosSweField : caps.getDataRecord().getFields()) { if (sosSweField.getElement() instanceof SweText) { final SweText sosSweText = (SweText) sosSweField.getElement(); if (sosSweText.isSetValue()) { map.put(sosSweText.getValue(), sosSweField.getName().getValue()); } else { throw new UnsupportedDecoderInputException(this, xbCapabilities) .withMessage( "Removable capabilities element %s contains a field with no value", xbCapabilities.getName()); } } else { throw new UnsupportedDecoderInputException(this, xbCapabilities) .withMessage( "Removable capabilities element %s contains a non-Text field", xbCapabilities.getName()); } } return map; }