[OLINGO-575] Merge EdmImpl classes

This commit is contained in:
Christian Amend 2015-03-18 13:55:50 +01:00
parent 36219d3258
commit 5cef4faeb6
112 changed files with 682 additions and 2687 deletions

View File

@ -30,11 +30,12 @@ import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.EdmEnabledODataClient;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.client.core.edm.EdmClientImpl;
import org.apache.olingo.client.core.edm.ClientEdmProvider;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.ext.proxy.api.AbstractTerm;
import org.apache.olingo.ext.proxy.api.PersistenceManager;
import org.apache.olingo.ext.proxy.commons.EntityContainerInvocationHandler;
@ -83,10 +84,15 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> {
IOUtils.closeQuietly(gzis);
IOUtils.closeQuietly(bais);
}
final Edm edm = metadata == null ? null : new EdmClientImpl(metadata.getSchemaByNsOrAlias());
//TODO: check runtime exception or not
if(version.compareTo(ODataServiceVersion.V40) < 0){
final Edm edm;
if (metadata != null) {
ClientEdmProvider provider = new ClientEdmProvider(metadata.getSchemaByNsOrAlias());
edm = new EdmProviderImpl(provider);
}else{
edm = null;
}
// TODO: check runtime exception or not
if (version.compareTo(ODataServiceVersion.V40) < 0) {
throw new ODataRuntimeException("Only OData V4 or higher supported.");
}
@ -140,7 +146,7 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> {
if (!ENTITY_CONTAINERS.containsKey(reference)) {
final Object entityContainer = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {reference},
new Class<?>[] { reference },
EntityContainerInvocationHandler.getInstance(reference, this));
ENTITY_CONTAINERS.put(reference, entityContainer);
}

View File

@ -34,5 +34,4 @@ public @interface EntityContainer {
String namespace();
boolean isDefaultEntityContainer() default false;
}

View File

@ -26,7 +26,6 @@ import java.lang.reflect.UndeclaredThrowableException;
import java.net.URI;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
@ -35,8 +34,6 @@ import org.apache.olingo.client.api.EdmEnabledODataClient;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.ComplexType;
@ -213,15 +210,16 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
final String containerNS, final String entitySetName, final AbstractService<?> service) {
final URIBuilder uriBuilder = service.getClient().newURIBuilder();
final Edm edm = service.getClient().getCachedEdm();
// final Edm edm = service.getClient().getCachedEdm();
final StringBuilder entitySetSegment = new StringBuilder();
if (StringUtils.isNotBlank(containerNS)) {
final EdmEntityContainer container = edm.getEntityContainer(new FullQualifiedName(containerNS));
if (!container.isDefault()) {
entitySetSegment.append(container.getFullQualifiedName().toString()).append('.');
}
}
//TODO: Container is always default in v4
// if (StringUtils.isNotBlank(containerNS)) {
// final EdmEntityContainer container = edm.getEntityContainer(new FullQualifiedName(containerNS));
// if (!container.isDefault()) {
// entitySetSegment.append(container.getFullQualifiedName().toString()).append('.');
// }
// }
entitySetSegment.append(entitySetName);
uriBuilder.appendEntitySetSegment(entitySetSegment.toString());

View File

@ -46,8 +46,6 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
protected final String namespace;
private final String name;
private final boolean defaultEC;
public static EntityContainerInvocationHandler getInstance(final Class<?> ref, final AbstractService<?> service) {
final EntityContainerInvocationHandler instance = new EntityContainerInvocationHandler(ref, service);
@ -64,7 +62,6 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
}
this.name = ((EntityContainer) annotation).name();
this.defaultEC = ((EntityContainer) annotation).isDefaultEntityContainer();
this.namespace = ((EntityContainer) annotation).namespace();
}
@ -72,10 +69,6 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
return service;
}
protected boolean isDefaultEntityContainer() {
return defaultEC;
}
protected String getEntityContainerName() {
return name;
}

View File

@ -49,9 +49,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmElement;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmTerm;
@ -655,22 +653,22 @@ public final class CoreUtils {
public static URI getTargetEntitySetURI(
final EdmEnabledODataClient client, final NavigationProperty property) {
final Edm edm = client.getCachedEdm();
// final Edm edm = client.getCachedEdm();
//
// final FullQualifiedName containerName =
// new FullQualifiedName(property.targetSchema(), property.targetContainer());
final FullQualifiedName containerName =
new FullQualifiedName(property.targetSchema(), property.targetContainer());
final EdmEntityContainer container = edm.getEntityContainer(containerName);
// final EdmEntityContainer container = edm.getEntityContainer(containerName);
final URIBuilder uriBuilder = client.newURIBuilder(client.getServiceRoot());
if (!container.isDefault()) {
final StringBuilder entitySetSegment = new StringBuilder();
entitySetSegment.append(container.getFullQualifiedName()).append('.');
entitySetSegment.append(property.targetEntitySet());
uriBuilder.appendEntitySetSegment(entitySetSegment.toString());
} else {
//TODO: Container can only be default in V4
// if (!container.isDefault()) {
// final StringBuilder entitySetSegment = new StringBuilder();
// entitySetSegment.append(container.getFullQualifiedName()).append('.');
// entitySetSegment.append(property.targetEntitySet());
// uriBuilder.appendEntitySetSegment(entitySetSegment.toString());
// } else {
uriBuilder.appendEntitySetSegment(property.targetEntitySet());
}
// }
return uriBuilder.build();
}

View File

@ -56,8 +56,7 @@ import javax.xml.datatype.Duration;
@org.apache.olingo.ext.proxy.api.annotations.Namespace("$namespace")
@org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "$container.Name",
namespace = "$namespace",
isDefaultEntityContainer = $container.Default)
namespace = "$namespace")
public interface $utility.capitalize($container.Name) extends PersistenceManager {
#foreach($entitySet in $container.EntitySets)

View File

@ -33,8 +33,7 @@ import java.io.InputStream;
@org.apache.olingo.ext.proxy.api.annotations.Namespace("ODataDemo")
@org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "DemoService",
namespace = "ODataDemo",
isDefaultEntityContainer = true)
namespace = "ODataDemo")
public interface DemoService extends PersistenceManager {
Products getProducts();

View File

@ -32,8 +32,7 @@ import java.io.InputStream;
@org.apache.olingo.ext.proxy.api.annotations.Namespace("Microsoft.Test.OData.Services.OpenTypesServiceV4")
@org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "DefaultContainer",
namespace = "Microsoft.Test.OData.Services.OpenTypesServiceV4",
isDefaultEntityContainer = true)
namespace = "Microsoft.Test.OData.Services.OpenTypesServiceV4")
public interface DefaultContainer extends PersistenceManager {
Row getRow();

View File

@ -33,8 +33,7 @@ import java.io.InputStream;
@org.apache.olingo.ext.proxy.api.annotations.Namespace("Microsoft.Test.OData.Services.ODataWCFService")
@org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "InMemoryEntities",
namespace = "Microsoft.Test.OData.Services.ODataWCFService",
isDefaultEntityContainer = true)
namespace = "Microsoft.Test.OData.Services.ODataWCFService")
public interface InMemoryEntities extends PersistenceManager {
Accounts getAccounts();

View File

@ -0,0 +1,211 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.Function;
import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
public class ClientEdmProvider extends EdmProvider {
private final Map<String, Schema> xmlSchemas;
public ClientEdmProvider(Map<String, Schema> xmlSchemas) {
this.xmlSchemas = xmlSchemas;
}
@Override
public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
Schema schema = xmlSchemas.get(enumTypeName.getNamespace());
if (schema != null) {
return schema.getEnumType(enumTypeName.getName());
}
return null;
}
@Override
public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException {
Schema schema = xmlSchemas.get(typeDefinitionName.getNamespace());
if (schema != null) {
return schema.getTypeDefinition(typeDefinitionName.getName());
}
return null;
}
@Override
public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
Schema schema = xmlSchemas.get(entityTypeName.getNamespace());
if (schema != null) {
return schema.getEntityType(entityTypeName.getName());
}
return null;
}
@Override
public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
Schema schema = xmlSchemas.get(complexTypeName.getNamespace());
if (schema != null) {
return schema.getComplexType(complexTypeName.getName());
}
return null;
}
@Override
public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
Schema schema = xmlSchemas.get(actionName.getNamespace());
if (schema != null) {
return schema.getActions(actionName.getName());
}
return null;
}
@Override
public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
Schema schema = xmlSchemas.get(functionName.getNamespace());
if (schema != null) {
return schema.getFunctions(functionName.getName());
}
return null;
}
@Override
public Term getTerm(final FullQualifiedName termName) throws ODataException {
Schema schema = xmlSchemas.get(termName.getNamespace());
if (schema != null) {
return schema.getTerm(termName.getName());
}
return null;
}
@Override
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
throws ODataException {
Schema schema = xmlSchemas.get(entityContainer.getNamespace());
if (schema != null) {
return schema.getEntityContainer().getEntitySet(entitySetName);
}
return null;
}
@Override
public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName)
throws ODataException {
Schema schema = xmlSchemas.get(entityContainer.getNamespace());
if (schema != null) {
return schema.getEntityContainer().getSingleton(singletonName);
}
return null;
}
@Override
public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName)
throws ODataException {
Schema schema = xmlSchemas.get(entityContainer.getNamespace());
if (schema != null) {
return schema.getEntityContainer().getActionImport(actionImportName);
}
return null;
}
@Override
public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName)
throws ODataException {
Schema schema = xmlSchemas.get(entityContainer.getNamespace());
if (schema != null) {
return schema.getEntityContainer().getFunctionImport(functionImportName);
}
return null;
}
@Override
public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
for (Schema schema : xmlSchemas.values()) {
if (schema.getEntityContainer() != null) {
return new EntityContainerInfo().setContainerName(entityContainerName).setExtendsContainer(
schema.getEntityContainer().getExtendsContainerFQN());
}
}
return null;
}
@Override
public List<AliasInfo> getAliasInfos() throws ODataException {
ArrayList<AliasInfo> aliasInfo = new ArrayList<AliasInfo>();
for (Schema schema : xmlSchemas.values()) {
if (schema.getAlias() != null) {
aliasInfo.add(new AliasInfo().setNamespace(schema.getNamespace()).setAlias(schema.getAlias()));
}
}
return aliasInfo;
}
@Override
public List<Schema> getSchemas() throws ODataException {
return new ArrayList<Schema>(xmlSchemas.values());
}
@Override
public EntityContainer getEntityContainer() throws ODataException {
for (Schema schema : xmlSchemas.values()) {
if (schema.getEntityContainer() != null) {
return schema.getEntityContainer();
}
}
return null;
}
@Override
public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException {
Schema schema = xmlSchemas.get(targetName.getNamespace());
if (schema != null) {
return schema.getAnnotationGroup(targetName.getName());
}
return null;
}
@Override
public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException {
final Schema schema = xmlSchemas.get(annotatedName.getNamespace());
if (schema != null) {
return schema.getAnnotatables().get(annotatedName.getName());
}
return null;
}
}

