use of org.geotoolkit.csw.xml.v202.UpdateType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method updateUnmarshalingTest.
/**
* Test simple Record Marshalling.
*/
@Test
public void updateUnmarshalingTest() throws JAXBException {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
/*
* Test 1 : Simple recordProperty (String)
*/
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" >\n" + " <csw:Update>\n" + " <csw:RecordProperty>\n" + " <csw:Name>/csw:Record/dc:contributor</csw:Name>\n" + " <csw:Value xsi:type=\"xs:string\" >Jane</csw:Value>\n" + " </csw:RecordProperty>\n" + " <csw:Constraint version=\"1.1.0\">\n" + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + " </csw:Constraint>\n" + " </csw:Update>\n" + "</csw:Transaction>\n";
TransactionType result = (TransactionType) unmarshaller.unmarshal(new StringReader(xml));
RecordPropertyType recordProperty = new RecordPropertyType("/csw:Record/dc:contributor", "Jane");
QueryConstraintType query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
UpdateType update = new UpdateType(Arrays.asList(recordProperty), query);
TransactionType expResult = new TransactionType("CSW", "2.0.2", update);
assertEquals(expResult, result);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:gco=\"http://www.isotc211.org/2005/gco\">\n" + " <csw:Update>\n" + " <csw:RecordProperty>\n" + " <csw:Name>/gmd:MD_Metadata/identificationInfo/extent/geographicElement</csw:Name>\n" + " <csw:Value xsi:type=\"gmd:EX_GeographicBoundingBox_Type\" >\n" + " <gmd:EX_GeographicBoundingBox>" + '\n' + " <gmd:extentTypeCode>\n" + " <gco:Boolean>true</gco:Boolean>\n" + " </gmd:extentTypeCode>\n" + " <gmd:westBoundLongitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:westBoundLongitude>\n" + " <gmd:eastBoundLongitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:eastBoundLongitude>\n" + " <gmd:southBoundLatitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:southBoundLatitude>\n" + " <gmd:northBoundLatitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:northBoundLatitude>\n" + " </gmd:EX_GeographicBoundingBox>" + '\n' + " </csw:Value>\n" + " </csw:RecordProperty>\n" + " <csw:Constraint version=\"1.1.0\">\n" + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + " </csw:Constraint>\n" + " </csw:Update>\n" + "</csw:Transaction>\n";
result = (TransactionType) unmarshaller.unmarshal(new StringReader(xml));
DefaultGeographicBoundingBox geographicElement = new DefaultGeographicBoundingBox(1.1, 1.1, 1.1, 1.1);
recordProperty = new RecordPropertyType("/gmd:MD_Metadata/identificationInfo/extent/geographicElement", geographicElement);
query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
update = new UpdateType(Arrays.asList(recordProperty), query);
expResult = new TransactionType("CSW", "2.0.2", update);
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
use of org.geotoolkit.csw.xml.v202.UpdateType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method updateMarshalingTest.
/**
* Test simple Record Marshalling.
*/
@Test
public void updateMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
Marshaller marshaller = pool.acquireMarshaller();
// <TODO
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<SimpleLiteral> subject = new ArrayList<>();
subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
subject.add(new SimpleLiteral("oceans elevation 2"));
SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
QueryConstraintType query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
UpdateType update = new UpdateType(record, query);
TransactionType request = new TransactionType("CSW", "2.0.2", update);
// marshaller.marshal(request, System.out);
// TODO/>
/*
* Test 2 : Simple recordProperty (String)
*/
RecordPropertyType recordProperty = new RecordPropertyType("/csw:Record/dc:contributor", "Jane");
query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
update = new UpdateType(Arrays.asList(recordProperty), query);
request = new TransactionType("CSW", "2.0.2", update);
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <csw:Update>\n" + " <csw:RecordProperty>\n" + " <csw:Name>/csw:Record/dc:contributor</csw:Name>\n" + " <csw:Value>Jane</csw:Value>\n" + " </csw:RecordProperty>\n" + " <csw:Constraint version=\"1.1.0\">\n" + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + " </csw:Constraint>\n" + " </csw:Update>\n" + "</csw:Transaction>\n";
StringWriter sw = new StringWriter();
marshaller.marshal(request, sw);
String result = sw.toString();
assertXmlEquals(expResult, result, "xmlns:*");
/*
* Test 3 : Complex recordProperty (GeographicBoundingBox)
*/
DefaultGeographicBoundingBox geographicElement = new DefaultGeographicBoundingBox(1.1, 1.1, 1.1, 1.1);
recordProperty = new RecordPropertyType("/gmd:MD_Metadata/identificationInfo/extent/geographicElement", geographicElement);
query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
update = new UpdateType(Arrays.asList(recordProperty), query);
request = new TransactionType("CSW", "2.0.2", update);
expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:gco=\"http://www.isotc211.org/2005/gco\">\n" + " <csw:Update>\n" + " <csw:RecordProperty>\n" + " <csw:Name>/gmd:MD_Metadata/identificationInfo/extent/geographicElement</csw:Name>\n" + " <csw:Value>\n" + " <gmd:EX_GeographicBoundingBox>" + '\n' + " <gmd:extentTypeCode>\n" + " <gco:Boolean>true</gco:Boolean>\n" + " </gmd:extentTypeCode>\n" + " <gmd:westBoundLongitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:westBoundLongitude>\n" + " <gmd:eastBoundLongitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:eastBoundLongitude>\n" + " <gmd:southBoundLatitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:southBoundLatitude>\n" + " <gmd:northBoundLatitude>\n" + " <gco:Decimal>1.1</gco:Decimal>\n" + " </gmd:northBoundLatitude>\n" + " </gmd:EX_GeographicBoundingBox>" + '\n' + " </csw:Value>\n" + " </csw:RecordProperty>\n" + " <csw:Constraint version=\"1.1.0\">\n" + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + " </csw:Constraint>\n" + " </csw:Update>\n" + "</csw:Transaction>\n";
sw = new StringWriter();
marshaller.marshal(request, sw);
result = sw.toString();
assertXmlEquals(expResult, result, "xmlns:*");
pool.recycle(marshaller);
}
use of org.geotoolkit.csw.xml.v202.UpdateType in project geotoolkit by Geomatys.
the class RecordPropertyTypeTest method getValueComplexTypeTest.
@Test
public void getValueComplexTypeTest() throws Exception {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<csw:Transaction xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\"" + " xmlns:gco=\"http://www.isotc211.org/2005/gco\" verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" >" + '\n' + " <csw:Update>" + '\n' + " <csw:RecordProperty>" + '\n' + " <csw:Name>/csw:Record/dc:contributor</csw:Name>" + '\n' + " <csw:Value>" + '\n' + " <gmd:EX_GeographicBoundingBox>" + '\n' + " <gmd:extentTypeCode>" + '\n' + " <gco:Boolean>true</gco:Boolean>" + '\n' + " </gmd:extentTypeCode>" + '\n' + " <gmd:westBoundLongitude>" + '\n' + " <gco:Decimal>1.1667</gco:Decimal>" + '\n' + " </gmd:westBoundLongitude>" + '\n' + " <gmd:eastBoundLongitude>" + '\n' + " <gco:Decimal>1.1667</gco:Decimal>" + '\n' + " </gmd:eastBoundLongitude>" + '\n' + " <gmd:southBoundLatitude>" + '\n' + " <gco:Decimal>36.6</gco:Decimal>" + '\n' + " </gmd:southBoundLatitude>" + '\n' + " <gmd:northBoundLatitude>" + '\n' + " <gco:Decimal>36.6</gco:Decimal>" + '\n' + " </gmd:northBoundLatitude>" + '\n' + " </gmd:EX_GeographicBoundingBox>" + '\n' + " </csw:Value>" + '\n' + " </csw:RecordProperty>" + '\n' + " <csw:Constraint version=\"1.1.0\">" + '\n' + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>" + '\n' + " </csw:Constraint>" + '\n' + " </csw:Update>" + '\n' + "</csw:Transaction>" + '\n';
TransactionType result = (TransactionType) unmarshaller.unmarshal(new StringReader(xml));
assertTrue(result.getInsertOrUpdateOrDelete().size() == 1);
assertTrue(result.getInsertOrUpdateOrDelete().get(0) instanceof UpdateType);
UpdateType update = (UpdateType) result.getInsertOrUpdateOrDelete().get(0);
assertTrue(update.getRecordProperty().size() == 1);
RecordPropertyType property = update.getRecordProperty().get(0);
assertTrue(property.getValue() instanceof Node);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<csw:Transaction xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:gco=\"http://www.isotc211.org/2005/gco\"" + " verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" >" + '\n' + " <csw:Update>" + '\n' + " <csw:RecordProperty>" + '\n' + " <csw:Name>/csw:Record/dc:contributor</csw:Name>" + '\n' + " <csw:Value>" + '\n' + " <gmd:EX_GeographicBoundingBox>" + '\n' + " <gmd:extentTypeCode>" + '\n' + " <gco:Boolean>true</gco:Boolean>" + '\n' + " </gmd:extentTypeCode>" + '\n' + " <gmd:westBoundLongitude>" + '\n' + " <gco:Decimal>1.1667</gco:Decimal>" + '\n' + " </gmd:westBoundLongitude>" + '\n' + " <gmd:eastBoundLongitude>" + '\n' + " <gco:Decimal>1.1667</gco:Decimal>" + '\n' + " </gmd:eastBoundLongitude>" + '\n' + " <gmd:southBoundLatitude>" + '\n' + " <gco:Decimal>36.6</gco:Decimal>" + '\n' + " </gmd:southBoundLatitude>" + '\n' + " <gmd:northBoundLatitude>" + '\n' + " <gco:Decimal>36.6</gco:Decimal>" + '\n' + " </gmd:northBoundLatitude>" + '\n' + " </gmd:EX_GeographicBoundingBox>" + '\n' + " </csw:Value>" + '\n' + " </csw:RecordProperty>" + '\n' + " <csw:Constraint version=\"1.1.0\">" + '\n' + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>" + '\n' + " </csw:Constraint>" + '\n' + " </csw:Update>" + '\n' + "</csw:Transaction>" + '\n';
result = (TransactionType) unmarshaller.unmarshal(new StringReader(xml));
assertTrue(result.getInsertOrUpdateOrDelete().size() == 1);
assertTrue(result.getInsertOrUpdateOrDelete().get(0) instanceof UpdateType);
update = (UpdateType) result.getInsertOrUpdateOrDelete().get(0);
assertTrue(update.getRecordProperty().size() == 1);
property = update.getRecordProperty().get(0);
assertTrue(property.getValue() instanceof Node);
final Node source = ((Node) property.getValue()).getNextSibling();
final Object obj;
if (CAN_PARSE_DOM_SOURCE) {
obj = unmarshaller.unmarshal(source);
} else {
Transformer xformer = TransformerFactory.newInstance().newTransformer();
StringWriter buffer = new StringWriter();
xformer.transform(new DOMSource(source), new StreamResult(buffer));
obj = unmarshaller.unmarshal(new StringReader(buffer.toString()));
}
assertTrue("unexpected type:" + property.getValue().getClass(), obj instanceof DefaultGeographicBoundingBox);
DefaultGeographicBoundingBox expResult = new DefaultGeographicBoundingBox(1.1667, 1.1667, 36.6, 36.6);
assertEquals(expResult, obj);
}
use of org.geotoolkit.csw.xml.v202.UpdateType in project geotoolkit by Geomatys.
the class RecordPropertyTypeTest method getValueStringTest.
/**
* Test simple Record Marshalling.
*/
@Test
public void getValueStringTest() throws JAXBException {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<csw:Transaction xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" >" + '\n' + " <csw:Update>" + '\n' + " <csw:RecordProperty>" + '\n' + " <csw:Name>/csw:Record/dc:contributor</csw:Name>" + '\n' + " <csw:Value>Jane</csw:Value>" + '\n' + " </csw:RecordProperty>" + '\n' + " <csw:Constraint version=\"1.1.0\">" + '\n' + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>" + '\n' + " </csw:Constraint>" + '\n' + " </csw:Update>" + '\n' + "</csw:Transaction>" + '\n';
TransactionType result = (TransactionType) unmarshaller.unmarshal(new StringReader(xml));
assertTrue(result.getInsertOrUpdateOrDelete().size() == 1);
assertTrue(result.getInsertOrUpdateOrDelete().get(0) instanceof UpdateType);
UpdateType update = (UpdateType) result.getInsertOrUpdateOrDelete().get(0);
assertTrue(update.getRecordProperty().size() == 1);
RecordPropertyType property = update.getRecordProperty().get(0);
assertTrue(property.getValue() instanceof Node);
final Node nValue = (Node) property.getValue();
assertEquals("Jane", nValue.getTextContent());
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<csw:Transaction xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" >" + '\n' + " <csw:Update>" + '\n' + " <csw:RecordProperty>" + '\n' + " <csw:Name>/csw:Record/dc:contributor</csw:Name>" + '\n' + " <csw:Value xsi:type=\"xs:string\">Jane</csw:Value>" + '\n' + " </csw:RecordProperty>" + '\n' + " <csw:Constraint version=\"1.1.0\">" + '\n' + " <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>" + '\n' + " </csw:Constraint>" + '\n' + " </csw:Update>" + '\n' + "</csw:Transaction>" + '\n';
result = (TransactionType) unmarshaller.unmarshal(new StringReader(xml));
assertTrue(result.getInsertOrUpdateOrDelete().size() == 1);
assertTrue(result.getInsertOrUpdateOrDelete().get(0) instanceof UpdateType);
update = (UpdateType) result.getInsertOrUpdateOrDelete().get(0);
assertTrue(update.getRecordProperty().size() == 1);
property = update.getRecordProperty().get(0);
assertTrue(property.getValue() instanceof Node);
final Node text = (Node) property.getValue();
assertEquals("Jane", text.getTextContent());
}
Aggregations