mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-03-05 16:19:05 +00:00
[OLINGO-768] Delete getTarget method at EdmAnnotations interface
The method never worked. Also the design dod not allow to return all possible target types. For example an entity type as target results in returning the EdmEntityType object but for functions we would have to return a list of functions. If needed we can implement another method later.
This commit is contained in:
parent
1ac59b22a8
commit
d9d33abe85
@ -35,6 +35,7 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
|
|||||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
|
import org.apache.olingo.commons.api.edm.TargetType;
|
||||||
import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
|
import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -115,8 +116,8 @@ public class MetadataTestITCase extends AbstractTestITCase {
|
|||||||
|
|
||||||
final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core.IsLanguageDependent"));
|
final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core.IsLanguageDependent"));
|
||||||
assertNotNull(isLanguageDependent);
|
assertNotNull(isLanguageDependent);
|
||||||
assertTrue(isLanguageDependent.getAppliesTo().contains("Property"));
|
assertTrue(isLanguageDependent.getAppliesTo().contains(TargetType.Property));
|
||||||
assertTrue(isLanguageDependent.getAppliesTo().contains("Term"));
|
assertTrue(isLanguageDependent.getAppliesTo().contains(TargetType.Term));
|
||||||
assertEquals(edm.getTypeDefinition(new FullQualifiedName("Core.Tag")), isLanguageDependent.getType());
|
assertEquals(edm.getTypeDefinition(new FullQualifiedName("Core.Tag")), isLanguageDependent.getType());
|
||||||
assertEquals(EdmBoolean.getInstance(), ((EdmTypeDefinition) isLanguageDependent.getType()).getUnderlyingType());
|
assertEquals(EdmBoolean.getInstance(), ((EdmTypeDefinition) isLanguageDependent.getType()).getUnderlyingType());
|
||||||
assertNotNull(isLanguageDependent.getAnnotation(descriptionTerm, null));
|
assertNotNull(isLanguageDependent.getAnnotation(descriptionTerm, null));
|
||||||
|
@ -33,7 +33,6 @@ import org.apache.olingo.commons.api.edm.Edm;
|
|||||||
import org.apache.olingo.commons.api.edm.EdmAction;
|
import org.apache.olingo.commons.api.edm.EdmAction;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotations;
|
import org.apache.olingo.commons.api.edm.EdmAnnotations;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
@ -164,9 +163,10 @@ public class MetadataTest extends AbstractTest {
|
|||||||
|
|
||||||
final EdmAnnotations annotationGroup = schema.getAnnotationGroups().get(2);
|
final EdmAnnotations annotationGroup = schema.getAnnotationGroups().get(2);
|
||||||
assertNotNull(annotationGroup);
|
assertNotNull(annotationGroup);
|
||||||
final EdmAnnotationsTarget annotationsTarget = annotationGroup.getTarget();
|
//TODO; Once there is a working getTarget method comment back in
|
||||||
assertNotNull(annotationsTarget);
|
// final EdmAnnotationsTarget annotationsTarget = annotationGroup.getTarget();
|
||||||
assertTrue(EdmAnnotationsTarget.TargetType.Property == annotationsTarget.getAnnotationsTargetType());
|
// assertNotNull(annotationsTarget);
|
||||||
|
// assertTrue(EdmAnnotationsTarget.TargetType.Property == annotationsTarget.getAnnotationsTargetType());
|
||||||
assertEquals("ODataDemo.Product/Name", annotationGroup.getTargetPath());
|
assertEquals("ODataDemo.Product/Name", annotationGroup.getTargetPath());
|
||||||
|
|
||||||
final EdmAnnotation annotation = annotationGroup.getAnnotations().get(0);
|
final EdmAnnotation annotation = annotationGroup.getAnnotations().get(0);
|
||||||
|
@ -24,11 +24,6 @@ package org.apache.olingo.commons.api.edm;
|
|||||||
*/
|
*/
|
||||||
public interface EdmAnnotations extends EdmAnnotatable{
|
public interface EdmAnnotations extends EdmAnnotatable{
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a model element in the entity model to which this annotations is targeted
|
|
||||||
*/
|
|
||||||
EdmAnnotationsTarget getTarget();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a string allowing annotation authors a means of conditionally applying an annotation
|
* @return a string allowing annotation authors a means of conditionally applying an annotation
|
||||||
*/
|
*/
|
||||||
|
@ -1,60 +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.commons.api.edm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for CSDL elements thar can be evaluated as <tt>target</tt> for <tt>edm:Annotations</tt>.
|
|
||||||
*
|
|
||||||
* @see EdmAnnotations
|
|
||||||
*/
|
|
||||||
public interface EdmAnnotationsTarget {
|
|
||||||
|
|
||||||
enum TargetType {
|
|
||||||
|
|
||||||
ActionImport(EdmActionImport.class),
|
|
||||||
ComplexType(EdmComplexType.class),
|
|
||||||
EntityContainer(EdmEntityContainer.class),
|
|
||||||
EntitySet(EdmEntitySet.class),
|
|
||||||
EntityType(EdmEntityType.class),
|
|
||||||
EnumType(EdmEnumType.class),
|
|
||||||
FunctionImport(EdmFunctionImport.class),
|
|
||||||
Member(EdmMember.class),
|
|
||||||
NavigationProperty(EdmNavigationProperty.class),
|
|
||||||
Property(EdmProperty.class),
|
|
||||||
Singleton(EdmSingleton.class),
|
|
||||||
Term(EdmTerm.class),
|
|
||||||
TypeDefinition(EdmTypeDefinition.class);
|
|
||||||
|
|
||||||
private final Class<?> edmClass;
|
|
||||||
|
|
||||||
TargetType(final Class<?> edmClass) {
|
|
||||||
this.edmClass = edmClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<?> getEdmClass() {
|
|
||||||
return edmClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {@link TargetType} of this target
|
|
||||||
*/
|
|
||||||
TargetType getAnnotationsTargetType();
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||||||
* Entity Sets or Singletons can be bound to each other using a navigation property binding so an
|
* Entity Sets or Singletons can be bound to each other using a navigation property binding so an
|
||||||
* {@link EdmBindingTarget} can either be an {@link EdmEntitySet} or an {@link EdmSingleton}.
|
* {@link EdmBindingTarget} can either be an {@link EdmEntitySet} or an {@link EdmSingleton}.
|
||||||
*/
|
*/
|
||||||
public interface EdmBindingTarget extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmBindingTarget extends EdmNamed, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the target for a given path.
|
* Returns the target for a given path.
|
||||||
|
@ -26,7 +26,7 @@ import java.util.List;
|
|||||||
* <br/>
|
* <br/>
|
||||||
* EdmEntityContainer hold the information of EntitySets, Singletons, ActionImports and FunctionImports contained
|
* EdmEntityContainer hold the information of EntitySets, Singletons, ActionImports and FunctionImports contained
|
||||||
*/
|
*/
|
||||||
public interface EdmEntityContainer extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmEntityContainer extends EdmNamed, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return namespace of this entity container
|
* @return namespace of this entity container
|
||||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* An EdmEnumType represents a set of related values.
|
* An EdmEnumType represents a set of related values.
|
||||||
*/
|
*/
|
||||||
public interface EdmEnumType extends EdmPrimitiveType, EdmAnnotationsTarget {
|
public interface EdmEnumType extends EdmPrimitiveType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get member according to given name
|
* Get member according to given name
|
||||||
|
@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.edm;
|
|||||||
/**
|
/**
|
||||||
* An {@link EdmEnumType} member element.
|
* An {@link EdmEnumType} member element.
|
||||||
*/
|
*/
|
||||||
public interface EdmMember extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmMember extends EdmNamed, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return value of this member as string
|
* @return value of this member as string
|
||||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
* <br/>
|
* <br/>
|
||||||
* EdmNavigationProperty allows navigation from one entity type to another via a relationship.
|
* EdmNavigationProperty allows navigation from one entity type to another via a relationship.
|
||||||
*/
|
*/
|
||||||
public interface EdmNavigationProperty extends EdmElement, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmNavigationProperty extends EdmElement, EdmAnnotatable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
EdmEntityType getType();
|
EdmEntityType getType();
|
||||||
|
@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.edm;
|
|||||||
/**
|
/**
|
||||||
* An EdmOperationImport can be an EdmActionImport or an EdmFunctionImport.
|
* An EdmOperationImport can be an EdmActionImport or an EdmFunctionImport.
|
||||||
*/
|
*/
|
||||||
public interface EdmOperationImport extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmOperationImport extends EdmNamed, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@link FullQualifiedName} of this OperationImport
|
* @return {@link FullQualifiedName} of this OperationImport
|
||||||
|
@ -25,7 +25,7 @@ import org.apache.olingo.commons.api.edm.geo.SRID;
|
|||||||
* <br/>
|
* <br/>
|
||||||
* EdmProperty defines a simple type or a complex type.
|
* EdmProperty defines a simple type or a complex type.
|
||||||
*/
|
*/
|
||||||
public interface EdmProperty extends EdmElement, EdmMappable, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmProperty extends EdmElement, EdmMappable, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the related MIME type for the property.
|
* Gets the related MIME type for the property.
|
||||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* Complex types and entity types are described in the Conceptual Schema Definition of the OData protocol.
|
* Complex types and entity types are described in the Conceptual Schema Definition of the OData protocol.
|
||||||
*/
|
*/
|
||||||
public interface EdmStructuredType extends EdmType, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmStructuredType extends EdmType, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get property by name
|
* Get property by name
|
||||||
|
@ -25,7 +25,7 @@ import org.apache.olingo.commons.api.edm.geo.SRID;
|
|||||||
/**
|
/**
|
||||||
* An {@link EdmTerm} defines a term in a vocabulary.
|
* An {@link EdmTerm} defines a term in a vocabulary.
|
||||||
*/
|
*/
|
||||||
public interface EdmTerm extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmTerm extends EdmNamed, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return type of value returned by the expression contained in an annotation using this term
|
* @return type of value returned by the expression contained in an annotation using this term
|
||||||
@ -49,7 +49,7 @@ public interface EdmTerm extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable
|
|||||||
* @return list of CSDL element that this term can be applied to; if no value is supplied, the term is not restricted
|
* @return list of CSDL element that this term can be applied to; if no value is supplied, the term is not restricted
|
||||||
* in its application.
|
* in its application.
|
||||||
*/
|
*/
|
||||||
List<String> getAppliesTo();
|
List<TargetType> getAppliesTo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if nullable
|
* @return true if nullable
|
||||||
|
@ -25,7 +25,7 @@ import org.apache.olingo.commons.api.edm.geo.SRID;
|
|||||||
* <br/>
|
* <br/>
|
||||||
* For more information on primitive types refer to {@link EdmPrimitiveType}.
|
* For more information on primitive types refer to {@link EdmPrimitiveType}.
|
||||||
*/
|
*/
|
||||||
public interface EdmTypeDefinition extends EdmPrimitiveType, EdmAnnotationsTarget, EdmAnnotatable {
|
public interface EdmTypeDefinition extends EdmPrimitiveType, EdmAnnotatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@link EdmPrimitiveType} this type definition is based upon
|
* @return {@link EdmPrimitiveType} this type definition is based upon
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.olingo.commons.api.edm;
|
||||||
|
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmAnd;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmApply;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmCast;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmEq;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmGe;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmGt;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmIf;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmIsOf;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElement;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmLe;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmLt;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmNe;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmNot;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmNull;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmOr;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
|
||||||
|
import org.apache.olingo.commons.api.edm.annotation.EdmUrlRef;
|
||||||
|
import org.apache.olingo.commons.api.edm.constants.EdmOnDelete;
|
||||||
|
import org.apache.olingo.server.api.edmx.EdmxReference;
|
||||||
|
|
||||||
|
public enum TargetType {
|
||||||
|
|
||||||
|
// CSDL Types
|
||||||
|
Action(EdmAction.class),
|
||||||
|
ActionImport(EdmActionImport.class),
|
||||||
|
Annotation(EdmAnnotation.class),
|
||||||
|
Apply(EdmApply.class),
|
||||||
|
Cast(EdmCast.class),
|
||||||
|
ComplexType(EdmComplexType.class),
|
||||||
|
EntityContainer(EdmEntityContainer.class),
|
||||||
|
EntitySet(EdmEntitySet.class),
|
||||||
|
EntityType(EdmEntityType.class),
|
||||||
|
EnumType(EdmEnumType.class),
|
||||||
|
Function(EdmFunction.class),
|
||||||
|
FunctionImport(EdmFunctionImport.class),
|
||||||
|
If(EdmIf.class),
|
||||||
|
IsOf(EdmIsOf.class),
|
||||||
|
LabeledElement(EdmLabeledElement.class),
|
||||||
|
Member(EdmMember.class),
|
||||||
|
NavigationProperty(EdmNavigationProperty.class),
|
||||||
|
Null(EdmNull.class),
|
||||||
|
OnDelete(EdmOnDelete.class),
|
||||||
|
Property(EdmProperty.class),
|
||||||
|
PropertyValue(EdmPropertyValue.class),
|
||||||
|
Record(EdmRecord.class),
|
||||||
|
ReferentialConstraint(EdmReferentialConstraint.class),
|
||||||
|
ReturnType(EdmReturnType.class),
|
||||||
|
Schema(EdmSchema.class),
|
||||||
|
Singleton(EdmSingleton.class),
|
||||||
|
Term(EdmTerm.class),
|
||||||
|
TypeDefinition(EdmTypeDefinition.class),
|
||||||
|
URLRef(EdmUrlRef.class),
|
||||||
|
Reference(EdmxReference.class),
|
||||||
|
// Logical Operators
|
||||||
|
And(EdmAnd.class),
|
||||||
|
Or(EdmOr.class),
|
||||||
|
Not(EdmNot.class),
|
||||||
|
// ComparisonOperators
|
||||||
|
Eq(EdmEq.class),
|
||||||
|
Ne(EdmNe.class),
|
||||||
|
Gt(EdmGt.class),
|
||||||
|
Ge(EdmGe.class),
|
||||||
|
Lt(EdmLt.class),
|
||||||
|
Le(EdmLe.class);
|
||||||
|
|
||||||
|
private final Class<?> edmClass;
|
||||||
|
|
||||||
|
TargetType(final Class<?> edmClass) {
|
||||||
|
this.edmClass = edmClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> getEdmClass() {
|
||||||
|
return edmClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -38,9 +38,4 @@ public class EdmActionImportImpl extends AbstractEdmOperationImport implements E
|
|||||||
public EdmAction getUnboundAction() {
|
public EdmAction getUnboundAction() {
|
||||||
return edm.getUnboundAction(actionImport.getActionFQN());
|
return edm.getUnboundAction(actionImport.getActionFQN());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.ActionImport;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,97 +18,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.olingo.commons.core.edm;
|
package org.apache.olingo.commons.core.edm;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotations;
|
import org.apache.olingo.commons.api.edm.EdmAnnotations;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmStructuredType;
|
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations;
|
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations;
|
||||||
|
|
||||||
public class EdmAnnotationsImpl extends AbstractEdmAnnotatable implements EdmAnnotations {
|
public class EdmAnnotationsImpl extends AbstractEdmAnnotatable implements EdmAnnotations {
|
||||||
|
|
||||||
private final Edm edm;
|
|
||||||
private final CsdlAnnotations annotationGroup;
|
private final CsdlAnnotations annotationGroup;
|
||||||
private EdmAnnotationsTarget target;
|
|
||||||
|
|
||||||
public EdmAnnotationsImpl(final Edm edm, final CsdlAnnotations annotationGroup) {
|
public EdmAnnotationsImpl(final Edm edm, final CsdlAnnotations annotationGroup) {
|
||||||
super(edm, annotationGroup);
|
super(edm, annotationGroup);
|
||||||
this.edm = edm;
|
|
||||||
this.annotationGroup = annotationGroup;
|
this.annotationGroup = annotationGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EdmAnnotationsTarget getTarget(final EdmStructuredType structured, final String path) {
|
|
||||||
EdmAnnotationsTarget _target = null;
|
|
||||||
if (structured != null) {
|
|
||||||
_target = path == null
|
|
||||||
? structured
|
|
||||||
: structured.getStructuralProperty(path);
|
|
||||||
if (_target == null) {
|
|
||||||
_target = structured.getNavigationProperty(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _target;
|
|
||||||
}
|
|
||||||
|
|
||||||
private EdmAnnotationsTarget getTarget(final EdmEnumType enumType, final String path) {
|
|
||||||
EdmAnnotationsTarget _target = null;
|
|
||||||
if (enumType != null) {
|
|
||||||
_target = path == null
|
|
||||||
? enumType
|
|
||||||
: enumType.getMember(path);
|
|
||||||
}
|
|
||||||
return _target;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EdmAnnotationsTarget getTarget() {
|
|
||||||
if (target == null) {
|
|
||||||
final String[] splitted = StringUtils.split(annotationGroup.getTarget(), '/');
|
|
||||||
final FullQualifiedName base = new FullQualifiedName(splitted[0]);
|
|
||||||
final String path = splitted.length > 1 ? splitted[1] : null;
|
|
||||||
|
|
||||||
final EdmEntityContainer baseEntityContainer = edm.getEntityContainer();
|
|
||||||
|
|
||||||
EdmAnnotationsTarget localTarget = baseEntityContainer == null ? null
|
|
||||||
: baseEntityContainer.getActionImport(path);
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = getTarget(edm.getComplexType(base), path);
|
|
||||||
if (localTarget == null) {
|
|
||||||
if (baseEntityContainer != null && baseEntityContainer.getFullQualifiedName().equals(base)) {
|
|
||||||
localTarget = baseEntityContainer;
|
|
||||||
}
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = baseEntityContainer == null ? null : baseEntityContainer.getEntitySet(path);
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = getTarget(edm.getEntityType(base), path);
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = getTarget(edm.getEnumType(base), path);
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = baseEntityContainer == null ? null : baseEntityContainer.getFunctionImport(path);
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = baseEntityContainer == null ? null : baseEntityContainer.getSingleton(path);
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = edm.getTerm(base);
|
|
||||||
if (localTarget == null) {
|
|
||||||
localTarget = edm.getTypeDefinition(base);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
target = localTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQualifier() {
|
public String getQualifier() {
|
||||||
return annotationGroup.getQualifier();
|
return annotationGroup.getQualifier();
|
||||||
|
@ -57,9 +57,4 @@ public class EdmComplexTypeImpl extends AbstractEdmStructuredType implements Edm
|
|||||||
baseType = buildBaseType(baseTypeName);
|
baseType = buildBaseType(baseTypeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.ComplexType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -309,9 +309,4 @@ public class EdmEntityContainerImpl extends AbstractEdmNamed implements EdmEntit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.EntityContainer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,4 @@ public class EdmEntitySetImpl extends AbstractEdmBindingTarget implements EdmEnt
|
|||||||
public boolean isIncludeInServiceDocument() {
|
public boolean isIncludeInServiceDocument() {
|
||||||
return entitySet.isIncludeInServiceDocument();
|
return entitySet.isIncludeInServiceDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.EntitySet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,4 @@ public class EdmEntityTypeImpl extends AbstractEdmStructuredType implements EdmE
|
|||||||
public boolean hasStream() {
|
public boolean hasStream() {
|
||||||
return hasStream;
|
return hasStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.EntityType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -251,11 +251,6 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
|
|||||||
return enumType.isFlags();
|
return enumType.isFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.EnumType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.getFullQualifiedName().getFullQualifiedNameAsString().hashCode();
|
return this.getFullQualifiedName().getFullQualifiedNameAsString().hashCode();
|
||||||
|
@ -56,9 +56,4 @@ public class EdmFunctionImportImpl extends AbstractEdmOperationImport implements
|
|||||||
public boolean isIncludeInServiceDocument() {
|
public boolean isIncludeInServiceDocument() {
|
||||||
return functionImport.isIncludeInServiceDocument();
|
return functionImport.isIncludeInServiceDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.FunctionImport;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,6 @@ public class EdmMemberImpl extends AbstractEdmNamed implements EdmMember {
|
|||||||
this.member = member;
|
this.member = member;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.Member;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return member.getValue();
|
return member.getValue();
|
||||||
|
@ -120,9 +120,4 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmEl
|
|||||||
}
|
}
|
||||||
return Collections.unmodifiableList(referentialConstraints);
|
return Collections.unmodifiableList(referentialConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.NavigationProperty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -102,11 +102,6 @@ public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty, Ed
|
|||||||
return property.getDefaultValue();
|
return property.getDefaultValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.Property;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPrimitive() {
|
public boolean isPrimitive() {
|
||||||
return typeInfo.isPrimitiveType();
|
return typeInfo.isPrimitiveType();
|
||||||
|
@ -28,9 +28,4 @@ public class EdmSingletonImpl extends AbstractEdmBindingTarget implements EdmSin
|
|||||||
public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final CsdlSingleton singleton) {
|
public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final CsdlSingleton singleton) {
|
||||||
super(edm, container, singleton);
|
super(edm, container, singleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.Singleton;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.olingo.commons.core.edm;
|
package org.apache.olingo.commons.core.edm;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
@ -26,6 +27,7 @@ import org.apache.olingo.commons.api.edm.EdmException;
|
|||||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmType;
|
import org.apache.olingo.commons.api.edm.EdmType;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
|
import org.apache.olingo.commons.api.edm.TargetType;
|
||||||
import org.apache.olingo.commons.api.edm.geo.SRID;
|
import org.apache.olingo.commons.api.edm.geo.SRID;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
|
import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||||
@ -37,7 +39,7 @@ public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm {
|
|||||||
private final EdmTypeInfo typeInfo;
|
private final EdmTypeInfo typeInfo;
|
||||||
private EdmType termType;
|
private EdmType termType;
|
||||||
private EdmTerm baseTerm;
|
private EdmTerm baseTerm;
|
||||||
private List<String> appliesTo;
|
private List<TargetType> appliesTo;
|
||||||
|
|
||||||
public EdmTermImpl(final Edm edm, final String namespace, final CsdlTerm term) {
|
public EdmTermImpl(final Edm edm, final String namespace, final CsdlTerm term) {
|
||||||
super(edm, term.getName(), term);
|
super(edm, term.getName(), term);
|
||||||
@ -81,10 +83,17 @@ public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAppliesTo() {
|
public List<TargetType> getAppliesTo() {
|
||||||
if (appliesTo == null) {
|
if (appliesTo == null) {
|
||||||
appliesTo = new ArrayList<String>();
|
ArrayList<TargetType> localAppliesTo = new ArrayList<TargetType>();
|
||||||
appliesTo.addAll(term.getAppliesTo());
|
for (String apply : term.getAppliesTo()) {
|
||||||
|
try {
|
||||||
|
localAppliesTo.add(TargetType.valueOf(apply));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new EdmException("Invalid AppliesTo value: " + apply, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appliesTo = Collections.unmodifiableList(localAppliesTo);
|
||||||
}
|
}
|
||||||
return appliesTo;
|
return appliesTo;
|
||||||
}
|
}
|
||||||
@ -118,9 +127,4 @@ public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm {
|
|||||||
public String getDefaultValue() {
|
public String getDefaultValue() {
|
||||||
return term.getDefaultValue();
|
return term.getDefaultValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.Term;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -144,9 +144,4 @@ public class EdmTypeDefinitionImpl extends AbstractEdmNamed implements EdmTypeDe
|
|||||||
public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
|
public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
|
||||||
return getUnderlyingType().fromUriLiteral(literal);
|
return getUnderlyingType().fromUriLiteral(literal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetType getAnnotationsTargetType() {
|
|
||||||
return TargetType.TypeDefinition;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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 static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmAnnotations;
|
||||||
|
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations;
|
||||||
|
import org.apache.olingo.commons.core.edm.EdmAnnotationsImpl;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class EdmAnnotationsImplTest {
|
||||||
|
|
||||||
|
private Edm edm;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setupEdm() {
|
||||||
|
edm = mock(Edm.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void initialAnnotationGroup() {
|
||||||
|
CsdlAnnotations csdlAnnotationGroup = new CsdlAnnotations();
|
||||||
|
EdmAnnotations annotationGroup = new EdmAnnotationsImpl(edm, csdlAnnotationGroup);
|
||||||
|
|
||||||
|
assertNotNull(annotationGroup.getAnnotations());
|
||||||
|
assertTrue(annotationGroup.getAnnotations().isEmpty());
|
||||||
|
|
||||||
|
assertNull(annotationGroup.getQualifier());
|
||||||
|
assertNull(annotationGroup.getTargetPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void annotationGroupWithQualifierAndPathButNonValidTarget() {
|
||||||
|
CsdlAnnotations csdlAnnotationGroup = new CsdlAnnotations();
|
||||||
|
csdlAnnotationGroup.setQualifier("qualifier");
|
||||||
|
csdlAnnotationGroup.setTarget("invalid.invalid");
|
||||||
|
EdmAnnotations annotationGroup = new EdmAnnotationsImpl(edm, csdlAnnotationGroup);
|
||||||
|
|
||||||
|
assertNotNull(annotationGroup.getAnnotations());
|
||||||
|
assertTrue(annotationGroup.getAnnotations().isEmpty());
|
||||||
|
|
||||||
|
assertEquals("qualifier", annotationGroup.getQualifier());
|
||||||
|
assertEquals("invalid.invalid", annotationGroup.getTargetPath());
|
||||||
|
}
|
||||||
|
}
|
@ -29,10 +29,10 @@ import static org.mockito.Mockito.when;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget.TargetType;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
|
import org.apache.olingo.commons.api.edm.TargetType;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
|
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
|
import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
|
import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
|
||||||
@ -93,8 +93,6 @@ public class EdmTermImplTest {
|
|||||||
EdmPrimitiveType type = (EdmPrimitiveType) initialTerm.getType();
|
EdmPrimitiveType type = (EdmPrimitiveType) initialTerm.getType();
|
||||||
assertEquals(type.getName(), "String");
|
assertEquals(type.getName(), "String");
|
||||||
|
|
||||||
assertEquals(TargetType.Term, initialTerm.getAnnotationsTargetType());
|
|
||||||
|
|
||||||
//initial facets
|
//initial facets
|
||||||
assertTrue(initialTerm.isNullable());
|
assertTrue(initialTerm.isNullable());
|
||||||
assertNull(initialTerm.getDefaultValue());
|
assertNull(initialTerm.getDefaultValue());
|
||||||
@ -114,13 +112,11 @@ public class EdmTermImplTest {
|
|||||||
assertFalse(derivedTerm.getAnnotations().isEmpty());
|
assertFalse(derivedTerm.getAnnotations().isEmpty());
|
||||||
assertEquals(1, derivedTerm.getAnnotations().size());
|
assertEquals(1, derivedTerm.getAnnotations().size());
|
||||||
assertFalse(derivedTerm.getAppliesTo().isEmpty());
|
assertFalse(derivedTerm.getAppliesTo().isEmpty());
|
||||||
assertEquals("Property", derivedTerm.getAppliesTo().get(0));
|
assertEquals(TargetType.Property, derivedTerm.getAppliesTo().get(0));
|
||||||
|
|
||||||
EdmPrimitiveType type = (EdmPrimitiveType) derivedTerm.getType();
|
EdmPrimitiveType type = (EdmPrimitiveType) derivedTerm.getType();
|
||||||
assertEquals(type.getName(), "String");
|
assertEquals(type.getName(), "String");
|
||||||
|
|
||||||
assertEquals(TargetType.Term, derivedTerm.getAnnotationsTargetType());
|
|
||||||
|
|
||||||
//set facets
|
//set facets
|
||||||
assertFalse(derivedTerm.isNullable());
|
assertFalse(derivedTerm.isNullable());
|
||||||
assertEquals("abc", derivedTerm.getDefaultValue());
|
assertEquals("abc", derivedTerm.getDefaultValue());
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.apache.olingo.server.tecsvc.provider;
|
package org.apache.olingo.server.tecsvc.provider;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user