View File

@ -1,36 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.Action;
public class EdmActionImpl extends EdmOperationImpl implements EdmAction {
public static EdmActionImpl getInstance(final Edm edm, final FullQualifiedName name, final Action action) {
return EdmOperationImpl.getInstance(new EdmActionImpl(edm, name, action));
}
private EdmActionImpl(final Edm edm, final FullQualifiedName name, final Action action) {
super(edm, name, action, EdmTypeKind.ACTION);
}
}

View File

@ -1,77 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport {
private final ActionImport actionImport;
private final EdmAnnotationHelper helper;
private FullQualifiedName actionFQN;
public EdmActionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
final ActionImport actionImport) {
super(edm, container, name, actionImport.getEntitySet());
this.actionImport = actionImport;
this.helper = new EdmAnnotationHelperImpl(edm, actionImport);
}
public FullQualifiedName getActionFQN() {
if (actionFQN == null) {
actionFQN = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(actionImport.getAction()).
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName();
}
return actionFQN;
}
@Override
public EdmAction getUnboundAction() {
return edm.getUnboundAction(getActionFQN());
}
@Override
public TargetType getAnnotationsTargetType() {
return TargetType.ActionImport;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -1,357 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmAnnotations;
import org.apache.olingo.commons.api.edm.EdmComplexType;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.Function;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.AbstractEdm;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmClientImpl extends AbstractEdm {
private final List<Schema> xmlSchemas;
private final Map<String, Schema> xmlSchemaByNamespace;
public EdmClientImpl(final Map<String, Schema> xmlSchemas) {
this.xmlSchemaByNamespace = xmlSchemas;
this.xmlSchemas = new ArrayList<Schema>();
for (Schema schema : xmlSchemaByNamespace.values()) {
if (!this.xmlSchemas.contains(schema)) {
this.xmlSchemas.add(schema);
}
}
}
@Override
protected Map<String, String> createAliasToNamespaceInfo() {
final Map<String, String> aliasToNamespace = new HashMap<String, String>();
for (Schema schema : xmlSchemas) {
aliasToNamespace.put(null, schema.getNamespace());
if (StringUtils.isNotBlank(schema.getAlias())) {
aliasToNamespace.put(schema.getAlias(), schema.getNamespace());
}
}
return aliasToNamespace;
}
@Override
protected Map<String, EdmSchema> createSchemas() {
final Map<String, EdmSchema> _schemas = new LinkedHashMap<String, EdmSchema>(xmlSchemas.size());
for (Schema schema : xmlSchemas) {
_schemas.put(schema.getNamespace(), new EdmSchemaImpl(this, schema));
}
return _schemas;
}
@Override
protected EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) {
EdmEntityContainer result = null;
final Schema schema = xmlSchemaByNamespace.get(containerName.getNamespace());
if (schema != null) {
final EntityContainer xmlEntityContainer = schema.getEntityContainer();
if (xmlEntityContainer != null) {
result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer);
}
}
return result;
}
@Override
protected EdmEnumType createEnumType(final FullQualifiedName enumName) {
EdmEnumType result = null;
final Schema schema = xmlSchemaByNamespace.get(enumName.getNamespace());
if (schema != null) {
final EnumType xmlEnumType = schema.getEnumType(enumName.getName());
if (xmlEnumType != null) {
result = new EdmEnumTypeImpl(this, enumName, xmlEnumType);
}
}
return result;
}
@Override
protected EdmTypeDefinition createTypeDefinition(final FullQualifiedName typeDefinitionName) {
EdmTypeDefinition result = null;
final Schema schema = xmlSchemaByNamespace.get(typeDefinitionName.getNamespace());
if (schema != null) {
final TypeDefinition xmlTypeDefinition = schema.
getTypeDefinition(typeDefinitionName.getName());
if (xmlTypeDefinition != null) {
result = new EdmTypeDefinitionImpl(this, typeDefinitionName, xmlTypeDefinition);
}
}
return result;
}
@Override
protected EdmEntityType createEntityType(final FullQualifiedName entityTypeName) {
EdmEntityType result = null;
final Schema schema = xmlSchemaByNamespace.get(entityTypeName.getNamespace());
if (schema != null) {
final EntityType xmlEntityType = schema.getEntityType(entityTypeName.getName());
if (xmlEntityType != null) {
result = EdmEntityTypeImpl.getInstance(this, entityTypeName, xmlEntityType);
}
}
return result;
}
@Override
protected EdmComplexType createComplexType(final FullQualifiedName complexTypeName) {
EdmComplexType result = null;
final Schema schema = xmlSchemaByNamespace.get(complexTypeName.getNamespace());
if (schema != null) {
final ComplexType xmlComplexType = schema.getComplexType(complexTypeName.getName());
if (xmlComplexType != null) {
result = EdmComplexTypeImpl.getInstance(this, complexTypeName, xmlComplexType);
}
}
return result;
}
@Override
protected EdmAction createUnboundAction(final FullQualifiedName actionName) {
EdmAction result = null;
final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace());
final List<Action> actions = schema.
getActions(actionName.getName());
boolean found = false;
for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
final Action action = itor.next();
if (!action.isBound()) {
found = true;
result = EdmActionImpl.getInstance(this, actionName, action);
}
}
return result;
}
@Override
protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) {
final List<EdmFunction> result = new ArrayList<EdmFunction>();
final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
final List<Function> functions = schema.
getFunctions(functionName.getName());
for (final Iterator<Function> itor = functions.iterator(); itor.hasNext();) {
final Function function = itor.next();
if (!function.isBound()) {
result.add(EdmFunctionImpl.getInstance(this, functionName, function));
}
}
return result;
}
@Override
protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
EdmFunction result = null;
final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
final List<Function> functions = schema.
getFunctions(functionName.getName());
boolean found = false;
for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
final Function function = itor.next();
if (!function.isBound()) {
final Set<String> functionParamNames = new HashSet<String>();
for (Parameter param : function.getParameters()) {
functionParamNames.add(param.getName());
}
found = parameterNames == null
? functionParamNames.isEmpty()
: functionParamNames.containsAll(parameterNames);
result = EdmFunctionImpl.getInstance(this, functionName, function);
}
}
return result;
}
@Override
protected EdmAction createBoundAction(final FullQualifiedName actionName,
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
EdmAction result = null;
final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace());
final List<Action> actions =
schema.getActions(actionName.getName());
boolean found = false;
for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
final Action action = itor.next();
if (action.isBound()) {
final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
setTypeExpression(action.getParameters().get(0).getType()).build();
if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
&& (isBindingParameterCollection == null
|| isBindingParameterCollection.booleanValue() == boundParam.isCollection())) {
found = true;
result = EdmActionImpl.getInstance(this, actionName, action);
}
}
}
return result;
}
@Override
protected EdmFunction createBoundFunction(final FullQualifiedName functionName,
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
final List<String> parameterNames) {
EdmFunction result = null;
final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
final List<Function> functions = schema.
getFunctions(functionName.getName());
boolean found = false;
for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
final Function function = itor.next();
if (function.isBound()) {
final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
setTypeExpression(function.getParameters().get(0).getType()).build();
if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
&& (isBindingParameterCollection == null
|| isBindingParameterCollection.booleanValue() == boundParam.isCollection())) {
final Set<String> functionParamNames = new HashSet<String>();
for (Parameter param : function.getParameters()) {
functionParamNames.add(param.getName());
}
found = parameterNames == null
? functionParamNames.isEmpty()
: functionParamNames.containsAll(parameterNames);
result = EdmFunctionImpl.getInstance(this, functionName, function);
}
}
}
return result;
}
@Override
protected EdmTerm createTerm(final FullQualifiedName termName) {
EdmTerm result = null;
final Schema schema = xmlSchemaByNamespace.get(termName.getNamespace());
if (schema != null) {
final Term term = schema.getTerm(termName.getName());
if (term != null) {
result = new EdmTermImpl(this, schema.getNamespace(), term);
}
}
return result;
}
@Override
protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) {
EdmAnnotationsImpl result = null;
final Schema schema = xmlSchemaByNamespace.get(targetName.getNamespace());
final Annotations annotationGroup =
schema.getAnnotationGroup(targetName.getName());
if (annotationGroup != null) {
result = new EdmAnnotationsImpl(this, schemas.get(schema.getNamespace()), annotationGroup);
}
return result;
}
@Override
protected List<EdmAnnotation> createAnnotations(final FullQualifiedName annotatedName) {
List<EdmAnnotation> result = null;
final Schema schema = xmlSchemaByNamespace.get(annotatedName.getNamespace());
final Annotatable annotatable =
schema.getAnnotatables().get(annotatedName.getName());
if (annotatable != null && annotatable.getAnnotations() != null) {
result = new ArrayList<EdmAnnotation>();
for (Annotation annotation : annotatable.getAnnotations()) {
final EdmTerm term = getTerm(new FullQualifiedName(annotation.getTerm()));
result.add(new EdmAnnotationImpl(this, annotation));
}
}
return result;
}
@Override
public boolean equals(final Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}

View File

@ -1,93 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.core.edm.AbstractEdmComplexType;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmComplexTypeImpl extends AbstractEdmComplexType {
private final EdmStructuredTypeHelper typeHelper;
private EdmAnnotationHelper annotationHelper;
public static EdmComplexTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn,
final ComplexType complexType) {
FullQualifiedName baseTypeName = null;
final String baseType = complexType.getBaseType();
baseTypeName = baseType == null
? null : new EdmTypeInfo.Builder().setTypeExpression(baseType).build().getFullQualifiedName();
final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, fqn, baseTypeName, complexType);
instance.baseType = instance.buildBaseType(baseTypeName);
return instance;
}
private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName,
final ComplexType complexType) {
super(edm, fqn, baseTypeName);
this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), complexType);
this.annotationHelper = new EdmAnnotationHelperImpl(edm, complexType);
}
@Override
protected Map<String, EdmProperty> getProperties() {
return typeHelper.getProperties();
}
@Override
protected Map<String, EdmNavigationProperty> getNavigationProperties() {
return typeHelper.getNavigationProperties();
}
@Override
public boolean isOpenType() {
return typeHelper.isOpenType();
}
@Override
public boolean isAbstract() {
return typeHelper.isAbstract();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return annotationHelper == null ? null : annotationHelper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return annotationHelper == null ? null : annotationHelper.getAnnotations();
}
}

