You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/03/25 14:49:14 UTC
[3/4] olingo-odata4 git commit: [OLINGO-575] Star deleting
unnecessary abstract edm classes
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java
deleted file mode 100644
index 6179f7f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java
+++ /dev/null
@@ -1,127 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-
-public abstract class AbstractEdmTypeDefinition extends EdmNamedImpl implements EdmTypeDefinition {
-
- private final String namespace;
-
- public AbstractEdmTypeDefinition(final Edm edm, final FullQualifiedName typeDefinitionName) {
- super(edm, typeDefinitionName.getName());
- namespace = typeDefinitionName.getNamespace();
- }
-
- @Override
- public abstract EdmPrimitiveType getUnderlyingType();
-
- @Override
- public boolean isCompatible(final EdmPrimitiveType primitiveType) {
- return getUnderlyingType().isCompatible(primitiveType);
- }
-
- @Override
- public Class<?> getDefaultType() {
- return getUnderlyingType().getDefaultType();
- }
-
- @Override
- public boolean validate(final String value, final Boolean isNullable, final Integer maxLength,
- final Integer precision, final Integer scale,
- final Boolean isUnicode) {
-
- return getUnderlyingType().validate(value, isNullable, maxLength, precision, scale, isUnicode);
- }
-
- @Override
- public <T> T valueOfString(final String value, final Boolean isNullable, final Integer maxLength,
- final Integer precision, final Integer scale,
- final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
-
- return getUnderlyingType().
- valueOfString(value, isNullable, maxLength, precision, scale, isUnicode, returnType);
- }
-
- @Override
- public String valueToString(final Object value, final Boolean isNullable, final Integer maxLength,
- final Integer precision, final Integer scale,
- final Boolean isUnicode) throws EdmPrimitiveTypeException {
-
- return getUnderlyingType().valueToString(value, isNullable, maxLength, precision, scale, isUnicode);
- }
-
- @Override
- public String toUriLiteral(final String literal) {
- return getUnderlyingType().toUriLiteral(literal);
- }
-
- @Override
- public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
- return getUnderlyingType().fromUriLiteral(literal);
- }
-
- @Override
- public FullQualifiedName getFullQualifiedName() {
- return new FullQualifiedName(getNamespace(), getName());
- }
-
- @Override
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public EdmTypeKind getKind() {
- return EdmTypeKind.DEFINITION;
- }
-
- @Override
- public abstract Integer getMaxLength();
-
- @Override
- public abstract Integer getPrecision();
-
- @Override
- public abstract Integer getScale();
-
- @Override
- public abstract Boolean isUnicode();
-
- @Override
- public TargetType getAnnotationsTargetType() {
- return TargetType.TypeDefinition;
- }
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return getFullQualifiedName();
- }
-
- @Override
- public String getAnnotationsTargetPath() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportInfoImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportInfoImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportInfoImpl.java
deleted file mode 100644
index 903cafb..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportInfoImpl.java
+++ /dev/null
@@ -1,45 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmException;
-
-import java.net.URI;
-
-public class EdmActionImportInfoImpl extends EdmOperationImportInfoImpl implements EdmActionImportInfo {
-
- private String actionImportName;
-
- public EdmActionImportInfoImpl(final String entityContainerName, final String actionImportName) {
- super(entityContainerName);
- this.actionImportName = actionImportName;
- }
-
- @Override
- public String getActionImportName() {
- return actionImportName;
- }
-
- @Override
- public URI getActionImportUri() {
- throw new EdmException("Not yet implemented");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationHelper.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationHelper.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationHelper.java
deleted file mode 100644
index 36fbcf9..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationHelper.java
+++ /dev/null
@@ -1,25 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmAnnotatable;
-
-public interface EdmAnnotationHelper extends EdmAnnotatable {
-//No additional methods needed for now.
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmElementImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmElementImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmElementImpl.java
deleted file mode 100644
index a757e38..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmElementImpl.java
+++ /dev/null
@@ -1,29 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmElement;
-
-public abstract class EdmElementImpl extends EdmNamedImpl implements EdmElement {
-
- public EdmElementImpl(final Edm edm, final String name) {
- super(edm, name);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetInfoImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetInfoImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetInfoImpl.java
deleted file mode 100644
index ed1e6a1..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetInfoImpl.java
+++ /dev/null
@@ -1,52 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.commons.api.edm.EdmException;
-
-import java.net.URI;
-
-public class EdmEntitySetInfoImpl implements EdmEntitySetInfo {
-
- private final String entityContainerName;
-
- private final String entitySetName;
-
- public EdmEntitySetInfoImpl(final String entityContainerName, final String entitySetName) {
- this.entityContainerName = entityContainerName;
- this.entitySetName = entitySetName;
- }
-
- @Override
- public String getEntityContainerName() {
- return entityContainerName;
- }
-
- @Override
- public String getEntitySetName() {
- return entitySetName;
- }
-
- @Override
- public URI getEntitySetUri() {
- throw new EdmException("Not yet implemented");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmFunctionImportInfoImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmFunctionImportInfoImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmFunctionImportInfoImpl.java
deleted file mode 100644
index 928fae5..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmFunctionImportInfoImpl.java
+++ /dev/null
@@ -1,45 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-
-import java.net.URI;
-
-public class EdmFunctionImportInfoImpl extends EdmOperationImportInfoImpl implements EdmFunctionImportInfo {
-
- private String functionImportName;
-
- public EdmFunctionImportInfoImpl(final String entityContainerName, final String functionImportName) {
- super(entityContainerName);
- this.functionImportName = functionImportName;
- }
-
- @Override
- public String getFunctionImportName() {
- return functionImportName;
- }
-
- @Override
- public URI getFunctionImportUri() {
- throw new EdmException("Not yet implemented");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNamedImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNamedImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNamedImpl.java
deleted file mode 100644
index 14d0059..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNamedImpl.java
+++ /dev/null
@@ -1,39 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmNamed;
-
-public abstract class EdmNamedImpl implements EdmNamed {
-
- protected final Edm edm;
-
- private final String name;
-
- public EdmNamedImpl(final Edm edm, final String name) {
- this.edm = edm;
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyBindingImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyBindingImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyBindingImpl.java
deleted file mode 100644
index 5815a6c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyBindingImpl.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.commons.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
-
-public class EdmNavigationPropertyBindingImpl implements EdmNavigationPropertyBinding {
-
- private final String path;
- private final String target;
-
- public EdmNavigationPropertyBindingImpl(final String path, final String target) {
- this.path = path;
- this.target = target;
- }
-
- @Override
- public String getPath() {
- return path;
- }
-
- @Override
- public String getTarget() {
- return target;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmOperationImportInfoImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmOperationImportInfoImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmOperationImportInfoImpl.java
deleted file mode 100644
index a57849f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmOperationImportInfoImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmOperationImportInfo;
-
-public abstract class EdmOperationImportInfoImpl implements EdmOperationImportInfo {
-
- protected String entityContainerName;
-
- public EdmOperationImportInfoImpl(final String entityContainerName) {
- this.entityContainerName = entityContainerName;
- }
-
- @Override
- public String getEntityContainerName() {
- return entityContainerName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSingletonInfoImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSingletonInfoImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSingletonInfoImpl.java
deleted file mode 100644
index c8cf569..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSingletonInfoImpl.java
+++ /dev/null
@@ -1,52 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-
-import java.net.URI;
-
-public class EdmSingletonInfoImpl implements EdmSingletonInfo {
-
- private final String entityContainerName;
-
- private final String singletonName;
-
- public EdmSingletonInfoImpl(final String entityContainerName, final String singletonName) {
- this.entityContainerName = entityContainerName;
- this.singletonName = singletonName;
- }
-
- @Override
- public String getEntityContainerName() {
- return entityContainerName;
- }
-
- @Override
- public String getSingletonName() {
- return singletonName;
- }
-
- @Override
- public URI getEntitySetUri() {
- throw new EdmException("Not yet implemented");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmStructuredTypeHelper.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmStructuredTypeHelper.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmStructuredTypeHelper.java
deleted file mode 100644
index 5790734..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmStructuredTypeHelper.java
+++ /dev/null
@@ -1,35 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-
-import java.util.Map;
-
-public interface EdmStructuredTypeHelper {
-
- Map<String, EdmProperty> getProperties();
-
- Map<String, EdmNavigationProperty> getNavigationProperties();
-
- boolean isOpenType();
-
- boolean isAbstract();
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeImpl.java
deleted file mode 100644
index 3a174e2..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeImpl.java
+++ /dev/null
@@ -1,52 +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.core.edm;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-
-public class EdmTypeImpl extends EdmNamedImpl implements EdmType {
-
- protected final FullQualifiedName typeName;
-
- protected final EdmTypeKind kind;
-
- public EdmTypeImpl(final Edm edm, final FullQualifiedName typeName, final EdmTypeKind kind) {
- super(edm, typeName.getName());
- this.typeName = typeName;
- this.kind = kind;
- }
-
- @Override
- public FullQualifiedName getFullQualifiedName() {
- return typeName;
- }
-
- @Override
- public String getNamespace() {
- return typeName.getNamespace();
- }
-
- @Override
- public EdmTypeKind getKind() {
- return kind;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java
deleted file mode 100644
index c6adc5e..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java
+++ /dev/null
@@ -1,244 +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.core.edm;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-
-public class EdmTypeInfo {
-
- public static class Builder {
-
- private String typeExpression;
-
- private String defaultNamespace;
-
- private Edm edm;
-
- public Builder setTypeExpression(final String typeExpression) {
- this.typeExpression = typeExpression;
- return this;
- }
-
- public Builder setDefaultNamespace(final String defaultNamespace) {
- this.defaultNamespace = defaultNamespace;
- return this;
- }
-
- public Builder setEdm(final Edm edm) {
- this.edm = edm;
- return this;
- }
-
- public EdmTypeInfo build() {
- return new EdmTypeInfo(edm, typeExpression.indexOf('.') == -1 && StringUtils.isNotBlank(defaultNamespace)
- ? defaultNamespace + "." + typeExpression
- : typeExpression);
- }
- }
-
- private final Edm edm;
-
- private final boolean collection;
-
- private final FullQualifiedName fullQualifiedName;
-
- private EdmPrimitiveTypeKind primitiveType;
-
- private EdmTypeDefinition typeDefinition;
-
- private EdmEnumType enumType;
-
- private EdmComplexType complexType;
-
- private EdmEntityType entityType;
-
- private EdmTypeInfo(final Edm edm, final String typeExpression) {
- this.edm = edm;
-
- String baseType;
- final int collStartIdx = typeExpression.indexOf("Collection(");
- final int collEndIdx = typeExpression.lastIndexOf(')');
- if (collStartIdx == -1) {
- baseType = typeExpression;
- collection = false;
- } else {
- if (collEndIdx == -1) {
- throw new IllegalArgumentException("Malformed type: " + typeExpression);
- }
-
- collection = true;
- baseType = typeExpression.substring(collStartIdx + 11, collEndIdx);
- }
-
- baseType = baseType.replaceAll("^#", "");
-
- final String typeName;
- final String namespace;
-
- final int lastDotIdx = baseType.lastIndexOf('.');
- if (lastDotIdx == -1) {
- namespace = EdmPrimitiveType.EDM_NAMESPACE;
- typeName = baseType;
- baseType = new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, baseType).toString();
- } else {
- namespace = baseType.substring(0, lastDotIdx);
- typeName = baseType.substring(lastDotIdx + 1);
- }
-
- if (StringUtils.isBlank(typeName)) {
- throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
- }
-
- final StringBuilder exp = new StringBuilder();
- exp.append(baseType);
-
- fullQualifiedName = new FullQualifiedName(namespace, typeName);
-
- try {
- primitiveType = EdmPrimitiveTypeKind.valueOf(fullQualifiedName.getName());
- } catch (final IllegalArgumentException e) {
- primitiveType = null;
- }
- if (primitiveType == null && this.edm != null) {
- typeDefinition = this.edm.getTypeDefinition(fullQualifiedName);
- if (typeDefinition == null) {
- enumType = this.edm.getEnumType(fullQualifiedName);
- if (enumType == null) {
- complexType = this.edm.getComplexType(fullQualifiedName);
- if (complexType == null) {
- entityType = this.edm.getEntityType(fullQualifiedName);
- }
- }
- }
- }
- }
-
- public String internal() {
- final StringBuilder deserialize = new StringBuilder();
-
- if (isCollection()) {
- deserialize.append("Collection(");
- }
-
- deserialize.append(getFullQualifiedName().toString());
-
- if (isCollection()) {
- deserialize.append(")");
- }
-
- return deserialize.toString();
- }
-
- public String external() {
- final StringBuilder serialize = new StringBuilder();
-
- if (isCollection()) {
- serialize.append('#');
- serialize.append("Collection(");
- }
-
- if (isPrimitiveType()) {
- serialize.append(getFullQualifiedName().getName());
- }else{
- serialize.append(getFullQualifiedName().toString());
- }
-
- if (isCollection()) {
- serialize.append(")");
- }
-
- if (!isPrimitiveType() && !isCollection()) {
- serialize.insert(0, '#');
- }
-
- return serialize.toString();
- }
-
- public boolean isCollection() {
- return collection;
- }
-
- public FullQualifiedName getFullQualifiedName() {
- return fullQualifiedName;
- }
-
- public boolean isPrimitiveType() {
- return primitiveType != null;
- }
-
- public EdmPrimitiveTypeKind getPrimitiveTypeKind() {
- return primitiveType;
- }
-
- public boolean isTypeDefinition() {
- return typeDefinition != null;
- }
-
- public EdmTypeDefinition getTypeDefinition() {
- return typeDefinition;
- }
-
- public boolean isEnumType() {
- return enumType != null;
- }
-
- public EdmEnumType getEnumType() {
- return enumType;
- }
-
- public boolean isComplexType() {
- return complexType != null;
- }
-
- public EdmComplexType getComplexType() {
- return complexType;
- }
-
- public boolean isEntityType() {
- return entityType != null;
- }
-
- public EdmEntityType getEntityType() {
- return entityType;
- }
-
- public EdmType getType() {
- return isPrimitiveType()
- ? EdmPrimitiveTypeFactory.getInstance(getPrimitiveTypeKind())
- : isTypeDefinition()
- ? getTypeDefinition()
- : isEnumType()
- ? getEnumType()
- : isComplexType()
- ? getComplexType()
- : isEntityType()
- ? getEntityType()
- : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
index 419adea..371a4a2 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
@@ -24,7 +24,7 @@ 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.provider.EdmTypeInfo;
public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmCast {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
index 03ae319..a1005c0 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
@@ -24,7 +24,7 @@ import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpressi
import org.apache.olingo.commons.api.edm.annotation.EdmIsOf;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.annotation.IsOf;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmIsOf {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmRecordImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmRecordImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmRecordImpl.java
index cd71c6c..4aaf731 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmRecordImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmRecordImpl.java
@@ -24,7 +24,7 @@ import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue;
import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
public class EdmRecordImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmRecord {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelper.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelper.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelper.java
new file mode 100644
index 0000000..bbbf136
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelper.java
@@ -0,0 +1,24 @@
+/*
+ * 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.core.edm.provider;
+
+import org.apache.olingo.commons.api.edm.EdmAnnotatable;
+
+public interface EdmAnnotationHelper extends EdmAnnotatable {
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java
index f4f0b6f..106584a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java
@@ -26,7 +26,6 @@ import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotation;
-import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
public class EdmAnnotationHelperImpl implements EdmAnnotationHelper {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java
index 9bebd12..cd32570 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java
@@ -34,7 +34,6 @@ import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression;
import org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression;
import org.apache.olingo.commons.api.edm.provider.annotation.PropertyValue;
-import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
import org.apache.olingo.commons.core.edm.annotation.EdmAndImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmAnnotationPathImpl;
import org.apache.olingo.commons.core.edm.annotation.EdmApplyImpl;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java
index d6bb531..e4a1ba7 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java
@@ -19,27 +19,33 @@
package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
import org.apache.olingo.commons.api.edm.EdmTerm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.Target;
import org.apache.olingo.commons.api.edm.provider.BindingTarget;
import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding;
-import org.apache.olingo.commons.core.edm.AbstractEdmBindingTarget;
-import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
-import org.apache.olingo.commons.core.edm.EdmNavigationPropertyBindingImpl;
-public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
+public abstract class EdmBindingTargetImpl extends EdmNamedImpl implements EdmBindingTarget {
private final BindingTarget target;
- private List<EdmNavigationPropertyBinding> navigationPropertyBindings;
private final EdmAnnotationHelper helper;
+ private final EdmEntityContainer container;
+
+ private List<EdmNavigationPropertyBinding> navigationPropertyBindings;
public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container, final BindingTarget target) {
- super(edm, container, target.getName(), target.getTypeFQN());
+ super(edm, target.getName());
+ this.container = container;
this.target = target;
this.helper = new EdmAnnotationHelperImpl(edm, target);
}
@@ -57,7 +63,71 @@ public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
}
return navigationPropertyBindings;
}
-
+
+ @Override
+ public EdmEntityContainer getEntityContainer() {
+ return container;
+ }
+
+ @Override
+ public EdmEntityType getEntityType() {
+ final EdmEntityType entityType = edm.getEntityType(target.getTypeFQN());
+ if (entityType == null) {
+ throw new EdmException("Can´t find entity type: " + target.getTypeFQN() + " for entity set or singleton: "
+ + getName());
+ }
+ return entityType;
+ }
+
+ @Override
+ public FullQualifiedName getAnnotationsTargetFQN() {
+ return container.getFullQualifiedName();
+ }
+
+ @Override
+ public String getAnnotationsTargetPath() {
+ return getName();
+ }
+
+ @Override
+ public EdmBindingTarget getRelatedBindingTarget(final String path) {
+ if (path == null) {
+ return null;
+ }
+ EdmBindingTarget bindingTarget = null;
+ boolean found = false;
+ for (final Iterator<EdmNavigationPropertyBinding> itor = getNavigationPropertyBindings().iterator(); itor.hasNext()
+ && !found;) {
+
+ final EdmNavigationPropertyBinding binding = itor.next();
+ if (path.startsWith(binding.getPath())) {
+ final Target edmTarget = new Target.Builder(binding.getTarget(), container).build();
+
+ final EdmEntityContainer entityContainer = edm.getEntityContainer(edmTarget.getEntityContainer());
+ if (entityContainer == null) {
+ throw new EdmException("Cannot find entity container with name: " + edmTarget.getEntityContainer());
+ }
+ try {
+ bindingTarget = entityContainer.getEntitySet(edmTarget.getTargetName());
+
+ if (bindingTarget == null) {
+ throw new EdmException("Cannot find EntitySet " + edmTarget.getTargetName());
+ }
+ } catch (EdmException e) {
+ // try with singletons ...
+ bindingTarget = entityContainer.getSingleton(edmTarget.getTargetName());
+
+ if (bindingTarget == null) {
+ throw new EdmException("Cannot find Singleton " + edmTarget.getTargetName());
+ }
+ } finally {
+ found = bindingTarget != null;
+ }
+ }
+ }
+
+ return bindingTarget;
+ }
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java
index 5b641ba..432a09f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java
@@ -18,21 +18,22 @@
*/
package org.apache.olingo.commons.core.edm.provider;
+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.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
-import org.apache.olingo.commons.core.edm.AbstractEdmComplexType;
-import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
-import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
-import java.util.List;
-import java.util.Map;
-
-public class EdmComplexTypeImpl extends AbstractEdmComplexType {
+public class EdmComplexTypeImpl extends EdmStructuredTypeImpl implements EdmComplexType {
private final EdmStructuredTypeHelper helper;
@@ -45,7 +46,7 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
}
private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
- super(edm, name, complexType.getBaseTypeFQN());
+ super(edm, name, EdmTypeKind.COMPLEX, complexType.getBaseTypeFQN());
this.helper = new EdmStructuredTypeHelperImpl(edm, name, complexType);
this.annotationHelper = new EdmAnnotationHelperImpl(edm, complexType);
}
@@ -79,4 +80,35 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
public List<EdmAnnotation> getAnnotations() {
return annotationHelper == null ? null : annotationHelper.getAnnotations();
}
+
+ @Override
+ protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) {
+ EdmComplexType baseType = null;
+ if (baseTypeName != null) {
+ baseType = edm.getComplexType(baseTypeName);
+ if (baseType == null) {
+ throw new EdmException("Can't find base type with name: " + baseTypeName + " for complex type: "
+ + getName());
+ }
+ }
+ return baseType;
+ }
+
+ @Override
+ public EdmComplexType getBaseType() {
+ checkBaseType();
+ return (EdmComplexType) baseType;
+ }
+
+ @Override
+ protected void checkBaseType() {
+ if (baseTypeName != null && baseType == null) {
+ baseType = buildBaseType(baseTypeName);
+ }
+ }
+
+ @Override
+ public TargetType getAnnotationsTargetType() {
+ return TargetType.ComplexType;
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java
new file mode 100644
index 0000000..686e45d
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java
@@ -0,0 +1,29 @@
+/*
+ * 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.core.edm.provider;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmElement;
+
+public abstract class EdmElementImpl extends EdmNamedImpl implements EdmElement {
+
+ public EdmElementImpl(final Edm edm, final String name) {
+ super(edm, name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java
index 6c768ce..94b7d4d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java
@@ -18,13 +18,17 @@
*/
package org.apache.olingo.commons.core.edm.provider;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
@@ -38,30 +42,146 @@ import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.commons.api.edm.provider.Singleton;
-import org.apache.olingo.commons.core.edm.AbstractEdmEntityContainer;
-import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
-public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
+public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityContainer {
private final EdmProvider provider;
private EntityContainer container;
private EdmAnnotationHelper helper;
- public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider,
+ protected final FullQualifiedName entityContainerName;
+ private final FullQualifiedName parentContainerName;
+
+ protected final Map<String, EdmSingleton> singletons = new HashMap<String, EdmSingleton>();
+ private boolean allSingletonsLoaded = false;
+
+ protected final Map<String, EdmEntitySet> entitySets = new HashMap<String, EdmEntitySet>();
+ private boolean allEntitySetsLoaded = false;
+
+ protected final Map<String, EdmActionImport> actionImports = new HashMap<String, EdmActionImport>();
+ private boolean allActionImportsLoaded = false;
+
+ protected final Map<String, EdmFunctionImport> functionImports = new HashMap<String, EdmFunctionImport>();
+ private boolean allFunctionImportsLoaded = false;
+
+ public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider,
final EntityContainerInfo entityContainerInfo) {
- super(edm, entityContainerInfo.getContainerName(), entityContainerInfo.getExtendsContainer());
+ super(edm, entityContainerInfo.getContainerName().getName());
this.provider = provider;
+ this.entityContainerName = entityContainerInfo.getContainerName();
+ this.parentContainerName = entityContainerInfo.getExtendsContainer();
}
public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, final FullQualifiedName containerFQN,
final EntityContainer entityContainer) {
- super(edm, containerFQN, entityContainer.getExtendsContainerFQN());
+ super(edm, containerFQN.getName());
this.provider = provider;
container = entityContainer;
+ this.entityContainerName = containerFQN;
+ this.parentContainerName = entityContainer.getExtendsContainerFQN();
this.helper = new EdmAnnotationHelperImpl(edm, entityContainer);
}
@Override
+ public String getNamespace() {
+ return entityContainerName.getNamespace();
+ }
+
+ @Override
+ public FullQualifiedName getFullQualifiedName() {
+ return entityContainerName;
+ }
+
+ @Override
+ public EdmSingleton getSingleton(final String singletonName) {
+ EdmSingleton singleton = singletons.get(singletonName);
+ if (singleton == null) {
+ singleton = createSingleton(singletonName);
+ if (singleton != null) {
+ singletons.put(singletonName, singleton);
+ }
+ }
+ return singleton;
+ }
+
+ @Override
+ public EdmEntitySet getEntitySet(final String entitySetName) {
+ EdmEntitySet entitySet = entitySets.get(entitySetName);
+ if (entitySet == null) {
+ entitySet = createEntitySet(entitySetName);
+ if (entitySet != null) {
+ entitySets.put(entitySetName, entitySet);
+ }
+ }
+ return entitySet;
+ }
+
+ @Override
+ public EdmActionImport getActionImport(final String actionImportName) {
+ EdmActionImport actionImport = actionImports.get(actionImportName);
+ if (actionImport == null) {
+ actionImport = createActionImport(actionImportName);
+ if (actionImport != null) {
+ actionImports.put(actionImportName, actionImport);
+ }
+ }
+ return actionImport;
+ }
+
+ @Override
+ public EdmFunctionImport getFunctionImport(final String functionImportName) {
+ EdmFunctionImport functionImport = functionImports.get(functionImportName);
+ if (functionImport == null) {
+ functionImport = createFunctionImport(functionImportName);
+ if (functionImport != null) {
+ functionImports.put(functionImportName, functionImport);
+ }
+ }
+ return functionImport;
+ }
+
+ @Override
+ public List<EdmEntitySet> getEntitySets() {
+ if (!allEntitySetsLoaded) {
+ loadAllEntitySets();
+ allEntitySetsLoaded = true;
+ }
+ return new ArrayList<EdmEntitySet>(entitySets.values());
+ }
+
+ @Override
+ public List<EdmFunctionImport> getFunctionImports() {
+ if (!allFunctionImportsLoaded) {
+ loadAllFunctionImports();
+ allFunctionImportsLoaded = true;
+ }
+ return new ArrayList<EdmFunctionImport>(functionImports.values());
+ }
+
+ @Override
+ public List<EdmSingleton> getSingletons() {
+ if (!allSingletonsLoaded) {
+ loadAllSingletons();
+ allSingletonsLoaded = true;
+ }
+ return new ArrayList<EdmSingleton>(singletons.values());
+ }
+
+ @Override
+ public List<EdmActionImport> getActionImports() {
+ if (!allActionImportsLoaded) {
+ loadAllActionImports();
+ allActionImportsLoaded = true;
+ }
+ return new ArrayList<EdmActionImport>(actionImports.values());
+ }
+
+ @Override
+ public FullQualifiedName getParentContainerName() {
+ return parentContainerName;
+ }
+
+
protected EdmSingleton createSingleton(final String singletonName) {
EdmSingleton singleton = null;
@@ -77,7 +197,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
return singleton;
}
- @Override
protected EdmEntitySet createEntitySet(final String entitySetName) {
EdmEntitySet entitySet = null;
@@ -93,7 +212,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
return entitySet;
}
- @Override
protected EdmActionImport createActionImport(final String actionImportName) {
EdmActionImport actionImport = null;
@@ -109,7 +227,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
return actionImport;
}
- @Override
protected EdmFunctionImport createFunctionImport(final String functionImportName) {
EdmFunctionImport functionImport = null;
@@ -125,7 +242,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
return functionImport;
}
- @Override
protected void loadAllEntitySets() {
loadContainer();
List<EntitySet> providerEntitySets = container.getEntitySets();
@@ -139,7 +255,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
}
}
- @Override
protected void loadAllFunctionImports() {
loadContainer();
List<FunctionImport> providerFunctionImports = container.getFunctionImports();
@@ -155,7 +270,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
}
- @Override
protected void loadAllSingletons() {
loadContainer();
List<Singleton> providerSingletons = container.getSingletons();
@@ -170,7 +284,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
}
- @Override
protected void loadAllActionImports() {
loadContainer();
List<ActionImport> providerActionImports = container.getActionImports();
@@ -200,6 +313,16 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
}
@Override
+ public String getAnnotationsTargetPath() {
+ return null;
+ }
+
+ @Override
+ public FullQualifiedName getAnnotationsTargetFQN() {
+ return getFullQualifiedName();
+ }
+
+ @Override
public TargetType getAnnotationsTargetType() {
return TargetType.EntityContainer;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java
index b6cbec6..0ee22e7 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java
@@ -18,33 +18,36 @@
*/
package org.apache.olingo.commons.core.edm.provider;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.provider.EntityType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
-import org.apache.olingo.commons.core.edm.AbstractEdmEntityType;
-import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
-import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class EdmEntityTypeImpl extends AbstractEdmEntityType {
+public class EdmEntityTypeImpl extends EdmStructuredTypeImpl implements EdmEntityType {
private final EdmStructuredTypeHelper helper;
-
private EntityType entityType;
-
private boolean baseTypeChecked = false;
-
private EdmAnnotationHelper annotationHelper;
+ private final boolean hasStream;
+ protected EdmEntityType entityBaseType;
+ private final List<String> keyPredicateNames = new ArrayList<String>();
+ private final Map<String, EdmKeyPropertyRef> keyPropertyRefs = new LinkedHashMap<String, EdmKeyPropertyRef>();
+ private List<EdmKeyPropertyRef> keyPropertyRefsList;
public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName name,
final EntityType entityType) {
@@ -53,9 +56,10 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
}
private EdmEntityTypeImpl(final Edm edm, final FullQualifiedName name, final EntityType entityType) {
- super(edm, name, entityType.getBaseTypeFQN(), entityType.hasStream());
+ super(edm, name, EdmTypeKind.ENTITY, entityType.getBaseTypeFQN());
this.entityType = entityType;
helper = new EdmStructuredTypeHelperImpl(edm, name, entityType);
+ hasStream = entityType.hasStream();
}
@Override
@@ -76,7 +80,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
entityBaseType = (EdmEntityType) baseType;
}
if (baseType == null
- || (baseType.isAbstract() && ((AbstractEdmEntityType) baseType).getKeyPropertyRefs().size() == 0)) {
+ || (baseType.isAbstract() && ((EdmEntityType) baseType).getKeyPropertyRefs().size() == 0)) {
final List<PropertyRef> key = entityType.getKey();
if (key != null) {
final List<EdmKeyPropertyRef> edmKey = new ArrayList<EdmKeyPropertyRef>();
@@ -90,6 +94,77 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
}
}
+ protected void setEdmKeyPropertyRef(final List<EdmKeyPropertyRef> edmKey) {
+ for (EdmKeyPropertyRef ref : edmKey) {
+ if (ref.getAlias() == null) {
+ keyPredicateNames.add(ref.getName());
+ keyPropertyRefs.put(ref.getName(), ref);
+ } else {
+ keyPredicateNames.add(ref.getAlias());
+ keyPropertyRefs.put(ref.getAlias(), ref);
+ }
+ }
+ }
+
+ @Override
+ protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) {
+ EdmEntityType baseType = null;
+ if (baseTypeName != null) {
+ baseType = edm.getEntityType(baseTypeName);
+ if (baseType == null) {
+ throw new EdmException("Cannot find base type with name: " + baseTypeName + " for entity type: " + getName());
+ }
+ }
+ return baseType;
+ }
+
+ @Override
+ public EdmEntityType getBaseType() {
+ checkBaseType();
+ return entityBaseType;
+ }
+
+ @Override
+ public List<String> getKeyPredicateNames() {
+ checkBaseType();
+ if (keyPredicateNames.isEmpty() && baseType != null) {
+ return entityBaseType.getKeyPredicateNames();
+ }
+ return keyPredicateNames;
+ }
+
+ @Override
+ public List<EdmKeyPropertyRef> getKeyPropertyRefs() {
+ checkBaseType();
+ if (keyPropertyRefsList == null) {
+ keyPropertyRefsList = new ArrayList<EdmKeyPropertyRef>(keyPropertyRefs.values());
+ }
+ if (keyPropertyRefsList.isEmpty() && entityBaseType != null) {
+ return entityBaseType.getKeyPropertyRefs();
+ }
+ return keyPropertyRefsList;
+ }
+
+ @Override
+ public EdmKeyPropertyRef getKeyPropertyRef(final String keyPredicateName) {
+ checkBaseType();
+ final EdmKeyPropertyRef edmKeyPropertyRef = keyPropertyRefs.get(keyPredicateName);
+ if (edmKeyPropertyRef == null && entityBaseType != null) {
+ return entityBaseType.getKeyPropertyRef(keyPredicateName);
+ }
+ return edmKeyPropertyRef;
+ }
+
+ @Override
+ public boolean hasStream() {
+ return hasStream;
+ }
+
+ @Override
+ public TargetType getAnnotationsTargetType() {
+ return TargetType.EntityType;
+ }
+
@Override
public boolean isOpenType() {
return helper.isOpenType();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java
index 9b4ca6a..1fdf73b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java
@@ -20,21 +20,26 @@ package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
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.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
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.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.EdmInt64;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-public class EdmEnumTypeImpl extends AbstractEdmEnumType {
+public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
private static final Set<EdmPrimitiveTypeKind> VALID_UNDERLYING_TYPES = new HashSet<EdmPrimitiveTypeKind>();
{
@@ -46,13 +51,15 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType {
};
private final EdmPrimitiveType underlyingType;
-
private final EnumType enumType;
-
+ private final String uriPrefix;
+ private final String uriSuffix;
+ private List<String> memberNames;
private List<EdmMember> members;
+ private Map<String, EdmMember> membersMap;
public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final EnumType enumType) {
- super(edm, enumName, enumType.isFlags());
+ super(edm, enumName, EdmTypeKind.ENUM);
if (enumType.getUnderlyingType() == null) {
underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);
@@ -66,14 +73,176 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType {
}
this.enumType = enumType;
+ this.uriPrefix = enumName.getFullQualifiedNameAsString() + '\'';
+ this.uriSuffix = "'";
}
@Override
public EdmPrimitiveType getUnderlyingType() {
return underlyingType;
}
+
+ @Override
+ public EdmMember getMember(final String name) {
+ if (membersMap == null) {
+ membersMap = new LinkedHashMap<String, EdmMember>();
+ for (final EdmMember member : getMembers()) {
+ membersMap.put(member.getName(), member);
+ }
+ }
+ return membersMap.get(name);
+ }
+
+ @Override
+ public List<String> getMemberNames() {
+ if (memberNames == null) {
+ memberNames = new ArrayList<String>();
+ for (final EdmMember member : getMembers()) {
+ memberNames.add(member.getName());
+ }
+ }
+ return memberNames;
+ }
+
+ @Override
+ public boolean isCompatible(final EdmPrimitiveType primitiveType) {
+ return equals(primitiveType);
+ }
@Override
+ public Class<?> getDefaultType() {
+ return getUnderlyingType().getDefaultType();
+ }
+
+ @Override
+ public boolean validate(final String value, final Boolean isNullable, final Integer maxLength,
+ final Integer precision, final Integer scale, final Boolean isUnicode) {
+
+ try {
+ valueOfString(value, isNullable, maxLength, precision, scale, isUnicode, getDefaultType());
+ return true;
+ } catch (final EdmPrimitiveTypeException e) {
+ return false;
+ }
+ }
+
+ private Long parseEnumValue(final String value) throws EdmPrimitiveTypeException {
+ Long result = null;
+ for (final String memberValue : value.split(",", isFlags() ? -1 : 1)) {
+ Long memberValueLong = null;
+ for (final EdmMember member : getMembers()) {
+ if (member.getName().equals(memberValue) || member.getValue().equals(memberValue)) {
+ memberValueLong = Long.decode(member.getValue());
+ }
+ }
+ if (memberValueLong == null) {
+ throw new EdmPrimitiveTypeException("The literal '" + value + "' has illegal content.");
+ }
+ result = result == null ? memberValueLong : result | memberValueLong;
+ }
+ return result;
+ }
+
+ @Override
+ public <T> T valueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+ final Integer precision, final Integer scale, final Boolean isUnicode, final Class<T> returnType)
+ throws EdmPrimitiveTypeException {
+
+ if (value == null) {
+ if (isNullable != null && !isNullable) {
+ throw new EdmPrimitiveTypeException("The literal 'null' is not allowed.");
+ }
+ return null;
+ }
+
+ try {
+ return EdmInt64.convertNumber(parseEnumValue(value), returnType);
+ } catch (final IllegalArgumentException e) {
+ throw new EdmPrimitiveTypeException("The literal '" + value
+ + "' cannot be converted to value type " + returnType + ".", e);
+ } catch (final ClassCastException e) {
+ throw new EdmPrimitiveTypeException("The value type " + returnType + " is not supported.", e);
+ }
+ }
+
+ protected String constructEnumValue(final long value) throws EdmPrimitiveTypeException {
+ long remaining = value;
+ StringBuilder result = new StringBuilder();
+
+ for (final EdmMember member : getMembers()) {
+ final long memberValue = Long.parseLong(member.getValue());
+ if ((memberValue & remaining) == memberValue) {
+ if (result.length() > 0) {
+ result.append(',');
+ }
+ result.append(member.getName());
+ remaining ^= memberValue;
+ }
+ }
+
+ if (remaining != 0) {
+ throw new EdmPrimitiveTypeException("The value '" + value + "' is not valid.");
+ }
+ return result.toString();
+ }
+
+ @Override
+ public String valueToString(final Object value, final Boolean isNullable, final Integer maxLength,
+ final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+ if (value == null) {
+ if (isNullable != null && !isNullable) {
+ throw new EdmPrimitiveTypeException("The value NULL is not allowed.");
+ }
+ return null;
+ }
+ if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) {
+ return constructEnumValue(((Number) value).longValue());
+ } else {
+ throw new EdmPrimitiveTypeException("The value type " + value.getClass() + " is not supported.");
+ }
+ }
+
+ @Override
+ public String toUriLiteral(final String literal) {
+ return literal == null ? null
+ : uriPrefix.isEmpty() && uriSuffix.isEmpty() ? literal : uriPrefix + literal + uriSuffix;
+ }
+
+ @Override
+ public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
+ if (literal == null) {
+ return null;
+ } else if (uriPrefix.isEmpty() && uriSuffix.isEmpty()) {
+ return literal;
+ } else if (literal.length() >= uriPrefix.length() + uriSuffix.length()
+ && literal.startsWith(uriPrefix) && literal.endsWith(uriSuffix)) {
+ return literal.substring(uriPrefix.length(), literal.length() - uriSuffix.length());
+ } else {
+ throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.");
+ }
+ }
+
+ @Override
+ public boolean isFlags() {
+ return enumType.isFlags();
+ }
+
+ @Override
+ public TargetType getAnnotationsTargetType() {
+ return TargetType.EnumType;
+ }
+
+ @Override
+ public String getAnnotationsTargetPath() {
+ return null;
+ }
+
+ @Override
+ public FullQualifiedName getAnnotationsTargetFQN() {
+ return getFullQualifiedName();
+ }
+
protected List<EdmMember> getMembers() {
if (members == null) {
members = new ArrayList<EdmMember>(enumType.getMembers().size());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmKeyPropertyRefImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
index a7f291d..1122f74 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
@@ -19,15 +19,20 @@
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmException;
+import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
-import org.apache.olingo.commons.core.edm.AbstractEdmKeyPropertyRef;
-public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
+public class EdmKeyPropertyRefImpl implements EdmKeyPropertyRef {
private final PropertyRef ref;
+ private EdmEntityType edmEntityType;
+ private EdmProperty property;
public EdmKeyPropertyRefImpl(final EdmEntityType edmEntityType, final PropertyRef ref) {
- super(edmEntityType);
+ this.edmEntityType = edmEntityType;
this.ref = ref;
}
@@ -40,4 +45,39 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
public String getAlias() {
return ref.getAlias();
}
+
+ @Override
+ public EdmProperty getProperty() {
+ if (property == null) {
+ if (getAlias() == null) {
+ property = edmEntityType.getStructuralProperty(getName());
+ if (property == null) {
+ throw new EdmException("Invalid key property ref specified. Can´t find property with name: "
+ + getName());
+ }
+ } else {
+ if (getName() == null || getName().isEmpty()) {
+ throw new EdmException("Alias but no path specified for propertyRef");
+ }
+ final String[] splitPath = getName().split("/");
+ EdmStructuredType structType = edmEntityType;
+ for (int i = 0; i < splitPath.length - 1; i++) {
+ final EdmProperty _property = structType.getStructuralProperty(splitPath[i]);
+ if (_property == null) {
+ throw new EdmException("Invalid property ref specified. Can´t find property with name: " + splitPath[i]
+ + " at type: " + structType.getNamespace() + "." + structType.getName());
+ }
+ structType = (EdmStructuredType) _property.getType();
+ }
+ property = structType.getStructuralProperty(splitPath[splitPath.length - 1]);
+ if (property == null) {
+ throw new EdmException("Invalid property ref specified. Can´t find property with name: "
+ + splitPath[splitPath.length - 1] + " at type: " + structType.getNamespace() + "."
+ + structType.getName());
+ }
+ }
+ }
+
+ return property;
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java
index 6c840fd..0bdf441 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java
@@ -22,20 +22,43 @@ import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
+import org.apache.olingo.commons.api.edm.EdmMember;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
-import org.apache.olingo.commons.core.edm.AbstractEdmMember;
-import org.apache.olingo.commons.core.edm.EdmAnnotationHelper;
-public class EdmMemberImpl extends AbstractEdmMember {
+public class EdmMemberImpl extends EdmNamedImpl implements EdmMember {
private final EdmAnnotationHelper helper;
+ private final FullQualifiedName enumFQN;
+ private final EnumMember member;
public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final EnumMember member) {
- super(edm, enumFQN, member.getName(), member.getValue());
+ super(edm, member.getName());
+ this.enumFQN = enumFQN;
+ this.member = member;
this.helper = new EdmAnnotationHelperImpl(edm, member);
}
+
+ @Override
+ public TargetType getAnnotationsTargetType() {
+ return TargetType.Member;
+ }
+
+ @Override
+ public FullQualifiedName getAnnotationsTargetFQN() {
+ return enumFQN;
+ }
+
+ @Override
+ public String getAnnotationsTargetPath() {
+ return getName();
+ }
+
+ @Override
+ public String getValue() {
+ return member.getValue();
+ }
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImpl.java
new file mode 100644
index 0000000..93e7583
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImpl.java
@@ -0,0 +1,39 @@
+/*
+ * 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.core.edm.provider;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmNamed;
+
+public abstract class EdmNamedImpl implements EdmNamed {
+
+ protected final Edm edm;
+
+ private final String name;
+
+ public EdmNamedImpl(final Edm edm, final String name) {
+ this.edm = edm;
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3a6293b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyBindingImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyBindingImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyBindingImpl.java
new file mode 100644
index 0000000..ac534b2
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyBindingImpl.java
@@ -0,0 +1,43 @@
+/*
+ * 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.core.edm.provider;
+
+import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
+
+public class EdmNavigationPropertyBindingImpl implements EdmNavigationPropertyBinding {
+
+ private final String path;
+ private final String target;
+
+ public EdmNavigationPropertyBindingImpl(final String path, final String target) {
+ this.path = path;
+ this.target = target;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public String getTarget() {
+ return target;
+ }
+
+}