[OLINGO-557] Some function imports for technical service
Change-Id: I4f6589672eed8c70dd138d74f09dbd3caddf6cfb Signed-off-by: Michael Bolz <michael.bolz@sap.com>
This commit is contained in:
parent
0d57a0763a
commit
93f2ed5cf2
|
@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -119,11 +118,9 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
XMLMetadata xmlMetadata = response.getBody();
|
||||
|
||||
assertNotNull(xmlMetadata);
|
||||
assertTrue(xmlMetadata instanceof XMLMetadata);
|
||||
assertEquals(2, xmlMetadata.getSchemas().size());
|
||||
assertEquals("olingo.odata.test1", xmlMetadata.getSchema("olingo.odata.test1").getNamespace());
|
||||
final List<Reference> references =
|
||||
((XMLMetadata) xmlMetadata).getReferences();
|
||||
final List<Reference> references = xmlMetadata.getReferences();
|
||||
assertEquals(1, references.size());
|
||||
assertThat(references.get(0).getUri().toASCIIString(), containsString("vocabularies/Org.OData.Core.V1"));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.fit.tecsvc.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.ODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FunctionImportITCase extends AbstractBaseTestITCase {
|
||||
|
||||
@Test
|
||||
public void entity() throws Exception {
|
||||
final ODataInvokeRequest<ODataEntity> request = getClient().getInvokeRequestFactory()
|
||||
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
|
||||
.appendOperationCallSegment("FICRTESTwoKeyNav").build(), ODataEntity.class);
|
||||
assertNotNull(request);
|
||||
|
||||
final ODataInvokeResponse<ODataEntity> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
|
||||
final ODataEntity entity = response.getBody();
|
||||
assertNotNull(entity);
|
||||
final ODataProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertEquals(1, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityCollection() {
|
||||
final ODataInvokeRequest<ODataEntitySet> request = getClient().getInvokeRequestFactory()
|
||||
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
|
||||
.appendOperationCallSegment("FICRTCollESTwoKeyNavParam").build(), ODataEntitySet.class,
|
||||
Collections.<String, ODataValue> singletonMap("ParameterInt16",
|
||||
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2)));
|
||||
assertNotNull(request);
|
||||
|
||||
final ODataInvokeResponse<ODataEntitySet> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
|
||||
final ODataEntitySet entitySet = response.getBody();
|
||||
assertNotNull(entitySet);
|
||||
final List<ODataEntity> entities = entitySet.getEntities();
|
||||
assertNotNull(entities);
|
||||
assertEquals(2, entities.size());
|
||||
final ODataEntity entity = entities.get(1);
|
||||
assertNotNull(entity);
|
||||
final ODataProperty property = entity.getProperty("PropertyString");
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals("2", property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
}
|
|
@ -139,13 +139,13 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
@Override
|
||||
protected void loadAllFunctionImports() {
|
||||
loadContainer();
|
||||
List<FunctionImport> providerFuctionImports = container.getFunctionImports();
|
||||
if (providerFuctionImports != null) {
|
||||
for (FunctionImport functionImport : providerFuctionImports) {
|
||||
List<FunctionImport> providerFunctionImports = container.getFunctionImports();
|
||||
if (providerFunctionImports != null) {
|
||||
for (FunctionImport functionImport : providerFunctionImports) {
|
||||
String functionName = functionImport.getName();
|
||||
if (!functionImports.containsKey(functionName)) {
|
||||
EdmFunctionImportImpl impl = new EdmFunctionImportImpl(edm, this, functionImport);
|
||||
functionImports.put(functionName, impl);
|
||||
functionImports.put(functionName,
|
||||
new EdmFunctionImportImpl(edm, this, functionImport));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,16 +29,17 @@ import java.util.Map;
|
|||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.EntitySet;
|
||||
import org.apache.olingo.commons.api.data.Link;
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.ValueType;
|
||||
import org.apache.olingo.commons.api.domain.ODataLinkType;
|
||||
import org.apache.olingo.commons.core.data.ComplexValueImpl;
|
||||
import org.apache.olingo.commons.core.data.EntityImpl;
|
||||
import org.apache.olingo.commons.core.data.EntitySetImpl;
|
||||
import org.apache.olingo.commons.core.data.LinkImpl;
|
||||
import org.apache.olingo.commons.core.data.ComplexValueImpl;
|
||||
import org.apache.olingo.commons.core.data.PropertyImpl;
|
||||
|
||||
public class DataCreator {
|
||||
|
@ -61,189 +62,171 @@ public class DataCreator {
|
|||
data.put("ESTwoKeyNav", createESTwoKeyNav());
|
||||
data.put("ESCompCollComp", createESCompCollComp());
|
||||
data.put("ESServerSidePaging", createESServerSidePaging());
|
||||
|
||||
|
||||
linkESTwoPrim(data);
|
||||
linkESAllPrim(data);
|
||||
linkESKeyNav(data);
|
||||
linkESTwoKeyNav(data);
|
||||
}
|
||||
|
||||
protected Map<String, EntitySet> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
private EntitySet createESServerSidePaging() {
|
||||
EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
for(int i = 1; i <= 503; i++) {
|
||||
|
||||
for (int i = 1; i <= 503; i++) {
|
||||
entitySet.getEntities().add(new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", i))
|
||||
.addProperty(createPrimitive("PropertyString", "Number:" + i))
|
||||
);
|
||||
.addProperty(createPrimitive("PropertyInt16", i))
|
||||
.addProperty(createPrimitive("PropertyString", "Number:" + i)));
|
||||
}
|
||||
|
||||
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
Map<String, EntitySet> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
private EntitySet createESKeyNav() {
|
||||
final EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
|
||||
entitySet.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
|
||||
entitySet.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
|
||||
entitySet.getEntities().add(createETKeyNavEntity(3, "I am String Property 3"));
|
||||
|
||||
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Entity createETKeyNavEntity(int propertyInt16, String propertyString) {
|
||||
// PropertyCompAllPrim
|
||||
ComplexValue cvCompAllPrim = createKeyNavAllPrimComplexValue();
|
||||
|
||||
// CollPropertyComp
|
||||
List<ComplexValue> ccComp = new ArrayList<ComplexValue>();
|
||||
ccComp.add(createCTPrimCompValue(1));
|
||||
ccComp.add(createCTPrimCompValue(2));
|
||||
ccComp.add(createCTPrimCompValue(3));
|
||||
|
||||
return new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", propertyInt16))
|
||||
.addProperty(createPrimitive("PropertyString", propertyString))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 1)))
|
||||
.addProperty(new PropertyImpl(null, "PropertyCompAllPrim", ValueType.COMPLEX, cvCompAllPrim))
|
||||
.addProperty(createComplex("PropertyCompTwoPrim",
|
||||
createPrimitive("PropertyInt16", 16),
|
||||
createPrimitive("PropertyString", "Test123")))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example",
|
||||
"Employee2@company.example",
|
||||
"Employee3@company.example"))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112))
|
||||
.addProperty(new PropertyImpl(null, "CollPropertyComp", ValueType.COLLECTION_COMPLEX, ccComp))
|
||||
.addProperty(createComplex("PropertyCompComp",
|
||||
createPrimitive("PropertyString", "1"),
|
||||
createComplex("PropertyComp", createPrimitive("PropertyInt16", 1))));
|
||||
.addProperty(createPrimitive("PropertyInt16", propertyInt16))
|
||||
.addProperty(createPrimitive("PropertyString", propertyString))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 1)))
|
||||
.addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim"))
|
||||
.addProperty(createComplex("PropertyCompTwoPrim",
|
||||
createPrimitive("PropertyInt16", 16),
|
||||
createPrimitive("PropertyString", "Test123")))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example",
|
||||
"Employee2@company.example",
|
||||
"Employee3@company.example"))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112))
|
||||
.addProperty(createComplexCollection("CollPropertyComp",
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 1),
|
||||
createKeyNavAllPrimComplexValue("PropertyComp")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 2),
|
||||
createKeyNavAllPrimComplexValue("PropertyComp")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 3),
|
||||
createKeyNavAllPrimComplexValue("PropertyComp"))))
|
||||
.addProperty(createComplex("PropertyCompComp",
|
||||
createPrimitive("PropertyString", "1"),
|
||||
createComplex("PropertyComp", createPrimitive("PropertyInt16", 1))));
|
||||
}
|
||||
|
||||
private ComplexValue createCTPrimCompValue(int properyInt16) {
|
||||
final ComplexValue cvBasePrimCompNav = new ComplexValueImpl();
|
||||
final ComplexValue cvAllPrim = createKeyNavAllPrimComplexValue();
|
||||
|
||||
cvBasePrimCompNav.getValue().add(createPrimitive("PropertyInt16", properyInt16));
|
||||
cvBasePrimCompNav.getValue().add(new PropertyImpl(null, "PropertyComp", ValueType.COMPLEX, cvAllPrim));
|
||||
|
||||
return cvBasePrimCompNav;
|
||||
}
|
||||
|
||||
|
||||
private EntitySet createESTwoKeyNav() {
|
||||
final EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
|
||||
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "1"));
|
||||
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "2"));
|
||||
entitySet.getEntities().add(createESTwoKeyNavEntity(2, "1"));
|
||||
entitySet.getEntities().add(createESTwoKeyNavEntity(3, "1"));
|
||||
|
||||
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Entity createESTwoKeyNavEntity(int propertyInt16, String propertyString) {
|
||||
return new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", propertyInt16))
|
||||
.addProperty(createPrimitive("PropertyString", propertyString))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 11),
|
||||
createComplex("PropertyComp",
|
||||
createPrimitive("PropertyString", "StringValue"),
|
||||
createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
|
||||
createPrimitive("PropertyBoolean", true),
|
||||
createPrimitive("PropertyByte", 255),
|
||||
createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 7, 16, 23)),
|
||||
createPrimitive("PropertyDecimal", 34),
|
||||
createPrimitive("PropertySingle", 179000000000000000000D),
|
||||
createPrimitive("PropertyDouble", -179000000000000000000D),
|
||||
createPrimitive("PropertyDuration", 6),
|
||||
createPrimitive("PropertyGuid", UUID.fromString("01234567-89ab-cdef-0123-456789abcdef")),
|
||||
createPrimitive("PropertyInt16", Short.MAX_VALUE),
|
||||
createPrimitive("PropertyInt32", Integer.MAX_VALUE),
|
||||
createPrimitive("PropertyInt64", Long.MAX_VALUE),
|
||||
createPrimitive("PropertySByte", Byte.MAX_VALUE),
|
||||
createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59))
|
||||
)
|
||||
))
|
||||
.addProperty(new PropertyImpl(null, "PropertyCompNav", ValueType.COMPLEX, createCTPrimCompValue(1)))
|
||||
.addProperty(new PropertyImpl(null, "CollPropertyComp", ValueType.COLLECTION_COMPLEX,
|
||||
new ArrayList<ComplexValue>()))
|
||||
.addProperty(createComplexCollection("CollPropertyCompNav",
|
||||
Arrays.asList(createPrimitive("PropertyInt16", 1))))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString", 1, 2))
|
||||
.addProperty(createComplex("PropertyCompTwoPrim",
|
||||
createPrimitive("PropertyInt16", 11),
|
||||
createPrimitive("PropertyString", "11")
|
||||
));
|
||||
.addProperty(createPrimitive("PropertyInt16", propertyInt16))
|
||||
.addProperty(createPrimitive("PropertyString", propertyString))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 11),
|
||||
createComplex("PropertyComp",
|
||||
createPrimitive("PropertyString", "StringValue"),
|
||||
createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
|
||||
createPrimitive("PropertyBoolean", true),
|
||||
createPrimitive("PropertyByte", 255),
|
||||
createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 7, 16, 23)),
|
||||
createPrimitive("PropertyDecimal", 34),
|
||||
createPrimitive("PropertySingle", 179000000000000000000D),
|
||||
createPrimitive("PropertyDouble", -179000000000000000000D),
|
||||
createPrimitive("PropertyDuration", 6),
|
||||
createPrimitive("PropertyGuid", UUID.fromString("01234567-89ab-cdef-0123-456789abcdef")),
|
||||
createPrimitive("PropertyInt16", Short.MAX_VALUE),
|
||||
createPrimitive("PropertyInt32", Integer.MAX_VALUE),
|
||||
createPrimitive("PropertyInt64", Long.MAX_VALUE),
|
||||
createPrimitive("PropertySByte", Byte.MAX_VALUE),
|
||||
createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59)))))
|
||||
.addProperty(createComplex("PropertyCompNav",
|
||||
createPrimitive("PropertyInt16", 1),
|
||||
createKeyNavAllPrimComplexValue("PropertyComp")))
|
||||
.addProperty(createComplexCollection("CollPropertyComp"))
|
||||
.addProperty(createComplexCollection("CollPropertyCompNav",
|
||||
Arrays.asList(createPrimitive("PropertyInt16", 1))))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString", 1, 2))
|
||||
.addProperty(createComplex("PropertyCompTwoPrim",
|
||||
createPrimitive("PropertyInt16", 11),
|
||||
createPrimitive("PropertyString", "11")));
|
||||
}
|
||||
|
||||
private ComplexValue createKeyNavAllPrimComplexValue() {
|
||||
ComplexValue cvAllPrim;
|
||||
cvAllPrim = new ComplexValueImpl();
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyString", "First Resource - positive values"));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 } ));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyBoolean", true));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyByte", 255));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 7, 16, 23)));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyDateTimeOffset", getTimestamp(2012, 12, 3, 7, 16, 23, 0)));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyDecimal", 34));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertySingle", 179000000000000000000D));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyDouble", -179000000000000000000D));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyDuration", 6));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyGuid", UUID.fromString("01234567-89ab-cdef-0123-456789abcdef")));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyInt16", Short.MAX_VALUE));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyInt32", Integer.MAX_VALUE));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyInt64", Long.MAX_VALUE));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertySByte", Byte.MAX_VALUE));
|
||||
cvAllPrim.getValue().add(createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59)));
|
||||
|
||||
return cvAllPrim;
|
||||
private Property createKeyNavAllPrimComplexValue(final String name) {
|
||||
return createComplex(name,
|
||||
createPrimitive("PropertyString", "First Resource - positive values"),
|
||||
createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
|
||||
createPrimitive("PropertyBoolean", true),
|
||||
createPrimitive("PropertyByte", 255),
|
||||
createPrimitive("PropertyDate", getDateTime(2012, 12, 3, 7, 16, 23)),
|
||||
createPrimitive("PropertyDateTimeOffset", getTimestamp(2012, 12, 3, 7, 16, 23, 0)),
|
||||
createPrimitive("PropertyDecimal", 34),
|
||||
createPrimitive("PropertySingle", 179000000000000000000D),
|
||||
createPrimitive("PropertyDouble", -179000000000000000000D),
|
||||
createPrimitive("PropertyDuration", 6),
|
||||
createPrimitive("PropertyGuid", UUID.fromString("01234567-89ab-cdef-0123-456789abcdef")),
|
||||
createPrimitive("PropertyInt16", Short.MAX_VALUE),
|
||||
createPrimitive("PropertyInt32", Integer.MAX_VALUE),
|
||||
createPrimitive("PropertyInt64", Long.MAX_VALUE),
|
||||
createPrimitive("PropertySByte", Byte.MAX_VALUE),
|
||||
createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59)));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntitySet createESCompCollComp() {
|
||||
final EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
|
||||
entitySet.getEntities().add(new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createComplexCollection("CollPropertyComp",
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 555),
|
||||
createPrimitive("PropertyString", "1 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 666),
|
||||
createPrimitive("PropertyString", "2 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 777),
|
||||
createPrimitive("PropertyString", "3 Test Complex in Complex Property"))
|
||||
))));
|
||||
|
||||
.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createComplexCollection("CollPropertyComp",
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 555),
|
||||
createPrimitive("PropertyString", "1 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 666),
|
||||
createPrimitive("PropertyString", "2 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 777),
|
||||
createPrimitive("PropertyString", "3 Test Complex in Complex Property"))))));
|
||||
|
||||
entitySet.getEntities().add(new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", 12345))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createComplexCollection("CollPropertyComp",
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 888),
|
||||
createPrimitive("PropertyString", "11 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 999),
|
||||
createPrimitive("PropertyString", "12 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 0),
|
||||
createPrimitive("PropertyString", "13 Test Complex in Complex Property"))
|
||||
))));
|
||||
|
||||
.addProperty(createPrimitive("PropertyInt16", 12345))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createComplexCollection("CollPropertyComp",
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 888),
|
||||
createPrimitive("PropertyString", "11 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 999),
|
||||
createPrimitive("PropertyString", "12 Test Complex in Complex Property")),
|
||||
Arrays.asList(
|
||||
createPrimitive("PropertyInt16", 0),
|
||||
createPrimitive("PropertyString", "13 Test Complex in Complex Property"))))));
|
||||
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
|
||||
private EntitySet createESTwoPrim() {
|
||||
EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
|
@ -451,42 +434,40 @@ public class DataCreator {
|
|||
}
|
||||
|
||||
private EntitySet createESMixPrimCollComp() {
|
||||
EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
Entity entity = new EntityImpl();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
|
||||
entity.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example", "Employee2@company.example", "Employee3@company.example"));
|
||||
entity.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 111),
|
||||
createPrimitive("PropertyString", "TEST A")));
|
||||
@SuppressWarnings("unchecked")
|
||||
final Property complexCollection = createComplexCollection("CollPropertyComp",
|
||||
Arrays.asList(createPrimitive("PropertyInt16", 123), createPrimitive("PropertyString", "TEST 1")),
|
||||
Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
|
||||
Arrays.asList(createPrimitive("PropertyInt16", 789), createPrimitive("PropertyString", "TEST 3")));
|
||||
entity.addProperty(complexCollection);
|
||||
entitySet.getEntities().add(entity);
|
||||
|
||||
entity = new EntityImpl();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", 7));
|
||||
entity.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example", "Employee2@company.example", "Employee3@company.example"));
|
||||
entity.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 222),
|
||||
createPrimitive("PropertyString", "TEST B")));
|
||||
entity.addProperty(complexCollection);
|
||||
entitySet.getEntities().add(entity);
|
||||
EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
entity = new EntityImpl();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", 0));
|
||||
entity.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example", "Employee2@company.example", "Employee3@company.example"));
|
||||
entity.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 333),
|
||||
createPrimitive("PropertyString", "TEST C")));
|
||||
entity.addProperty(complexCollection);
|
||||
entitySet.getEntities().add(entity);
|
||||
entitySet.getEntities().add(new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example", "Employee2@company.example", "Employee3@company.example"))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 111),
|
||||
createPrimitive("PropertyString", "TEST A")))
|
||||
.addProperty(complexCollection));
|
||||
|
||||
entitySet.getEntities().add(new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", 7))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example", "Employee2@company.example", "Employee3@company.example"))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 222),
|
||||
createPrimitive("PropertyString", "TEST B")))
|
||||
.addProperty(complexCollection));
|
||||
|
||||
entitySet.getEntities().add(new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", 0))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example", "Employee2@company.example", "Employee3@company.example"))
|
||||
.addProperty(createComplex("PropertyComp",
|
||||
createPrimitive("PropertyInt16", 333),
|
||||
createPrimitive("PropertyString", "TEST C")))
|
||||
.addProperty(complexCollection));
|
||||
|
||||
return entitySet;
|
||||
}
|
||||
|
@ -552,27 +533,27 @@ public class DataCreator {
|
|||
private EntitySet createESMedia() {
|
||||
EntitySet entitySet = new EntitySetImpl();
|
||||
|
||||
Entity entity = new EntityImpl();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", 1));
|
||||
entity.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
|
||||
Entity entity = new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", 1))
|
||||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entitySet.getEntities().add(entity);
|
||||
|
||||
entity = new EntityImpl();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", 2));
|
||||
entity.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
|
||||
entity = new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", 2))
|
||||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entitySet.getEntities().add(entity);
|
||||
|
||||
entity = new EntityImpl();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", 3));
|
||||
entity.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
|
||||
entity = new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", 3))
|
||||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entitySet.getEntities().add(entity);
|
||||
|
||||
entity = new EntityImpl();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", 4));
|
||||
entity.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
|
||||
entity = new EntityImpl()
|
||||
.addProperty(createPrimitive("PropertyInt16", 4))
|
||||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entitySet.getEntities().add(entity);
|
||||
|
||||
|
@ -581,18 +562,19 @@ public class DataCreator {
|
|||
|
||||
private byte[] createImage(final String color) {
|
||||
return ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 100 100\">\n"
|
||||
+ " <g stroke=\"darkmagenta\" stroke-width=\"16\" fill=\"" + color + "\">\n"
|
||||
+ " <circle cx=\"50\" cy=\"50\" r=\"42\"/>\n"
|
||||
+ " </g>\n"
|
||||
+ "</svg>\n").getBytes(Charset.forName("UTF-8"));
|
||||
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 100 100\">\n"
|
||||
+ " <g stroke=\"darkmagenta\" stroke-width=\"16\" fill=\"" + color + "\">\n"
|
||||
+ " <circle cx=\"50\" cy=\"50\" r=\"42\"/>\n"
|
||||
+ " </g>\n"
|
||||
+ "</svg>\n").getBytes(Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
private void linkESTwoPrim(Map<String, EntitySet> data) {
|
||||
final EntitySet entitySet = data.get("ESTwoPrim");
|
||||
final List<Entity> targetEntities = data.get("ESAllPrim").getEntities();
|
||||
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETAllPrimMany", targetEntities.subList(1, 3));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETAllPrimMany",
|
||||
targetEntities.get(1), targetEntities.get(2));
|
||||
|
||||
setLink(entitySet.getEntities().get(3), "NavPropertyETAllPrimOne", targetEntities.get(0));
|
||||
}
|
||||
|
@ -601,73 +583,77 @@ public class DataCreator {
|
|||
final EntitySet entitySet = data.get("ESAllPrim");
|
||||
final List<Entity> targetEntities = data.get("ESTwoPrim").getEntities();
|
||||
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoPrimMany", targetEntities.subList(1, 2));
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoPrimMany", targetEntities.get(1));
|
||||
setLink(entitySet.getEntities().get(0), "NavPropertyETTwoPrimOne", targetEntities.get(3));
|
||||
|
||||
setLinks(entitySet.getEntities().get(2), "NavPropertyETTwoPrimMany",
|
||||
Arrays.asList(targetEntities.get(0), targetEntities.get(2), targetEntities.get(3)));
|
||||
targetEntities.get(0), targetEntities.get(2), targetEntities.get(3));
|
||||
}
|
||||
|
||||
|
||||
private void linkESKeyNav(Map<String, EntitySet> data) {
|
||||
final EntitySet entitySet = data.get("ESKeyNav");
|
||||
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
||||
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
|
||||
final List<Entity> esMediaTargets = data.get("ESMedia").getEntities();
|
||||
|
||||
|
||||
// NavPropertyETKeyNavMany
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETKeyNavMany", esKeyNavTargets.subList(0, 2));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETKeyNavMany", esKeyNavTargets.subList(1, 3));
|
||||
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETKeyNavMany",
|
||||
esKeyNavTargets.get(0), esKeyNavTargets.get(1));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETKeyNavMany",
|
||||
esKeyNavTargets.get(1), esKeyNavTargets.get(2));
|
||||
|
||||
// NavPropertyETKeyNavOne
|
||||
setLink(entitySet.getEntities().get(0), "NavPropertyETKeyNavOne", esKeyNavTargets.get(1));
|
||||
setLink(entitySet.getEntities().get(1), "NavPropertyETKeyNavOne", esKeyNavTargets.get(2));
|
||||
|
||||
|
||||
// NavPropertyETTwoKeyNavOne
|
||||
setLink(entitySet.getEntities().get(0), "NavPropertyETTwoKeyNavOne", esTwoKeyNavTargets.get(0));
|
||||
setLink(entitySet.getEntities().get(1), "NavPropertyETTwoKeyNavOne", esTwoKeyNavTargets.get(1));
|
||||
setLink(entitySet.getEntities().get(2), "NavPropertyETTwoKeyNavOne", esTwoKeyNavTargets.get(2));
|
||||
|
||||
|
||||
// NavPropertyETTwoKeyNavMany
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoKeyNavMany", esTwoKeyNavTargets.subList(0, 2));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETTwoKeyNavMany", esTwoKeyNavTargets.subList(2, 3));
|
||||
setLinks(entitySet.getEntities().get(2), "NavPropertyETTwoKeyNavMany", esTwoKeyNavTargets.subList(3, 4));
|
||||
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoKeyNavMany",
|
||||
esTwoKeyNavTargets.get(0), esTwoKeyNavTargets.get(1));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETTwoKeyNavMany", esTwoKeyNavTargets.get(2));
|
||||
setLinks(entitySet.getEntities().get(2), "NavPropertyETTwoKeyNavMany", esTwoKeyNavTargets.get(3));
|
||||
|
||||
// NavPropertyETMediaOne
|
||||
setLink(entitySet.getEntities().get(0), "NavPropertyETMediaOne", esMediaTargets.get(0));
|
||||
setLink(entitySet.getEntities().get(1), "NavPropertyETMediaOne", esMediaTargets.get(1));
|
||||
setLink(entitySet.getEntities().get(2), "NavPropertyETMediaOne", esMediaTargets.get(2));
|
||||
}
|
||||
|
||||
|
||||
private void linkESTwoKeyNav(Map<String, EntitySet> data) {
|
||||
final EntitySet entitySet = data.get("ESTwoKeyNav");
|
||||
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
||||
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
|
||||
|
||||
|
||||
// NavPropertyETKeyNavOne
|
||||
setLink(entitySet.getEntities().get(0), "NavPropertyETKeyNavOne", esKeyNavTargets.get(0));
|
||||
setLink(entitySet.getEntities().get(1), "NavPropertyETKeyNavOne", esKeyNavTargets.get(0));
|
||||
setLink(entitySet.getEntities().get(2), "NavPropertyETKeyNavOne", esKeyNavTargets.get(1));
|
||||
setLink(entitySet.getEntities().get(3), "NavPropertyETKeyNavOne", esKeyNavTargets.get(2));
|
||||
|
||||
|
||||
// NavPropertyETKeyNavMany
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETKeyNavMany", esKeyNavTargets.subList(0, 2));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETKeyNavMany", esKeyNavTargets.subList(0, 2));
|
||||
setLinks(entitySet.getEntities().get(2), "NavPropertyETKeyNavMany", esKeyNavTargets.subList(1, 3));
|
||||
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETKeyNavMany",
|
||||
esKeyNavTargets.get(0), esKeyNavTargets.get(1));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETKeyNavMany",
|
||||
esKeyNavTargets.get(0), esKeyNavTargets.get(1));
|
||||
setLinks(entitySet.getEntities().get(2), "NavPropertyETKeyNavMany",
|
||||
esKeyNavTargets.get(1), esKeyNavTargets.get(2));
|
||||
|
||||
// NavPropertyETTwoKeyNavOne
|
||||
setLink(entitySet.getEntities().get(0), "NavPropertyETTwoKeyNavOne", esTwoKeyNavTargets.get(0));
|
||||
setLink(entitySet.getEntities().get(2), "NavPropertyETTwoKeyNavOne", esTwoKeyNavTargets.get(1));
|
||||
setLink(entitySet.getEntities().get(3), "NavPropertyETTwoKeyNavOne", esTwoKeyNavTargets.get(2));
|
||||
|
||||
|
||||
// NavPropertyETTwoKeyNavMany
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoKeyNavMany", esKeyNavTargets.subList(0, 2));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETTwoKeyNavMany", esKeyNavTargets.subList(0, 1));
|
||||
setLinks(entitySet.getEntities().get(2), "NavPropertyETTwoKeyNavMany", esKeyNavTargets.subList(1, 2));
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoKeyNavMany",
|
||||
esKeyNavTargets.get(0), esKeyNavTargets.get(1));
|
||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETTwoKeyNavMany", esKeyNavTargets.get(0));
|
||||
setLinks(entitySet.getEntities().get(2), "NavPropertyETTwoKeyNavMany", esKeyNavTargets.get(1));
|
||||
}
|
||||
|
||||
|
||||
protected static Property createPrimitive(final String name, final Object value) {
|
||||
return new PropertyImpl(null, name, ValueType.PRIMITIVE, value);
|
||||
}
|
||||
|
@ -719,18 +705,28 @@ public class DataCreator {
|
|||
}
|
||||
|
||||
protected static void setLink(Entity entity, final String navigationPropertyName, final Entity target) {
|
||||
Link link = new LinkImpl();
|
||||
link.setTitle(navigationPropertyName);
|
||||
Link link = entity.getNavigationLink(navigationPropertyName);
|
||||
if (link == null) {
|
||||
link = new LinkImpl();
|
||||
link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
|
||||
link.setTitle(navigationPropertyName);
|
||||
entity.getNavigationLinks().add(link);
|
||||
}
|
||||
link.setInlineEntity(target);
|
||||
entity.getNavigationLinks().add(link);
|
||||
}
|
||||
|
||||
protected static void setLinks(Entity entity, final String navigationPropertyName, final List<Entity> targets) {
|
||||
Link link = new LinkImpl();
|
||||
link.setTitle(navigationPropertyName);
|
||||
EntitySet target = new EntitySetImpl();
|
||||
target.getEntities().addAll(targets);
|
||||
link.setInlineEntitySet(target);
|
||||
entity.getNavigationLinks().add(link);
|
||||
protected static void setLinks(Entity entity, final String navigationPropertyName, final Entity... targets) {
|
||||
Link link = entity.getNavigationLink(navigationPropertyName);
|
||||
if (link == null) {
|
||||
link = new LinkImpl();
|
||||
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
||||
link.setTitle(navigationPropertyName);
|
||||
EntitySet target = new EntitySetImpl();
|
||||
target.getEntities().addAll(Arrays.asList(targets));
|
||||
link.setInlineEntitySet(target);
|
||||
entity.getNavigationLinks().add(link);
|
||||
} else {
|
||||
link.getInlineEntitySet().getEntities().addAll(Arrays.asList(targets));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,11 @@ import org.apache.olingo.commons.api.data.Entity;
|
|||
import org.apache.olingo.commons.api.data.EntitySet;
|
||||
import org.apache.olingo.commons.api.data.Link;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.domain.ODataLinkType;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
|
@ -45,8 +44,6 @@ import org.apache.olingo.commons.api.edm.EdmStructuredType;
|
|||
import org.apache.olingo.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.commons.core.data.EntityImpl;
|
||||
import org.apache.olingo.commons.core.data.EntitySetImpl;
|
||||
import org.apache.olingo.commons.core.data.LinkImpl;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
|
||||
|
@ -59,7 +56,6 @@ import org.apache.olingo.server.api.uri.UriParameter;
|
|||
public class DataProvider {
|
||||
|
||||
protected static final String MEDIA_PROPERTY_NAME = "$value";
|
||||
// private static final String KEY_NAME = "PropertyInt16";
|
||||
|
||||
final private Map<String, EntitySet> data;
|
||||
private Edm edm;
|
||||
|
@ -133,37 +129,6 @@ public class DataProvider {
|
|||
}
|
||||
}
|
||||
|
||||
// public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
|
||||
// final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
|
||||
// List<Entity> entities = readAll(edmEntitySet).getEntities();
|
||||
// Entity entity = new EntityImpl();
|
||||
// final List<String> keyNames = edmEntityType.getKeyPredicateNames();
|
||||
// if (keyNames.size() == 1 && keyNames.get(0).equals(KEY_NAME)) {
|
||||
// entity.addProperty(DataCreator.createPrimitive(KEY_NAME, findFreeKeyValue(entities)));
|
||||
// } else {
|
||||
// throw new DataProviderException("Key construction not supported!");
|
||||
// }
|
||||
// createProperties(edmEntityType, entity.getProperties());
|
||||
// entities.add(entity);
|
||||
// return entity;
|
||||
// }
|
||||
//
|
||||
// private Integer findFreeKeyValue(final List<Entity> entities) {
|
||||
// Integer result = 0;
|
||||
// boolean free;
|
||||
// do {
|
||||
// ++result;
|
||||
// free = true;
|
||||
// for (final Entity entity : entities) {
|
||||
// if (result.equals(entity.getProperty(KEY_NAME).getValue())) {
|
||||
// free = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// } while (!free);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
|
||||
final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
|
||||
final EntitySet entitySet = readAll(edmEntitySet);
|
||||
|
@ -253,8 +218,7 @@ public class DataProvider {
|
|||
}
|
||||
|
||||
public void update(final String rawBaseUri, final EdmEntitySet edmEntitySet, Entity entity,
|
||||
final Entity changedEntity, final boolean patch,
|
||||
final boolean isInsert) throws DataProviderException {
|
||||
final Entity changedEntity, final boolean patch, final boolean isInsert) throws DataProviderException {
|
||||
|
||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||
final List<String> keyNames = entityType.getKeyPredicateNames();
|
||||
|
@ -320,8 +284,7 @@ public class DataProvider {
|
|||
}
|
||||
|
||||
private void handleDeepInsert(final String rawBaseUri, final EdmEntitySet edmEntitySet, final Entity entity,
|
||||
final Entity changedEntity)
|
||||
throws DataProviderException {
|
||||
final Entity changedEntity) throws DataProviderException {
|
||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||
|
||||
for (final String navPropertyName : entityType.getNavigationPropertyNames()) {
|
||||
|
@ -331,41 +294,40 @@ public class DataProvider {
|
|||
// Deep inserts are not allowed in update operations, so we can be sure, that we do not override
|
||||
// a navigation link!
|
||||
final EdmNavigationProperty navigationProperty = entityType.getNavigationProperty(navPropertyName);
|
||||
final EdmBindingTarget target = edmEntitySet.getRelatedBindingTarget(navPropertyName);
|
||||
final EdmEntityType inlineEntityType = navigationProperty.getType();
|
||||
final EdmEntitySet target = (EdmEntitySet) edmEntitySet.getRelatedBindingTarget(navPropertyName);
|
||||
|
||||
if (navigationProperty.isCollection()) {
|
||||
final List<Entity> entities =
|
||||
createInlineEntities(rawBaseUri, target, inlineEntityType, navigationLink.getInlineEntitySet());
|
||||
createInlineEntities(rawBaseUri, target, navigationLink.getInlineEntitySet());
|
||||
|
||||
for (final Entity inlineEntity : entities) {
|
||||
createLink(navigationProperty, entity, inlineEntity);
|
||||
}
|
||||
} else {
|
||||
final Entity inlineEntity =
|
||||
createInlineEntity(rawBaseUri, target, inlineEntityType, navigationLink.getInlineEntity());
|
||||
createInlineEntity(rawBaseUri, target, navigationLink.getInlineEntity());
|
||||
createLink(navigationProperty, entity, inlineEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Entity> createInlineEntities(final String rawBaseUri, final EdmBindingTarget target,
|
||||
final EdmEntityType type, final EntitySet changedEntitySet) throws DataProviderException {
|
||||
private List<Entity> createInlineEntities(final String rawBaseUri, final EdmEntitySet targetEntitySet,
|
||||
final EntitySet changedEntitySet) throws DataProviderException {
|
||||
List<Entity> entities = new ArrayList<Entity>();
|
||||
|
||||
for (final Entity newEntity : changedEntitySet.getEntities()) {
|
||||
entities.add(createInlineEntity(rawBaseUri, target, type, newEntity));
|
||||
entities.add(createInlineEntity(rawBaseUri, targetEntitySet, newEntity));
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
private Entity createInlineEntity(final String rawBaseUri, final EdmBindingTarget target,
|
||||
final EdmEntityType type, final Entity changedEntity) throws DataProviderException {
|
||||
private Entity createInlineEntity(final String rawBaseUri, final EdmEntitySet targetEntitySet,
|
||||
final Entity changedEntity) throws DataProviderException {
|
||||
|
||||
final Entity inlineEntity = create((EdmEntitySet) target);
|
||||
update(rawBaseUri, (EdmEntitySet) target, inlineEntity, changedEntity, false, true);
|
||||
final Entity inlineEntity = create(targetEntitySet);
|
||||
update(rawBaseUri, targetEntitySet, inlineEntity, changedEntity, false, true);
|
||||
|
||||
return inlineEntity;
|
||||
}
|
||||
|
@ -380,27 +342,11 @@ public class DataProvider {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO Duplicated code in DataCreator
|
||||
private void setLink(final EdmNavigationProperty navigationProperty, final Entity srcEntity,
|
||||
final Entity destEntity) {
|
||||
|
||||
Link link = srcEntity.getNavigationLink(navigationProperty.getName());
|
||||
if (link == null) {
|
||||
link = new LinkImpl();
|
||||
link.setTitle(navigationProperty.getName());
|
||||
srcEntity.getNavigationLinks().add(link);
|
||||
}
|
||||
|
||||
private void setLink(final EdmNavigationProperty navigationProperty, Entity srcEntity, final Entity targetEntity) {
|
||||
if (navigationProperty.isCollection()) {
|
||||
if (link.getInlineEntitySet() == null) {
|
||||
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
||||
link.setInlineEntitySet(new EntitySetImpl());
|
||||
}
|
||||
|
||||
link.getInlineEntitySet().getEntities().add(destEntity);
|
||||
DataCreator.setLinks(srcEntity, navigationProperty.getName(), targetEntity);
|
||||
} else {
|
||||
link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
|
||||
link.setInlineEntity(destEntity);
|
||||
DataCreator.setLink(srcEntity, navigationProperty.getName(), targetEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,10 +369,8 @@ public class DataProvider {
|
|||
} else {
|
||||
final EdmComplexType type = (EdmComplexType) edmProperty.getType();
|
||||
for (final String propertyName : type.getPropertyNames()) {
|
||||
List<Property> newProperties = null;
|
||||
if(newProperty != null && newProperty.asComplex() != null){
|
||||
newProperties = newProperty.asComplex().getValue();
|
||||
}
|
||||
final List<Property> newProperties = newProperty == null || newProperty.asComplex() == null ? null :
|
||||
newProperty.asComplex().getValue();
|
||||
updateProperty(type.getStructuralProperty(propertyName),
|
||||
findProperty(propertyName, property.asComplex().getValue()),
|
||||
newProperties == null ? null : findProperty(propertyName, newProperties),
|
||||
|
@ -454,6 +398,16 @@ public class DataProvider {
|
|||
entity.setMediaContentType(type);
|
||||
}
|
||||
|
||||
public EntitySet readFunctionEntitySet(final EdmFunction function, final List<UriParameter> parameters)
|
||||
throws DataProviderException {
|
||||
return FunctionData.entityCollectionFunction(function.getName(), parameters, data);
|
||||
}
|
||||
|
||||
public Entity readFunctionEntity(final EdmFunction function, final List<UriParameter> parameters)
|
||||
throws DataProviderException {
|
||||
return FunctionData.entityFunction(function.getName(), parameters, data);
|
||||
}
|
||||
|
||||
public void setEdm(final Edm edm) {
|
||||
this.edm = edm;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.server.tecsvc.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.EntitySet;
|
||||
import org.apache.olingo.commons.core.data.EntitySetImpl;
|
||||
import org.apache.olingo.server.api.uri.UriParameter;
|
||||
import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
|
||||
|
||||
public class FunctionData {
|
||||
|
||||
protected static EntitySet entityCollectionFunction(final String name, final List<UriParameter> parameters,
|
||||
final Map<String, EntitySet> data) throws DataProviderException {
|
||||
if (name.equals("UFCRTCollETTwoKeyNavParam")) {
|
||||
final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
|
||||
EntitySet result = new EntitySetImpl();
|
||||
final int endIndex = parameters.isEmpty() ? 0 : Short.valueOf(parameters.get(0).getText());
|
||||
result.getEntities().addAll(
|
||||
esTwoKeyNav.subList(0,
|
||||
endIndex < 0 ? 0 : endIndex > esTwoKeyNav.size() ? esTwoKeyNav.size() : endIndex));
|
||||
return result;
|
||||
} else if (name.equals("UFCRTCollETMixPrimCollCompTwoParam")) {
|
||||
return data.get("ESMixPrimCollComp");
|
||||
} else if (name.equals("UFCRTCollETMedia")) {
|
||||
return data.get("ESMedia");
|
||||
} else {
|
||||
throw new DataProviderException("Function " + name + " is not yet implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
protected static Entity entityFunction(final String name, final List<UriParameter> parameters,
|
||||
final Map<String, EntitySet> data) throws DataProviderException {
|
||||
final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
|
||||
if (name.equals("UFCRTETTwoKeyNav")) {
|
||||
return esTwoKeyNav.get(0);
|
||||
} else if (name.equals("UFCRTETTwoKeyNavParam")) {
|
||||
final int index = parameters.isEmpty() ? 0 : Short.valueOf(parameters.get(0).getText());
|
||||
return index < 0 || index >= esTwoKeyNav.size() ? null : esTwoKeyNav.get(index);
|
||||
} else if (name.equals("UFCRTETMedia")) {
|
||||
final int index = parameters.isEmpty() ? 1 : Short.valueOf(parameters.get(0).getText());
|
||||
final List<Entity> esMedia = data.get("ESMedia").getEntities();
|
||||
return index < 1 || index > esTwoKeyNav.size() ? null : esMedia.get(index - 1);
|
||||
} else {
|
||||
throw new DataProviderException("Function " + name + " is not yet implemented.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ package org.apache.olingo.server.tecsvc.processor;
|
|||
import java.util.Locale;
|
||||
|
||||
import org.apache.olingo.commons.api.data.ContextURL;
|
||||
import org.apache.olingo.commons.api.data.ContextURL.Builder;
|
||||
import org.apache.olingo.commons.api.data.ContextURL.Suffix;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.EntitySet;
|
||||
|
@ -50,6 +51,7 @@ import org.apache.olingo.server.api.serializer.ODataSerializer;
|
|||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
import org.apache.olingo.server.api.uri.UriInfo;
|
||||
import org.apache.olingo.server.api.uri.UriResourceEntitySet;
|
||||
import org.apache.olingo.server.api.uri.UriResourceFunction;
|
||||
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
||||
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
|
||||
import org.apache.olingo.server.tecsvc.data.DataProvider;
|
||||
|
@ -77,6 +79,11 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
validateOptions(uriInfo.asUriInfoResource());
|
||||
|
||||
final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo.asUriInfoResource());
|
||||
final EdmEntityType edmEntityType = edmEntitySet == null ?
|
||||
(EdmEntityType) ((UriResourceFunction) uriInfo.getUriResourceParts()
|
||||
.get(uriInfo.getUriResourceParts().size() - 1)).getType() :
|
||||
edmEntitySet.getEntityType();
|
||||
|
||||
final EntitySet entitySetInitial = readEntityCollection(uriInfo);
|
||||
if (entitySetInitial == null) {
|
||||
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
||||
|
@ -102,10 +109,10 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
ODataSerializer serializer = odata.createSerializer(format);
|
||||
final ExpandOption expand = uriInfo.getExpandOption();
|
||||
final SelectOption select = uriInfo.getSelectOption();
|
||||
response.setContent(serializer.entityCollection(edmEntitySet.getEntityType(), entitySet,
|
||||
response.setContent(serializer.entityCollection(edmEntityType, entitySet,
|
||||
EntityCollectionSerializerOptions.with()
|
||||
.contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
|
||||
getContextUrl(edmEntitySet, false, expand, select))
|
||||
getContextUrl(edmEntitySet, edmEntityType, false, expand, select))
|
||||
.count(uriInfo.getCountOption())
|
||||
.expand(expand).select(select)
|
||||
.build()));
|
||||
|
@ -143,6 +150,11 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
|
||||
validateOptions(uriInfo.asUriInfoResource());
|
||||
final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo);
|
||||
final EdmEntityType edmEntityType = edmEntitySet == null ?
|
||||
(EdmEntityType) ((UriResourceFunction) uriInfo.getUriResourceParts()
|
||||
.get(uriInfo.getUriResourceParts().size() - 1)).getType() :
|
||||
edmEntitySet.getEntityType();
|
||||
|
||||
final Entity entity = readEntity(uriInfo);
|
||||
|
||||
final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
|
||||
|
@ -152,7 +164,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
response.setContent(serializer.entity(edmEntitySet.getEntityType(), entity,
|
||||
EntitySerializerOptions.with()
|
||||
.contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
|
||||
getContextUrl(edmEntitySet, true, expand, select))
|
||||
getContextUrl(edmEntitySet, edmEntityType, true, expand, select))
|
||||
.expand(expand).select(select)
|
||||
.build()));
|
||||
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
|
||||
|
@ -205,7 +217,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
response.setContent(serializer.entity(edmEntityType, entity,
|
||||
EntitySerializerOptions.with()
|
||||
.contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
|
||||
getContextUrl(edmEntitySet, true, null, null))
|
||||
getContextUrl(edmEntitySet, edmEntityType, true, null, null))
|
||||
.build()));
|
||||
response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
|
||||
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
|
||||
|
@ -269,12 +281,15 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
}
|
||||
}
|
||||
|
||||
private ContextURL getContextUrl(final EdmEntitySet entitySet, final boolean isSingleEntity,
|
||||
final ExpandOption expand, final SelectOption select) throws SerializerException {
|
||||
return ContextURL.with().entitySet(entitySet)
|
||||
.selectList(odata.createUriHelper()
|
||||
.buildContextURLSelectList(entitySet.getEntityType(), expand, select))
|
||||
.suffix(isSingleEntity ? Suffix.ENTITY : null)
|
||||
.build();
|
||||
private ContextURL getContextUrl(final EdmEntitySet entitySet, final EdmEntityType entityType,
|
||||
final boolean isSingleEntity, final ExpandOption expand, final SelectOption select) throws SerializerException {
|
||||
Builder builder = ContextURL.with();
|
||||
builder = entitySet == null ?
|
||||
isSingleEntity ? builder.type(entityType) : builder.asCollection().type(entityType) :
|
||||
builder.entitySet(entitySet);
|
||||
builder = builder.selectList(odata.createUriHelper()
|
||||
.buildContextURLSelectList(entityType, expand, select))
|
||||
.suffix(isSingleEntity ? Suffix.ENTITY : null);
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.apache.olingo.commons.api.data.EntitySet;
|
|||
import org.apache.olingo.commons.api.data.Link;
|
||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
|
||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.server.api.OData;
|
||||
|
@ -36,6 +38,7 @@ import org.apache.olingo.server.api.uri.UriInfoResource;
|
|||
import org.apache.olingo.server.api.uri.UriParameter;
|
||||
import org.apache.olingo.server.api.uri.UriResource;
|
||||
import org.apache.olingo.server.api.uri.UriResourceEntitySet;
|
||||
import org.apache.olingo.server.api.uri.UriResourceFunction;
|
||||
import org.apache.olingo.server.api.uri.UriResourceNavigation;
|
||||
import org.apache.olingo.server.tecsvc.data.DataProvider;
|
||||
|
||||
|
@ -61,34 +64,31 @@ public abstract class TechnicalProcessor implements Processor {
|
|||
}
|
||||
|
||||
protected EdmEntitySet getEdmEntitySet(final UriInfoResource uriInfo) throws ODataApplicationException {
|
||||
EdmEntitySet entitySet = null;
|
||||
final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
|
||||
// first must be entity set
|
||||
if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
|
||||
|
||||
// First must be entity set or function import.
|
||||
blockTypeFilters(resourcePaths.get(0));
|
||||
if (resourcePaths.get(0) instanceof UriResourceEntitySet) {
|
||||
entitySet = ((UriResourceEntitySet) resourcePaths.get(0)).getEntitySet();
|
||||
} else if (resourcePaths.get(0) instanceof UriResourceFunction) {
|
||||
entitySet = ((UriResourceFunction) resourcePaths.get(0)).getFunctionImport().getReturnedEntitySet();
|
||||
} else {
|
||||
throw new ODataApplicationException("Invalid resource type.",
|
||||
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
|
||||
}
|
||||
|
||||
final UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
|
||||
if (uriResource.getTypeFilterOnCollection() != null || uriResource.getTypeFilterOnEntry() != null) {
|
||||
throw new ODataApplicationException("Type filters are not supported.",
|
||||
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
|
||||
}
|
||||
EdmEntitySet entitySet = uriResource.getEntitySet();
|
||||
|
||||
int navigationCount = 0;
|
||||
while (++navigationCount < resourcePaths.size()
|
||||
while (entitySet != null
|
||||
&& ++navigationCount < resourcePaths.size()
|
||||
&& resourcePaths.get(navigationCount) instanceof UriResourceNavigation) {
|
||||
final UriResourceNavigation uriNavigationResource = (UriResourceNavigation) resourcePaths.get(navigationCount);
|
||||
if (uriNavigationResource.getTypeFilterOnCollection() != null
|
||||
|| uriNavigationResource.getTypeFilterOnEntry() != null) {
|
||||
throw new ODataApplicationException("Type filters are not supported.",
|
||||
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
|
||||
}
|
||||
if (uriNavigationResource.getProperty().containsTarget()) {
|
||||
final UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) resourcePaths.get(navigationCount);
|
||||
blockTypeFilters(uriResourceNavigation);
|
||||
if (uriResourceNavigation.getProperty().containsTarget()) {
|
||||
throw new ODataApplicationException("Containment navigation is not supported.",
|
||||
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
|
||||
}
|
||||
final EdmBindingTarget target = entitySet.getRelatedBindingTarget(uriNavigationResource.getProperty().getName());
|
||||
final EdmBindingTarget target = entitySet.getRelatedBindingTarget(uriResourceNavigation.getProperty().getName());
|
||||
if (target instanceof EdmEntitySet) {
|
||||
entitySet = (EdmEntitySet) target;
|
||||
} else {
|
||||
|
@ -107,8 +107,31 @@ public abstract class TechnicalProcessor implements Processor {
|
|||
*/
|
||||
protected Entity readEntity(final UriInfoResource uriInfo) throws ODataApplicationException {
|
||||
final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
|
||||
final UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
|
||||
Entity entity = dataProvider.read(uriResource.getEntitySet(), uriResource.getKeyPredicates());
|
||||
|
||||
Entity entity = null;
|
||||
if (resourcePaths.get(0) instanceof UriResourceEntitySet) {
|
||||
final UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
|
||||
entity = dataProvider.read(uriResource.getEntitySet(), uriResource.getKeyPredicates());
|
||||
} else if (resourcePaths.get(0) instanceof UriResourceFunction) {
|
||||
final UriResourceFunction uriResource = (UriResourceFunction) resourcePaths.get(0);
|
||||
final EdmFunction function = uriResource.getFunction();
|
||||
if (function.getReturnType().getType() instanceof EdmEntityType) {
|
||||
final List<UriParameter> key = uriResource.getKeyPredicates();
|
||||
if (key.isEmpty()) {
|
||||
if (uriResource.isCollection()) { // handled in readEntityCollection()
|
||||
return null;
|
||||
} else {
|
||||
entity = dataProvider.readFunctionEntity(function, uriResource.getParameters());
|
||||
}
|
||||
} else {
|
||||
entity = dataProvider.read((EdmEntityType) function.getReturnType().getType(),
|
||||
dataProvider.readFunctionEntitySet(function, uriResource.getParameters()),
|
||||
key);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (entity == null) {
|
||||
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
||||
}
|
||||
|
@ -119,7 +142,7 @@ public abstract class TechnicalProcessor implements Processor {
|
|||
final UriResourceNavigation uriNavigationResource = (UriResourceNavigation) resourcePaths.get(navigationCount);
|
||||
final EdmNavigationProperty navigationProperty = uriNavigationResource.getProperty();
|
||||
final List<UriParameter> key = uriNavigationResource.getKeyPredicates();
|
||||
if (navigationProperty.isCollection() && key.isEmpty()) {
|
||||
if (navigationProperty.isCollection() && key.isEmpty()) { // handled in readEntityCollection()
|
||||
return entity;
|
||||
}
|
||||
final Link link = entity.getNavigationLink(navigationProperty.getName());
|
||||
|
@ -142,7 +165,12 @@ public abstract class TechnicalProcessor implements Processor {
|
|||
final Link link = entity.getNavigationLink(getLastNavigation(uriInfo).getProperty().getName());
|
||||
return link == null ? null : link.getInlineEntitySet();
|
||||
} else {
|
||||
return dataProvider.readAll(((UriResourceEntitySet) resourcePaths.get(0)).getEntitySet());
|
||||
if (resourcePaths.get(0) instanceof UriResourceFunction) {
|
||||
final UriResourceFunction uriResource = (UriResourceFunction) resourcePaths.get(0);
|
||||
return dataProvider.readFunctionEntitySet(uriResource.getFunction(), uriResource.getParameters());
|
||||
} else {
|
||||
return dataProvider.readAll(((UriResourceEntitySet) resourcePaths.get(0)).getEntitySet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,6 +185,21 @@ public abstract class TechnicalProcessor implements Processor {
|
|||
return (UriResourceNavigation) resourcePaths.get(--navigationCount);
|
||||
}
|
||||
|
||||
private void blockTypeFilters(final UriResource uriResource) throws ODataApplicationException {
|
||||
if (uriResource instanceof UriResourceEntitySet
|
||||
&& (((UriResourceEntitySet) uriResource).getTypeFilterOnCollection() != null
|
||||
|| ((UriResourceEntitySet) uriResource).getTypeFilterOnEntry() != null)
|
||||
|| uriResource instanceof UriResourceFunction
|
||||
&& (((UriResourceFunction) uriResource).getTypeFilterOnCollection() != null
|
||||
|| ((UriResourceFunction) uriResource).getTypeFilterOnEntry() != null)
|
||||
|| uriResource instanceof UriResourceNavigation
|
||||
&& (((UriResourceNavigation) uriResource).getTypeFilterOnCollection() != null
|
||||
|| ((UriResourceNavigation) uriResource).getTypeFilterOnEntry() != null)) {
|
||||
throw new ODataApplicationException("Type filters are not supported.",
|
||||
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
protected void validateOptions(final UriInfoResource uriInfo) throws ODataApplicationException {
|
||||
if (uriInfo.getIdOption() != null
|
||||
|| uriInfo.getSearchOption() != null) {
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ServerSidePagingHandler {
|
|||
public static void applyServerSidePaging(final SkipTokenOption skipTokenOption, final EntitySet entitySet,
|
||||
final EdmEntitySet edmEntitySet, final String rawRequestUri) throws ODataApplicationException {
|
||||
|
||||
if (shouldApplyServerSidePaging(edmEntitySet)) {
|
||||
if (edmEntitySet != null && shouldApplyServerSidePaging(edmEntitySet)) {
|
||||
final int maxPageSize = getMaxPageSize();
|
||||
final int page = getPage(skipTokenOption);
|
||||
final int itemsToSkip = maxPageSize * page;
|
||||
|
|
|
@ -123,19 +123,21 @@ public class ContainerProvider {
|
|||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINInvisibleRTInt16"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINInvisible2RTInt16"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETKeyNav"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESTwoKeyNav"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETTwoKeyNavParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTStringTwoParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollStringTwoParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTAllPrimTwoParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESMixPrimCollCompTwoParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTESMixPrimCollCompTwoParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollETMixPrimCollCompTwoParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrim"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETMedia"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESMedia"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESMedia"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrimParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrim"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollString"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTString"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESTwoKeyNavParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESTwoKeyNavParam"));
|
||||
functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrimParam"));
|
||||
|
||||
return container;
|
||||
|
@ -444,106 +446,120 @@ public class ContainerProvider {
|
|||
if (entityContainer.equals(nameContainer)) {
|
||||
if (name.equals("FINRTInt16")) {
|
||||
return new FunctionImport()
|
||||
.setName("FINRTInt16")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFNRTInt16)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FINInvisibleRTInt16")) {
|
||||
return new FunctionImport()
|
||||
.setName("FINInvisibleRTInt16")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFNRTInt16);
|
||||
|
||||
} else if (name.equals("FINInvisible2RTInt16")) {
|
||||
return new FunctionImport()
|
||||
.setName("FINInvisible2RTInt16")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFNRTInt16);
|
||||
|
||||
} else if (name.equals("FICRTETKeyNav")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTETKeyNav")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTETKeyNav);
|
||||
|
||||
} else if (name.equals("FICRTESTwoKeyNav")) {
|
||||
return new FunctionImport()
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTETTwoKeyNav)
|
||||
.setEntitySet(new Target().setEntityContainer(entityContainer).setTargetName("ESTwoKeyNav"))
|
||||
.setIncludeInServiceDocument(true);
|
||||
} else if (name.equals("FICRTETTwoKeyNavParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTETTwoKeyNavParam")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTETTwoKeyNavParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTStringTwoParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTStringTwoParam")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTStringTwoParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTCollStringTwoParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTCollStringTwoParam")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCollStringTwoParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTCTAllPrimTwoParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTCTAllPrimTwoParam")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCTAllPrimTwoParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTESMixPrimCollCompTwoParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTESMixPrimCollCompTwoParam")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTESMixPrimCollCompTwoParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FINRTESMixPrimCollCompTwoParam")) {
|
||||
} else if (name.equals("FICRTCollETMixPrimCollCompTwoParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FINRTESMixPrimCollCompTwoParam")
|
||||
.setFunction(FunctionProvider.nameUFNRTESMixPrimCollCompTwoParam)
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCollETMixPrimCollCompTwoParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTCollCTTwoPrim")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTCollCTTwoPrim")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCollCTTwoPrim)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTETMedia")) {
|
||||
} else if (name.equals("FICRTESMedia")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTETMedia")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTETMedia)
|
||||
.setEntitySet(new Target().setEntityContainer(entityContainer).setTargetName("ESMedia"))
|
||||
.setIncludeInServiceDocument(true);
|
||||
} else if (name.equals("FICRTCollESMedia")) {
|
||||
return new FunctionImport()
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCollETMedia)
|
||||
.setEntitySet(new Target().setEntityContainer(entityContainer).setTargetName("ESMedia"))
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTCTTwoPrimParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTCTTwoPrimParam")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCTTwoPrimParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTCTTwoPrim")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTCTTwoPrim")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCTTwoPrim)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTCollString")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTCollString")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCollString)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTString")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTString")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTString)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTESTwoKeyNavParam")) {
|
||||
} else if (name.equals("FICRTCollESTwoKeyNavParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTESTwoKeyNavParam")
|
||||
.setFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam)
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCollETTwoKeyNavParam)
|
||||
.setEntitySet(new Target().setEntityContainer(entityContainer).setTargetName("ESTwoKeyNav"))
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
} else if (name.equals("FICRTCollCTTwoPrimParam")) {
|
||||
return new FunctionImport()
|
||||
.setName("FICRTCollCTTwoPrimParam")
|
||||
.setName(name)
|
||||
.setFunction(FunctionProvider.nameUFCRTCollCTTwoPrimParam)
|
||||
.setIncludeInServiceDocument(true);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.olingo.server.api.edm.provider.ReturnType;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class FunctionProvider {
|
||||
|
@ -112,6 +113,12 @@ public class FunctionProvider {
|
|||
public static final FullQualifiedName nameBFESTwoKeyNavRTESTwoKeyNav =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "BFESTwoKeyNavRTESTwoKeyNav");
|
||||
|
||||
public static final FullQualifiedName nameBFCESTwoKeyNavRTCTNavFiveProp = new FullQualifiedName(
|
||||
SchemaProvider.NAMESPACE, "BFCESTwoKeyNavRTCTNavFiveProp");
|
||||
|
||||
public static final FullQualifiedName nameBFCESTwoKeyNavRTCollCTNavFiveProp = new FullQualifiedName(
|
||||
SchemaProvider.NAMESPACE, "BFCESTwoKeyNavRTCollCTNavFiveProp");
|
||||
|
||||
// Unbound Functions
|
||||
public static final FullQualifiedName nameUFCRTCollCTTwoPrim =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCollCTTwoPrim");
|
||||
|
@ -129,15 +136,19 @@ public class FunctionProvider {
|
|||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCTTwoPrimParam");
|
||||
public static final FullQualifiedName nameUFCRTESMixPrimCollCompTwoParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTESMixPrimCollCompTwoParam");
|
||||
public static final FullQualifiedName nameUFCRTESTwoKeyNavParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTESTwoKeyNavParam");
|
||||
public static final FullQualifiedName nameUFCRTCollETTwoKeyNavParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCollETTwoKeyNavParam");
|
||||
public static final FullQualifiedName nameUFCRTETAllPrimTwoParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTETAllPrimTwoParam");
|
||||
public static final FullQualifiedName nameUFCRTETKeyNav = new FullQualifiedName(SchemaProvider.NAMESPACE,
|
||||
"UFCRTETKeyNav");
|
||||
public static final FullQualifiedName nameUFCRTETMedia = new FullQualifiedName(SchemaProvider.NAMESPACE,
|
||||
"UFCRTETMedia");
|
||||
public static final FullQualifiedName nameUFCRTCollETMedia = new FullQualifiedName(SchemaProvider.NAMESPACE,
|
||||
"UFCRTCollETMedia");
|
||||
|
||||
public static final FullQualifiedName nameUFCRTETTwoKeyNav =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTETTwoKeyNav");
|
||||
public static final FullQualifiedName nameUFCRTETTwoKeyNavParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTETTwoKeyNavParam");
|
||||
|
||||
|
@ -150,30 +161,23 @@ public class FunctionProvider {
|
|||
public static final FullQualifiedName nameUFCRTStringTwoParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTStringTwoParam");
|
||||
|
||||
public static final FullQualifiedName nameUFNRTESMixPrimCollCompTwoParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFNRTESMixPrimCollCompTwoParam");
|
||||
public static final FullQualifiedName nameUFCRTCollETMixPrimCollCompTwoParam =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFCRTCollETMixPrimCollCompTwoParam");
|
||||
|
||||
public static final FullQualifiedName nameUFNRTInt16 =
|
||||
new FullQualifiedName(SchemaProvider.NAMESPACE, "UFNRTInt16");
|
||||
|
||||
public static final FullQualifiedName nameUFNRTCollCTNavFiveProp = new FullQualifiedName(SchemaProvider.NAMESPACE,
|
||||
"UFNRTCollCTNavFiveProp");
|
||||
|
||||
public static final FullQualifiedName nameBFCESTwoKeyNavRTCTNavFiveProp = new FullQualifiedName(
|
||||
SchemaProvider.NAMESPACE, "BFCESTwoKeyNavRTCTNavFiveProp");
|
||||
|
||||
public static final FullQualifiedName nameBFCESTwoKeyNavRTCollCTNavFiveProp = new FullQualifiedName(
|
||||
SchemaProvider.NAMESPACE, "BFCESTwoKeyNavRTCollCTNavFiveProp");
|
||||
|
||||
public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
|
||||
|
||||
if (functionName.equals(nameUFNRTInt16)) {
|
||||
return Arrays.asList(
|
||||
new Function()
|
||||
.setName("UFNRTInt16")
|
||||
.setParameters(new ArrayList<Parameter>())
|
||||
.setReturnType(
|
||||
new ReturnType().setType(PropertyProvider.nameInt16))
|
||||
);
|
||||
.setName(functionName.getName())
|
||||
.setParameters(Collections.<Parameter> emptyList())
|
||||
.setReturnType(new ReturnType().setType(PropertyProvider.nameInt16)));
|
||||
|
||||
} else if (functionName.equals(nameUFCRTETKeyNav)) {
|
||||
return Arrays.asList(
|
||||
|
@ -185,6 +189,14 @@ public class FunctionProvider {
|
|||
new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
|
||||
);
|
||||
|
||||
} else if (functionName.equals(nameUFCRTETTwoKeyNav)) {
|
||||
return Collections.singletonList(
|
||||
new Function()
|
||||
.setName(functionName.getName())
|
||||
.setParameters(Collections.<Parameter> emptyList())
|
||||
.setComposable(true)
|
||||
.setReturnType(
|
||||
new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)));
|
||||
} else if (functionName.equals(nameUFCRTETTwoKeyNavParam)) {
|
||||
return Arrays.asList(
|
||||
new Function()
|
||||
|
@ -238,11 +250,11 @@ public class FunctionProvider {
|
|||
|
||||
);
|
||||
|
||||
} else if (functionName.equals(nameUFCRTESTwoKeyNavParam)) {
|
||||
} else if (functionName.equals(nameUFCRTCollETTwoKeyNavParam)) {
|
||||
return Arrays.asList(
|
||||
new Function()
|
||||
.setName("UFCRTESTwoKeyNavParam")
|
||||
.setParameters(Arrays.asList(
|
||||
.setParameters(Collections.singletonList(
|
||||
new Parameter()
|
||||
.setName("ParameterInt16")
|
||||
.setType(PropertyProvider.nameInt16)
|
||||
|
@ -351,8 +363,16 @@ public class FunctionProvider {
|
|||
.setReturnType(
|
||||
new ReturnType().setType(EntityTypeProvider.nameETMedia).setNullable(false))
|
||||
);
|
||||
} else if (functionName.equals(nameUFCRTCollETMedia)) {
|
||||
return Arrays.asList(
|
||||
new Function()
|
||||
.setName(functionName.getName())
|
||||
.setParameters(Collections.<Parameter> emptyList())
|
||||
.setComposable(true)
|
||||
.setReturnType(
|
||||
new ReturnType().setType(EntityTypeProvider.nameETMedia).setCollection(true).setNullable(false)));
|
||||
|
||||
} else if (functionName.equals(nameUFNRTESMixPrimCollCompTwoParam)) {
|
||||
} else if (functionName.equals(nameUFCRTCollETMixPrimCollCompTwoParam)) {
|
||||
return Arrays.asList(
|
||||
new Function()
|
||||
.setName("UFNRTESMixPrimCollCompTwoParam")
|
||||
|
|
|
@ -130,7 +130,7 @@ public class SchemaProvider {
|
|||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETTwoKeyNavParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETTwoKeyNavParamCTTwoPrim));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTStringTwoParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTESTwoKeyNavParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollETTwoKeyNavParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTString));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollStringTwoParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollString));
|
||||
|
@ -140,7 +140,7 @@ public class SchemaProvider {
|
|||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrim));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrim));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETMedia));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTESMixPrimCollCompTwoParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollETMixPrimCollCompTwoParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETAllPrimTwoParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTESMixPrimCollCompTwoParam));
|
||||
functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTCollCTNavFiveProp));
|
||||
|
|
|
@ -299,7 +299,7 @@ public class ODataHandlerTest {
|
|||
any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));
|
||||
|
||||
EntityCollectionProcessor entityCollectionProcessor = mock(EntityCollectionProcessor.class);
|
||||
dispatch(HttpMethod.GET, "FICRTESTwoKeyNavParam(ParameterInt16=123)", entityCollectionProcessor);
|
||||
dispatch(HttpMethod.GET, "FICRTCollESTwoKeyNavParam(ParameterInt16=123)", entityCollectionProcessor);
|
||||
verify(entityCollectionProcessor).readEntityCollection(
|
||||
any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));
|
||||
|
||||
|
|
|
@ -219,11 +219,11 @@ public class UriResourceImplTest {
|
|||
|
||||
// function collection
|
||||
impl = new UriResourceFunctionImpl();
|
||||
functionImport = edm.getEntityContainer(null).getFunctionImport("FICRTESTwoKeyNavParam");
|
||||
functionImport = edm.getEntityContainer(null).getFunctionImport("FICRTCollESTwoKeyNavParam");
|
||||
assertNotNull(function);
|
||||
UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
|
||||
impl.setFunctionImport(functionImport, Arrays.asList(parameter));
|
||||
assertEquals("FICRTESTwoKeyNavParam", impl.toString());
|
||||
assertEquals("FICRTCollESTwoKeyNavParam", impl.toString());
|
||||
|
||||
impl.setFunction(functionImport.getUnboundFunction(Arrays.asList("ParameterInt16")));
|
||||
assertEquals(true, impl.isCollection());
|
||||
|
|
|
@ -1699,13 +1699,13 @@ public class TestFullResourcePath {
|
|||
.n()
|
||||
.isFunction("BFCETBaseTwoKeyNavRTETTwoKeyNav");
|
||||
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)"
|
||||
+ "/olingo.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
|
||||
+ "/olingo.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
|
||||
|
@ -1733,10 +1733,10 @@ public class TestFullResourcePath {
|
|||
.isKeyPredicate(0, "PropertyInt16", "2")
|
||||
.isKeyPredicate(1, "PropertyString", "'3'");
|
||||
|
||||
testUri.run("FICRTETMedia()/$value")
|
||||
testUri.run("FICRTESMedia()/$value")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTETMedia")
|
||||
.isFunctionImport("FICRTESMedia")
|
||||
.isFunction("UFCRTETMedia")
|
||||
.n()
|
||||
.isValue();
|
||||
|
@ -1748,11 +1748,11 @@ public class TestFullResourcePath {
|
|||
.isFunction("UFCRTETKeyNav")
|
||||
.n()
|
||||
.isRef();
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/$ref")
|
||||
testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/$ref")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTETTwoKeyNavParam")
|
||||
.isFunction("UFCRTETTwoKeyNavParam")
|
||||
.n()
|
||||
.isRef();
|
||||
|
||||
|
@ -1777,12 +1777,12 @@ public class TestFullResourcePath {
|
|||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)"
|
||||
+ "/olingo.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
|
||||
|
@ -1802,11 +1802,11 @@ public class TestFullResourcePath {
|
|||
.isParameter(1, "ParameterString", "'2'")
|
||||
.isType(EntityTypeProvider.nameETMixPrimCollComp);
|
||||
|
||||
testUri.run("FINRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
|
||||
testUri.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FINRTESMixPrimCollCompTwoParam")
|
||||
.isFunction("UFNRTESMixPrimCollCompTwoParam")
|
||||
.isFunctionImport("FICRTESMixPrimCollCompTwoParam")
|
||||
.isFunction("UFCRTESMixPrimCollCompTwoParam")
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isParameter(1, "ParameterString", "'2'")
|
||||
.isType(EntityTypeProvider.nameETMixPrimCollComp);
|
||||
|
@ -1836,53 +1836,53 @@ public class TestFullResourcePath {
|
|||
@Test
|
||||
public void runFunctionImpEsAlias() throws Exception {
|
||||
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@parameterAlias)", "@parameterAlias=1");
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@parameterAlias)/$count", "@parameterAlias=1");
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@invalidAlias)", "@validAlias=1");
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=@parameterAlias)", "@parameterAlias=1");
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=@parameterAlias)/$count", "@parameterAlias=1");
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=@invalidAlias)", "@validAlias=1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runFunctionImpEsCast() throws Exception {
|
||||
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/olingo.odata.test1.ETBaseTwoKeyNav")
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)/olingo.odata.test1.ETBaseTwoKeyNav")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/olingo.odata.test1.ETBaseTwoKeyNav/$count")
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)/olingo.odata.test1.ETBaseTwoKeyNav/$count")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
|
||||
.n()
|
||||
.isCount();
|
||||
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)"
|
||||
+ "/olingo.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
|
||||
.isKeyPredicate(0, "PropertyInt16", "2")
|
||||
.isKeyPredicate(1, "PropertyString", "'3'");
|
||||
|
||||
testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
|
||||
testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)"
|
||||
+ "/olingo.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
|
||||
+ "/olingo.odata.test1.ETTwoBaseTwoKeyNav")
|
||||
.isKind(UriInfoKind.resource).goPath()
|
||||
.first()
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
|
||||
|
|
|
@ -655,9 +655,9 @@ public class TestUriParserImpl {
|
|||
.isType(EntityTypeProvider.nameETTwoKeyNav, false);
|
||||
|
||||
// returning collection of entity (aka entitySet)
|
||||
testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)")
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
testRes.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav, true);
|
||||
}
|
||||
|
||||
|
@ -686,20 +686,20 @@ public class TestUriParserImpl {
|
|||
.isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
|
||||
|
||||
// test chains; returning collection of entity (aka entitySet)
|
||||
testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')")
|
||||
testRes.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')")
|
||||
.at(0)
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav, false)
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||
.isKeyPredicate(1, "PropertyString", "'ABC'");
|
||||
|
||||
// test chains; returning collection of entity (aka entitySet)
|
||||
testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')/PropertyInt16")
|
||||
testRes.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')/PropertyInt16")
|
||||
.at(0)
|
||||
.isFunctionImport("FICRTESTwoKeyNavParam")
|
||||
.isFunction("UFCRTESTwoKeyNavParam")
|
||||
.isFunctionImport("FICRTCollESTwoKeyNavParam")
|
||||
.isFunction("UFCRTCollETTwoKeyNavParam")
|
||||
.isType(EntityTypeProvider.nameETTwoKeyNav, false)
|
||||
.isParameter(0, "ParameterInt16", "1")
|
||||
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||
|
|
|
@ -171,7 +171,7 @@ public class ExpressionTest {
|
|||
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
EdmEntityType entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTCollETTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityBaseType))
|
||||
.asUriInfoResource());
|
||||
|
@ -179,7 +179,7 @@ public class ExpressionTest {
|
|||
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTCollETTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceFunctionImpl().setFunction(function).setCollectionTypeFilter(entityBaseType))
|
||||
.asUriInfoResource());
|
||||
|
@ -187,7 +187,7 @@ public class ExpressionTest {
|
|||
|
||||
// no typed
|
||||
entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
function = edm.getUnboundFunction(FunctionProvider.nameUFCRTCollETTwoKeyNavParam, Arrays.asList("ParameterInt16"));
|
||||
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.all));
|
||||
assertEquals(null, expression.getType());
|
||||
|
||||
|
|
|
@ -145,11 +145,11 @@ public class UriValidatorTest {
|
|||
|
||||
{ "FINRTInt16()" },
|
||||
{ "FICRTETKeyNav()" },
|
||||
{ "FICRTESTwoKeyNavParam(ParameterInt16=1)" },
|
||||
{ "FICRTETTwoKeyNavParam(ParameterInt16=1)" },
|
||||
{ "FICRTCollString()" },
|
||||
{ "FICRTCTTwoPrim()" },
|
||||
{ "FICRTCollCTTwoPrim()" },
|
||||
{ "FICRTETMedia()" },
|
||||
{ "FICRTESMedia()" },
|
||||
|
||||
{ "ESTwoKeyNav/olingo.odata.test1.BAESTwoKeyNavRTESTwoKeyNav" },
|
||||
{ "ESAllPrim/olingo.odata.test1.BAESAllPrimRTETAllPrim" },
|
||||
|
|
Loading…
Reference in New Issue