View File

@ -1,173 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.core.edm.AbstractEdmEntityContainer;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
private final EntityContainer xmlEntityContainer;
private EdmAnnotationHelper helper;
public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
final EntityContainer xmlEntityContainer) {
super(edm, entityContainerName, xmlEntityContainer.getExtendsContainer() == null
? null : new FullQualifiedName(xmlEntityContainer.getExtendsContainer()));
this.xmlEntityContainer = xmlEntityContainer;
this.helper = new EdmAnnotationHelperImpl(edm, xmlEntityContainer);
}
@Override
public boolean isDefault() {
return true;
}
@Override
protected EdmSingleton createSingleton(final String singletonName) {
final Singleton singleton = xmlEntityContainer.getSingleton(singletonName);
return singleton == null
? null
: new EdmSingletonImpl(edm, this, singletonName, new EdmTypeInfo.Builder().
setTypeExpression(singleton.getType()).
setDefaultNamespace(entityContainerName.getNamespace()).
build().getFullQualifiedName(), singleton);
}
@Override
protected EdmEntitySet createEntitySet(final String entitySetName) {
EdmEntitySet result = null;
final EntitySet entitySet = xmlEntityContainer.getEntitySet(entitySetName);
if (entitySet != null) {
final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getType()).
setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
result = new EdmEntitySetImpl(edm, this, entitySetName, entityType, entitySet);
}
return result;
}
@Override
protected EdmActionImport createActionImport(final String actionImportName) {
EdmActionImport result = null;
final ActionImport actionImport = xmlEntityContainer.getActionImport(actionImportName);
if (actionImport != null) {
result = new EdmActionImportImpl(edm, this, actionImportName, actionImport);
}
return result;
}
@Override
protected EdmFunctionImport createFunctionImport(final String functionImportName) {
EdmFunctionImport result = null;
final FunctionImport functionImport = xmlEntityContainer.getFunctionImport(functionImportName);
if (functionImport != null) {
result = new EdmFunctionImportImpl(edm, this, functionImportName, functionImport);
}
return result;
}
@Override
protected void loadAllEntitySets() {
List<? extends EntitySet> localEntitySets = xmlEntityContainer.getEntitySets();
if (localEntitySets != null) {
for (EntitySet entitySet : localEntitySets) {
EdmEntitySet edmSet;
final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getType()).
setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
edmSet = new EdmEntitySetImpl(edm, this, entitySet.getName(), entityType, entitySet);
entitySets.put(edmSet.getName(), edmSet);
}
}
}
@Override
protected void loadAllFunctionImports() {
final List<? extends FunctionImport> localFunctionImports = xmlEntityContainer.getFunctionImports();
for (FunctionImport functionImport : localFunctionImports) {
EdmFunctionImport edmFunctionImport;
edmFunctionImport = new EdmFunctionImportImpl(edm, this, functionImport.getName(), functionImport);
functionImports.put(edmFunctionImport.getName(), edmFunctionImport);
}
}
@Override
protected void loadAllSingletons() {
final List<Singleton> localSingletons = xmlEntityContainer.getSingletons();
if (localSingletons != null) {
for (Singleton singleton : localSingletons) {
singletons.put(singleton.getName(), new EdmSingletonImpl(edm, this, singleton.getName(),
new EdmTypeInfo.Builder().
setTypeExpression(singleton.getType()).setDefaultNamespace(entityContainerName.getNamespace()).
build().getFullQualifiedName(), singleton));
}
}
}
@Override
protected void loadAllActionImports() {
final List<ActionImport> localActionImports = xmlEntityContainer.getActionImports();
if (actionImports != null) {
for (ActionImport actionImport : localActionImports) {
actionImports.put(actionImport.getName(), new EdmActionImportImpl(edm, this, actionImport.getName(),
actionImport));
}
}
}
@Override
public TargetType getAnnotationsTargetType() {
return TargetType.EntityContainer;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper == null ? null : helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper == null ? Collections.<EdmAnnotation> emptyList() : helper.getAnnotations();
}
}

View File

@ -1,48 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
private final EntitySet entitySet;
public EdmEntitySetImpl(final Edm edm, final EdmEntityContainer container, final String name,
final FullQualifiedName type, final EntitySet entitySet) {
super(edm, container, name, type, entitySet);
this.entitySet = entitySet;
}
@Override
public boolean isIncludeInServiceDocument() {
return entitySet.isIncludeInServiceDocument();
}
@Override
public TargetType getAnnotationsTargetType() {
return TargetType.EntitySet;
}
}

View File

@ -1,113 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.core.edm.AbstractEdmEntityType;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmEntityTypeImpl extends AbstractEdmEntityType {
private final EdmStructuredTypeHelper typeHelper;
private EdmAnnotationHelper annotationHelper;
public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, final EntityType entityType) {
final FullQualifiedName baseTypeName = entityType.getBaseType() == null
? null
: new EdmTypeInfo.Builder().setTypeExpression(entityType.getBaseType()).build().getFullQualifiedName();
final EdmEntityTypeImpl instance = new EdmEntityTypeImpl(edm, fqn, baseTypeName, entityType);
instance.baseType = instance.buildBaseType(baseTypeName);
if (instance.baseType == null) {
instance.entityBaseType = null;
final List<EdmKeyPropertyRef> edmKey;
// Abstract EntityTypes do not necessarily have keys
if (entityType.isAbstract() && entityType.getKey() == null) {
edmKey = new ArrayList<EdmKeyPropertyRef>();
} else {
edmKey = new ArrayList<EdmKeyPropertyRef>(entityType.getKey().size());
for (PropertyRef ref : entityType.getKey()) {
edmKey.add(new EdmKeyPropertyRefImpl(instance, ref));
}
}
instance.setEdmKeyPropertyRef(edmKey);
} else {
instance.entityBaseType = (EdmEntityType) instance.baseType;
}
return instance;
}
private EdmEntityTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName,
final EntityType entityType) {
super(edm, fqn, baseTypeName, entityType.hasStream());
this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), entityType);
this.annotationHelper = new EdmAnnotationHelperImpl(edm, entityType);
}
@Override
protected Map<String, EdmProperty> getProperties() {
return typeHelper.getProperties();
}
@Override
protected Map<String, EdmNavigationProperty> getNavigationProperties() {
return typeHelper.getNavigationProperties();
}
@Override
public boolean isOpenType() {
return typeHelper.isOpenType();
}
@Override
public boolean isAbstract() {
return typeHelper.isAbstract();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return annotationHelper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return annotationHelper.getAnnotations();
}
}

View File

@ -1,98 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmMember;
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.core.edm.AbstractEdmEnumType;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public class EdmEnumTypeImpl extends AbstractEdmEnumType {
private static final EdmPrimitiveTypeKind[] VALID_UNDERLYING_TYPES = new EdmPrimitiveTypeKind[] {
EdmPrimitiveTypeKind.Byte,
EdmPrimitiveTypeKind.SByte,
EdmPrimitiveTypeKind.Int16,
EdmPrimitiveTypeKind.Int32,
EdmPrimitiveTypeKind.Int64
};
private final EdmPrimitiveType underlyingType;
private final List<String> memberNames;
private final Map<String, EdmMember> members;
public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName fqn,
final EnumType xmlEnumType) {
super(edm, fqn, xmlEnumType.isFlags());
if (xmlEnumType.getUnderlyingType() == null) {
this.underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);
} else {
final EdmPrimitiveTypeKind underlyingTipeKind =
EdmPrimitiveTypeKind.valueOfFQN(xmlEnumType.getUnderlyingType());
if (!ArrayUtils.contains(VALID_UNDERLYING_TYPES, underlyingTipeKind)) {
throw new EdmException("Not allowed as underlying type: " + underlyingTipeKind);
}
this.underlyingType = EdmPrimitiveTypeFactory.getInstance(underlyingTipeKind);
}
final List<EnumMember> xmlMembers = xmlEnumType.getMembers();
final List<String> _memberNames = new ArrayList<String>();
final Map<String, EdmMember> _members = new LinkedHashMap<String, EdmMember>(xmlMembers.size());
for (EnumMember xmlMember : xmlMembers) {
_memberNames.add(xmlMember.getName());
_members.put(xmlMember.getName(), new EdmMemberImpl(edm, fqn, xmlMember));
}
this.memberNames = Collections.unmodifiableList(_memberNames);
this.members = Collections.unmodifiableMap(_members);
}
@Override
public EdmPrimitiveType getUnderlyingType() {
return underlyingType;
}
@Override
public List<String> getMemberNames() {
return memberNames;
}
@Override
protected Collection<? extends EdmMember> getMembers() {
return members.values();
}
}

View File

@ -1,44 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.Function;
public class EdmFunctionImpl extends EdmOperationImpl implements EdmFunction {
private final Function function;
public static EdmFunctionImpl getInstance(final Edm edm, final FullQualifiedName name, final Function function) {
return EdmOperationImpl.getInstance(new EdmFunctionImpl(edm, name, function));
}
private EdmFunctionImpl(final Edm edm, final FullQualifiedName name, final Function function) {
super(edm, name, function, EdmTypeKind.FUNCTION);
this.function = function;
}
@Override
public boolean isComposable() {
return function.isComposable();
}
}

View File

