http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java deleted file mode 100644 index 7e3f7f0..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java +++ /dev/null @@ -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(); - } - -}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java deleted file mode 100644 index 85934cb..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java +++ /dev/null @@ -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; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java deleted file mode 100644 index c35de08..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java deleted file mode 100644 index d044f8c..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java deleted file mode 100644 index 0930bf2..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java +++ /dev/null @@ -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(); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java deleted file mode 100644 index ad9baba..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java deleted file mode 100644 index 796b602..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java +++ /dev/null @@ -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(); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java deleted file mode 100644 index b14fece..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java deleted file mode 100644 index 5b8e784..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java deleted file mode 100644 index 69fb192..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java deleted file mode 100644 index cc30e37..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java +++ /dev/null @@ -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(); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java deleted file mode 100644 index 27bc5f4..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java deleted file mode 100644 index be3e49e..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java deleted file mode 100644 index aafc05d..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java +++ /dev/null @@ -1,49 +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.EdmTerm; -import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint; -import org.apache.olingo.commons.core.edm.AbstractEdmReferentialConstraint; -import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; - -public class EdmReferentialConstraintImpl extends AbstractEdmReferentialConstraint { - - private final EdmAnnotationHelper helper; - - public EdmReferentialConstraintImpl(final Edm edm, final ReferentialConstraint constraint) { - super(constraint.getProperty(), constraint.getReferencedProperty()); - this.helper = new EdmAnnotationHelperImpl(edm, constraint); - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List<EdmAnnotation> getAnnotations() { - return helper.getAnnotations(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java deleted file mode 100644 index 03d1537..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java +++ /dev/null @@ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java deleted file mode 100644 index 41c4900..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java +++ /dev/null @@ -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; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java deleted file mode 100644 index 4216727..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java +++ /dev/null @@ -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; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java deleted file mode 100644 index bc6e173..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java +++ /dev/null @@ -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(); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java deleted file mode 100644 index 2885ce2..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java +++ /dev/null @@ -1,170 +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.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; -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.Term; -import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; -import org.apache.olingo.commons.core.edm.EdmNamedImpl; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class EdmTermImpl extends EdmNamedImpl 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 EdmAnnotationHelper 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()); - - 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 - public FullQualifiedName getFullQualifiedName() { - return fqn; - } - - @Override - public EdmType getType() { - if (termType == null) { - termType = typeInfo.isPrimitiveType() - ? EdmPrimitiveTypeFactory.getInstance(typeInfo.getPrimitiveTypeKind()) - : typeInfo.isTypeDefinition() - ? typeInfo.getTypeDefinition() - : typeInfo.isEnumType() - ? typeInfo.getEnumType() - : typeInfo.isComplexType() - ? typeInfo.getComplexType() - : null; - if (termType == null) { - throw new EdmException("Cannot find type with name: " + typeInfo.getFullQualifiedName()); - } - } - - return termType; - } - - @Override - public EdmTerm getBaseTerm() { - if (baseTerm == null && term.getBaseTerm() != null) { - baseTerm = edm.getTerm(new FullQualifiedName(term.getBaseTerm())); - } - return baseTerm; - } - - @Override - public List<Class<?>> getAppliesTo() { - if (appliesTo == null) { - appliesTo = new ArrayList<Class<?>>(); - for (String element : term.getAppliesTo()) { - try { - appliesTo.add(ClassUtils.getClass(EdmTerm.class.getPackage().getName() + ".Edm" + element)); - } catch (ClassNotFoundException e) { - LOG.error("Could not load Edm class for {}", element, e); - } - } - } - return appliesTo; - } - - @Override - public Boolean isNullable() { - return term.isNullable(); - } - - @Override - public Integer getMaxLength() { - return term.getMaxLength(); - } - - @Override - public Integer getPrecision() { - return term.getPrecision(); - } - - @Override - public Integer getScale() { - return term.getScale(); - } - - @Override - public SRID getSrid() { - return term.getSrid(); - } - - @Override - public String getDefaultValue() { - return term.getDefaultValue(); - } - - @Override - public TargetType getAnnotationsTargetType() { - return TargetType.Term; - } - - @Override - public FullQualifiedName getAnnotationsTargetFQN() { - return getFullQualifiedName(); - } - - @Override - public String getAnnotationsTargetPath() { - return null; - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List<EdmAnnotation> getAnnotations() { - return helper.getAnnotations(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java deleted file mode 100644 index 1b6f1f5..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java +++ /dev/null @@ -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.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.EdmAnnotationHelper; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; - -public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition { - - private final TypeDefinition typeDefinition; - - private final EdmPrimitiveType edmPrimitiveTypeInstance; - - private final EdmAnnotationHelper helper; - - public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName, - final TypeDefinition typeDefinition) { - - super(edm, typeDefinitionName); - this.typeDefinition = typeDefinition; - try { - this.edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance( - EdmPrimitiveTypeKind.valueOfFQN(typeDefinition.getUnderlyingType())); - } catch (IllegalArgumentException e) { - throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e); - } - this.helper = new EdmAnnotationHelperImpl(edm, typeDefinition); - } - - @Override - public EdmPrimitiveType getUnderlyingType() { - 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 typeDefinition.getSrid(); - } - - @Override - public Boolean isUnicode() { - return typeDefinition.isUnicode(); - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List<EdmAnnotation> getAnnotations() { - return helper.getAnnotations(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java deleted file mode 100644 index 6d510a5..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java +++ /dev/null @@ -1,80 +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.annotation; - -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.api.edm.annotation.EdmCast; -import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; -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 { - - private final Edm edm; - - private final Cast cast; - - private final EdmDynamicAnnotationExpression value; - - private EdmType type; - - public EdmCastImpl(final Edm edm, final Cast cast, final EdmDynamicAnnotationExpression value) { - this.edm = edm; - this.cast = cast; - this.value = value; - } - - @Override - public Integer getMaxLength() { - return cast.getMaxLength(); - } - - @Override - public Integer getPrecision() { - return cast.getPrecision(); - } - - @Override - public Integer getScale() { - return cast.getScale(); - } - - @Override - public SRID getSrid() { - return cast.getSrid(); - } - - @Override - public EdmType getType() { - if (type == null) { - final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(cast.getType()).build(); - type = typeInfo.getType(); - } - return type; - } - - @Override - public EdmDynamicAnnotationExpression getValue() { - return value; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java deleted file mode 100644 index 397163a..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java +++ /dev/null @@ -1,139 +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.annotation; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.commons.api.Constants; -import org.apache.olingo.commons.api.domain.ODataEnumValue; -import org.apache.olingo.commons.api.domain.ODataValue; -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.annotation.EdmConstantAnnotationExpression; -import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.ConstantAnnotationExpression; -import org.apache.olingo.commons.core.domain.ODataCollectionValueImpl; -import org.apache.olingo.commons.core.domain.ODataEnumValueImpl; -import org.apache.olingo.commons.core.domain.ODataPrimitiveValueImpl; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; - -public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotationExpression { - - private final ODataValue value; - - public EdmConstantAnnotationExpressionImpl(final ConstantAnnotationExpression constExprConstruct) { - if (constExprConstruct.getType() == ConstantAnnotationExpression.Type.EnumMember) { - final List<ODataEnumValue> enumValues = new ArrayList<ODataEnumValue>(); - String enumTypeName = null; - for (String split : StringUtils.split(constExprConstruct.getValue(), ' ')) { - final String[] enumSplit = StringUtils.split(split, '/'); - enumTypeName = enumSplit[0]; - enumValues.add(new ODataEnumValueImpl(enumSplit[0], enumSplit[1])); - } - if (enumValues.size() == 1) { - value = enumValues.get(0); - } else { - final ODataCollectionValueImpl collValue = new ODataCollectionValueImpl(enumTypeName); - for (ODataValue enumValue : enumValues) { - collValue.add(enumValue); - } - value = collValue; - } - } else { - EdmPrimitiveTypeKind kind; - switch (constExprConstruct.getType()) { - case Binary: - kind = EdmPrimitiveTypeKind.Binary; - break; - case Bool: - kind = EdmPrimitiveTypeKind.Boolean; - break; - case Date: - kind = EdmPrimitiveTypeKind.Date; - break; - case DateTimeOffset: - kind = EdmPrimitiveTypeKind.DateTimeOffset; - break; - case Decimal: - kind = EdmPrimitiveTypeKind.Decimal; - break; - case Duration: - kind = EdmPrimitiveTypeKind.Duration; - break; - case Float: - kind = EdmPrimitiveTypeKind.Single; - break; - case Guid: - kind = EdmPrimitiveTypeKind.Guid; - break; - case Int: - kind = EdmPrimitiveTypeKind.Int32; - break; - case TimeOfDay: - kind = EdmPrimitiveTypeKind.TimeOfDay; - break; - case String: - default: - kind = EdmPrimitiveTypeKind.String; - } - final ODataPrimitiveValueImpl.BuilderImpl primitiveValueBuilder = new ODataPrimitiveValueImpl.BuilderImpl(); - primitiveValueBuilder.setType(kind); - try { - final EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(kind); - primitiveValueBuilder.setValue( - primitiveType.valueOfString(constExprConstruct.getValue(), - null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, - primitiveType.getDefaultType())); - } catch (final EdmPrimitiveTypeException e) { - throw new IllegalArgumentException(e); - } - - value = primitiveValueBuilder.build(); - } - } - - @Override - public boolean isConstant() { - return true; - } - - @Override - public EdmConstantAnnotationExpression asConstant() { - return this; - } - - @Override - public boolean isDynamic() { - return false; - } - - @Override - public EdmDynamicAnnotationExpression asDynamic() { - return null; - } - - @Override - public ODataValue getValue() { - return value; - } - -}
