[OLINGO-200] V4 Atom and JSON parsers on their way - still to refine, but most features are in, and specific tests were added
This commit is contained in:
parent
e4bf21325d
commit
ce18b8e056
|
@ -91,7 +91,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
|
|||
public Feed getFeed(final ODataEntitySet entitySet, final Class<? extends Feed> reference) {
|
||||
final Feed feed = ResourceFactory.newFeed(reference);
|
||||
|
||||
feed.setContextURL(entitySet.getContextURL());
|
||||
feed.setCount(entitySet.getCount());
|
||||
|
||||
final URI next = entitySet.getNext();
|
||||
|
@ -115,7 +114,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
|
|||
public Entry getEntry(final ODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
|
||||
final Entry entry = ResourceFactory.newEntry(reference);
|
||||
|
||||
entry.setContextURL(entity.getContextURL());
|
||||
entry.setId(entity.getReference());
|
||||
entry.setType(entity.getName());
|
||||
|
||||
|
@ -281,8 +279,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
|
|||
? client.getObjectFactory().newEntitySet()
|
||||
: client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
|
||||
|
||||
entitySet.setContextURL(resource.getContextURL());
|
||||
|
||||
if (resource.getCount() != null) {
|
||||
entitySet.setCount(resource.getCount());
|
||||
}
|
||||
|
@ -315,7 +311,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
|
|||
: client.getObjectFactory().newEntity(resource.getType(),
|
||||
URIUtils.getURI(base, resource.getSelfLink().getHref()));
|
||||
|
||||
entity.setContextURL(resource.getContextURL());
|
||||
entity.setReference(resource.getId());
|
||||
|
||||
if (StringUtils.isNotBlank(resource.getETag())) {
|
||||
|
@ -380,9 +375,9 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
|
|||
private ODataValue getODataValue(final Property resource) {
|
||||
ODataValue value = null;
|
||||
|
||||
if (resource.getValue().isSimple()) {
|
||||
if (resource.getValue().isPrimitive()) {
|
||||
value = client.getPrimitiveValueBuilder().
|
||||
setText(resource.getValue().asSimple().get()).
|
||||
setText(resource.getValue().asPrimitive().get()).
|
||||
setType(resource.getType() == null
|
||||
? null
|
||||
: EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), resource.getType())).build();
|
||||
|
|
|
@ -53,7 +53,7 @@ public class AtomTest extends AbstractTest {
|
|||
|
||||
private String cleanup(final String input) throws Exception {
|
||||
final TransformerFactory factory = TransformerFactory.newInstance();
|
||||
final Source xslt = new StreamSource(getClass().getResourceAsStream("../atom_cleanup.xsl"));
|
||||
final Source xslt = new StreamSource(getClass().getResourceAsStream("atom_cleanup.xsl"));
|
||||
final Transformer transformer = factory.newTransformer(xslt);
|
||||
|
||||
final StringWriter result = new StringWriter();
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
|
@ -48,20 +49,23 @@ public class JSONTest extends AtomTest {
|
|||
}
|
||||
|
||||
private void cleanup(final ObjectNode node) {
|
||||
if (node.has(Constants.JSON_TYPE)) {
|
||||
node.remove(Constants.JSON_TYPE);
|
||||
if (node.has(Constants.JSON_METADATA)) {
|
||||
node.remove(Constants.JSON_METADATA);
|
||||
}
|
||||
if (node.has(Constants.JSON_EDIT_LINK)) {
|
||||
node.remove(Constants.JSON_EDIT_LINK);
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE));
|
||||
}
|
||||
if (node.has(Constants.JSON_READ_LINK)) {
|
||||
node.remove(Constants.JSON_READ_LINK);
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK));
|
||||
}
|
||||
if (node.has(Constants.JSON_MEDIAEDIT_LINK)) {
|
||||
node.remove(Constants.JSON_MEDIAEDIT_LINK);
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK));
|
||||
}
|
||||
if (node.has(Constants.JSON_MEDIAREAD_LINK)) {
|
||||
node.remove(Constants.JSON_MEDIAREAD_LINK);
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK));
|
||||
}
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK));
|
||||
}
|
||||
if (node.has(Constants.JSON_MEDIA_CONTENT_TYPE)) {
|
||||
node.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
|
||||
|
@ -71,10 +75,13 @@ public class JSONTest extends AtomTest {
|
|||
final Map.Entry<String, JsonNode> field = itor.next();
|
||||
|
||||
if (field.getKey().charAt(0) == '#'
|
||||
|| field.getKey().endsWith(Constants.JSON_TYPE_SUFFIX)
|
||||
|| field.getKey().endsWith(Constants.JSON_MEDIAEDIT_LINK_SUFFIX)
|
||||
|| field.getKey().endsWith(
|
||||
getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))
|
||||
|| field.getKey().endsWith(
|
||||
getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
|
||||
|| field.getKey().endsWith(Constants.JSON_MEDIA_CONTENT_TYPE_SUFFIX)
|
||||
|| field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK_SUFFIX)
|
||||
|| field.getKey().endsWith(
|
||||
getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
|
||||
|| field.getKey().endsWith(Constants.JSON_MEDIA_ETAG_SUFFIX)) {
|
||||
|
||||
toRemove.add(field.getKey());
|
||||
|
@ -95,10 +102,12 @@ public class JSONTest extends AtomTest {
|
|||
@Override
|
||||
protected void assertSimilar(final String filename, final String actual) throws Exception {
|
||||
final JsonNode orig = OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
|
||||
replace("Categories" + Constants.JSON_NAVIGATION_LINK_SUFFIX,
|
||||
replace("Categories" + getClient().getServiceVersion().getJSONMap().
|
||||
get(ODataServiceVersion.JSON_NAVIGATION_LINK),
|
||||
"Categories" + Constants.JSON_BIND_LINK_SUFFIX).
|
||||
replace("\"Products(0)/Categories\"", "[\"Products(0)/Categories\"]").
|
||||
replace(Constants.JSON_NAVIGATION_LINK_SUFFIX, Constants.JSON_BIND_LINK_SUFFIX));
|
||||
replace(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
|
||||
Constants.JSON_BIND_LINK_SUFFIX));
|
||||
cleanup((ObjectNode) orig);
|
||||
assertEquals(orig, OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes())));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.client.core.v4;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.StringWriter;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.core.AtomLinksQualifier;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class AtomTest extends JSONTest {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
return v4Client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataPubFormat getODataPubFormat() {
|
||||
return ODataPubFormat.ATOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataFormat getODataFormat() {
|
||||
return ODataFormat.XML;
|
||||
}
|
||||
|
||||
private String cleanup(final String input) throws Exception {
|
||||
final TransformerFactory factory = TransformerFactory.newInstance();
|
||||
final Source xslt = new StreamSource(getClass().getResourceAsStream("atom_cleanup.xsl"));
|
||||
final Transformer transformer = factory.newTransformer(xslt);
|
||||
|
||||
final StringWriter result = new StringWriter();
|
||||
transformer.transform(new StreamSource(new ByteArrayInputStream(input.getBytes())), new StreamResult(result));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
protected void assertSimilar(final String filename, final String actual) throws Exception {
|
||||
final Diff diff = new Diff(cleanup(IOUtils.toString(getClass().getResourceAsStream(filename))), actual);
|
||||
diff.overrideElementQualifier(new AtomLinksQualifier());
|
||||
assertTrue(diff.similar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void additionalEntries() throws Exception {
|
||||
// no test
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.client.core.v4;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.core.AbstractTest;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JSONTest extends AbstractTest {
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
return v4Client;
|
||||
}
|
||||
|
||||
protected ODataPubFormat getODataPubFormat() {
|
||||
return ODataPubFormat.JSON;
|
||||
}
|
||||
|
||||
protected ODataFormat getODataFormat() {
|
||||
return ODataFormat.JSON;
|
||||
}
|
||||
|
||||
private void cleanup(final ObjectNode node) {
|
||||
if (node.has(Constants.JSON_CONTEXT)) {
|
||||
node.remove(Constants.JSON_CONTEXT);
|
||||
}
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE));
|
||||
}
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK));
|
||||
}
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_READ_LINK));
|
||||
}
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK));
|
||||
}
|
||||
if (node.has(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK))) {
|
||||
node.remove(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK));
|
||||
}
|
||||
if (node.has(Constants.JSON_MEDIA_CONTENT_TYPE)) {
|
||||
node.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
|
||||
}
|
||||
final List<String> toRemove = new ArrayList<String>();
|
||||
for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
|
||||
final Map.Entry<String, JsonNode> field = itor.next();
|
||||
|
||||
if (field.getKey().charAt(0) == '#'
|
||||
|| field.getKey().endsWith(
|
||||
getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_TYPE))
|
||||
|| field.getKey().endsWith(
|
||||
getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK))
|
||||
|| field.getKey().endsWith(Constants.JSON_MEDIA_CONTENT_TYPE_SUFFIX)
|
||||
|| field.getKey().endsWith(
|
||||
getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK))
|
||||
|| field.getKey().endsWith(Constants.JSON_MEDIA_ETAG_SUFFIX)) {
|
||||
|
||||
toRemove.add(field.getKey());
|
||||
} else if (field.getValue().isObject()) {
|
||||
cleanup((ObjectNode) field.getValue());
|
||||
} else if (field.getValue().isArray()) {
|
||||
for (final Iterator<JsonNode> arrayItems = field.getValue().elements(); arrayItems.hasNext();) {
|
||||
final JsonNode arrayItem = arrayItems.next();
|
||||
if (arrayItem.isObject()) {
|
||||
cleanup((ObjectNode) arrayItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node.remove(toRemove);
|
||||
}
|
||||
|
||||
protected void assertSimilar(final String filename, final String actual) throws Exception {
|
||||
final JsonNode orig = OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
|
||||
replace(getClient().getServiceVersion().getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
|
||||
Constants.JSON_BIND_LINK_SUFFIX));
|
||||
cleanup((ObjectNode) orig);
|
||||
assertEquals(orig, OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes())));
|
||||
}
|
||||
|
||||
protected void entry(final String filename, final ODataPubFormat format) throws Exception {
|
||||
final StringWriter writer = new StringWriter();
|
||||
getClient().getSerializer().entry(getClient().getDeserializer().toEntry(
|
||||
getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getObject(), writer);
|
||||
|
||||
assertSimilar(filename + "." + getSuffix(format), writer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalEntries() throws Exception {
|
||||
entry("entity.minimal", getODataPubFormat());
|
||||
// entry("entity.full", getODataPubFormat());
|
||||
entry("entity.primitive", getODataPubFormat());
|
||||
entry("entity.complex", getODataPubFormat());
|
||||
entry("entity.collection.primitive", getODataPubFormat());
|
||||
entry("entity.collection.complex", getODataPubFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entries() throws Exception {
|
||||
entry("Products_5", getODataPubFormat());
|
||||
entry("VipCustomer", getODataPubFormat());
|
||||
}
|
||||
|
||||
protected void property(final String filename, final ODataFormat format) throws Exception {
|
||||
final StringWriter writer = new StringWriter();
|
||||
getClient().getSerializer().property(getClient().getDeserializer().
|
||||
toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getObject(), writer);
|
||||
|
||||
assertSimilar(filename + "." + getSuffix(format), writer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void properties() throws Exception {
|
||||
property("Products_5_SkinColor", getODataFormat());
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{"@odata.context":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products/$entity","@odata.type":"#Microsoft.Test.OData.Services.ODataWCFService.Product","@odata.id":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)","@odata.editLink":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)","ProductID":5,"Name":"Cheetos","QuantityPerUnit":"100g Bag","UnitPrice@odata.type":"#Single","UnitPrice":3.24,"QuantityInStock":100,"Discontinued":true,"UserAccess@odata.type":"#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel","UserAccess":"None","SkinColor@odata.type":"#Microsoft.Test.OData.Services.ODataWCFService.Color","SkinColor":"Red","CoverColors@odata.type":"#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)","CoverColors":["Green","Blue","Blue"],"Details@odata.associationLink":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details/$ref","Details@odata.navigationLink":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details","#Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight":{"title":"Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight","target":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"},"#Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails":{"title":"Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails","target":"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"}}
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
<entry xml:base="http://odatae2etest.azurewebsites.net/javatest/DefaultService/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products/$entity">
|
||||
<id>http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)</id>
|
||||
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
|
||||
<link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details" />
|
||||
<title />
|
||||
<updated>2014-03-28T11:24:49Z</updated>
|
||||
<author>
|
||||
<name />
|
||||
</author>
|
||||
<content type="application/xml">
|
||||
<m:properties>
|
||||
<d:ProductID m:type="Int32">5</d:ProductID>
|
||||
<d:Name>Cheetos</d:Name>
|
||||
<d:QuantityPerUnit>100g Bag</d:QuantityPerUnit>
|
||||
<d:UnitPrice m:type="Single">3.24</d:UnitPrice>
|
||||
<d:QuantityInStock m:type="Int32">100</d:QuantityInStock>
|
||||
<d:Discontinued m:type="Boolean">true</d:Discontinued>
|
||||
<d:UserAccess m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel">None</d:UserAccess>
|
||||
<d:SkinColor m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color">Red</d:SkinColor>
|
||||
<d:CoverColors m:type="#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)">
|
||||
<m:element>Green</m:element>
|
||||
<m:element>Blue</m:element>
|
||||
<m:element>Blue</m:element>
|
||||
</d:CoverColors>
|
||||
</m:properties>
|
||||
</content>
|
||||
</entry>
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"@odata.context": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products(5)/SkinColor",
|
||||
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Color",
|
||||
"value": "Red"
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
<m:value xmlns:d="http://docs.oasis-open.org/odata/ns/data"
|
||||
xmlns:georss="http://www.georss.org/georss"
|
||||
xmlns:gml="http://www.opengis.net/gml"
|
||||
m:context="http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Products(5)/SkinColor"
|
||||
m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color"
|
||||
xmlns:m="http://docs.oasis-open.org/odata/ns/metadata">Red</m:value>
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"@odata.context": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#VipCustomer",
|
||||
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Customer",
|
||||
"@odata.id": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer",
|
||||
"@odata.editLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer",
|
||||
"PersonID": 1,
|
||||
"FirstName": "Bob",
|
||||
"LastName": "Cat",
|
||||
"MiddleName": "Vat",
|
||||
"HomeAddress": {
|
||||
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Address",
|
||||
"Street": "1 Microsoft Way",
|
||||
"City": "London",
|
||||
"PostalCode": "98052"
|
||||
},
|
||||
"Home@odata.type": "#GeographyPoint",
|
||||
"Home": {
|
||||
"type": "Point",
|
||||
"coordinates": [23.1, 32.1],
|
||||
"crs": {
|
||||
"type": "name",
|
||||
"properties": {
|
||||
"name": "EPSG:4326"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Numbers@odata.type": "#Collection(String)",
|
||||
"Numbers": ["111-111-1111"],
|
||||
"Emails@odata.type": "#Collection(String)",
|
||||
"Emails": ["abc@abc.com"],
|
||||
"City": "London",
|
||||
"Birthday@odata.type": "#DateTimeOffset",
|
||||
"Birthday": "1957-04-03T00:00:00Z",
|
||||
"TimeBetweenLastTwoOrders@odata.type": "#Duration",
|
||||
"TimeBetweenLastTwoOrders": "PT0.0000001S",
|
||||
"Parent@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Parent/$ref",
|
||||
"Parent@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Parent",
|
||||
"Orders@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders/$ref",
|
||||
"Orders@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders",
|
||||
"Company@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Company/$ref",
|
||||
"Company@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Company",
|
||||
"#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": {
|
||||
"title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
|
||||
"target": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"
|
||||
},
|
||||
"#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": {
|
||||
"title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress",
|
||||
"target": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
<entry xml:base="http://odatae2etest.azurewebsites.net/javatest/DefaultService/"
|
||||
xmlns="http://www.w3.org/2005/Atom"
|
||||
xmlns:d="http://docs.oasis-open.org/odata/ns/data"
|
||||
xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
|
||||
xmlns:georss="http://www.georss.org/georss"
|
||||
xmlns:gml="http://www.opengis.net/gml"
|
||||
m:context="http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#VipCustomer">
|
||||
<id>http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer</id>
|
||||
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
|
||||
<link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Parent" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Company" />
|
||||
<title />
|
||||
<updated>2014-03-28T13:03:32Z</updated>
|
||||
<author>
|
||||
<name />
|
||||
</author>
|
||||
<content type="application/xml">
|
||||
<m:properties>
|
||||
<d:PersonID m:type="Int32">1</d:PersonID>
|
||||
<d:FirstName>Bob</d:FirstName>
|
||||
<d:LastName>Cat</d:LastName>
|
||||
<d:MiddleName>Vat</d:MiddleName>
|
||||
<d:HomeAddress m:type="#Microsoft.Test.OData.Services.ODataWCFService.Address">
|
||||
<d:Street>1 Microsoft Way</d:Street>
|
||||
<d:City>London</d:City>
|
||||
<d:PostalCode>98052</d:PostalCode>
|
||||
</d:HomeAddress>
|
||||
<d:Home m:type="GeographyPoint">
|
||||
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
|
||||
<gml:pos>32.1 23.1</gml:pos>
|
||||
</gml:Point>
|
||||
</d:Home>
|
||||
<d:Numbers m:type="#Collection(String)">
|
||||
<m:element>111-111-1111</m:element>
|
||||
</d:Numbers>
|
||||
<d:Emails m:type="#Collection(String)">
|
||||
<m:element>abc@abc.com</m:element>
|
||||
</d:Emails>
|
||||
<d:City>London</d:City>
|
||||
<d:Birthday m:type="DateTimeOffset">1957-04-03T00:00:00Z</d:Birthday>
|
||||
<d:TimeBetweenLastTwoOrders m:type="Duration">PT0.0000001S</d:TimeBetweenLastTwoOrders>
|
||||
</m:properties>
|
||||
</content>
|
||||
</entry>
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.w3.org/2005/Atom"
|
||||
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
|
||||
version="1.0">
|
||||
|
||||
<xsl:template match="atom:updated"/>
|
||||
<xsl:template match="atom:author"/>
|
||||
<xsl:template match="atom:title">
|
||||
<xsl:if test="string-length(.) > 0">
|
||||
<title type="{@type}">
|
||||
<xsl:apply-templates/>
|
||||
</title>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="atom:link[@rel = 'self' or @rel = 'edit' or @rel = 'edit-media']"/>
|
||||
|
||||
<xsl:template match="m:action"/>
|
||||
|
||||
<xsl:template match="@*[name() = 'm:etag' or name() = 'm:context']"/>
|
||||
|
||||
<xsl:template match="node()|@*">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"Address": {
|
||||
"Street": "Obere Str. 57",
|
||||
"City": "Berlin",
|
||||
"Region": null,
|
||||
"PostalCode": "D-12209"
|
||||
}
|
||||
}
|
|
@ -3,11 +3,12 @@
|
|||
{
|
||||
"Number": "425-555-1212",
|
||||
"Type": "Home"
|
||||
}, {
|
||||
"odata.type": "#Model.CellPhoneNumber",
|
||||
},
|
||||
{
|
||||
"@odata.type": "#Model.CellPhoneNumber",
|
||||
"Number": "425-555-0178",
|
||||
"Type": "Cell",
|
||||
"Carrier": "Sprint"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
|
||||
"@odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"EmailAddresses": [
|
||||
"Julie@Swansworth.com",
|
||||
"Julie.Swansworth@work.com"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"CompanyID": 0,
|
||||
"CompanyCategory": "IT",
|
||||
"Revenue": 100000,
|
||||
"Name": "MS",
|
||||
"Address": {
|
||||
"Street": "1 Microsoft Way",
|
||||
"City": "Redmond",
|
||||
"PostalCode": "98052",
|
||||
"CompanyName": "Microsoft"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"@odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"@odata.id": "Customers('ALFKI')",
|
||||
"@odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
|
||||
"@odata.editLink": "Customers('ALFKI')",
|
||||
"ID": "ALFKI",
|
||||
"CompanyName": "Alfreds Futterkiste",
|
||||
"ContactName": "Maria Anders",
|
||||
"ContactTitle": "Sales Representative",
|
||||
"Phone": "030-0074321",
|
||||
"Fax": "030-0076545",
|
||||
"Address": {
|
||||
"Street": "Obere Str. 57",
|
||||
"City": "Berlin",
|
||||
"Region": null,
|
||||
"PostalCode": "D-12209",
|
||||
"Country@odata.associationLink": "Customers('ALFKI')/Address/Country/$ref",
|
||||
"Country@odata.navigationLink": "Customers('ALFKI')/Address/Country"
|
||||
},
|
||||
"Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
|
||||
"Orders@odata.navigationLink": "Customers('ALFKI')/Orders"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"@odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"ID": "ALFKI",
|
||||
"CompanyName": "Alfreds Futterkiste",
|
||||
"ContactName": "Maria Anders",
|
||||
"ContactTitle": "Sales Representative",
|
||||
"Phone": "030-0074321",
|
||||
"Fax": "030-0076545",
|
||||
"Address": {
|
||||
"Street": "Obere Str. 57",
|
||||
"City": "Berlin",
|
||||
"Region": null,
|
||||
"PostalCode": "D-12209"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"NullValue": null,
|
||||
"TrueValue": true,
|
||||
"FalseValue": false,
|
||||
"BinaryValue": "T0RhdGE",
|
||||
"IntegerValue": -128,
|
||||
"DoubleValue": 3.1415926535897931,
|
||||
"SingleValue": "INF",
|
||||
"DecimalValue": 34.95,
|
||||
"StringValue": "Say \"Hello\",\nthen go",
|
||||
"DateValue": "2012-12-03",
|
||||
"DateTimeOffsetValue": "2012-12-03T07:16:23Z",
|
||||
"DurationValue": "P12DT23H59M59.999999999999S",
|
||||
"TimeOfDayValue": "07:59:59.999",
|
||||
"GuidValue": "01234567-89ab-cdef-0123-456789abcdef",
|
||||
"Int64Value": 0,
|
||||
"ColorEnumValue": "Yellow",
|
||||
"GeographyPoint": {
|
||||
"type": "point",
|
||||
"coordinates": [142.1, 64.1]
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"odata.id": "Customers('ALFKI')",
|
||||
"odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
|
||||
"odata.editLink": "Customers('ALFKI')",
|
||||
"Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
|
||||
"Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
|
||||
"ID": "ALFKI",
|
||||
"CompanyName": "Alfreds Futterkiste",
|
||||
"ContactName": "Maria Anders",
|
||||
"ContactTitle": "Sales Representative",
|
||||
"Phone": "030-0074321",
|
||||
"Fax": "030-0076545",
|
||||
"Address": {
|
||||
"Street": "Obere Str. 57",
|
||||
"City": "Berlin",
|
||||
"Region": null,
|
||||
"PostalCode": "D-12209",
|
||||
"Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
|
||||
"Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"odata.count": 1,
|
||||
"value": [
|
||||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"odata.id": "Customers('ALFKI')",
|
||||
"odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
|
||||
"odata.editLink": "Customers('ALFKI')",
|
||||
"Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
|
||||
"Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
|
||||
"ID": "ALFKI",
|
||||
"CompanyName": "Alfreds Futterkiste",
|
||||
"ContactName": "Maria Anders",
|
||||
"ContactTitle": "Sales Representative",
|
||||
"Phone": "030-0074321",
|
||||
"Fax": "030-0076545",
|
||||
"Address": {
|
||||
"Street": "Obere Str. 57",
|
||||
"City": "Berlin",
|
||||
"Region": null,
|
||||
"PostalCode": "D-12209",
|
||||
"Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
|
||||
"Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
|
||||
}
|
||||
}
|
||||
],
|
||||
"odata.nextLink": "http://host/service/EntitySet?$skiptoken=342r89"
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"odata.count": 1,
|
||||
"value": [
|
||||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"odata.id": "Customers('ALFKI')",
|
||||
"odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
|
||||
"odata.editLink": "Customers('ALFKI')",
|
||||
"Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
|
||||
"Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
|
||||
"ID": "ALFKI",
|
||||
"CompanyName": "Alfreds Futterkiste",
|
||||
"ContactName": "Maria Anders",
|
||||
"ContactTitle": "Sales Representative",
|
||||
"Phone": "030-0074321",
|
||||
"Fax": "030-0076545",
|
||||
"Address": {
|
||||
"Street": "Obere Str. 57",
|
||||
"City": "Berlin",
|
||||
"Region": null,
|
||||
"PostalCode": "D-12209",
|
||||
"Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
|
||||
"Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
|
||||
}
|
||||
},
|
||||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"odata.id": "Customers('MUSKI')",
|
||||
"odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
|
||||
"odata.editLink": "Customers('MUSKI')",
|
||||
"Orders@odata.navigationLink": "Customers('MUSKI')/Orders",
|
||||
"Orders@odata.associationLink": "Customers('MUSKI')/Orders/$ref",
|
||||
"ID": "MUSKI",
|
||||
"CompanyName": "Mustermanns Futterkiste",
|
||||
"ContactName": "Mustermann Max",
|
||||
"ContactTitle": "Some Guy",
|
||||
"Phone": "030-002222",
|
||||
"Fax": "030-004444",
|
||||
"Address": {
|
||||
"Street": "Musterstrasse 42",
|
||||
"City": "Musterstadt",
|
||||
"Region": "SomeRegion",
|
||||
"PostalCode": "D-42042"
|
||||
}
|
||||
}
|
||||
],
|
||||
"odata.nextLink": "http://host/service/EntitySet?$skiptoken=342r89"
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"odata.context": "http://host/service/$metadata#Customers/$entity",
|
||||
"odata.id": "Customers('ALFKI')",
|
||||
"odata.etag": "W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"",
|
||||
"odata.editLink": "Customers('ALFKI')",
|
||||
"Orders@odata.navigationLink": "Customers('ALFKI')/Orders",
|
||||
"Orders@odata.associationLink": "Customers('ALFKI')/Orders/$ref",
|
||||
"ID": "ALFKI",
|
||||
"CompanyName": "Alfreds Futterkiste",
|
||||
"ContactName": "Maria Anders",
|
||||
"ContactTitle": "Sales Representative",
|
||||
"Phone": "030-0074321",
|
||||
"Fax": "030-0076545",
|
||||
"Address": [ {
|
||||
"Street": "Obere Str. 57",
|
||||
"City": "Berlin",
|
||||
"Region": null,
|
||||
"PostalCode": "D-12209",
|
||||
"Country@odata.navigationLink": "Customers('ALFKI')/Address/Country",
|
||||
"Country@odata.associationLink":"Customers('ALFKI')/Address/Country/$ref"
|
||||
}, {
|
||||
"Street": "Musterstrasse 42",
|
||||
"City": "Musterstadt",
|
||||
"Region": "SomeRegion",
|
||||
"PostalCode": "D-42042"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"NullValue" : null
|
||||
}
|
|
@ -137,44 +137,24 @@ public interface Constants {
|
|||
public static final String ELEM_URI = "uri";
|
||||
|
||||
// JSON stuff
|
||||
public final static String JSON_CONTEXT = "@odata.context";
|
||||
|
||||
public final static String JSON_METADATA = "odata.metadata";
|
||||
|
||||
public final static String JSON_CONTEXT = "@odata.context";
|
||||
|
||||
public final static String JSON_METADATA_ETAG = "@odata.metadataEtag";
|
||||
|
||||
public final static String JSON_TYPE = "odata.type";
|
||||
|
||||
public final static String JSON_TYPE_SUFFIX = "@" + JSON_TYPE;
|
||||
|
||||
public final static String JSON_ETAG = "odata.etag";
|
||||
|
||||
public final static String JSON_MEDIA_ETAG = "odata.mediaETag";
|
||||
|
||||
public final static String JSON_MEDIA_ETAG_SUFFIX = "@" + JSON_MEDIA_ETAG;
|
||||
|
||||
public final static String JSON_ID = "odata.id";
|
||||
|
||||
public final static String JSON_READ_LINK = "odata.readLink";
|
||||
|
||||
public final static String JSON_EDIT_LINK = "odata.editLink";
|
||||
|
||||
public final static String JSON_MEDIAREAD_LINK = "odata.mediaReadLink";
|
||||
|
||||
public final static String JSON_MEDIAEDIT_LINK = "odata.mediaEditLink";
|
||||
|
||||
public final static String JSON_MEDIAEDIT_LINK_SUFFIX = "@" + JSON_MEDIAEDIT_LINK;
|
||||
|
||||
public final static String JSON_MEDIA_CONTENT_TYPE = "odata.mediaContentType";
|
||||
|
||||
public final static String JSON_MEDIA_CONTENT_TYPE_SUFFIX = "@" + JSON_MEDIA_CONTENT_TYPE;
|
||||
|
||||
public final static String JSON_NAVIGATION_LINK_SUFFIX = "@odata.navigationLinkUrl";
|
||||
|
||||
public final static String JSON_BIND_LINK_SUFFIX = "@odata.bind";
|
||||
|
||||
public final static String JSON_ASSOCIATION_LINK_SUFFIX = "@odata.associationLinkUrl";
|
||||
|
||||
public final static String JSON_NULL = "odata.null";
|
||||
|
||||
public final static String VALUE = "value";
|
||||
|
|
|
@ -38,21 +38,6 @@ public interface Entry {
|
|||
*/
|
||||
URI getBaseURI();
|
||||
|
||||
/**
|
||||
* The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
|
||||
* fragment identifying the relevant portion of the metadata document.
|
||||
*
|
||||
* @return context URL.
|
||||
*/
|
||||
URI getContextURL();
|
||||
|
||||
/**
|
||||
* Set context URL.
|
||||
*
|
||||
* @param contextURL context URL.
|
||||
*/
|
||||
void setContextURL(final URI contextURL);
|
||||
|
||||
/**
|
||||
* Gets entry type.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.api.data;
|
||||
|
||||
public interface EnumValue extends Value {
|
||||
|
||||
@Override
|
||||
String get();
|
||||
}
|
|
@ -30,21 +30,6 @@ public interface Feed {
|
|||
*/
|
||||
URI getBaseURI();
|
||||
|
||||
/**
|
||||
* The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
|
||||
* fragment identifying the relevant portion of the metadata document.
|
||||
*
|
||||
* @return context URL.
|
||||
*/
|
||||
URI getContextURL();
|
||||
|
||||
/**
|
||||
* Set context URL.
|
||||
*
|
||||
* @param contextURL context URL.
|
||||
*/
|
||||
void setContextURL(final URI contextURL);
|
||||
|
||||
/**
|
||||
* Sets number of entries.
|
||||
*
|
||||
|
|
|
@ -18,18 +18,8 @@
|
|||
*/
|
||||
package org.apache.olingo.commons.api.data;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public interface Property {
|
||||
|
||||
/**
|
||||
* The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
|
||||
* fragment identifying the relevant portion of the metadata document.
|
||||
*
|
||||
* @return context URL.
|
||||
*/
|
||||
URI getContextURL();
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(String name);
|
||||
|
|
|
@ -22,10 +22,12 @@ public interface Value {
|
|||
|
||||
boolean isNull();
|
||||
|
||||
boolean isSimple();
|
||||
boolean isPrimitive();
|
||||
|
||||
boolean isGeospatial();
|
||||
|
||||
boolean isEnum();
|
||||
|
||||
boolean isComplex();
|
||||
|
||||
boolean isCollection();
|
||||
|
@ -34,7 +36,9 @@ public interface Value {
|
|||
|
||||
NullValue asNull();
|
||||
|
||||
PrimitiveValue asSimple();
|
||||
PrimitiveValue asPrimitive();
|
||||
|
||||
EnumValue asEnum();
|
||||
|
||||
GeospatialValue asGeospatial();
|
||||
|
||||
|
|
|
@ -21,11 +21,15 @@ package org.apache.olingo.commons.api.domain;
|
|||
public enum ODataPropertyType {
|
||||
|
||||
/**
|
||||
* Primitive (including geospatial and enum).
|
||||
* Primitive (including geospatial).
|
||||
*/
|
||||
PRIMITIVE,
|
||||
/**
|
||||
* Collection
|
||||
* Enum.
|
||||
*/
|
||||
ENUM,
|
||||
/**
|
||||
* Collection.
|
||||
*/
|
||||
COLLECTION,
|
||||
/**
|
||||
|
|
|
@ -48,6 +48,22 @@ public enum ODataServiceVersion {
|
|||
|
||||
public static final String MEDIA_EDIT_LINK_REL = "mediaEditLinkRel";
|
||||
|
||||
public static final String JSON_TYPE = "jsonType";
|
||||
|
||||
public static final String JSON_ID = "jsonId";
|
||||
|
||||
public static final String JSON_READ_LINK = "jsonReadLink";
|
||||
|
||||
public static final String JSON_EDIT_LINK = "jsonEditLink";
|
||||
|
||||
public static final String JSON_MEDIAREAD_LINK = "jsonMediaReadLink";
|
||||
|
||||
public static final String JSON_MEDIAEDIT_LINK = "jsonMediaEditLink";
|
||||
|
||||
public static final String JSON_ASSOCIATION_LINK = "jsonAssociationLink";
|
||||
|
||||
public static final String JSON_NAVIGATION_LINK = "jsonNavigationLink";
|
||||
|
||||
private static final Map<String, String> V30_NAMESPACES = Collections.unmodifiableMap(new HashMap<String, String>() {
|
||||
|
||||
private static final long serialVersionUID = 3109256773218160485L;
|
||||
|
@ -62,6 +78,22 @@ public enum ODataServiceVersion {
|
|||
}
|
||||
});
|
||||
|
||||
private static final Map<String, String> V30_JSON = Collections.unmodifiableMap(new HashMap<String, String>() {
|
||||
|
||||
private static final long serialVersionUID = 3109256773218160485L;
|
||||
|
||||
{
|
||||
put(JSON_TYPE, "odata.type");
|
||||
put(JSON_ID, "odata.id");
|
||||
put(JSON_READ_LINK, "odata.readLink");
|
||||
put(JSON_EDIT_LINK, "odata.editLink");
|
||||
put(JSON_MEDIAREAD_LINK, "odata.mediaReadLink");
|
||||
put(JSON_MEDIAEDIT_LINK, "odata.mediaEditLink");
|
||||
put(JSON_ASSOCIATION_LINK, "@odata.associationLinkUrl");
|
||||
put(JSON_NAVIGATION_LINK, "@odata.navigationLinkUrl");
|
||||
}
|
||||
});
|
||||
|
||||
private static final Map<String, String> V40_NAMESPACES = Collections.unmodifiableMap(new HashMap<String, String>() {
|
||||
|
||||
private static final long serialVersionUID = 3109256773218160485L;
|
||||
|
@ -76,6 +108,22 @@ public enum ODataServiceVersion {
|
|||
}
|
||||
});
|
||||
|
||||
private static final Map<String, String> V40_JSON = Collections.unmodifiableMap(new HashMap<String, String>() {
|
||||
|
||||
private static final long serialVersionUID = 3109256773218160485L;
|
||||
|
||||
{
|
||||
put(JSON_TYPE, "@odata.type");
|
||||
put(JSON_ID, "@odata.id");
|
||||
put(JSON_READ_LINK, "@odata.readLink");
|
||||
put(JSON_EDIT_LINK, "@odata.editLink");
|
||||
put(JSON_MEDIAREAD_LINK, "@odata.mediaReadLink");
|
||||
put(JSON_MEDIAEDIT_LINK, "@odata.mediaEditLink");
|
||||
put(JSON_ASSOCIATION_LINK, "@odata.associationLink");
|
||||
put(JSON_NAVIGATION_LINK, "@odata.navigationLink");
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Validates format and range of a data service version string.
|
||||
*
|
||||
|
@ -135,6 +183,14 @@ public enum ODataServiceVersion {
|
|||
: V40_NAMESPACES;
|
||||
}
|
||||
|
||||
public Map<String, String> getJSONMap() {
|
||||
return this == V10 || this == V20
|
||||
? Collections.<String, String>emptyMap()
|
||||
: this == V30
|
||||
? V30_JSON
|
||||
: V40_JSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return version;
|
||||
|
|
|
@ -75,8 +75,9 @@ abstract class AbstractAtomDealer {
|
|||
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES);
|
||||
this.typeQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_TYPE);
|
||||
this.nullQName = new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_NULL);
|
||||
this.elementQName =
|
||||
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT);
|
||||
this.elementQName = version == ODataServiceVersion.V30
|
||||
? new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES), Constants.ELEM_ELEMENT)
|
||||
: new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ELEM_ELEMENT);
|
||||
this.countQName =
|
||||
new QName(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT);
|
||||
this.uriQName =
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.data.CollectionValue;
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.Value;
|
||||
|
@ -95,7 +94,7 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
|
||||
final Map.Entry<String, JsonNode> field = itor.next();
|
||||
|
||||
if (type == null && field.getKey().endsWith(Constants.JSON_TYPE_SUFFIX)) {
|
||||
if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
|
||||
type = field.getValue().asText();
|
||||
} else {
|
||||
final JSONPropertyImpl property = new JSONPropertyImpl();
|
||||
|
@ -122,10 +121,14 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
final JsonNode child = nodeItor.next();
|
||||
|
||||
if (child.isValueNode()) {
|
||||
value.get().add(fromPrimitive(child, type));
|
||||
if (typeInfo == null || typeInfo.isPrimitiveType()) {
|
||||
value.get().add(fromPrimitive(child, type));
|
||||
} else {
|
||||
value.get().add(new EnumValueImpl(child.asText()));
|
||||
}
|
||||
} else if (child.isContainerNode()) {
|
||||
if (child.has(Constants.JSON_TYPE)) {
|
||||
((ObjectNode) child).remove(Constants.JSON_TYPE);
|
||||
if (child.has(jsonType)) {
|
||||
((ObjectNode) child).remove(jsonType);
|
||||
}
|
||||
value.get().add(fromComplex(child));
|
||||
}
|
||||
|
@ -145,6 +148,8 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
? ODataPropertyType.COLLECTION
|
||||
: typeInfo.isPrimitiveType()
|
||||
? ODataPropertyType.PRIMITIVE
|
||||
: node.isValueNode()
|
||||
? ODataPropertyType.ENUM
|
||||
: ODataPropertyType.COMPLEX;
|
||||
|
||||
switch (propType) {
|
||||
|
@ -153,13 +158,17 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
break;
|
||||
|
||||
case COMPLEX:
|
||||
if (node.has(Constants.JSON_TYPE)) {
|
||||
property.setType(node.get(Constants.JSON_TYPE).asText());
|
||||
((ObjectNode) node).remove(Constants.JSON_TYPE);
|
||||
if (node.has(jsonType)) {
|
||||
property.setType(node.get(jsonType).asText());
|
||||
((ObjectNode) node).remove(jsonType);
|
||||
}
|
||||
property.setValue(fromComplex(node));
|
||||
break;
|
||||
|
||||
case ENUM:
|
||||
property.setValue(new EnumValueImpl(node.asText()));
|
||||
break;
|
||||
|
||||
case PRIMITIVE:
|
||||
if (property.getType() == null) {
|
||||
property.setType(getPrimitiveType(node).getFullQualifiedName().toString());
|
||||
|
|
|
@ -56,22 +56,24 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
|
|||
|
||||
if (value.isNull()) {
|
||||
jgen.writeNull();
|
||||
} else if (value.isSimple()) {
|
||||
} else if (value.isPrimitive()) {
|
||||
final boolean isNumber = typeInfo == null
|
||||
? NumberUtils.isNumber(value.asSimple().get())
|
||||
? NumberUtils.isNumber(value.asPrimitive().get())
|
||||
: ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind());
|
||||
final boolean isBoolean = typeInfo == null
|
||||
? (value.asSimple().get().equalsIgnoreCase(Boolean.TRUE.toString())
|
||||
|| value.asSimple().get().equalsIgnoreCase(Boolean.FALSE.toString()))
|
||||
? (value.asPrimitive().get().equalsIgnoreCase(Boolean.TRUE.toString())
|
||||
|| value.asPrimitive().get().equalsIgnoreCase(Boolean.FALSE.toString()))
|
||||
: typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean;
|
||||
|
||||
if (isNumber) {
|
||||
jgen.writeNumber(value.asSimple().get());
|
||||
jgen.writeNumber(value.asPrimitive().get());
|
||||
} else if (isBoolean) {
|
||||
jgen.writeBoolean(BooleanUtils.toBoolean(value.asSimple().get()));
|
||||
jgen.writeBoolean(BooleanUtils.toBoolean(value.asPrimitive().get()));
|
||||
} else {
|
||||
jgen.writeString(value.asSimple().get());
|
||||
jgen.writeString(value.asPrimitive().get());
|
||||
}
|
||||
} else if (value.isEnum()) {
|
||||
jgen.writeString(value.asEnum().get());
|
||||
} else if (value.isGeospatial()) {
|
||||
jgen.writeStartObject();
|
||||
geoSerializer.serialize(jgen, value.asGeospatial().get());
|
||||
|
|
|
@ -31,8 +31,6 @@ abstract class AbstractODataObject extends AbstractPayloadObject {
|
|||
|
||||
private URI baseURI;
|
||||
|
||||
private URI contextURL;
|
||||
|
||||
private String id;
|
||||
|
||||
private String title;
|
||||
|
@ -49,20 +47,6 @@ abstract class AbstractODataObject extends AbstractPayloadObject {
|
|||
this.baseURI = URI.create(baseURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
|
||||
* fragment identifying the relevant portion of the metadata document.
|
||||
*
|
||||
* @return context URL.
|
||||
*/
|
||||
public URI getContextURL() {
|
||||
return contextURL;
|
||||
}
|
||||
|
||||
public void setContextURL(final URI contextURL) {
|
||||
this.contextURL = contextURL;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.commons.core.data;
|
||||
|
||||
import java.net.URI;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
|
@ -28,29 +27,12 @@ import org.apache.olingo.commons.api.data.Value;
|
|||
|
||||
public abstract class AbstractPropertyImpl implements Property {
|
||||
|
||||
private URI contextURL;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private Value value;
|
||||
|
||||
/**
|
||||
* The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
|
||||
* fragment identifying the relevant portion of the metadata document.
|
||||
*
|
||||
* @return context URL.
|
||||
*/
|
||||
@Override
|
||||
public URI getContextURL() {
|
||||
return contextURL;
|
||||
}
|
||||
|
||||
public void setContextURL(final URI contextURL) {
|
||||
this.contextURL = contextURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
|||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.apache.olingo.commons.api.data.CollectionValue;
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.EnumValue;
|
||||
import org.apache.olingo.commons.api.data.GeospatialValue;
|
||||
import org.apache.olingo.commons.api.data.NullValue;
|
||||
import org.apache.olingo.commons.api.data.PrimitiveValue;
|
||||
|
@ -37,7 +38,7 @@ public abstract class AbstractValue implements Value {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isSimple() {
|
||||
public boolean isPrimitive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -46,6 +47,11 @@ public abstract class AbstractValue implements Value {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnum() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplex() {
|
||||
return false;
|
||||
|
@ -62,8 +68,8 @@ public abstract class AbstractValue implements Value {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PrimitiveValue asSimple() {
|
||||
return isSimple() ? (PrimitiveValue) this : null;
|
||||
public PrimitiveValue asPrimitive() {
|
||||
return isPrimitive() ? (PrimitiveValue) this : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,6 +77,11 @@ public abstract class AbstractValue implements Value {
|
|||
return isGeospatial() ? (GeospatialValue) this : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumValue asEnum() {
|
||||
return isEnum() ? (EnumValue) this : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComplexValue asComplex() {
|
||||
return isComplex() ? (ComplexValue) this : null;
|
||||
|
|
|
@ -384,6 +384,7 @@ public class AtomDeserializer extends AbstractAtomDealer {
|
|||
@SuppressWarnings("unchecked")
|
||||
public <T, V extends T> Container<T> read(final InputStream input, final Class<V> reference)
|
||||
throws XMLStreamException {
|
||||
|
||||
if (AtomFeedImpl.class.equals(reference)) {
|
||||
return (Container<T>) feed(input);
|
||||
} else if (AtomEntryImpl.class.equals(reference)) {
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.commons.core.data;
|
||||
|
||||
import java.net.URI;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
|
@ -28,7 +26,6 @@ import javax.xml.stream.events.XMLEvent;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.data.CollectionValue;
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.Value;
|
||||
import org.apache.olingo.commons.api.domain.ODataPropertyType;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
@ -73,17 +70,24 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
return value;
|
||||
}
|
||||
|
||||
private ComplexValue fromComplex(final XMLEventReader reader, final StartElement start)
|
||||
private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
|
||||
throws XMLStreamException {
|
||||
|
||||
final ComplexValue value = new ComplexValueImpl();
|
||||
Value value = null;
|
||||
|
||||
boolean foundEndProperty = false;
|
||||
while (reader.hasNext() && !foundEndProperty) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isStartElement()) {
|
||||
value.get().add(deserialize(reader, event.asStartElement()));
|
||||
if (value == null) {
|
||||
value = new ComplexValueImpl();
|
||||
}
|
||||
value.asComplex().get().add(deserialize(reader, event.asStartElement()));
|
||||
}
|
||||
|
||||
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
|
||||
value = new EnumValueImpl(event.asCharacters().getData());
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
|
@ -108,9 +112,10 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isStartElement()) {
|
||||
switch (guessPropertyType(reader)) {
|
||||
switch (guessPropertyType(reader, typeInfo)) {
|
||||
case COMPLEX:
|
||||
value.get().add(fromComplex(reader, event.asStartElement()));
|
||||
case ENUM:
|
||||
value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
|
||||
break;
|
||||
|
||||
case PRIMITIVE:
|
||||
|
@ -130,7 +135,9 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
return value;
|
||||
}
|
||||
|
||||
private ODataPropertyType guessPropertyType(final XMLEventReader reader) throws XMLStreamException {
|
||||
private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
|
||||
throws XMLStreamException {
|
||||
|
||||
XMLEvent child = null;
|
||||
while (reader.hasNext() && child == null) {
|
||||
final XMLEvent event = reader.peek();
|
||||
|
@ -143,7 +150,9 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
|
||||
final ODataPropertyType type;
|
||||
if (child == null) {
|
||||
type = ODataPropertyType.PRIMITIVE;
|
||||
type = typeInfo == null || typeInfo.isPrimitiveType()
|
||||
? ODataPropertyType.PRIMITIVE
|
||||
: ODataPropertyType.ENUM;
|
||||
} else {
|
||||
if (child.isStartElement()) {
|
||||
if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
|
||||
|
@ -154,7 +163,9 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
type = ODataPropertyType.COMPLEX;
|
||||
}
|
||||
} else if (child.isCharacters()) {
|
||||
type = ODataPropertyType.PRIMITIVE;
|
||||
type = typeInfo == null || typeInfo.isPrimitiveType()
|
||||
? ODataPropertyType.PRIMITIVE
|
||||
: ODataPropertyType.ENUM;
|
||||
} else {
|
||||
type = ODataPropertyType.EMPTY;
|
||||
}
|
||||
|
@ -165,20 +176,17 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
|
||||
public AtomPropertyImpl deserialize(final XMLEventReader reader, final StartElement start)
|
||||
throws XMLStreamException {
|
||||
|
||||
final AtomPropertyImpl property = new AtomPropertyImpl();
|
||||
|
||||
final Attribute context = start.getAttributeByName(contextQName);
|
||||
|
||||
property.setContextURL(context == null ? null : URI.create(context.getValue()));
|
||||
|
||||
final QName name = start.getName();
|
||||
|
||||
if (ODataServiceVersion.V40 == version && v4PropertyValueQName.equals(name)) {
|
||||
if (ODataServiceVersion.V40 == version && v4PropertyValueQName.equals(start.getName())) {
|
||||
// retrieve name from context
|
||||
final String contextURL = property.getContextURL().toASCIIString();
|
||||
property.setName(contextURL.substring(contextURL.lastIndexOf("/") + 1));
|
||||
final Attribute context = start.getAttributeByName(contextQName);
|
||||
if (context != null) {
|
||||
property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
|
||||
}
|
||||
} else {
|
||||
property.setName(name.getLocalPart());
|
||||
property.setName(start.getName().getLocalPart());
|
||||
}
|
||||
|
||||
final Attribute nullAttr = start.getAttributeByName(this.nullQName);
|
||||
|
@ -197,7 +205,7 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
}
|
||||
|
||||
final ODataPropertyType propType = typeInfo == null
|
||||
? guessPropertyType(reader)
|
||||
? guessPropertyType(reader, typeInfo)
|
||||
: typeInfo.isCollection()
|
||||
? ODataPropertyType.COLLECTION
|
||||
: typeInfo.isPrimitiveType()
|
||||
|
@ -210,7 +218,7 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
|
|||
break;
|
||||
|
||||
case COMPLEX:
|
||||
value = fromComplex(reader, start);
|
||||
value = fromComplexOrEnum(reader, start);
|
||||
break;
|
||||
|
||||
case PRIMITIVE:
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.olingo.commons.api.data.CollectionValue;
|
|||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.Value;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||
|
||||
class AtomPropertySerializer extends AbstractAtomDealer {
|
||||
|
||||
|
@ -38,16 +39,23 @@ class AtomPropertySerializer extends AbstractAtomDealer {
|
|||
|
||||
private void collection(final XMLStreamWriter writer, final CollectionValue value) throws XMLStreamException {
|
||||
for (Value item : value.get()) {
|
||||
writer.writeStartElement(Constants.PREFIX_DATASERVICES, Constants.ELEM_ELEMENT,
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
|
||||
if (version == ODataServiceVersion.V30) {
|
||||
writer.writeStartElement(Constants.PREFIX_DATASERVICES, Constants.ELEM_ELEMENT,
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
|
||||
} else {
|
||||
writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ELEM_ELEMENT,
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
|
||||
}
|
||||
value(writer, item);
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void value(final XMLStreamWriter writer, final Value value) throws XMLStreamException {
|
||||
if (value.isSimple()) {
|
||||
writer.writeCharacters(value.asSimple().get());
|
||||
if (value.isPrimitive()) {
|
||||
writer.writeCharacters(value.asPrimitive().get());
|
||||
} else if (value.isEnum()) {
|
||||
writer.writeCharacters(value.asEnum().get());
|
||||
} else if (value.isGeospatial()) {
|
||||
this.geoSerializer.serialize(writer, value.asGeospatial().get());
|
||||
} else if (value.isCollection()) {
|
||||
|
@ -62,22 +70,34 @@ class AtomPropertySerializer extends AbstractAtomDealer {
|
|||
public void property(final XMLStreamWriter writer, final Property property, final boolean standalone)
|
||||
throws XMLStreamException {
|
||||
|
||||
writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(),
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
|
||||
|
||||
if (version == ODataServiceVersion.V40 && property.getContextURL() != null) {
|
||||
writer.writeAttribute(
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
|
||||
Constants.CONTEXT,
|
||||
property.getContextURL().toASCIIString());
|
||||
if (version == ODataServiceVersion.V40 && standalone) {
|
||||
writer.writeStartElement(Constants.PREFIX_METADATA, Constants.VALUE,
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
|
||||
} else {
|
||||
writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(),
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
|
||||
}
|
||||
|
||||
if (standalone) {
|
||||
namespaces(writer);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(property.getType())) {
|
||||
String type = property.getType();
|
||||
if (version == ODataServiceVersion.V40) {
|
||||
final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
|
||||
if (typeInfo.isPrimitiveType()) {
|
||||
if (typeInfo.isCollection()) {
|
||||
type = "#Collection(" + typeInfo.getFullQualifiedName().getName() + ")";
|
||||
} else {
|
||||
type = typeInfo.getFullQualifiedName().getName();
|
||||
}
|
||||
} else {
|
||||
type = "#" + property.getType();
|
||||
}
|
||||
}
|
||||
writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
|
||||
Constants.ATTR_TYPE, property.getType());
|
||||
Constants.ATTR_TYPE, type);
|
||||
}
|
||||
|
||||
if (property.getValue().isNull()) {
|
||||
|
|
|
@ -127,13 +127,6 @@ public class AtomSerializer extends AbstractAtomDealer {
|
|||
}
|
||||
|
||||
private void entry(final XMLStreamWriter writer, final Entry entry) throws XMLStreamException {
|
||||
if (version == ODataServiceVersion.V40 && entry.getContextURL() != null) {
|
||||
writer.writeAttribute(
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
|
||||
Constants.CONTEXT,
|
||||
entry.getContextURL().toASCIIString());
|
||||
}
|
||||
|
||||
if (entry.getBaseURI() != null) {
|
||||
writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entry.getBaseURI().toASCIIString());
|
||||
}
|
||||
|
@ -191,13 +184,6 @@ public class AtomSerializer extends AbstractAtomDealer {
|
|||
}
|
||||
|
||||
private void feed(final XMLStreamWriter writer, final Feed feed) throws XMLStreamException {
|
||||
if (version == ODataServiceVersion.V40 && feed.getContextURL() != null) {
|
||||
writer.writeAttribute(
|
||||
version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA),
|
||||
Constants.CONTEXT,
|
||||
feed.getContextURL().toASCIIString());
|
||||
}
|
||||
|
||||
if (feed.getBaseURI() != null) {
|
||||
writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, feed.getBaseURI().toASCIIString());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.data;
|
||||
|
||||
import org.apache.olingo.commons.api.data.EnumValue;
|
||||
|
||||
public class EnumValueImpl extends AbstractValue implements EnumValue {
|
||||
|
||||
private final String value;
|
||||
|
||||
public EnumValueImpl(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnum() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
|
@ -88,13 +88,17 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
|
|||
|
||||
final JSONEntryImpl entry = new JSONEntryImpl();
|
||||
|
||||
String contextURL = null;
|
||||
if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
|
||||
entry.setContextURL(URI.create(tree.get(Constants.JSON_CONTEXT).textValue()));
|
||||
contextURL = tree.get(Constants.JSON_CONTEXT).textValue();
|
||||
tree.remove(Constants.JSON_CONTEXT);
|
||||
} else if (tree.hasNonNull(Constants.JSON_METADATA)) {
|
||||
entry.setContextURL(URI.create(tree.get(Constants.JSON_METADATA).textValue()));
|
||||
contextURL = tree.get(Constants.JSON_METADATA).textValue();
|
||||
tree.remove(Constants.JSON_METADATA);
|
||||
}
|
||||
if (contextURL != null) {
|
||||
entry.setBaseURI(contextURL.substring(0, contextURL.indexOf(Constants.METADATA)));
|
||||
}
|
||||
|
||||
if (tree.hasNonNull(Constants.JSON_MEDIA_ETAG)) {
|
||||
entry.setMediaETag(tree.get(Constants.JSON_MEDIA_ETAG).textValue());
|
||||
|
@ -106,40 +110,40 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
|
|||
tree.remove(Constants.JSON_ETAG);
|
||||
}
|
||||
|
||||
if (tree.hasNonNull(Constants.JSON_TYPE)) {
|
||||
entry.setType(tree.get(Constants.JSON_TYPE).textValue());
|
||||
tree.remove(Constants.JSON_TYPE);
|
||||
if (tree.hasNonNull(jsonType)) {
|
||||
entry.setType(tree.get(jsonType).textValue());
|
||||
tree.remove(jsonType);
|
||||
}
|
||||
|
||||
if (tree.hasNonNull(Constants.JSON_ID)) {
|
||||
entry.setId(tree.get(Constants.JSON_ID).textValue());
|
||||
tree.remove(Constants.JSON_ID);
|
||||
if (tree.hasNonNull(jsonId)) {
|
||||
entry.setId(tree.get(jsonId).textValue());
|
||||
tree.remove(jsonId);
|
||||
}
|
||||
|
||||
if (tree.hasNonNull(Constants.JSON_READ_LINK)) {
|
||||
if (tree.hasNonNull(jsonReadLink)) {
|
||||
final LinkImpl link = new LinkImpl();
|
||||
link.setRel(Constants.SELF_LINK_REL);
|
||||
link.setHref(tree.get(Constants.JSON_READ_LINK).textValue());
|
||||
link.setHref(tree.get(jsonReadLink).textValue());
|
||||
entry.setSelfLink(link);
|
||||
|
||||
tree.remove(Constants.JSON_READ_LINK);
|
||||
tree.remove(jsonReadLink);
|
||||
}
|
||||
|
||||
if (tree.hasNonNull(Constants.JSON_EDIT_LINK)) {
|
||||
if (tree.hasNonNull(jsonEditLink)) {
|
||||
final LinkImpl link = new LinkImpl();
|
||||
link.setRel(Constants.EDIT_LINK_REL);
|
||||
link.setHref(tree.get(Constants.JSON_EDIT_LINK).textValue());
|
||||
link.setHref(tree.get(jsonEditLink).textValue());
|
||||
entry.setEditLink(link);
|
||||
|
||||
tree.remove(Constants.JSON_EDIT_LINK);
|
||||
tree.remove(jsonEditLink);
|
||||
}
|
||||
|
||||
if (tree.hasNonNull(Constants.JSON_MEDIAREAD_LINK)) {
|
||||
entry.setMediaContentSource(tree.get(Constants.JSON_MEDIAREAD_LINK).textValue());
|
||||
tree.remove(Constants.JSON_MEDIAREAD_LINK);
|
||||
if (tree.hasNonNull(jsonMediaReadLink)) {
|
||||
entry.setMediaContentSource(tree.get(jsonMediaReadLink).textValue());
|
||||
tree.remove(jsonMediaReadLink);
|
||||
}
|
||||
if (tree.hasNonNull(Constants.JSON_MEDIAEDIT_LINK)) {
|
||||
tree.remove(Constants.JSON_MEDIAEDIT_LINK);
|
||||
if (tree.hasNonNull(jsonMediaEditLink)) {
|
||||
tree.remove(jsonMediaEditLink);
|
||||
}
|
||||
if (tree.hasNonNull(Constants.JSON_MEDIA_CONTENT_TYPE)) {
|
||||
entry.setMediaContentType(tree.get(Constants.JSON_MEDIA_CONTENT_TYPE).textValue());
|
||||
|
@ -150,7 +154,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
|
|||
for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
|
||||
final Map.Entry<String, JsonNode> field = itor.next();
|
||||
|
||||
if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK_SUFFIX)) {
|
||||
if (field.getKey().endsWith(jsonNavigationLink)) {
|
||||
final LinkImpl link = new LinkImpl();
|
||||
link.setTitle(getTitle(field));
|
||||
link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
|
||||
|
@ -168,8 +172,8 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
|
|||
entry.getNavigationLinks().add(link);
|
||||
|
||||
toRemove.add(field.getKey());
|
||||
toRemove.add(setInline(field.getKey(), Constants.JSON_NAVIGATION_LINK_SUFFIX, tree, parser.getCodec(), link));
|
||||
} else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK_SUFFIX)) {
|
||||
toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, parser.getCodec(), link));
|
||||
} else if (field.getKey().endsWith(jsonAssociationLink)) {
|
||||
final LinkImpl link = new LinkImpl();
|
||||
link.setTitle(getTitle(field));
|
||||
link.setRel(version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL) + getTitle(field));
|
||||
|
@ -178,7 +182,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
|
|||
entry.getAssociationLinks().add(link);
|
||||
|
||||
toRemove.add(field.getKey());
|
||||
} else if (field.getKey().endsWith(Constants.JSON_MEDIAEDIT_LINK_SUFFIX)) {
|
||||
} else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaEditLink))) {
|
||||
final LinkImpl link = new LinkImpl();
|
||||
link.setTitle(getTitle(field));
|
||||
link.setRel(version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL) + getTitle(field));
|
||||
|
@ -192,7 +196,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
|
|||
}
|
||||
|
||||
toRemove.add(field.getKey());
|
||||
toRemove.add(setInline(field.getKey(), Constants.JSON_MEDIAEDIT_LINK_SUFFIX, tree, parser.getCodec(), link));
|
||||
toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link));
|
||||
} else if (field.getKey().endsWith(Constants.JSON_MEDIA_CONTENT_TYPE)) {
|
||||
final String linkTitle = getTitle(field);
|
||||
for (Link link : entry.getMediaEditLinks()) {
|
||||
|
@ -220,7 +224,7 @@ public class JSONEntryDeserializer extends AbstractJsonDeserializer<JSONEntryImp
|
|||
for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
|
||||
final Map.Entry<String, JsonNode> field = itor.next();
|
||||
|
||||
if (type == null && field.getKey().endsWith(Constants.JSON_TYPE_SUFFIX)) {
|
||||
if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
|
||||
type = field.getValue().asText();
|
||||
} else {
|
||||
final JSONPropertyImpl property = new JSONPropertyImpl();
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.apache.olingo.commons.core.data;
|
|||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import java.net.URI;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
|
||||
/**
|
||||
* A single entry, represented via JSON.
|
||||
|
@ -34,17 +32,6 @@ public class JSONEntryImpl extends AbstractEntry {
|
|||
|
||||
private String mediaETag;
|
||||
|
||||
@Override
|
||||
public URI getBaseURI() {
|
||||
URI baseURI = null;
|
||||
if (getContextURL() != null) {
|
||||
final String metadataURI = getContextURL().toASCIIString();
|
||||
baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(Constants.METADATA)));
|
||||
}
|
||||
|
||||
return baseURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* The odata.mediaEtag annotation MAY be included; its value MUST be the ETag of the binary stream represented by this
|
||||
* media entity or named stream property.
|
||||
|
|
|
@ -45,14 +45,8 @@ public class JSONEntrySerializer extends AbstractJsonSerializer<JSONEntryImpl> {
|
|||
|
||||
jgen.writeStartObject();
|
||||
|
||||
if (entry.getContextURL() != null) {
|
||||
jgen.writeStringField(
|
||||
version == ODataServiceVersion.V40 ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
|
||||
entry.getContextURL().toASCIIString());
|
||||
}
|
||||
|
||||
if (entry.getId() != null) {
|
||||
jgen.writeStringField(Constants.JSON_ID, entry.getId());
|
||||
jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entry.getId());
|
||||
}
|
||||
|
||||
final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
|
||||
|
@ -100,7 +94,7 @@ public class JSONEntrySerializer extends AbstractJsonSerializer<JSONEntryImpl> {
|
|||
|
||||
for (Link link : entry.getMediaEditLinks()) {
|
||||
if (link.getTitle() == null) {
|
||||
jgen.writeStringField(Constants.JSON_MEDIAEDIT_LINK, link.getHref());
|
||||
jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), link.getHref());
|
||||
}
|
||||
|
||||
if (link.getInlineEntry() != null) {
|
||||
|
|
|
@ -51,22 +51,14 @@ public class JSONFeedImpl extends AbstractPayloadObject implements Feed {
|
|||
@Override
|
||||
public URI getBaseURI() {
|
||||
URI baseURI = null;
|
||||
if (getContextURL() != null) {
|
||||
final String metadataURI = getContextURL().toASCIIString();
|
||||
if (contextURL != null) {
|
||||
final String metadataURI = contextURL.toASCIIString();
|
||||
baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(Constants.METADATA)));
|
||||
}
|
||||
|
||||
return baseURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getContextURL() {
|
||||
return contextURL;
|
||||
}
|
||||
|
||||
public void setContextURL(final URI context) {
|
||||
this.contextURL = context;
|
||||
}
|
||||
|
|
|
@ -34,13 +34,8 @@ public class JSONFeedSerializer extends AbstractJsonSerializer<JSONFeedImpl> {
|
|||
|
||||
jgen.writeStartObject();
|
||||
|
||||
if (feed.getContextURL() != null) {
|
||||
jgen.writeStringField(
|
||||
version == ODataServiceVersion.V40 ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
|
||||
feed.getContextURL().toASCIIString());
|
||||
}
|
||||
if (feed.getId() != null) {
|
||||
jgen.writeStringField(Constants.JSON_ID, feed.getId());
|
||||
jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), feed.getId());
|
||||
}
|
||||
if (feed.getCount() != null) {
|
||||
jgen.writeNumberField(Constants.JSON_COUNT, feed.getCount());
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
|
||||
/**
|
||||
|
@ -41,24 +40,24 @@ public class JSONPropertyDeserializer extends AbstractJsonDeserializer<JSONPrope
|
|||
|
||||
final JSONPropertyImpl property = new JSONPropertyImpl();
|
||||
|
||||
String contextURL = null;
|
||||
if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
|
||||
property.setContextURL(URI.create(tree.get(Constants.JSON_CONTEXT).textValue()));
|
||||
contextURL = tree.get(Constants.JSON_CONTEXT).textValue();
|
||||
tree.remove(Constants.JSON_CONTEXT);
|
||||
} else if (tree.hasNonNull(Constants.JSON_METADATA)) {
|
||||
property.setContextURL(URI.create(tree.get(Constants.JSON_METADATA).textValue()));
|
||||
contextURL = tree.get(Constants.JSON_METADATA).textValue();
|
||||
tree.remove(Constants.JSON_METADATA);
|
||||
}
|
||||
|
||||
if (property.getContextURL() != null) {
|
||||
final String contextURL = property.getContextURL().toASCIIString();
|
||||
if (contextURL != null) {
|
||||
final int dashIdx = contextURL.lastIndexOf('#');
|
||||
if (dashIdx != -1) {
|
||||
property.setType(contextURL.substring(dashIdx + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (tree.has(Constants.JSON_TYPE) && property.getType() == null) {
|
||||
property.setType(tree.get(Constants.JSON_TYPE).asText());
|
||||
if (tree.has(jsonType) && property.getType() == null) {
|
||||
property.setType(tree.get(jsonType).asText());
|
||||
}
|
||||
|
||||
if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) {
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.SerializerProvider;
|
|||
import java.io.IOException;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
|
||||
/**
|
||||
* Writes out JSON string from <tt>JSONPropertyImpl</tt>.
|
||||
|
@ -39,16 +38,12 @@ public class JSONPropertySerializer extends AbstractJsonSerializer<JSONPropertyI
|
|||
|
||||
jgen.writeStartObject();
|
||||
|
||||
if (property.getContextURL() != null) {
|
||||
jgen.writeStringField(
|
||||
version == ODataServiceVersion.V40 ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
|
||||
property.getContextURL().toASCIIString());
|
||||
}
|
||||
|
||||
if (property.getValue().isNull()) {
|
||||
jgen.writeBooleanField(Constants.JSON_NULL, true);
|
||||
} else if (property.getValue().isSimple()) {
|
||||
jgen.writeStringField(Constants.VALUE, property.getValue().asSimple().get());
|
||||
} else if (property.getValue().isPrimitive()) {
|
||||
jgen.writeStringField(Constants.VALUE, property.getValue().asPrimitive().get());
|
||||
} else if (property.getValue().isEnum()) {
|
||||
jgen.writeStringField(Constants.VALUE, property.getValue().asEnum().get());
|
||||
} else if (property.getValue().isGeospatial() || property.getValue().isCollection()) {
|
||||
property(jgen, property, Constants.VALUE);
|
||||
} else if (property.getValue().isComplex()) {
|
||||
|
|
|
@ -30,14 +30,44 @@ public abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
|
|||
|
||||
protected ODataServiceVersion version;
|
||||
|
||||
protected String jsonType;
|
||||
|
||||
protected String jsonId;
|
||||
|
||||
protected String jsonReadLink;
|
||||
|
||||
protected String jsonEditLink;
|
||||
|
||||
protected String jsonMediaEditLink;
|
||||
|
||||
protected String jsonMediaReadLink;
|
||||
|
||||
protected String jsonAssociationLink;
|
||||
|
||||
protected String jsonNavigationLink;
|
||||
|
||||
protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
|
||||
throws IOException, JsonProcessingException;
|
||||
|
||||
protected String getJSONAnnotation(final String string) {
|
||||
return string.startsWith("@") ? string : "@" + string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
|
||||
throws IOException, JsonProcessingException {
|
||||
|
||||
version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null);
|
||||
|
||||
jsonType = version.getJSONMap().get(ODataServiceVersion.JSON_TYPE);
|
||||
jsonId = version.getJSONMap().get(ODataServiceVersion.JSON_ID);
|
||||
jsonReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_READ_LINK);
|
||||
jsonEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK);
|
||||
jsonMediaReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK);
|
||||
jsonMediaEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK);
|
||||
jsonAssociationLink = version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK);
|
||||
jsonNavigationLink = version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK);
|
||||
|
||||
return doDeserialize(jp, ctxt);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class PrimitiveValueImpl extends AbstractValue implements PrimitiveValue
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isSimple() {
|
||||
public boolean isPrimitive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue