use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeWriter in project geotoolkit by Geomatys.
the class XmlFeatureTypeTest method testWriteComplexFeatureType.
@Test
public void testWriteComplexFeatureType() throws JAXBException, IOException, ParserConfigurationException, SAXException {
final StringWriter sw = new StringWriter();
final JAXBFeatureTypeWriter writer = new JAXBFeatureTypeWriter();
writer.write(complexType, sw);
DomCompare.compare(XmlFeatureTypeTest.class.getResourceAsStream("/org/geotoolkit/feature/xml/ComplexType.xsd"), sw.toString());
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeWriter in project geotoolkit by Geomatys.
the class XmlFeatureTypeTest method testWriteSimpleGeomFeatureType.
@Test
public void testWriteSimpleGeomFeatureType() throws JAXBException, IOException, ParserConfigurationException, SAXException {
final StringWriter sw = new StringWriter();
final JAXBFeatureTypeWriter writer = new JAXBFeatureTypeWriter();
writer.write(simpleTypeGeom, sw);
DomCompare.compare(XmlFeatureTypeTest.class.getResourceAsStream("/org/geotoolkit/feature/xml/SimpleGeomType.xsd"), sw.toString());
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeWriter in project geotoolkit by Geomatys.
the class XmlFeatureTypeTest method testWriteMultiGeomFeatureType.
@Test
public void testWriteMultiGeomFeatureType() throws JAXBException, IOException, ParserConfigurationException, SAXException {
final StringWriter sw = new StringWriter();
final JAXBFeatureTypeWriter writer = new JAXBFeatureTypeWriter();
writer.write(multiGeomType, sw);
DomCompare.compare(XmlFeatureTypeTest.class.getResourceAsStream("/org/geotoolkit/feature/xml/MultiGeomType.xsd"), sw.toString());
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeWriter in project geotoolkit by Geomatys.
the class FeatureTypeToReferenceConverter method convert.
/**
* {@inheritDoc}
*/
@Override
public Reference convert(final FeatureType source, final Map<String, Object> params) throws UnconvertibleObjectException {
if (params.get(TMP_DIR_PATH) == null) {
throw new UnconvertibleObjectException("The output directory should be defined.");
}
if (source == null) {
throw new UnconvertibleObjectException("The output directory should be defined.");
}
Reference reference = new Reference();
reference.setMimeType((String) params.get(MIME));
reference.setEncoding((String) params.get(ENCODING));
reference.setSchema((String) params.get(SCHEMA));
reference.setMimeType((String) params.get(MIME));
reference.setEncoding((String) params.get(ENCODING));
final String randomFileName = UUID.randomUUID().toString();
// Write FeatureType
try {
final String schemaFileName = randomFileName + "_schema" + ".xsd";
// create file
final Path schemaFile = buildPath(params, schemaFileName);
final OutputStream schemaStream = Files.newOutputStream(schemaFile);
// write featureType xsd on file
final JAXBFeatureTypeWriter xmlFTWriter = new JAXBFeatureTypeWriter();
xmlFTWriter.write(source, schemaStream);
final String relLoc = getRelativeLocation(schemaFile, params);
reference.setHref((String) params.get(TMP_DIR_URL) + "/" + relLoc);
} catch (JAXBException ex) {
throw new UnconvertibleObjectException("Can't write FeatureType into xsd schema.", ex);
} catch (IOException ex) {
throw new UnconvertibleObjectException("Can't create xsd schema file.", ex);
}
return reference;
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeWriter in project geotoolkit by Geomatys.
the class FeatureTypeToComplexConverter method convert.
/**
* {@inheritDoc}
*/
@Override
public Data convert(final FeatureType source, final Map<String, Object> params) throws UnconvertibleObjectException {
if (source == null) {
throw new UnconvertibleObjectException("The output data should be defined.");
}
final Data complex = new Data();
final Object tmpEncoding = params == null ? null : params.get(ENCODING);
if (tmpEncoding instanceof String) {
complex.setEncoding((String) tmpEncoding);
}
complex.setMimeType(WPSMimeType.TEXT_GML.val());
try {
final JAXBFeatureTypeWriter xmlWriter = new JAXBFeatureTypeWriter();
complex.getContent().add(xmlWriter.writeToElement(source));
} catch (JAXBException | ParserConfigurationException ex) {
throw new UnconvertibleObjectException("Can't write FeatureType into ResponseDocument.", ex);
}
return complex;
}
Aggregations