@ -1,89 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport {
private final FunctionImport functionImport;
private final EdmAnnotationHelper helper;
private FullQualifiedName functionFQN;
public EdmFunctionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
final FunctionImport functionImport) {
super(edm, container, name, functionImport.getEntitySet());
this.functionImport = functionImport;
this.helper = new EdmAnnotationHelperImpl(edm, functionImport);
}
@Override
public TargetType getAnnotationsTargetType() {
return TargetType.FunctionImport;
}
@Override
public FullQualifiedName getFunctionFqn() {
if (functionFQN == null) {
functionFQN = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getFunction()).
setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName();
}
return functionFQN;
}
@Override
public List<EdmFunction> getUnboundFunctions() {
return edm.getUnboundFunctions(getFunctionFqn());
}
@Override
public EdmFunction getUnboundFunction(final List<String> parameterNames) {
return edm.getUnboundFunction(getFunctionFqn(), parameterNames);
}
@Override
public boolean isIncludeInServiceDocument() {
return functionImport.isIncludeInServiceDocument();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -1,43 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.core.edm.AbstractEdmKeyPropertyRef;
public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
private final PropertyRef propertyRef;
public EdmKeyPropertyRefImpl(final EdmEntityType edmEntityType, final PropertyRef propertyRef) {
super(edmEntityType);
this.propertyRef = propertyRef;
}
@Override
public String getName() {
return propertyRef.getName();
}
@Override
public String getAlias() {
return propertyRef.getAlias();
}
}

View File

@ -1,54 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.client.core.edm.xml.EnumMemberImpl;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
import org.apache.olingo.commons.core.edm.AbstractEdmMember;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
public class EdmMemberImpl extends AbstractEdmMember {
private EdmAnnotationHelper helper;
public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final EnumMember member) {
super(edm, enumFQN, member.getName(), member.getValue());
this.helper = member instanceof EnumMemberImpl
? new EdmAnnotationHelperImpl(edm, member)
: null;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper == null ? null : helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper == null ? Collections.<EdmAnnotation>emptyList() : helper.getAnnotations();
}
}

View File

@ -1,123 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmReferentialConstraint;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint;
import org.apache.olingo.commons.core.edm.AbstractEdmNavigationProperty;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
private final FullQualifiedName structuredTypeName;
private final NavigationProperty navigationProperty;
private final EdmTypeInfo edmTypeInfo;
private final EdmAnnotationHelper helper;
private List<EdmReferentialConstraint> referentialConstraints;
public EdmNavigationPropertyImpl(
final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) {
super(edm, navigationProperty.getName());
this.structuredTypeName = structuredTypeName;
this.navigationProperty = navigationProperty;
this.edmTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(navigationProperty.getType()).build();
this.helper = new EdmAnnotationHelperImpl(edm, navigationProperty);
}
@Override
protected FullQualifiedName getTypeFQN() {
return edmTypeInfo.getFullQualifiedName();
}
@Override
protected String internatGetPartner() {
return navigationProperty.getPartner();
}
@Override
public boolean isCollection() {
return edmTypeInfo.isCollection();
}
@Override
public boolean isNullable() {
return navigationProperty.isNullable();
}
@Override
public Boolean containsTarget() {
return navigationProperty.isContainsTarget();
}
@Override
public String getReferencingPropertyName(final String referencedPropertyName) {
for (EdmReferentialConstraint constraint : getReferentialConstraints()) {
if (constraint.getReferencedPropertyName().equals(referencedPropertyName)) {
return constraint.getPropertyName();
}
}
return null;
}
@Override
public List<EdmReferentialConstraint> getReferentialConstraints() {
if (referentialConstraints == null) {
final List<ReferentialConstraint> providerConstraints = navigationProperty.getReferentialConstraints();
referentialConstraints = new ArrayList<EdmReferentialConstraint>();
if (providerConstraints != null) {
for (ReferentialConstraint constraint : providerConstraints) {
referentialConstraints.add(new EdmReferentialConstraintImpl(edm, constraint));
}
}
}
return referentialConstraints;
}
@Override
public FullQualifiedName getAnnotationsTargetFQN() {
return structuredTypeName;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -1,113 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmParameter;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.Operation;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.core.edm.AbstractEdmOperation;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
public abstract class EdmOperationImpl extends AbstractEdmOperation {
protected final Operation operation;
protected final EdmAnnotationHelper helper;
protected static <T extends EdmOperationImpl> T getInstance(final T instance) {
final List<? extends Parameter> parameters = instance.operation.getParameters();
final List<EdmParameter> _parameters = new ArrayList<EdmParameter>(parameters.size());
for (Parameter parameter : parameters) {
_parameters.add(new EdmParameterImpl(instance.edm, parameter));
}
instance.setParameters(_parameters);
final String entitySetPath = instance.operation.getEntitySetPath();
if (StringUtils.isNotBlank(entitySetPath)) {
// remove bindingParameter info and keep path only
int firstSlashIndex = entitySetPath.indexOf("/");
instance.setEntitySetPath(entitySetPath.substring(firstSlashIndex + 1));
}
instance.setIsBound(instance.operation.isBound());
if (instance.operation.getReturnType() != null) {
instance.setReturnType(EdmReturnTypeImpl.getInstance(instance.edm, instance.operation.getReturnType()));
}
return instance;
}
protected EdmOperationImpl(final Edm edm, final FullQualifiedName name, final Operation operation,
final EdmTypeKind kind) {
super(edm, name, kind);
this.operation = operation;
this.helper = new EdmAnnotationHelperImpl(edm, operation);
}
private EdmParameter getBindingParameter() {
EdmParameter bindingParam = null;
if (isBound()) {
final String bindingParamName = operation.getParameters().get(0).getName();
bindingParam = getParameter(bindingParamName);
}
return bindingParam;
}
@Override
public FullQualifiedName getBindingParameterTypeFqn() {
FullQualifiedName bpfqn = null;
final EdmParameter bindingParam = getBindingParameter();
if (bindingParam != null) {
bpfqn = new FullQualifiedName(bindingParam.getType().getNamespace(), bindingParam.getType().getName());
}
return bpfqn;
}
@Override
public Boolean isBindingParameterTypeCollection() {
Boolean result = null;
final EdmParameter bindingParam = getBindingParameter();
if (bindingParam != null) {
result = bindingParam.isCollection();
}
return result;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -1,48 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.Target;
import org.apache.olingo.commons.core.edm.AbstractEdmOperationImport;
public abstract class EdmOperationImportImpl extends AbstractEdmOperationImport {
protected EdmOperationImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
final String entitySet) {
super(edm, container, name, entitySet == null ? null : new Target.Builder(entitySet, container).build());
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return null;
}
@Override
public List<EdmAnnotation> getAnnotations() {
return Collections.<EdmAnnotation>emptyList();
}
}

View File

@ -1,96 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmMapping;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.core.edm.AbstractEdmParameter;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmParameterImpl extends AbstractEdmParameter {
private final Parameter parameter;
private final EdmTypeInfo typeInfo;
private EdmAnnotationHelper helper;
public EdmParameterImpl(final Edm edm, final Parameter parameter) {
super(edm, parameter.getName(), new FullQualifiedName(parameter.getType()));
this.parameter = parameter;
this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(parameter.getType()).build();
this.helper = new EdmAnnotationHelperImpl(edm, parameter);
}
@Override
public boolean isCollection() {
return typeInfo.isCollection();
}
@Override
public EdmMapping getMapping() {
throw new UnsupportedOperationException("Not supported in client code.");
}
@Override
public boolean isNullable() {
return parameter.isNullable();
}
@Override
public Integer getMaxLength() {
return parameter.getMaxLength();
}
@Override
public Integer getPrecision() {
return parameter.getPrecision();
}
@Override
public Integer getScale() {
return parameter.getScale();
}
@Override
public SRID getSrid() {
return parameter.getSrid();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper == null ? null : helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper == null ? Collections.<EdmAnnotation> emptyList() : helper.getAnnotations();
}
}

View File

@ -1,121 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmMapping;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.core.edm.AbstractEdmProperty;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmPropertyImpl extends AbstractEdmProperty {
private final FullQualifiedName structuredTypeName;
private final Property property;
private final EdmTypeInfo typeInfo;
private EdmAnnotationHelper helper;
public EdmPropertyImpl(final Edm edm, final FullQualifiedName structuredTypeName, final Property property) {
super(edm, property.getName());
this.structuredTypeName = structuredTypeName;
this.property = property;
this.typeInfo =
new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType())
.build();
this.helper = new EdmAnnotationHelperImpl(edm, property);
}
@Override
protected EdmTypeInfo getTypeInfo() {
return typeInfo;
}
@Override
public EdmMapping getMapping() {
throw new UnsupportedOperationException("Not supported in client code.");
}
@Override
public String getMimeType() {
throw new UnsupportedOperationException("Not supported in client code.");
}
@Override
public boolean isNullable() {
return property.isNullable();
}
@Override
public Integer getMaxLength() {
return property.getMaxLength();
}
@Override
public Integer getPrecision() {
return property.getPrecision();
}
@Override
public Integer getScale() {
return property.getScale();
}
@Override
public boolean isUnicode() {
return property.isUnicode();
}
@Override
public String getDefaultValue() {
return property.getDefaultValue();
}
@Override
public SRID getSrid() {
return property.getSrid();
}
@Override
public FullQualifiedName getAnnotationsTargetFQN() {
return structuredTypeName;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper == null ? null : helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper == null ? Collections.<EdmAnnotation> emptyList() : helper.getAnnotations();
}
}

View File

@ -1,74 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.ReturnType;
import org.apache.olingo.commons.core.edm.AbstractEdmReturnType;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmReturnTypeImpl extends AbstractEdmReturnType {
private final ReturnType returnType;
private final boolean isCollection;
public static EdmReturnTypeImpl getInstance(final Edm edm, final ReturnType returnType) {
final EdmTypeInfo returnTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(returnType.getType()).build();
return new EdmReturnTypeImpl(edm, returnType, returnTypeInfo);
}
private EdmReturnTypeImpl(final Edm edm, final ReturnType returnType, final EdmTypeInfo returnTypeInfo) {
super(edm, returnTypeInfo.getFullQualifiedName());
this.returnType = returnType;
this.isCollection = returnTypeInfo.isCollection();
}
@Override
public boolean isCollection() {
return isCollection;
}
@Override
public boolean isNullable() {
return returnType.isNullable();
}
@Override
public Integer getMaxLength() {
return returnType.getMaxLength();
}
@Override
public Integer getPrecision() {
return returnType.getPrecision();
}
@Override
public Integer getScale() {
return returnType.getScale();
}
@Override
public SRID getSrid() {
return returnType == null ? null : returnType.getSrid();
}
}

View File

@ -1,237 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmAnnotations;
import org.apache.olingo.commons.api.edm.EdmComplexType;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.Function;
import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.AbstractEdmSchema;
public class EdmSchemaImpl extends AbstractEdmSchema {
private final Edm edm;
private final Schema schema;
private Map<FullQualifiedName, EdmEntityContainer> entityContainerByName;
private List<EdmEntityContainer> entityContainers;
public EdmSchemaImpl(final Edm edm, final Schema schema) {
super(schema.getNamespace(), schema.getAlias());
this.edm = edm;
this.schema = schema;
}
@Override
public List<EdmEntityContainer> getEntityContainers() {
if (entityContainers == null) {
entityContainerByName = new HashMap<FullQualifiedName, EdmEntityContainer>();
entityContainers = super.getEntityContainers();
if (getEntityContainer() != null) {
entityContainerByName.put(getEntityContainer().getFullQualifiedName(), getEntityContainer());
}
}
return entityContainers;
}
@Override
public EdmEntityContainer getEntityContainer(final FullQualifiedName name) {
getEntityContainers();
return entityContainerByName.get(name);
}
private EdmEntityContainer createEntityContainer(final String name) {
final EntityContainer defaultContainer = schema.getEntityContainer();
if (defaultContainer != null) {
final FullQualifiedName entityContainerName =
new FullQualifiedName(schema.getNamespace(), defaultContainer.getName());
return new EdmEntityContainerImpl(edm, entityContainerName, defaultContainer);
}
return null;
}
@Override
protected EdmEntityContainer createEntityContainer() {
final EntityContainer defaultContainer = schema.getEntityContainer();
if (defaultContainer != null) {
return createEntityContainer(defaultContainer.getName());
}
return null;
}
@Override
protected List<EdmTypeDefinition> createTypeDefinitions() {
final List<EdmTypeDefinition> typeDefinitions = new ArrayList<EdmTypeDefinition>();
final List<TypeDefinition> providerTypeDefinitions =
schema.getTypeDefinitions();
if (providerTypeDefinitions != null) {
for (TypeDefinition def : providerTypeDefinitions) {
typeDefinitions.add(
new EdmTypeDefinitionImpl(edm, new FullQualifiedName(namespace, def.getName()), def));
}
}
return typeDefinitions;
}
@Override
protected List<EdmEnumType> createEnumTypes() {
final List<EdmEnumType> enumTypes = new ArrayList<EdmEnumType>();
final List<EnumType> providerEnumTypes = schema.getEnumTypes();
if (providerEnumTypes != null) {
for (EnumType enumType : providerEnumTypes) {
enumTypes.add(
new EdmEnumTypeImpl(edm, new FullQualifiedName(namespace, enumType.getName()), enumType));
}
}
return enumTypes;
}
@Override
protected List<EdmEntityType> createEntityTypes() {
final List<EdmEntityType> entityTypes = new ArrayList<EdmEntityType>();
final List<? extends EntityType> providerEntityTypes = schema.getEntityTypes();
if (providerEntityTypes != null) {
for (EntityType entityType : providerEntityTypes) {
entityTypes.add(EdmEntityTypeImpl.getInstance(edm,
new FullQualifiedName(namespace, entityType.getName()), entityType));
}
}
return entityTypes;
}
@Override
protected List<EdmComplexType> createComplexTypes() {
final List<EdmComplexType> complexTypes = new ArrayList<EdmComplexType>();
final List<? extends ComplexType> providerComplexTypes = schema.getComplexTypes();
if (providerComplexTypes != null) {
for (ComplexType complexType : providerComplexTypes) {
complexTypes.add(EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName(namespace, complexType.getName()),
complexType));
}
}
return complexTypes;
}
@Override
protected List<EdmAction> createActions() {
final List<EdmAction> actions = new ArrayList<EdmAction>();
final List<Action> providerActions = schema.getActions();
if (providerActions != null) {
for (Action action : providerActions) {
actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action));
}
}
return actions;
}
@Override
protected List<EdmFunction> createFunctions() {
final List<EdmFunction> functions = new ArrayList<EdmFunction>();
final List<Function> providerFunctions = schema.getFunctions();
if (providerFunctions != null) {
for (Function function : providerFunctions) {
functions.add(
EdmFunctionImpl.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
}
return functions;
}
return functions;
}
@Override
protected List<EdmTerm> createTerms() {
final List<EdmTerm> terms = new ArrayList<EdmTerm>();
final List<Term> providerTerms = schema.getTerms();
if (providerTerms != null) {
for (Term term : providerTerms) {
terms.add(new EdmTermImpl(edm, getNamespace(), term));
}
}
return terms;
}
@Override
protected List<EdmAnnotations> createAnnotationGroups() {
final List<EdmAnnotations> annotationGroups = new ArrayList<EdmAnnotations>();
final List<Annotations> providerAnnotations =
schema.getAnnotationGroups();
if (providerAnnotations != null) {
for (Annotations annotationGroup : providerAnnotations) {
annotationGroups.add(new EdmAnnotationsImpl(edm, this, annotationGroup));
}
}
return annotationGroups;
}
@Override
protected List<EdmAnnotation> createAnnotations() {
final List<EdmAnnotation> annotations = new ArrayList<EdmAnnotation>();
final List<Annotation> providerAnnotations =
schema.getAnnotations();
if (providerAnnotations != null) {
for (Annotation annotation : providerAnnotations) {
annotations.add(new EdmAnnotationImpl(edm, annotation));
}
}
return annotations;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
EdmAnnotation result = null;
for (EdmAnnotation annotation : getAnnotations()) {
if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName())) {
result = annotation;
}
}
return result;
}
}

