[OLINGO-575] Edm cleanup: Remove EdmAnnotationHelperImpl

This commit is contained in:
Michael Bolz 2015-03-27 13:41:03 +01:00
parent 4f33c704cf
commit 16b94eb47e
29 changed files with 130 additions and 322 deletions

View File

@ -1,26 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.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.EdmAnnotatable;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
@ -28,16 +25,16 @@ import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotation;
public class EdmAnnotationHelperImpl implements EdmAnnotatable {
import java.util.ArrayList;
import java.util.List;
private final Edm edm;
public abstract class AbstractEdmAnnotatable extends AbstractEdmBase implements EdmAnnotatable {
private final Annotatable annotatable;
private List<EdmAnnotation> annotations;
public EdmAnnotationHelperImpl(final Edm edm, final Annotatable annotatable) {
this.edm = edm;
public AbstractEdmAnnotatable(final Edm edm, final Annotatable annotatable) {
super(edm);
this.annotatable = annotatable;
}
@ -57,11 +54,12 @@ public class EdmAnnotationHelperImpl implements EdmAnnotatable {
public List<EdmAnnotation> getAnnotations() {
if (annotations == null) {
annotations = new ArrayList<EdmAnnotation>();
for (Annotation annotation : annotatable.getAnnotations()) {
annotations.add(new EdmAnnotationImpl(edm, annotation));
if(annotatable != null) {
for (Annotation annotation : annotatable.getAnnotations()) {
annotations.add(new EdmAnnotationImpl(edm, annotation));
}
}
}
return annotations;
}
}

View File

@ -19,11 +19,13 @@
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmElement;
import org.apache.olingo.commons.api.edm.EdmAnnotatable;
public abstract class EdmElementImpl extends EdmNamedImpl implements EdmElement {
public abstract class AbstractEdmBase implements EdmAnnotatable {
public EdmElementImpl(final Edm edm, final String name) {
super(edm, name);
protected final Edm edm;
public AbstractEdmBase(final Edm edm) {
this.edm = edm;
}
}

View File

@ -23,31 +23,27 @@ import java.util.Iterator;
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.EdmBindingTarget;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmException;
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.Target;
import org.apache.olingo.commons.api.edm.provider.BindingTarget;
import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding;
public abstract class EdmBindingTargetImpl extends EdmNamedImpl implements EdmBindingTarget {
public abstract class AbstractEdmBindingTarget extends AbstractEdmNamed implements EdmBindingTarget {
private final BindingTarget target;
private final EdmAnnotationHelperImpl helper;
private final EdmEntityContainer container;
private List<EdmNavigationPropertyBinding> navigationPropertyBindings;
public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container, final BindingTarget target) {
super(edm, target.getName());
public AbstractEdmBindingTarget(final Edm edm, final EdmEntityContainer container, final BindingTarget target) {
super(edm, target.getName(), target);
this.container = container;
this.target = target;
this.helper = new EdmAnnotationHelperImpl(edm, target);
}
@Override
@ -128,14 +124,4 @@ public abstract class EdmBindingTargetImpl extends EdmNamedImpl implements EdmBi
return bindingTarget;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -20,15 +20,14 @@ package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmNamed;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
public abstract class EdmNamedImpl implements EdmNamed {
protected final Edm edm;
public abstract class AbstractEdmNamed extends AbstractEdmAnnotatable implements EdmNamed {
private final String name;
public EdmNamedImpl(final Edm edm, final String name) {
this.edm = edm;
public AbstractEdmNamed(final Edm edm, final String name, final Annotatable annotatable) {
super(edm, annotatable);
this.name = name;
}

View File

@ -24,30 +24,27 @@ 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.EdmBindingTarget;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmOperation;
import org.apache.olingo.commons.api.edm.EdmParameter;
import org.apache.olingo.commons.api.edm.EdmReturnType;
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;
public abstract class EdmOperationImpl extends EdmTypeImpl implements EdmOperation {
public abstract class AbstractEdmOperation extends EdmTypeImpl implements EdmOperation {
protected final Operation operation;
protected final EdmAnnotationHelperImpl helper;
private final Map<String, EdmParameter> parameters = new LinkedHashMap<String, EdmParameter>();
private String entitySetPath;
private boolean isBound;
private EdmReturnType returnType;
private List<String> parameterNames;
protected static <T extends EdmOperationImpl> T getInstance(final T instance) {
protected static <T extends AbstractEdmOperation> T getInstance(final T instance) {
final List<Parameter> providerParameters = instance.operation.getParameters();
if (providerParameters != null) {
final List<EdmParameter> _parameters = new ArrayList<EdmParameter>(providerParameters.size());
@ -71,12 +68,11 @@ public abstract class EdmOperationImpl extends EdmTypeImpl implements EdmOperati
return instance;
}
protected EdmOperationImpl(final Edm edm, final FullQualifiedName name, final Operation operation,
final EdmTypeKind kind) {
protected AbstractEdmOperation(final Edm edm, final FullQualifiedName name, final Operation operation,
final EdmTypeKind kind) {
super(edm, name, kind);
super(edm, name, kind, operation);
this.operation = operation;
this.helper = new EdmAnnotationHelperImpl(edm, operation);
}
protected void setParameters(final List<EdmParameter> _parameters) {
@ -159,16 +155,6 @@ public abstract class EdmOperationImpl extends EdmTypeImpl implements EdmOperati
return null;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
@Override
public String getEntitySetPath(){
return operation.getEntitySetPath();

View File

@ -18,31 +18,25 @@
*/
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.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmOperationImport;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.Target;
import org.apache.olingo.commons.api.edm.provider.OperationImport;
public abstract class EdmOperationImportImpl extends EdmNamedImpl implements EdmOperationImport {
public abstract class AbstractEdmOperationImport extends AbstractEdmNamed implements EdmOperationImport {
protected final EdmEntityContainer container;
private final Target entitySet;
private EdmEntitySet returnedEntitySet;
private final EdmAnnotationHelperImpl helper;
public EdmOperationImportImpl(final Edm edm, final EdmEntityContainer container,
final OperationImport operationImport) {
super(edm, operationImport.getName());
public AbstractEdmOperationImport(final Edm edm, final EdmEntityContainer container,
final OperationImport operationImport) {
super(edm, operationImport.getName(), operationImport);
this.container = container;
this.helper = new EdmAnnotationHelperImpl(edm, operationImport);
this.entitySet = new Target.Builder(operationImport.getEntitySet(), container).build();
}
@ -80,14 +74,4 @@ public abstract class EdmOperationImportImpl extends EdmNamedImpl implements Edm
public String getAnnotationsTargetPath() {
return getName();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -36,7 +36,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public abstract class EdmStructuredTypeImpl extends EdmTypeImpl implements EdmStructuredType {
public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements EdmStructuredType {
protected EdmStructuredType baseType;
protected FullQualifiedName baseTypeName;
@ -47,13 +47,13 @@ public abstract class EdmStructuredTypeImpl extends EdmTypeImpl implements EdmSt
private Map<String, EdmNavigationProperty> navigationProperties;
private final StructuralType structuredType;
public EdmStructuredTypeImpl(
final Edm edm,
final FullQualifiedName typeName,
final EdmTypeKind kind,
final StructuralType structuredType) {
public AbstractEdmStructuredType(
final Edm edm,
final FullQualifiedName typeName,
final EdmTypeKind kind,
final StructuralType structuredType) {
super(edm, typeName, kind);
super(edm, typeName, kind, structuredType);
this.baseTypeName = structuredType.getBaseTypeFQN();
this.structuredType = structuredType;
}

View File

@ -24,10 +24,10 @@ 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 class EdmActionImpl extends AbstractEdmOperation implements EdmAction {
public static EdmActionImpl getInstance(final Edm edm, final FullQualifiedName name, final Action action) {
return EdmOperationImpl.getInstance(new EdmActionImpl(edm, name, action));
return AbstractEdmOperation.getInstance(new EdmActionImpl(edm, name, action));
}
private EdmActionImpl(final Edm edm, final FullQualifiedName name, final Action action) {

View File

@ -24,7 +24,7 @@ import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport {
public class EdmActionImportImpl extends AbstractEdmOperationImport implements EdmActionImport {
private final ActionImport actionImport;

View File

@ -60,18 +60,15 @@ 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 {
public class EdmAnnotationImpl extends AbstractEdmAnnotatable implements EdmAnnotation {
private final Edm edm;
private final Annotation annotation;
private final EdmAnnotationHelperImpl helper;
private EdmTerm term;
private EdmAnnotationExpression expression;
public EdmAnnotationImpl(final Edm edm, final Annotation annotation) {
this.edm = edm;
super(edm, annotation);
this.annotation = annotation;
this.helper = new EdmAnnotationHelperImpl(edm, annotation);
}
@Override
@ -225,15 +222,4 @@ public class EdmAnnotationImpl implements EdmAnnotation {
}
return expression;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -18,21 +18,15 @@
*/
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.EdmComplexType;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
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.ComplexType;
public class EdmComplexTypeImpl extends EdmStructuredTypeImpl implements EdmComplexType {
private EdmAnnotationHelperImpl annotationHelper;
public class EdmComplexTypeImpl extends AbstractEdmStructuredType implements EdmComplexType {
public static EdmComplexTypeImpl getInstance(
final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
@ -41,19 +35,8 @@ public class EdmComplexTypeImpl extends EdmStructuredTypeImpl implements EdmComp
private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
super(edm, name, EdmTypeKind.COMPLEX, complexType);
this.annotationHelper = new EdmAnnotationHelperImpl(edm, complexType);
}
@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();
}
@Override
protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) {
EdmComplexType baseType = null;

View File

@ -19,7 +19,6 @@
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -27,13 +26,11 @@ import java.util.Map;
import org.apache.olingo.commons.api.ODataException;
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.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmException;
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.EdmProvider;
@ -43,11 +40,10 @@ 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;
public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityContainer {
public class EdmEntityContainerImpl extends AbstractEdmNamed implements EdmEntityContainer {
private final EdmProvider provider;
private EntityContainer container;
private EdmAnnotationHelperImpl helper;
protected final FullQualifiedName entityContainerName;
private final FullQualifiedName parentContainerName;
@ -66,7 +62,7 @@ public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityCon
public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider,
final EntityContainerInfo entityContainerInfo) {
super(edm, entityContainerInfo.getContainerName().getName());
super(edm, entityContainerInfo.getContainerName().getName(), null);
this.provider = provider;
this.entityContainerName = entityContainerInfo.getContainerName();
this.parentContainerName = entityContainerInfo.getExtendsContainer();
@ -74,12 +70,11 @@ public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityCon
public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, final FullQualifiedName containerFQN,
final EntityContainer entityContainer) {
super(edm, containerFQN.getName());
super(edm, containerFQN.getName(), entityContainer);
this.provider = provider;
container = entityContainer;
this.entityContainerName = containerFQN;
this.parentContainerName = entityContainer.getExtendsContainerFQN();
this.helper = new EdmAnnotationHelperImpl(edm, entityContainer);
}
@Override
@ -326,14 +321,4 @@ public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityCon
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

@ -23,7 +23,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
public class EdmEntitySetImpl extends AbstractEdmBindingTarget implements EdmEntitySet {
private EntitySet entitySet;

View File

@ -24,22 +24,19 @@ 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.EdmException;
import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
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.EntityType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
public class EdmEntityTypeImpl extends EdmStructuredTypeImpl implements EdmEntityType {
public class EdmEntityTypeImpl extends AbstractEdmStructuredType implements EdmEntityType {
private EntityType entityType;
private boolean baseTypeChecked = false;
private EdmAnnotationHelperImpl annotationHelper;
private final boolean hasStream;
protected EdmEntityType entityBaseType;
private final List<String> keyPredicateNames = new ArrayList<String>();
@ -56,7 +53,6 @@ public class EdmEntityTypeImpl extends EdmStructuredTypeImpl implements EdmEntit
super(edm, name, EdmTypeKind.ENTITY, entityType);
this.entityType = entityType;
hasStream = entityType.hasStream();
this.annotationHelper = new EdmAnnotationHelperImpl(edm, entityType);
}
@Override
@ -151,14 +147,4 @@ public class EdmEntityTypeImpl extends EdmStructuredTypeImpl implements EdmEntit
public TargetType getAnnotationsTargetType() {
return TargetType.EntityType;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return annotationHelper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return annotationHelper.getAnnotations();
}
}

View File

@ -42,13 +42,13 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
private static final Set<EdmPrimitiveTypeKind> VALID_UNDERLYING_TYPES = new HashSet<EdmPrimitiveTypeKind>();
{
static {
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;
@ -58,7 +58,7 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
private LinkedHashMap<String, EdmMember> membersMap;
public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final EnumType enumType) {
super(edm, enumName, EdmTypeKind.ENUM);
super(edm, enumName, EdmTypeKind.ENUM, enumType);
if (enumType.getUnderlyingType() == null) {
underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);

View File

@ -26,12 +26,12 @@ 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 {
public class EdmFunctionImpl extends AbstractEdmOperation 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));
return AbstractEdmOperation.getInstance(new EdmFunctionImpl(edm, name, function));
}
private EdmFunctionImpl(final Edm edm, final FullQualifiedName name, final Function function) {

View File

@ -27,7 +27,7 @@ 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;
public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport {
public class EdmFunctionImportImpl extends AbstractEdmOperationImport implements EdmFunctionImport {
private final FunctionImport functionImport;

View File

@ -18,26 +18,20 @@
*/
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.EdmMember;
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;
public class EdmMemberImpl extends EdmNamedImpl implements EdmMember {
public class EdmMemberImpl extends AbstractEdmNamed implements EdmMember {
private final EdmAnnotationHelperImpl helper;
private final FullQualifiedName enumFQN;
private final EnumMember member;
public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final EnumMember member) {
super(edm, member.getName());
super(edm, member.getName(), member);
this.enumFQN = enumFQN;
this.member = member;
this.helper = new EdmAnnotationHelperImpl(edm, member);
}
@Override
@ -59,15 +53,4 @@ public class EdmMemberImpl extends EdmNamedImpl implements EdmMember {
public String getValue() {
return member.getValue();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -22,32 +22,29 @@ 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.EdmElement;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmReferentialConstraint;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
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;
public class EdmNavigationPropertyImpl extends EdmElementImpl implements EdmNavigationProperty {
public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmElement, EdmNavigationProperty {
private final FullQualifiedName structuredTypeName;
private final NavigationProperty navigationProperty;
private final EdmAnnotationHelperImpl helper;
private List<EdmReferentialConstraint> referentialConstraints;
private EdmEntityType typeImpl;
private EdmNavigationProperty partnerNavigationProperty;
public EdmNavigationPropertyImpl(
final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) {
super(edm, navigationProperty.getName());
super(edm, navigationProperty.getName(), navigationProperty);
this.structuredTypeName = structuredTypeName;
this.navigationProperty = navigationProperty;
this.helper = new EdmAnnotationHelperImpl(edm, navigationProperty);
}
@Override
@ -139,14 +136,4 @@ public class EdmNavigationPropertyImpl extends EdmElementImpl implements EdmNavi
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

@ -18,29 +18,24 @@
*/
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.EdmElement;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmMapping;
import org.apache.olingo.commons.api.edm.EdmParameter;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.Parameter;
public class EdmParameterImpl extends EdmElementImpl implements EdmParameter {
public class EdmParameterImpl extends AbstractEdmNamed implements EdmParameter, EdmElement {
private final Parameter parameter;
private final EdmAnnotationHelperImpl helper;
private final EdmTypeInfo typeInfo;
private EdmType typeImpl;
public EdmParameterImpl(final Edm edm, final Parameter parameter) {
super(edm, parameter.getName());
super(edm, parameter.getName(), parameter);
this.parameter = parameter;
this.helper = new EdmAnnotationHelperImpl(edm, parameter);
this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(parameter.getType()).build();
}
@ -79,16 +74,6 @@ public class EdmParameterImpl extends EdmElementImpl implements EdmParameter {
return parameter.getSrid();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
@Override
public EdmType getType() {
if (typeImpl == null) {

View File

@ -18,34 +18,29 @@
*/
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.EdmElement;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmMapping;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmType;
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;
public class EdmPropertyImpl extends EdmElementImpl implements EdmProperty {
public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty, EdmElement {
private final FullQualifiedName structuredTypeName;
private final Property property;
private final EdmTypeInfo typeInfo;
private EdmAnnotationHelperImpl helper;
private EdmType propertyType;
public EdmPropertyImpl(final Edm edm, final FullQualifiedName structuredTypeName, final Property property) {
super(edm, property.getName());
super(edm, property.getName(), property);
this.structuredTypeName = structuredTypeName;
this.property = property;
typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build();
this.helper = new EdmAnnotationHelperImpl(edm, property);
}
@Override
@ -125,16 +120,6 @@ public class EdmPropertyImpl extends EdmElementImpl implements EdmProperty {
return structuredTypeName;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
@Override
public boolean isPrimitive() {
return typeInfo.isPrimitiveType();

View File

@ -18,22 +18,17 @@
*/
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.EdmReferentialConstraint;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint;
public class EdmReferentialConstraintImpl implements EdmReferentialConstraint {
public class EdmReferentialConstraintImpl extends AbstractEdmAnnotatable implements EdmReferentialConstraint {
private final EdmAnnotationHelperImpl helper;
private final ReferentialConstraint constraint;
public EdmReferentialConstraintImpl(final Edm edm, final ReferentialConstraint constraint) {
super(edm, constraint);
this.constraint = constraint;
this.helper = new EdmAnnotationHelperImpl(edm, constraint);
}
@Override
@ -45,14 +40,4 @@ public class EdmReferentialConstraintImpl implements EdmReferentialConstraint {
public String getReferencedPropertyName() {
return constraint.getReferencedProperty();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -23,7 +23,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.provider.Singleton;
public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton {
public class EdmSingletonImpl extends AbstractEdmBindingTarget implements EdmSingleton {
public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final Singleton singleton) {
super(edm, container, singleton);

View File

@ -23,7 +23,6 @@ import java.util.List;
import org.apache.commons.lang3.ClassUtils;
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.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmType;
@ -34,24 +33,22 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EdmTermImpl extends EdmNamedImpl implements EdmTerm {
public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm {
private static final Logger LOG = LoggerFactory.getLogger(EdmTermImpl.class);
private final Term term;
private final FullQualifiedName fqn;
private final EdmTypeInfo typeInfo;
private final EdmAnnotationHelperImpl helper;
private EdmType termType;
private EdmTerm baseTerm;
private List<Class<?>> appliesTo;
public EdmTermImpl(final Edm edm, final String namespace, final Term term) {
super(edm, term.getName());
super(edm, term.getName(), term);
this.term = term;
this.fqn = new FullQualifiedName(namespace, term.getName());
this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(term.getType()).build();
this.helper = new EdmAnnotationHelperImpl(edm, term);
}
@Override
@ -146,15 +143,4 @@ public class EdmTermImpl extends EdmNamedImpl implements EdmTerm {
public String getAnnotationsTargetPath() {
return null;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
}

View File

@ -18,15 +18,11 @@
*/
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.EdmException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
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.constants.EdmTypeKind;
@ -34,20 +30,17 @@ 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.primitivetype.EdmPrimitiveTypeFactory;
public class EdmTypeDefinitionImpl extends EdmNamedImpl implements EdmTypeDefinition {
public class EdmTypeDefinitionImpl extends AbstractEdmNamed implements EdmTypeDefinition {
private TypeDefinition typeDefinition;
private FullQualifiedName typeDefinitionName;
private EdmPrimitiveType edmPrimitiveTypeInstance;
private final EdmAnnotationHelperImpl helper;
public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
final TypeDefinition typeDefinition) {
super(edm, typeDefinitionName.getName());
super(edm, typeDefinitionName.getName(), typeDefinition);
this.typeDefinitionName = typeDefinitionName;
this.typeDefinition = typeDefinition;
this.helper = new EdmAnnotationHelperImpl(edm, typeDefinition);
}
@Override
@ -163,19 +156,8 @@ public class EdmTypeDefinitionImpl extends EdmNamedImpl implements EdmTypeDefini
return getFullQualifiedName();
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
return helper.getAnnotation(term);
}
@Override
public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations();
}
@Override
public String getAnnotationsTargetPath() {
return getName();
}
}

View File

@ -22,14 +22,16 @@ import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmType;
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.Annotatable;
public class EdmTypeImpl extends EdmNamedImpl implements EdmType {
public class EdmTypeImpl extends AbstractEdmNamed implements EdmType {
protected final FullQualifiedName typeName;
protected final EdmTypeKind kind;
public EdmTypeImpl(final Edm edm, final FullQualifiedName typeName, final EdmTypeKind kind) {
super(edm, typeName.getName());
public EdmTypeImpl(final Edm edm, final FullQualifiedName typeName, final EdmTypeKind kind,
final Annotatable annotatable) {
super(edm, typeName.getName(), annotatable);
this.typeName = typeName;
this.kind = kind;
}

View File

@ -35,9 +35,7 @@ public class EdmTypeInfo {
public static class Builder {
private String typeExpression;
private String defaultNamespace;
private Edm edm;
public Builder setTypeExpression(final String typeExpression) {
@ -62,25 +60,15 @@ public class EdmTypeInfo {
}
}
private final Edm edm;
private final boolean collection;
private final FullQualifiedName fullQualifiedName;
private EdmPrimitiveTypeKind primitiveType;
private EdmTypeDefinition typeDefinition;
private EdmEnumType enumType;
private EdmComplexType complexType;
private EdmEntityType entityType;
private EdmTypeInfo(final Edm edm, final String typeExpression) {
this.edm = edm;
String baseType;
final int collStartIdx = typeExpression.indexOf("Collection(");
final int collEndIdx = typeExpression.lastIndexOf(')');
@ -105,7 +93,6 @@ public class EdmTypeInfo {
if (lastDotIdx == -1) {
namespace = EdmPrimitiveType.EDM_NAMESPACE;
typeName = baseType;
baseType = new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, baseType).toString();
} else {
namespace = baseType.substring(0, lastDotIdx);
typeName = baseType.substring(lastDotIdx + 1);
@ -115,9 +102,6 @@ public class EdmTypeInfo {
throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
}
final StringBuilder exp = new StringBuilder();
exp.append(baseType);
fullQualifiedName = new FullQualifiedName(namespace, typeName);
try {
@ -125,14 +109,14 @@ public class EdmTypeInfo {
} catch (final IllegalArgumentException e) {
primitiveType = null;
}
if (primitiveType == null && this.edm != null) {
typeDefinition = this.edm.getTypeDefinition(fullQualifiedName);
if (primitiveType == null && edm != null) {
typeDefinition = edm.getTypeDefinition(fullQualifiedName);
if (typeDefinition == null) {
enumType = this.edm.getEnumType(fullQualifiedName);
enumType = edm.getEnumType(fullQualifiedName);
if (enumType == null) {
complexType = this.edm.getComplexType(fullQualifiedName);
complexType = edm.getComplexType(fullQualifiedName);
if (complexType == null) {
entityType = this.edm.getEntityType(fullQualifiedName);
entityType = edm.getEntityType(fullQualifiedName);
}
}
}

View File

@ -18,25 +18,42 @@
*/
package org.apache.olingo.server.core.edm.provider;
import org.apache.olingo.commons.api.edm.EdmAnnotatable;
import org.apache.olingo.commons.api.edm.EdmNamed;
import org.apache.olingo.commons.core.edm.provider.EdmNamedImpl;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.core.edm.provider.AbstractEdmNamed;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
public class EdmNamedImplTest {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class AbstractEdmNamedTest {
@Test
public void getNameTest() {
EdmNamed obj = new EdmNamedImplTester("Name");
assertEquals("Name", obj.getName());
EdmAnnotatable an = (EdmAnnotatable) obj;
assertNotNull(an.getAnnotations().get(0));
}
private class EdmNamedImplTester extends EdmNamedImpl {
private class EdmNamedImplTester extends AbstractEdmNamed {
public EdmNamedImplTester(final String name) {
super(null, name);
super(null, name, new AnnoTester());
}
}
private class AnnoTester implements Annotatable {
@Override
public List<Annotation> getAnnotations() {
Annotation annotation = new Annotation();
annotation.setTerm("NS.SimpleTerm");
return Arrays.asList(annotation);
}
}
}

View File

@ -18,13 +18,20 @@
*/
package org.apache.olingo.server.core.edm.provider;
import org.apache.olingo.commons.api.edm.EdmAnnotatable;
import org.apache.olingo.commons.api.edm.EdmType;
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.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.core.edm.provider.EdmTypeImpl;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class EdmTypeImplTest {
@ -34,12 +41,22 @@ public class EdmTypeImplTest {
assertEquals("name", type.getName());
assertEquals("namespace", type.getNamespace());
assertEquals(EdmTypeKind.UNDEFINED, type.getKind());
EdmAnnotatable an = (EdmAnnotatable) type;
assertNotNull(an.getAnnotations().get(0));
}
private class EdmTypeImplTester extends EdmTypeImpl {
public EdmTypeImplTester(final FullQualifiedName name, final EdmTypeKind kind) {
super(null, name, kind);
super(null, name, kind, new AnnoTester());
}
}
private class AnnoTester implements Annotatable {
@Override
public List<Annotation> getAnnotations() {
Annotation annotation = new Annotation();
annotation.setTerm("NS.SimpleTerm");
return Arrays.asList(annotation);
}
}
}