View File

@ -1,40 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Singleton;
public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton {
public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final String name,
final FullQualifiedName type, final Singleton singleton) {
super(edm, container, name, type, singleton);
}
@Override
public TargetType getAnnotationsTargetType() {
return TargetType.Singleton;
}
}

View File

@ -1,85 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.api.edm.provider.StructuralType;
import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
private final Edm edm;
private final FullQualifiedName structuredTypeName;
private final StructuralType structuralType;
private Map<String, EdmProperty> properties;
private Map<String, EdmNavigationProperty> navigationProperties;
public EdmStructuredTypeHelperImpl(final Edm edm, final FullQualifiedName structuredTypeName,
final StructuralType structuralType) {
this.edm = edm;
this.structuredTypeName = structuredTypeName;
this.structuralType = structuralType;
}
@Override
public Map<String, EdmProperty> getProperties() {
if (properties == null) {
properties = new LinkedHashMap<String, EdmProperty>();
for (Property property : structuralType.getProperties()) {
properties.put(property.getName(), new EdmPropertyImpl(edm, structuredTypeName, property));
}
}
return properties;
}
@Override
public Map<String, EdmNavigationProperty> getNavigationProperties() {
if (navigationProperties == null) {
navigationProperties = new LinkedHashMap<String, EdmNavigationProperty>();
for (NavigationProperty navigationProperty : structuralType.getNavigationProperties()) {
navigationProperties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl(
edm, structuredTypeName, navigationProperty));
}
}
return navigationProperties;
}
@Override
public boolean isOpenType() {
return structuralType.isOpenType();
}
@Override
public boolean isAbstract() {
return structuralType.isAbstract();
}
}

View File

@ -41,7 +41,15 @@ public class NavigationPropertyDeserializer extends AbstractEdmDeserializer<Navi
if ("Name".equals(jp.getCurrentName())) {
property.setName(jp.nextTextValue());
} else if ("Type".equals(jp.getCurrentName())) {
property.setType(jp.nextTextValue());
String metadataTypeName = jp.nextTextValue();
if (metadataTypeName.startsWith("Collection(")) {
property.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1,
metadataTypeName.length() - 1));
property.setCollection(true);
} else {
property.setType(metadataTypeName);
property.setCollection(false);
}
} else if ("Nullable".equals(jp.getCurrentName())) {
property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("Partner".equals(jp.getCurrentName())) {

View File

@ -42,7 +42,15 @@ public class ParameterDeserializer extends AbstractEdmDeserializer<ParameterImpl
if ("Name".equals(jp.getCurrentName())) {
parameter.setName(jp.nextTextValue());
} else if ("Type".equals(jp.getCurrentName())) {
parameter.setType(jp.nextTextValue());
String metadataTypeName = jp.nextTextValue();
if (metadataTypeName.startsWith("Collection(")) {
parameter.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1,
metadataTypeName.length() - 1));
parameter.setCollection(true);
} else {
parameter.setType(metadataTypeName);
parameter.setCollection(false);
}
} else if ("Nullable".equals(jp.getCurrentName())) {
parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("MaxLength".equals(jp.getCurrentName())) {

View File

@ -42,7 +42,15 @@ public class PropertyDeserializer extends AbstractEdmDeserializer<PropertyImpl>
if ("Name".equals(jp.getCurrentName())) {
property.setName(jp.nextTextValue());
} else if ("Type".equals(jp.getCurrentName())) {
property.setType(jp.nextTextValue());
String metadataTypeName = jp.nextTextValue();
if (metadataTypeName.startsWith("Collection(")) {
property.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1,
metadataTypeName.length() - 1));
property.setCollection(true);
} else {
property.setType(metadataTypeName);
property.setCollection(false);
}
} else if ("Nullable".equals(jp.getCurrentName())) {
property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("DefaultValue".equals(jp.getCurrentName())) {

View File

@ -18,10 +18,12 @@
*/
package org.apache.olingo.client.core.edm.xml;
import org.apache.olingo.commons.api.edm.provider.Property;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonDeserialize(using = PropertyDeserializer.class)
public class PropertyImpl extends org.apache.olingo.commons.api.edm.provider.Property {
public class PropertyImpl extends Property {
private static final long serialVersionUID = -4521766603286651372L;

View File

@ -40,7 +40,15 @@ public class ReturnTypeDeserializer extends AbstractEdmDeserializer<ReturnTypeIm
final JsonToken token = jp.getCurrentToken();
if (token == JsonToken.FIELD_NAME) {
if ("Type".equals(jp.getCurrentName())) {
returnType.setType(jp.nextTextValue());
String metadataTypeName = jp.nextTextValue();
if (metadataTypeName.startsWith("Collection(")) {
returnType.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1,
metadataTypeName.length() - 1));
returnType.setCollection(true);
} else {
returnType.setType(metadataTypeName);
returnType.setCollection(false);
}
} else if ("Nullable".equals(jp.getCurrentName())) {
returnType.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("MaxLength".equals(jp.getCurrentName())) {

View File

@ -28,7 +28,7 @@ import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
import org.apache.olingo.client.api.serialization.ODataReader;
import org.apache.olingo.client.core.edm.EdmClientImpl;
import org.apache.olingo.client.core.edm.ClientEdmProvider;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Property;
@ -44,6 +44,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -67,7 +68,8 @@ public class ODataReaderImpl implements ODataReader {
@Override
public Edm readMetadata(final Map<String, Schema> xmlSchemas) {
return new EdmClientImpl(xmlSchemas);
ClientEdmProvider prov = new ClientEdmProvider(xmlSchemas);
return new EdmProviderImpl(prov);
}
@Override

View File

@ -27,13 +27,13 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.TimeZone;
import org.apache.olingo.client.core.edm.EdmEnumTypeImpl;
import org.apache.olingo.client.core.edm.xml.EnumTypeImpl;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.geo.Geospatial;
import org.apache.olingo.commons.api.edm.geo.Point;
import org.apache.olingo.commons.core.edm.provider.EdmEnumTypeImpl;
import org.junit.Test;
public class URIEscapeTest {

View File

@ -30,11 +30,11 @@ import org.apache.olingo.client.api.uri.FilterArgFactory;
import org.apache.olingo.client.api.uri.FilterFactory;
import org.apache.olingo.client.api.uri.URIFilter;
import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.client.core.edm.EdmEnumTypeImpl;
import org.apache.olingo.client.core.edm.xml.EnumTypeImpl;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.core.edm.provider.EdmEnumTypeImpl;
import org.junit.Test;
public class FilterFactoryTest extends AbstractTest {

View File

@ -223,7 +223,9 @@ public class MetadataTest extends AbstractTest {
final Function productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0);
assertNotNull(productsByRating.getParameter("Rating"));
assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType());
assertEquals("Collection(ODataDemo.Product)", productsByRating.getReturnType().getType());
// assertEquals("Collection(ODataDemo.Product)", productsByRating.getReturnType().getType());
assertEquals("ODataDemo.Product", productsByRating.getReturnType().getType());
assertTrue(productsByRating.getReturnType().isCollection());
final Singleton contoso = metadata.getSchema(0).getEntityContainer().getSingleton("Contoso");
assertNotNull(contoso);
@ -252,16 +254,19 @@ public class MetadataTest extends AbstractTest {
assertNotNull(fi);
assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
final EdmFunction edmFunction = edm.getUnboundFunction(
new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), null);
final EdmFunction edmFunction =
edm.getUnboundFunction(
new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), function
.getParameterNames());
assertNotNull(edmFunction);
assertEquals(edmFunction.getName(), fi.getUnboundFunction(null).getName());
assertEquals(edmFunction.getNamespace(), fi.getUnboundFunction(null).getNamespace());
assertEquals(edmFunction.getParameterNames(), fi.getUnboundFunction(null).getParameterNames());
assertEquals(edmFunction.getName(), fi.getUnboundFunction(function.getParameterNames()).getName());
assertEquals(edmFunction.getNamespace(), fi.getUnboundFunction(function.getParameterNames()).getNamespace());
assertEquals(edmFunction.getParameterNames(), fi.getUnboundFunction(function.getParameterNames())
.getParameterNames());
assertEquals(edmFunction.getReturnType().getType().getName(),
fi.getUnboundFunction(null).getReturnType().getType().getName());
fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getName());
assertEquals(edmFunction.getReturnType().getType().getNamespace(),
fi.getUnboundFunction(null).getReturnType().getType().getNamespace());
fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getNamespace());
}
final EdmTypeDefinition weight = edm.getTypeDefinition(new FullQualifiedName("ODataDemo", "Weight"));

View File

@ -38,15 +38,6 @@ public interface EdmEntityContainer extends EdmNamed, EdmAnnotationsTarget, EdmA
*/
FullQualifiedName getFullQualifiedName();
/**
* Returns whether this container is the default container in the current schema.
* <br/>
* According to CSDL specifications, this method will always return <tt>true</tt> for OData 4.0.
*
* @return whether this container is the default container in the current schema, always <tt>true</tt> for OData 4.0
*/
boolean isDefault();
/**
* Get contained Singleton by name.
*

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.commons.api.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import java.util.List;
public abstract class EdmProvider {
/**
@ -192,4 +192,20 @@ public abstract class EdmProvider {
public EntityContainer getEntityContainer() throws ODataException {
return null;
}
/**
* @param targetName
* @return {@link Annotations} group for the given Target
*/
public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException {
return null;
}
/**
* @param annotatedName
* @return Annotatble element by target name
*/
public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException {
return null;
}
}

View File

@ -55,8 +55,11 @@ public class TypeDefinition extends AbstractEdmItem implements Named, Annotatabl
}
public String getUnderlyingType() {
if(underlyingType != null){
return underlyingType.getFullQualifiedNameAsString();
}
return null;
}
public TypeDefinition setUnderlyingType(final String underlyingType) {
this.underlyingType = new FullQualifiedName(underlyingType);

View File

@ -60,11 +60,6 @@ public abstract class AbstractEdmEntityContainer extends EdmNamedImpl implements
this.parentContainerName = parentContainerName;
}
@Override
public boolean isDefault() {
return true;
}
@Override
public String getNamespace() {
return entityContainerName.getNamespace();

View File

@ -53,7 +53,7 @@ public abstract class AbstractEdmEnumType extends EdmTypeImpl implements EdmEnum
uriSuffix = "'";
}
protected abstract Collection<? extends EdmMember> getMembers();
protected abstract Collection<EdmMember> getMembers();
@Override
public EdmMember getMember(final String name) {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm.annotation;
package org.apache.olingo.commons.core.edm.annotation;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmType;
@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpressi
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.annotation.Cast;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression;
public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmCast {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm.annotation;
package org.apache.olingo.commons.core.edm.annotation;
import java.util.ArrayList;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm.annotation;
package org.apache.olingo.commons.core.edm.annotation;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmType;
@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.edm.annotation.EdmIsOf;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.annotation.IsOf;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression;
public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmIsOf {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm.annotation;
package org.apache.olingo.commons.core.edm.annotation;
import java.util.List;
@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue;
import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression;
public class EdmRecordImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmRecord {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;
@ -43,5 +43,4 @@ public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmAc
public TargetType getAnnotationsTargetType() {
return TargetType.ActionImport;
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.List;

View File

@ -16,15 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.client.core.edm.annotation.EdmCastImpl;
import org.apache.olingo.client.core.edm.annotation.EdmConstantAnnotationExpressionImpl;
import org.apache.olingo.client.core.edm.annotation.EdmIsOfImpl;
import org.apache.olingo.client.core.edm.annotation.EdmRecordImpl;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotatable;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
@ -42,11 +38,14 @@ import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.annotation.EdmAndImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmAnnotationPathImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmApplyImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmCastImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmCollectionImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmConstantAnnotationExpressionImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmEqImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmGeImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmGtImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmIfImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmIsOfImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmLabeledElementImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmLabeledElementReferenceImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmLeImpl;
@ -59,6 +58,7 @@ import org.apache.olingo.commons.core.edm.annotation.EdmOrImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmPathImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmPropertyPathImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmPropertyValueImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmRecordImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmUrlRefImpl;
public class EdmAnnotationImpl implements EdmAnnotation {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.List;
@ -38,13 +38,9 @@ import org.apache.olingo.commons.api.edm.provider.Annotations;
public class EdmAnnotationsImpl implements EdmAnnotations {
private final Edm edm;
private final EdmSchema schema;
private final Annotations annotationGroup;
private EdmAnnotationsTarget target;
private List<EdmAnnotation> annotations;
public EdmAnnotationsImpl(final Edm edm, final EdmSchema schema, final Annotations annotationGroup) {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.List;
@ -26,7 +26,6 @@ import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.BindingTarget;
import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding;
import org.apache.olingo.commons.core.edm.AbstractEdmBindingTarget;
@ -36,15 +35,11 @@ import org.apache.olingo.commons.core.edm.EdmNavigationPropertyBindingImpl;
public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
private final BindingTarget target;
private List<EdmNavigationPropertyBinding> navigationPropertyBindings;
private final EdmAnnotationHelper helper;
private List<EdmNavigationPropertyBinding> navigationPropertyBindings;
public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container,
final String name, final FullQualifiedName type, final BindingTarget target) {
super(edm, container, name, type);
public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container, final BindingTarget target) {
super(edm, container, target.getName(), target.getTypeFQN());
this.target = target;
this.helper = new EdmAnnotationHelperImpl(edm, target);
}
@ -52,7 +47,7 @@ public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
@Override
public List<EdmNavigationPropertyBinding> getNavigationPropertyBindings() {
if (navigationPropertyBindings == null) {
List<? extends NavigationPropertyBinding> providerBindings = target.getNavigationPropertyBindings();
List<NavigationPropertyBinding> providerBindings = target.getNavigationPropertyBindings();
navigationPropertyBindings = new ArrayList<EdmNavigationPropertyBinding>();
if (providerBindings != null) {
for (NavigationPropertyBinding binding : providerBindings) {
@ -63,6 +58,7 @@ public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
return navigationPropertyBindings;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
@ -26,6 +26,7 @@ import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.core.edm.AbstractEdmComplexType;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
import java.util.List;
@ -35,6 +36,8 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
private final EdmStructuredTypeHelper helper;
private EdmAnnotationHelper annotationHelper;
public static EdmComplexTypeImpl getInstance(
final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
@ -43,7 +46,8 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
super(edm, name, complexType.getBaseTypeFQN());
helper = new EdmStructuredTypeHelperImpl(edm, name, complexType);
this.helper = new EdmStructuredTypeHelperImpl(edm, name, complexType);
this.annotationHelper = new EdmAnnotationHelperImpl(edm, complexType);
}
@Override
@ -68,11 +72,11 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return annotationHelper == null ? null : annotationHelper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return annotationHelper == null ? null : annotationHelper.getAnnotations();
}
}

View File

@ -16,7 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.Edm;
@ -36,14 +39,13 @@ import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.core.edm.AbstractEdmEntityContainer;
import java.util.List;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
private final EdmProvider provider;
private EntityContainer container;
private EdmAnnotationHelper helper;
public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider,
final EntityContainerInfo entityContainerInfo) {
@ -56,6 +58,7 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
super(edm, containerFQN, entityContainer.getExtendsContainerFQN());
this.provider = provider;
container = entityContainer;
this.helper = new EdmAnnotationHelperImpl(edm, entityContainer);
}
@Override
@ -196,13 +199,18 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
}
}
@Override
public TargetType getAnnotationsTargetType() {
return TargetType.EntityContainer;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return helper == null ? null : helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return helper == null ? Collections.<EdmAnnotation> emptyList() : helper.getAnnotations();
}
}

View File

@ -16,17 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
import java.util.List;
public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
private EntitySet entitySet;
@ -45,14 +41,4 @@ public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntityS
public TargetType getAnnotationsTargetType() {
return TargetType.EntitySet;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
@ -29,6 +29,7 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.core.edm.AbstractEdmEntityType;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
import java.util.ArrayList;
@ -43,6 +44,8 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
private boolean baseTypeChecked = false;
private EdmAnnotationHelper annotationHelper;
public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName name,
final EntityType entityType) {
@ -99,11 +102,11 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return annotationHelper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return annotationHelper.getAnnotations();
}
}

View File

@ -16,12 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmMember;
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@ -33,6 +36,15 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public class EdmEnumTypeImpl extends AbstractEdmEnumType {
private static final Set<EdmPrimitiveTypeKind> VALID_UNDERLYING_TYPES = new HashSet<EdmPrimitiveTypeKind>();
{
VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Byte);
VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.SByte);
VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Int16);
VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Int32);
VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Int64);
};
private final EdmPrimitiveType underlyingType;
private final EnumType enumType;
@ -45,8 +57,12 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType {
if (enumType.getUnderlyingType() == null) {
underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);
} else {
underlyingType = EdmPrimitiveTypeFactory.getInstance(
EdmPrimitiveTypeKind.valueOfFQN(enumType.getUnderlyingType()));
EdmPrimitiveTypeKind underlyingTypeKind = EdmPrimitiveTypeKind.valueOfFQN(enumType.getUnderlyingType());
if (!VALID_UNDERLYING_TYPES.contains(underlyingTypeKind)) {
throw new EdmException("Not allowed as underlying type: " + underlyingTypeKind);
}
underlyingType = EdmPrimitiveTypeFactory.getInstance(underlyingTypeKind);
}
this.enumType = enumType;
@ -58,11 +74,11 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType {
}
@Override
protected List<? extends EdmMember> getMembers() {
protected List<EdmMember> getMembers() {
if (members == null) {
members = new ArrayList<EdmMember>(enumType.getMembers().size());
for (EnumMember member : enumType.getMembers()) {
members.add(new EdmMemberImpl(edm, getFullQualifiedName(), member.getName(), member.getValue()));
members.add(new EdmMemberImpl(edm, getFullQualifiedName(), member));
}
}
return members;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmException;

View File

@ -16,24 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import java.util.List;
public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport {
private final FunctionImport functionImport;
public EdmFunctionImportImpl(final Edm edm, final EdmEntityContainer container, final FunctionImport functionImport) {
super(edm, container, functionImport);
this.functionImport = functionImport;
}
@ -62,9 +60,4 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm
public TargetType getAnnotationsTargetType() {
return TargetType.FunctionImport;
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;

View File

@ -16,30 +16,35 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
import org.apache.olingo.commons.core.edm.AbstractEdmMember;
import java.util.List;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
public class EdmMemberImpl extends AbstractEdmMember {
public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final String name, final String value) {
super(edm, enumFQN, name, value);
private final EdmAnnotationHelper helper;
public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final EnumMember member) {
super(edm, enumFQN, member.getName(), member.getValue());
this.helper = new EdmAnnotationHelperImpl(edm, member);
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotations();
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
@ -26,6 +26,7 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint;
import org.apache.olingo.commons.core.edm.AbstractEdmNavigationProperty;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import java.util.ArrayList;
import java.util.List;
@ -33,18 +34,16 @@ import java.util.List;
public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
private final FullQualifiedName structuredTypeName;
private final NavigationProperty navigationProperty;
private List<EdmReferentialConstraint> referentialConstraints;
private final EdmAnnotationHelper helper;
public EdmNavigationPropertyImpl(
final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) {
super(edm, navigationProperty.getName());
this.structuredTypeName = structuredTypeName;
this.navigationProperty = navigationProperty;
this.helper = new EdmAnnotationHelperImpl(edm, navigationProperty);
}
@Override
@ -93,7 +92,7 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
if (providerConstraints != null) {
for (ReferentialConstraint constraint : providerConstraints) {
referentialConstraints.add(
new EdmReferentialConstraintImpl(constraint.getProperty(), constraint.getReferencedProperty()));
new EdmReferentialConstraintImpl(edm, constraint));
}
}
}
@ -107,11 +106,11 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotations();
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.List;
@ -30,10 +30,12 @@ import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.Operation;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.core.edm.AbstractEdmOperation;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
public abstract class EdmOperationImpl extends AbstractEdmOperation {
protected final Operation operation;
protected final EdmAnnotationHelper helper;
protected static <T extends EdmOperationImpl> T getInstance(final T instance) {
final List<Parameter> providerParameters = instance.operation.getParameters();
@ -64,6 +66,7 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation {
super(edm, name, kind);
this.operation = operation;
this.helper = new EdmAnnotationHelperImpl(edm, operation);
}
@Override
@ -86,12 +89,11 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation {
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotations();
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
@ -25,24 +25,28 @@ import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.Target;
import org.apache.olingo.commons.api.edm.provider.OperationImport;
import org.apache.olingo.commons.core.edm.AbstractEdmOperationImport;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import java.util.List;
public abstract class EdmOperationImportImpl extends AbstractEdmOperationImport {
private final EdmAnnotationHelper helper;
public EdmOperationImportImpl(final Edm edm, final EdmEntityContainer container,
final OperationImport operationImport) {
super(edm, container, operationImport.getName(), new Target.Builder(operationImport.getEntitySet(), container
).build());
this.helper = new EdmAnnotationHelperImpl(edm, operationImport);
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotations();
}
}

View File

@ -16,7 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
@ -25,16 +27,17 @@ import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.core.edm.AbstractEdmParameter;
import java.util.List;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
public class EdmParameterImpl extends AbstractEdmParameter {
private final Parameter parameter;
private final EdmAnnotationHelper helper;
public EdmParameterImpl(final Edm edm, final Parameter parameter) {
super(edm, parameter.getName(), parameter.getTypeFQN());
this.parameter = parameter;
this.helper = new EdmAnnotationHelperImpl(edm, parameter);
}
@Override
@ -74,11 +77,11 @@ public class EdmParameterImpl extends AbstractEdmParameter {
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotations();
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.List;
@ -28,15 +28,15 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.core.edm.AbstractEdmProperty;
import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
public class EdmPropertyImpl extends AbstractEdmProperty {
private final FullQualifiedName structuredTypeName;
private final Property property;
private final EdmTypeInfo typeInfo;
private EdmAnnotationHelper helper;
public EdmPropertyImpl(final Edm edm, final FullQualifiedName structuredTypeName, final Property property) {
super(edm, property.getName());
@ -44,6 +44,7 @@ public class EdmPropertyImpl extends AbstractEdmProperty {
this.structuredTypeName = structuredTypeName;
this.property = property;
typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build();
this.helper = new EdmAnnotationHelperImpl(edm, property);
}
@Override
@ -108,11 +109,11 @@ public class EdmPropertyImpl extends AbstractEdmProperty {
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return helper.getAnnotations();
}
}

View File

@ -16,7 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.EdmAction;
@ -34,6 +41,9 @@ import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
@ -42,27 +52,18 @@ import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.Function;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.AbstractEdm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class EdmProviderImpl extends AbstractEdm {
private final EdmProvider provider;
private final Map<FullQualifiedName, List<Action>> actionsMap = new HashMap<FullQualifiedName, List<Action>>();
private final Map<FullQualifiedName, List<Function>> functionsMap = new HashMap<FullQualifiedName, List<Function>>();
public EdmProviderImpl(final EdmProvider provider) {
this.provider = provider;
}
@Override
@ -328,16 +329,48 @@ public class EdmProviderImpl extends AbstractEdm {
@Override
protected EdmTerm createTerm(final FullQualifiedName termName) {
throw new UnsupportedOperationException("Not supported yet.");
try {
Term providerTerm = provider.getTerm(termName);
if (providerTerm != null) {
return new EdmTermImpl(this, termName.getNamespace(), providerTerm);
}
return null;
} catch (ODataException e) {
throw new EdmException(e);
}
}
//TODO: Check implementation
@Override
protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) {
throw new UnsupportedOperationException("Not supported yet.");
try {
EdmSchema schema = getSchema(targetName.getNamespace());
Annotations providerGroup = provider.getAnnotationsGroup(targetName);
if (providerGroup != null) {
return new EdmAnnotationsImpl(this, schema, providerGroup);
}
return null;
} catch (ODataException e) {
throw new EdmException(e);
}
}
@Override
protected List<EdmAnnotation> createAnnotations(final FullQualifiedName annotatedName) {
throw new UnsupportedOperationException("Not supported yet.");
try {
Annotatable providerAnnotatable = provider.getAnnoatatable(annotatedName);
if (providerAnnotatable != null && providerAnnotatable.getAnnotations() != null) {
List<EdmAnnotation> result = new ArrayList<EdmAnnotation>();
for(Annotation annotation : providerAnnotatable.getAnnotations()){
//Load Term
getTerm(new FullQualifiedName(annotation.getTerm()));
result.add(new EdmAnnotationImpl(this, annotation));
}
return result;
}
return null;
} catch (ODataException e) {
throw new EdmException(e);
}
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
package org.apache.olingo.commons.core.edm.provider;
import java.util.List;
@ -45,5 +45,4 @@ public class EdmReferentialConstraintImpl extends AbstractEdmReferentialConstrai
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.geo.SRID;
@ -59,6 +59,6 @@ public class EdmReturnTypeImpl extends AbstractEdmReturnType {
@Override
public SRID getSrid() {
return null; // TODO: provide implementation
return returnType.getSrid();
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.List;
@ -34,21 +34,22 @@ import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.Function;
import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.AbstractEdmSchema;
public class EdmSchemaImpl extends AbstractEdmSchema {
private final Schema schema;
private final Edm edm;
private final EdmProvider provider;
public EdmSchemaImpl(final Edm edm, final EdmProvider provider, final Schema schema) {
@ -143,26 +144,51 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
@Override
protected List<EdmTerm> createTerms() {
throw new UnsupportedOperationException("Not supported yet.");
final List<EdmTerm> terms = new ArrayList<EdmTerm>();
final List<Term> providerTerms = schema.getTerms();
if (providerTerms != null) {
for (Term term : providerTerms) {
terms.add(new EdmTermImpl(edm, getNamespace(), term));
}
}
return terms;
}
@Override
protected List<EdmAnnotations> createAnnotationGroups() {
throw new UnsupportedOperationException("Not supported yet.");
final List<EdmAnnotations> annotationGroups = new ArrayList<EdmAnnotations>();
final List<Annotations> providerAnnotations =
schema.getAnnotationGroups();
if (providerAnnotations != null) {
for (Annotations annotationGroup : providerAnnotations) {
annotationGroups.add(new EdmAnnotationsImpl(edm, this, annotationGroup));
}
}
return annotationGroups;
}
@Override
protected List<EdmAnnotation> createAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
final List<EdmAnnotation> annotations = new ArrayList<EdmAnnotation>();
final List<Annotation> providerAnnotations =
schema.getAnnotations();
if (providerAnnotations != null) {
for (Annotation annotation : providerAnnotations) {
annotations.add(new EdmAnnotationImpl(edm, annotation));
}
}
return annotations;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
EdmAnnotation result = null;
for (EdmAnnotation annotation : getAnnotations()) {
if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName())) {
result = annotation;
}
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
return result;
}
}

View File

@ -16,17 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import java.util.List;
public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton {
public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final Singleton singleton) {
@ -37,14 +33,4 @@ public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSinglet
public TargetType getAnnotationsTargetType() {
return TargetType.Singleton;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
@ -33,18 +33,13 @@ import java.util.Map;
public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
private final Edm edm;
private final FullQualifiedName structuredTypeName;
private final StructuralType structuredType;
private Map<String, EdmProperty> properties;
private Map<String, EdmNavigationProperty> navigationProperties;
public EdmStructuredTypeHelperImpl(
final Edm edm, final FullQualifiedName structuredTypeName, final StructuralType structuredType) {
this.edm = edm;
this.structuredTypeName = structuredTypeName;
this.structuredType = structuredType;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
package org.apache.olingo.commons.core.edm.provider;
import java.util.List;
@ -35,18 +35,19 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition {
private final TypeDefinition typeDefinition;
private final EdmPrimitiveType edmPrimitiveTypeInstance;
private TypeDefinition typeDefinition;
private EdmPrimitiveType edmPrimitiveTypeInstance;
private final EdmAnnotationHelper helper;
public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
final TypeDefinition typeDefinition) {
super(edm, typeDefinitionName);
this.typeDefinition = typeDefinition;
try {
if (typeDefinition.getUnderlyingType() == null) {
throw new EdmException("Underlying Type for type definition: "
+ typeDefinitionName.getFullQualifiedNameAsString() + " must not be null.");
}
this.edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance(
EdmPrimitiveTypeKind.valueOfFQN(typeDefinition.getUnderlyingType()));
} catch (IllegalArgumentException e) {
@ -57,6 +58,14 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition {
@Override
public EdmPrimitiveType getUnderlyingType() {
if (edmPrimitiveTypeInstance == null) {
try {
edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance(
EdmPrimitiveTypeKind.valueOfFQN(typeDefinition.getUnderlyingType()));
} catch (IllegalArgumentException e) {
throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e);
}
}
return edmPrimitiveTypeInstance;
}

View File

@ -21,9 +21,9 @@ package org.apache.olingo.server.core;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.server.api.ServiceMetadata;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -1,55 +0,0 @@
/*
* 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.core.edm.provider;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
import org.apache.olingo.commons.api.edm.provider.BindingTarget;
import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding;
import org.apache.olingo.commons.core.edm.AbstractEdmBindingTarget;
import org.apache.olingo.commons.core.edm.EdmNavigationPropertyBindingImpl;
public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
private final BindingTarget target;
private List<EdmNavigationPropertyBinding> navigationPropertyBindings;
public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container, final BindingTarget target) {
super(edm, container, target.getName(), target.getTypeFQN());
this.target = target;
}
@Override
public List<EdmNavigationPropertyBinding> getNavigationPropertyBindings() {
if (navigationPropertyBindings == null) {
List<NavigationPropertyBinding> providerBindings = target.getNavigationPropertyBindings();
navigationPropertyBindings = new ArrayList<EdmNavigationPropertyBinding>();
if (providerBindings != null) {
for (NavigationPropertyBinding binding : providerBindings) {
navigationPropertyBindings.add(new EdmNavigationPropertyBindingImpl(binding.getPath(), binding.getTarget()));
}
}
}
return navigationPropertyBindings;
}
}

View File

@ -1,42 +0,0 @@
/*
* 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.core.edm.provider;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.core.edm.AbstractEdmReferentialConstraint;
import java.util.List;
public class EdmReferentialConstraintImpl extends AbstractEdmReferentialConstraint {
public EdmReferentialConstraintImpl(final String property, final String referencedProperty) {
super(property, referencedProperty);
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -1,95 +0,0 @@
/*
* 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.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.AbstractEdmTypeDefinition;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition {
private TypeDefinition typeDefinition;
private EdmPrimitiveType edmPrimitiveTypeInstance;
public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
final TypeDefinition typeDefinition) {
super(edm, typeDefinitionName);
this.typeDefinition = typeDefinition;
}
@Override
public EdmPrimitiveType getUnderlyingType() {
if (edmPrimitiveTypeInstance == null) {
try {
edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance(
EdmPrimitiveTypeKind.valueOfFQN(typeDefinition.getUnderlyingType()));
} catch (IllegalArgumentException e) {
throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e);
}
}
return edmPrimitiveTypeInstance;
}
@Override
public Integer getMaxLength() {
return typeDefinition.getMaxLength();
}
@Override
public Integer getPrecision() {
return typeDefinition.getPrecision();
}
@Override
public Integer getScale() {
return typeDefinition.getScale();
}
@Override
public SRID getSrid() {
return null; // TODO: provide implementation
}
@Override
public Boolean isUnicode() {
return typeDefinition.isUnicode();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -40,6 +40,8 @@ import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.api.edm.provider.ReturnType;
import org.apache.olingo.commons.core.edm.provider.EdmActionImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -26,6 +26,8 @@ import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.Target;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.core.edm.provider.EdmActionImportImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -27,6 +27,8 @@ import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.core.edm.provider.EdmComplexTypeImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -33,6 +33,8 @@ import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.core.edm.provider.EdmEntityContainerImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -30,6 +30,9 @@ import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.core.edm.provider.EdmEntityContainerImpl;
import org.apache.olingo.commons.core.edm.provider.EdmEntitySetImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Test;
import java.util.Arrays;

View File

@ -43,6 +43,8 @@ import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.core.edm.provider.EdmEntityTypeImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -27,6 +27,8 @@ import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.apache.olingo.commons.core.edm.provider.EdmEnumTypeImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Test;
import java.util.Arrays;

View File

@ -24,6 +24,8 @@ import org.apache.olingo.commons.api.edm.EdmReturnType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Function;
import org.apache.olingo.commons.api.edm.provider.ReturnType;
import org.apache.olingo.commons.core.edm.provider.EdmFunctionImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -30,6 +30,9 @@ import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.api.edm.provider.ReturnType;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.apache.olingo.commons.core.edm.provider.EdmEntityContainerImpl;
import org.apache.olingo.commons.core.edm.provider.EdmFunctionImportImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Test;
import java.util.Arrays;

View File

@ -25,6 +25,7 @@ import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.core.edm.provider.EdmKeyPropertyRefImpl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

View File

@ -31,6 +31,8 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Mapping;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.core.edm.provider.EdmParameterImpl;
import org.apache.olingo.commons.core.edm.provider.EdmPropertyImpl;
import org.junit.Test;
public class EdmMappingTest {

View File

@ -19,6 +19,8 @@
package org.apache.olingo.server.core.edm.provider;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
import org.apache.olingo.commons.core.edm.provider.EdmMemberImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@ -29,8 +31,7 @@ public class EdmMemberImplTest {
@Test
public void enumMember() {
final EnumMember member = new EnumMember().setName("name").setValue("value");
final EdmMemberImpl memberImpl =
new EdmMemberImpl(mock(EdmProviderImpl.class), null, member.getName(), member.getValue());
final EdmMemberImpl memberImpl = new EdmMemberImpl(mock(EdmProviderImpl.class), null, member);
assertEquals("name", memberImpl.getName());
assertEquals("value", memberImpl.getValue());

View File

@ -28,6 +28,8 @@ import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint;
import org.apache.olingo.commons.core.edm.provider.EdmNavigationPropertyImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Test;
import java.util.ArrayList;

View File

@ -30,6 +30,8 @@ import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.provider.EdmParameterImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

View File

@ -30,6 +30,8 @@ import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.provider.EdmPropertyImpl;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

View File

@ -27,6 +27,7 @@ import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.Function;
import org.apache.olingo.commons.api.edm.provider.Parameter;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -35,6 +35,7 @@ import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.EnumType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;

View File

@ -29,6 +29,8 @@ import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.ReturnType;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.commons.core.edm.provider.EdmReturnTypeImpl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

View File

@ -29,6 +29,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
@ -49,6 +50,7 @@ import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;
@ -314,8 +316,10 @@ public class EdmSchemaImplTest {
providerSchema.setEntityContainer(container);
List<TypeDefinition> typeDefinitions = new ArrayList<TypeDefinition>();
typeDefinitions.add(new TypeDefinition().setName("typeDefinition1"));
typeDefinitions.add(new TypeDefinition().setName("typeDefinition2"));
typeDefinitions.add(new TypeDefinition().setName("typeDefinition1").setUnderlyingType(
EdmPrimitiveTypeKind.String.getFullQualifiedName()));
typeDefinitions.add(new TypeDefinition().setName("typeDefinition2").setUnderlyingType(
EdmPrimitiveTypeKind.String.getFullQualifiedName()));
providerSchema.setTypeDefinitions(typeDefinitions);
List<EnumType> enumTypes = new ArrayList<EnumType>();

Some files were not shown because too many files have changed in this diff Show More