[OLINGO-186] client-side implementation of commons Edm interfaces completed: some refactoring on server-side performed to extract common abstract implementation
This commit is contained in:
parent
a8c0e9ea84
commit
bae3d847a8
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.api.edm.xml;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public interface CommonParameter extends Named {
|
||||
|
||||
String getType();
|
||||
|
@ -30,16 +28,16 @@ public interface CommonParameter extends Named {
|
|||
|
||||
void setNullable(boolean nullable);
|
||||
|
||||
String getMaxLength();
|
||||
Integer getMaxLength();
|
||||
|
||||
void setMaxLength(String maxLength);
|
||||
void setMaxLength(Integer maxLength);
|
||||
|
||||
BigInteger getPrecision();
|
||||
Integer getPrecision();
|
||||
|
||||
void setPrecision(BigInteger precision);
|
||||
void setPrecision(Integer precision);
|
||||
|
||||
BigInteger getScale();
|
||||
Integer getScale();
|
||||
|
||||
void setScale(BigInteger scale);
|
||||
void setScale(Integer scale);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.api.edm.xml;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.ConcurrencyMode;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.StoreGeneratedPattern;
|
||||
|
||||
|
@ -36,21 +35,21 @@ public interface CommonProperty extends Named {
|
|||
|
||||
void setDefaultValue(String defaultValue);
|
||||
|
||||
String getMaxLength();
|
||||
Integer getMaxLength();
|
||||
|
||||
void setMaxLength(String maxLength);
|
||||
void setMaxLength(Integer maxLength);
|
||||
|
||||
boolean isFixedLength();
|
||||
|
||||
void setFixedLength(boolean fixedLength);
|
||||
|
||||
BigInteger getPrecision();
|
||||
Integer getPrecision();
|
||||
|
||||
void setPrecision(BigInteger precision);
|
||||
void setPrecision(Integer precision);
|
||||
|
||||
BigInteger getScale();
|
||||
Integer getScale();
|
||||
|
||||
void setScale(BigInteger scale);
|
||||
void setScale(Integer scale);
|
||||
|
||||
boolean isUnicode();
|
||||
|
||||
|
|
|
@ -22,5 +22,5 @@ public interface Member {
|
|||
|
||||
String getName();
|
||||
|
||||
Integer getValue();
|
||||
String getValue();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.api.edm.xml;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v3.Annotations;
|
||||
import java.util.List;
|
||||
|
||||
public interface Schema {
|
||||
|
|
|
@ -16,15 +16,14 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.api.edm;
|
||||
package org.apache.olingo.odata4.client.api.edm.xml;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Schema;
|
||||
|
||||
/**
|
||||
* Entry point for access information about EDM metadata.
|
||||
*/
|
||||
public interface EdmMetadata {
|
||||
public interface XMLMetadata {
|
||||
|
||||
/**
|
||||
* Checks whether the given key is a valid namespace or alias in the EdM metadata document.
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.odata4.client.api.edm.xml.v4;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Named;
|
||||
|
||||
public interface BindingTarget extends Named, AnnotatedEdmItem {
|
||||
|
||||
String getEntityType();
|
||||
|
||||
void setEntityType(String entityType);
|
||||
|
||||
List<? extends NavigationPropertyBinding> getNavigationPropertyBindings();
|
||||
}
|
|
@ -22,6 +22,10 @@ import java.util.List;
|
|||
|
||||
public interface EntityContainer extends org.apache.olingo.odata4.client.api.edm.xml.EntityContainer {
|
||||
|
||||
List<? extends Singleton> getSingletons();
|
||||
|
||||
Singleton getSingleton(String name);
|
||||
|
||||
/**
|
||||
* Gets the first action import with given name.
|
||||
*
|
||||
|
|
|
@ -18,13 +18,9 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.api.edm.xml.v4;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EntitySet extends org.apache.olingo.odata4.client.api.edm.xml.EntitySet, AnnotatedEdmItem {
|
||||
public interface EntitySet extends org.apache.olingo.odata4.client.api.edm.xml.EntitySet, BindingTarget {
|
||||
|
||||
boolean isIncludeInServiceDocument();
|
||||
|
||||
void setIncludeInServiceDocument(boolean includeInServiceDocument);
|
||||
|
||||
List<? extends NavigationPropertyBinding> getNavigationPropertyBindings();
|
||||
}
|
||||
|
|
|
@ -18,15 +18,13 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.api.edm.xml.v4;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public interface ReturnType {
|
||||
|
||||
String getMaxLength();
|
||||
Integer getMaxLength();
|
||||
|
||||
BigInteger getPrecision();
|
||||
Integer getPrecision();
|
||||
|
||||
BigInteger getScale();
|
||||
Integer getScale();
|
||||
|
||||
String getSrid();
|
||||
|
||||
|
@ -34,13 +32,13 @@ public interface ReturnType {
|
|||
|
||||
boolean isNullable();
|
||||
|
||||
void setMaxLength(String maxLength);
|
||||
void setMaxLength(Integer maxLength);
|
||||
|
||||
void setNullable(boolean nullable);
|
||||
|
||||
void setPrecision(BigInteger precision);
|
||||
void setPrecision(Integer precision);
|
||||
|
||||
void setScale(BigInteger scale);
|
||||
void setScale(Integer scale);
|
||||
|
||||
void setSrid(String srid);
|
||||
|
||||
|
|
|
@ -18,15 +18,8 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.api.edm.xml.v4;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Named;
|
||||
|
||||
public interface Singleton extends Named {
|
||||
|
||||
String getType();
|
||||
|
||||
void setType(String type);
|
||||
|
||||
List<? extends NavigationPropertyBinding> getNavigationPropertyBindings();
|
||||
public interface Singleton extends Named, BindingTarget {
|
||||
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ public interface TypeDefinition extends Named {
|
|||
|
||||
List<? extends Annotation> getAnnotations();
|
||||
|
||||
String getMaxLength();
|
||||
Integer getMaxLength();
|
||||
|
||||
BigInteger getPrecision();
|
||||
Integer getPrecision();
|
||||
|
||||
BigInteger getScale();
|
||||
Integer getScale();
|
||||
|
||||
String getSrid();
|
||||
|
||||
|
@ -38,11 +38,11 @@ public interface TypeDefinition extends Named {
|
|||
|
||||
boolean isUnicode();
|
||||
|
||||
void setMaxLength(String maxLength);
|
||||
void setMaxLength(Integer maxLength);
|
||||
|
||||
void setPrecision(BigInteger precision);
|
||||
void setPrecision(Integer precision);
|
||||
|
||||
void setScale(BigInteger scale);
|
||||
void setScale(Integer scale);
|
||||
|
||||
void setSrid(String srid);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.olingo.odata4.client.api.op;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Edmx;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ import org.w3c.dom.Element;
|
|||
*/
|
||||
public interface ODataDeserializer extends Serializable {
|
||||
|
||||
Edmx toMetadata(InputStream input);
|
||||
XMLMetadata toMetadata(InputStream input);
|
||||
|
||||
/**
|
||||
* Gets the ServiceDocumentResource object represented by the given InputStream.
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.olingo.odata4.client.api.op;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import org.apache.olingo.odata4.client.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
|
||||
/**
|
||||
* OData reader.
|
||||
|
@ -37,7 +37,7 @@ public interface ODataReader extends Serializable {
|
|||
* @param input stream to de-serialize.
|
||||
* @return metadata representation.
|
||||
*/
|
||||
EdmMetadata readMetadata(InputStream input);
|
||||
Edm readMetadata(InputStream input);
|
||||
|
||||
/**
|
||||
* Parses an OData service document.
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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.odata4.client.api.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
|
||||
public class EdmTypeInfo {
|
||||
|
||||
private final String typeExpression;
|
||||
|
||||
private final boolean collection;
|
||||
|
||||
private final FullQualifiedName fullQualifiedName;
|
||||
|
||||
public EdmTypeInfo(final String typeExpression, final String defaultNamespace) {
|
||||
this(typeExpression.indexOf('.') == -1
|
||||
? defaultNamespace + "." + typeExpression
|
||||
: typeExpression);
|
||||
}
|
||||
|
||||
public EdmTypeInfo(final String typeExpression) {
|
||||
this.typeExpression = typeExpression;
|
||||
|
||||
String baseType;
|
||||
final int collStartIdx = typeExpression.indexOf("Collection(");
|
||||
final int collEndIdx = typeExpression.lastIndexOf(')');
|
||||
if (collStartIdx == -1) {
|
||||
baseType = typeExpression;
|
||||
this.collection = false;
|
||||
} else {
|
||||
if (collEndIdx == -1) {
|
||||
throw new IllegalArgumentException("Malformed type: " + typeExpression);
|
||||
}
|
||||
|
||||
this.collection = true;
|
||||
baseType = typeExpression.substring(collStartIdx + 11, collEndIdx);
|
||||
}
|
||||
|
||||
final int lastDotIdx = baseType.lastIndexOf('.');
|
||||
if (lastDotIdx == -1) {
|
||||
throw new IllegalArgumentException("Cannot find namespace or alias in " + typeExpression);
|
||||
}
|
||||
final String namespace = baseType.substring(0, lastDotIdx);
|
||||
final String typeName = baseType.substring(lastDotIdx + 1);
|
||||
if (StringUtils.isBlank(typeName)) {
|
||||
throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
|
||||
}
|
||||
|
||||
this.fullQualifiedName = new FullQualifiedName(namespace, typeName);
|
||||
}
|
||||
|
||||
public String getTypeExpression() {
|
||||
return typeExpression;
|
||||
}
|
||||
|
||||
public boolean isCollection() {
|
||||
return collection;
|
||||
}
|
||||
|
||||
public FullQualifiedName getFullQualifiedName() {
|
||||
return fullQualifiedName;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonFunctionImport;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.EntityContainer;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.EntitySet;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySetInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmEntitySetInfoImpl;
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmFunctionImportInfoImpl;
|
||||
|
||||
public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetadata {
|
||||
|
||||
protected final XMLMetadata xmlMetadata;
|
||||
|
||||
private List<EdmEntitySetInfo> entitySetInfos;
|
||||
|
||||
private List<EdmFunctionImportInfo> functionImportInfos;
|
||||
|
||||
public static EdmServiceMetadata getInstance(final XMLMetadata xmlMetadata) {
|
||||
return xmlMetadata instanceof org.apache.olingo.odata4.client.core.edm.xml.v3.XMLMetadataImpl
|
||||
? new org.apache.olingo.odata4.client.core.edm.v3.EdmServiceMetadataImpl(
|
||||
(org.apache.olingo.odata4.client.core.edm.xml.v3.XMLMetadataImpl) xmlMetadata)
|
||||
: new org.apache.olingo.odata4.client.core.edm.v4.EdmServiceMetadataImpl(
|
||||
(org.apache.olingo.odata4.client.core.edm.xml.v4.XMLMetadataImpl) xmlMetadata);
|
||||
|
||||
}
|
||||
|
||||
public AbstractEdmServiceMetadataImpl(final XMLMetadata xmlMetadata) {
|
||||
this.xmlMetadata = xmlMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getMetadata() {
|
||||
throw new UnsupportedOperationException("Not supported in client code.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmEntitySetInfo> getEntitySetInfos() {
|
||||
synchronized (this) {
|
||||
if (entitySetInfos == null) {
|
||||
entitySetInfos = new ArrayList<EdmEntitySetInfo>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (EntitySet entitySet : entityContainer.getEntitySets()) {
|
||||
entitySetInfos.add(
|
||||
new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return entitySetInfos;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmFunctionImportInfo> getFunctionImportInfos() {
|
||||
synchronized (this) {
|
||||
if (functionImportInfos == null) {
|
||||
functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
functionImportInfos.add(
|
||||
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return functionImportInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return EqualsBuilder.reflectionEquals(this, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Action;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
|
||||
|
||||
public class EdmActionImpl extends EdmOperationImpl implements EdmAction {
|
||||
|
||||
public static EdmActionImpl getInstance(final Edm edm, final FullQualifiedName name, final Action action) {
|
||||
return EdmOperationImpl.getInstance(new EdmActionImpl(edm, name, action));
|
||||
}
|
||||
|
||||
private EdmActionImpl(final Edm edm, final FullQualifiedName name, final Action action) {
|
||||
super(edm, name, action, EdmTypeKind.ACTION);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ActionImport;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
|
||||
|
||||
public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport {
|
||||
|
||||
private final ActionImport actionImport;
|
||||
|
||||
public EdmActionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final ActionImport actionImport) {
|
||||
|
||||
super(edm, container, name, actionImport);
|
||||
this.actionImport = actionImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmAction getAction() {
|
||||
return edm.getAction(
|
||||
new EdmTypeInfo(actionImport.getAction(), container.getNamespace()).getFullQualifiedName(), null, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.BindingTarget;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.NavigationPropertyBinding;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmBindingTarget;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmException;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Target;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmBindingTarget;
|
||||
|
||||
public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
|
||||
|
||||
private final BindingTarget target;
|
||||
|
||||
public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container,
|
||||
final String name, final FullQualifiedName type, final BindingTarget target) {
|
||||
|
||||
super(edm, container, name, type);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmBindingTarget getRelatedBindingTarget(final String path) {
|
||||
EdmBindingTarget bindingTarget = null;
|
||||
|
||||
final List<? extends NavigationPropertyBinding> navigationPropertyBindings = target.getNavigationPropertyBindings();
|
||||
if (navigationPropertyBindings != null) {
|
||||
boolean found = false;
|
||||
for (final Iterator<? extends NavigationPropertyBinding> itor = navigationPropertyBindings.iterator();
|
||||
itor.hasNext() && !found;) {
|
||||
|
||||
final NavigationPropertyBinding binding = itor.next();
|
||||
if (binding.getPath().equals(path)) {
|
||||
final Target edmTarget = new Target.Builder(binding.getTarget(), container).build();
|
||||
|
||||
final EdmEntityContainer entityContainer = edm.getEntityContainer(edmTarget.getEntityContainer());
|
||||
if (entityContainer == null) {
|
||||
throw new EdmException("Cant find entity container with name: " + edmTarget.getEntityContainer());
|
||||
}
|
||||
bindingTarget = entityContainer.getEntitySet(edmTarget.getTargetName());
|
||||
if (bindingTarget == null) {
|
||||
bindingTarget = entityContainer.getSingleton(edmTarget.getTargetName());
|
||||
if (bindingTarget == null) {
|
||||
throw new EdmException("Cant find target with name: " + edmTarget.getTargetName());
|
||||
}
|
||||
|
||||
found = true;
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bindingTarget;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.EnumType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ComplexType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityContainer;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.TypeDefinition;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.ActionImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.FunctionImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.ParameterImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.SchemaImpl;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmImpl;
|
||||
|
||||
public class EdmClientImpl extends AbstractEdmImpl {
|
||||
|
||||
private final XMLMetadata xmlMetadata;
|
||||
|
||||
private final EdmServiceMetadata serviceMetadata;
|
||||
|
||||
public EdmClientImpl(final XMLMetadata xmlMetadata) {
|
||||
this.xmlMetadata = xmlMetadata;
|
||||
this.serviceMetadata = AbstractEdmServiceMetadataImpl.getInstance(xmlMetadata);
|
||||
}
|
||||
|
||||
public XMLMetadata getXMLMetadata() {
|
||||
return xmlMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmServiceMetadata createServiceMetadata() {
|
||||
return serviceMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> createAliasToNamespaceInfo() {
|
||||
final Map<String, String> aliasToNamespace = new HashMap<String, String>();
|
||||
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
aliasToNamespace.put(null, schema.getNamespace());
|
||||
if (StringUtils.isNotBlank(schema.getAlias())) {
|
||||
aliasToNamespace.put(schema.getAlias(), schema.getNamespace());
|
||||
}
|
||||
}
|
||||
|
||||
return aliasToNamespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) {
|
||||
EdmEntityContainer result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(containerName.getNamespace());
|
||||
if (schema != null) {
|
||||
final EntityContainer xmlEntityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
if (xmlEntityContainer != null) {
|
||||
result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmEnumType createEnumType(final FullQualifiedName enumName) {
|
||||
EdmEnumType result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(enumName.getNamespace());
|
||||
if (schema != null) {
|
||||
final EnumType xmlEnumType = schema.getEnumType(enumName.getName());
|
||||
if (xmlEnumType != null) {
|
||||
result = new EdmEnumTypeImpl(this, enumName, xmlEnumType);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmTypeDefinition createTypeDefinition(final FullQualifiedName typeDefinitionName) {
|
||||
EdmTypeDefinition result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(typeDefinitionName.getNamespace());
|
||||
if (schema instanceof SchemaImpl) {
|
||||
final TypeDefinition xmlTypeDefinition = ((SchemaImpl) schema).getTypeDefinition(typeDefinitionName.getName());
|
||||
if (xmlTypeDefinition != null) {
|
||||
result = new EdmTypeDefinitionImpl(this, typeDefinitionName, xmlTypeDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmEntityType createEntityType(final FullQualifiedName entityTypeName) {
|
||||
EdmEntityType result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(entityTypeName.getNamespace());
|
||||
if (schema instanceof SchemaImpl) {
|
||||
final EntityType xmlEntityType = ((SchemaImpl) schema).getEntityType(entityTypeName.getName());
|
||||
if (xmlEntityType != null) {
|
||||
result = EdmEntityTypeImpl.getInstance(this, entityTypeName, xmlEntityType);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmComplexType createComplexType(final FullQualifiedName complexTypeName) {
|
||||
EdmComplexType result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(complexTypeName.getNamespace());
|
||||
if (schema instanceof SchemaImpl) {
|
||||
final ComplexType xmlComplexType = ((SchemaImpl) schema).getComplexType(complexTypeName.getName());
|
||||
if (xmlComplexType != null) {
|
||||
result = EdmComplexTypeImpl.getInstance(this, complexTypeName, xmlComplexType);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmAction createUnboundAction(final FullQualifiedName actionName) {
|
||||
EdmAction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(actionName.getNamespace());
|
||||
if (schema instanceof SchemaImpl) {
|
||||
final List<ActionImpl> actions = ((SchemaImpl) schema).getActions(actionName.getName());
|
||||
boolean found = false;
|
||||
for (Iterator<ActionImpl> itor = actions.iterator(); itor.hasNext() && !found;) {
|
||||
final ActionImpl action = itor.next();
|
||||
if (!action.isBound()) {
|
||||
found = true;
|
||||
result = EdmActionImpl.getInstance(this, actionName, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
|
||||
EdmFunction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(functionName.getNamespace());
|
||||
if (schema instanceof SchemaImpl) {
|
||||
final List<FunctionImpl> functions = ((SchemaImpl) schema).getFunctions(functionName.getName());
|
||||
boolean found = false;
|
||||
for (Iterator<FunctionImpl> itor = functions.iterator(); itor.hasNext() && !found;) {
|
||||
final FunctionImpl function = itor.next();
|
||||
if (!function.isBound()) {
|
||||
final Set<String> functionParamNames = new HashSet<String>();
|
||||
for (ParameterImpl param : function.getParameters()) {
|
||||
functionParamNames.add(param.getName());
|
||||
}
|
||||
found = parameterNames == null
|
||||
? functionParamNames.isEmpty()
|
||||
: functionParamNames.containsAll(parameterNames);
|
||||
result = EdmFunctionImpl.getInstance(this, functionName, function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmAction createBoundAction(final FullQualifiedName actionName,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
|
||||
|
||||
EdmAction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(actionName.getNamespace());
|
||||
if (schema instanceof SchemaImpl) {
|
||||
final List<ActionImpl> actions = ((SchemaImpl) schema).getActions(actionName.getName());
|
||||
boolean found = false;
|
||||
for (Iterator<ActionImpl> itor = actions.iterator(); itor.hasNext() && !found;) {
|
||||
final ActionImpl action = itor.next();
|
||||
if (action.isBound()) {
|
||||
final EdmTypeInfo boundParam = new EdmTypeInfo(action.getParameters().get(0).getType());
|
||||
if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
|
||||
&& isBindingParameterCollection.booleanValue() == boundParam.isCollection()) {
|
||||
|
||||
found = true;
|
||||
result = EdmActionImpl.getInstance(this, actionName, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunction createBoundFunction(final FullQualifiedName functionName,
|
||||
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
|
||||
final List<String> parameterNames) {
|
||||
|
||||
EdmFunction result = null;
|
||||
|
||||
final Schema schema = xmlMetadata.getSchema(functionName.getNamespace());
|
||||
if (schema instanceof SchemaImpl) {
|
||||
final List<FunctionImpl> functions = ((SchemaImpl) schema).getFunctions(functionName.getName());
|
||||
boolean found = false;
|
||||
for (Iterator<FunctionImpl> itor = functions.iterator(); itor.hasNext() && !found;) {
|
||||
final FunctionImpl function = itor.next();
|
||||
if (function.isBound()) {
|
||||
final EdmTypeInfo boundParam = new EdmTypeInfo(function.getParameters().get(0).getType());
|
||||
if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
|
||||
&& isBindingParameterCollection.booleanValue() == boundParam.isCollection()) {
|
||||
|
||||
final Set<String> functionParamNames = new HashSet<String>();
|
||||
for (ParameterImpl param : function.getParameters()) {
|
||||
functionParamNames.add(param.getName());
|
||||
}
|
||||
found = parameterNames == null
|
||||
? functionParamNames.isEmpty()
|
||||
: functionParamNames.containsAll(parameterNames);
|
||||
result = EdmFunctionImpl.getInstance(this, functionName, function);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return EqualsBuilder.reflectionEquals(this, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.Map;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ComplexType;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmComplexType;
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmStructuredTypeHelper;
|
||||
|
||||
public class EdmComplexTypeImpl extends AbstractEdmComplexType {
|
||||
|
||||
private final EdmStructuredTypeHelper helper;
|
||||
|
||||
public static EdmComplexTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn,
|
||||
final ComplexType complexType) {
|
||||
|
||||
final FullQualifiedName baseTypeName = complexType.getBaseType() == null
|
||||
? null : new EdmTypeInfo(complexType.getBaseType()).getFullQualifiedName();
|
||||
final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, fqn, baseTypeName, complexType);
|
||||
instance.baseType = instance.buildBaseType(baseTypeName);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName,
|
||||
final ComplexType complexType) {
|
||||
|
||||
super(edm, fqn, baseTypeName);
|
||||
this.helper = new EdmStructuredTypeHelperImpl(edm, complexType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, EdmProperty> getProperties() {
|
||||
return helper.getProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, EdmNavigationProperty> getNavigationProperties() {
|
||||
return helper.getNavigationProperties();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ActionImport;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityContainer;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntitySet;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.FunctionImport;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Singleton;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmException;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmEntityContainer;
|
||||
|
||||
public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
||||
|
||||
private final EntityContainer xmlEntityContainer;
|
||||
|
||||
public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
|
||||
final EntityContainer xmlEntityContainer) {
|
||||
|
||||
super(edm, entityContainerName);
|
||||
this.xmlEntityContainer = xmlEntityContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmSingleton createSingleton(final String singletonName) {
|
||||
final Singleton singleton = xmlEntityContainer.getSingleton(singletonName);
|
||||
if (singleton == null) {
|
||||
throw new EdmException("Singleton named '" + singletonName + "' not found in " + entityContainerName);
|
||||
}
|
||||
return new EdmSingletonImpl(edm, this, singletonName,
|
||||
new EdmTypeInfo(singleton.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
|
||||
singleton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmEntitySet createEntitySet(final String entitySetName) {
|
||||
final EntitySet entitySet = (EntitySet) xmlEntityContainer.getEntitySet(entitySetName);
|
||||
if (entitySet == null) {
|
||||
throw new EdmException("EntitySet named '" + entitySetName + "' not found in " + entityContainerName);
|
||||
}
|
||||
return new EdmEntitySetImpl(edm, this, entitySetName,
|
||||
new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
|
||||
entitySet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmActionImport createActionImport(final String actionImportName) {
|
||||
final ActionImport actionImport = xmlEntityContainer.getActionImport(actionImportName);
|
||||
if (actionImport == null) {
|
||||
throw new EdmException("ActionImport named '" + actionImportName + "' not found in " + entityContainerName);
|
||||
}
|
||||
return new EdmActionImportImpl(edm, this, actionImportName, actionImport);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmFunctionImport createFunctionImport(final String functionImportName) {
|
||||
final FunctionImport functionImport = (FunctionImport) xmlEntityContainer.getFunctionImport(functionImportName);
|
||||
if (functionImport == null) {
|
||||
throw new EdmException("FunctionImport named '" + functionImportName + "' not found in " + entityContainerName);
|
||||
}
|
||||
return new EdmFunctionImportImpl(edm, this, functionImportName, functionImport);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* 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
|
||||
|
@ -16,32 +16,20 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.server.api.edm.provider;
|
||||
package org.apache.olingo.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntitySet;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
|
||||
public class Target {
|
||||
public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
|
||||
|
||||
private String targetName;
|
||||
public EdmEntitySetImpl(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final FullQualifiedName type, final EntitySet entitySet) {
|
||||
|
||||
private FullQualifiedName entityContainer;
|
||||
|
||||
public String getTargetName() {
|
||||
return targetName;
|
||||
}
|
||||
|
||||
public Target setTargetName(final String targetPathName) {
|
||||
targetName = targetPathName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FullQualifiedName getEntityContainer() {
|
||||
return entityContainer;
|
||||
}
|
||||
|
||||
public Target setEntityContainer(final FullQualifiedName entityContainer) {
|
||||
this.entityContainer = entityContainer;
|
||||
return this;
|
||||
super(edm, container, name, type, entitySet);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.PropertyRef;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityType;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmKeyPropertyRef;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmStructuredTypeHelper;
|
||||
|
||||
public class EdmEntityTypeImpl extends AbstractEdmEntityType {
|
||||
|
||||
private final EdmStructuredTypeHelper helper;
|
||||
|
||||
public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, final EntityType entityType) {
|
||||
final FullQualifiedName baseTypeName = entityType.getBaseType() == null
|
||||
? null : new EdmTypeInfo(entityType.getBaseType()).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 = new ArrayList<EdmKeyPropertyRef>(
|
||||
entityType.getKey().getPropertyRefs().size());
|
||||
for (PropertyRef ref : entityType.getKey().getPropertyRefs()) {
|
||||
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.isHasStream());
|
||||
this.helper = new EdmStructuredTypeHelperImpl(edm, entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, EdmProperty> getProperties() {
|
||||
return helper.getProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, EdmNavigationProperty> getNavigationProperties() {
|
||||
return helper.getNavigationProperties();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmMemberImpl;
|
||||
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.olingo.odata4.client.api.edm.xml.EnumType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Member;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmMember;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmEnumType;
|
||||
import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
|
||||
|
||||
public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType {
|
||||
|
||||
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 = EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance();
|
||||
} else {
|
||||
this.underlyingType = EdmPrimitiveTypeKind.fromString(
|
||||
xmlEnumType.getUnderlyingType()).getEdmPrimitiveTypeInstance();
|
||||
// TODO: Should we validate that the underlying type is of byte, sbyte, in16, int32 or int64?
|
||||
}
|
||||
|
||||
final List<? extends Member> xmlMembers = xmlEnumType.getMembers();
|
||||
final List<String> _memberNames = new ArrayList<String>();
|
||||
final Map<String, EdmMember> _members = new LinkedHashMap<String, EdmMember>(xmlMembers.size());
|
||||
for (Member xmlMember : xmlMembers) {
|
||||
_memberNames.add(xmlMember.getName());
|
||||
_members.put(xmlMember.getName(), new EdmMemberImpl(edm, xmlMember.getName(), xmlMember.getValue()));
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Function;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.FunctionImport;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
|
||||
|
||||
public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport {
|
||||
|
||||
private final FunctionImport functionImport;
|
||||
|
||||
public EdmFunctionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final FunctionImport functionImport) {
|
||||
|
||||
super(edm, container, name, functionImport);
|
||||
this.functionImport = functionImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmFunction getFunction(final List<String> parameterNames) {
|
||||
return edm.getFunction(
|
||||
new EdmTypeInfo(functionImport.getFunction(), container.getNamespace()).getFullQualifiedName(),
|
||||
null, null, parameterNames);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.PropertyRef;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.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 getKeyPropertyName() {
|
||||
return propertyRef.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlias() {
|
||||
return propertyRef.getAlias();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
throw new UnsupportedOperationException("Not supported in client code.");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.NavigationProperty;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ReferentialConstraint;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmNavigationProperty;
|
||||
|
||||
public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
|
||||
|
||||
private final NavigationProperty navigationProperty;
|
||||
|
||||
private final EdmTypeInfo edmTypeInfo;
|
||||
|
||||
public EdmNavigationPropertyImpl(final Edm edm, final NavigationProperty navigationProperty) {
|
||||
super(edm, navigationProperty.getName());
|
||||
this.navigationProperty = navigationProperty;
|
||||
this.edmTypeInfo = new EdmTypeInfo(navigationProperty.getType());
|
||||
}
|
||||
|
||||
@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 String getReferencingPropertyName(final String referencedPropertyName) {
|
||||
final List<? extends ReferentialConstraint> referentialConstraints = navigationProperty.getReferentialConstraints();
|
||||
if (referentialConstraints != null) {
|
||||
for (ReferentialConstraint constraint : referentialConstraints) {
|
||||
if (constraint.getReferencedProperty().equals(referencedPropertyName)) {
|
||||
return constraint.getProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonParameter;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Action;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmParameter;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmOperation;
|
||||
|
||||
public abstract class EdmOperationImpl extends AbstractEdmOperation {
|
||||
|
||||
protected final Action operation;
|
||||
|
||||
protected static <T extends EdmOperationImpl> T getInstance(final T instance) {
|
||||
|
||||
final List<? extends CommonParameter> parameters = instance.operation.getParameters();
|
||||
if (parameters != null) {
|
||||
final List<EdmParameter> _parameters = new ArrayList<EdmParameter>(parameters.size());
|
||||
for (CommonParameter parameter : parameters) {
|
||||
_parameters.add(EdmParameterImpl.getInstance(instance.edm, parameter));
|
||||
}
|
||||
instance.setParameters(_parameters);
|
||||
}
|
||||
|
||||
instance.setEntitySetPath(instance.operation.getEntitySetPath());
|
||||
|
||||
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 Action operation,
|
||||
final EdmTypeKind kind) {
|
||||
|
||||
super(edm, name, kind);
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.OperationImport;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Target;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmOperationImport;
|
||||
|
||||
public abstract class EdmOperationImportImpl extends AbstractEdmOperationImport {
|
||||
|
||||
protected EdmOperationImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
|
||||
final OperationImport operationImport) {
|
||||
|
||||
super(edm, container, name, new Target.Builder(operationImport.getEntitySet(), container).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonParameter;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmMapping;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmParameter;
|
||||
|
||||
public class EdmParameterImpl extends AbstractEdmParameter {
|
||||
|
||||
private final CommonParameter parameter;
|
||||
|
||||
private final EdmTypeInfo parameterInfo;
|
||||
|
||||
public static EdmParameterImpl getInstance(final Edm edm, final CommonParameter parameter) {
|
||||
final EdmTypeInfo paramTypeInfo = new EdmTypeInfo(parameter.getType());
|
||||
return new EdmParameterImpl(edm, parameter, paramTypeInfo);
|
||||
}
|
||||
|
||||
private EdmParameterImpl(final Edm edm, final CommonParameter parameter, final EdmTypeInfo parameterInfo) {
|
||||
super(edm, parameter.getName(), parameterInfo.getFullQualifiedName());
|
||||
this.parameter = parameter;
|
||||
this.parameterInfo = parameterInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollection() {
|
||||
return parameterInfo.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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonProperty;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmMapping;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmProperty;
|
||||
|
||||
public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty {
|
||||
|
||||
private final CommonProperty property;
|
||||
|
||||
private final EdmTypeInfo edmTypeInfo;
|
||||
|
||||
public EdmPropertyImpl(final Edm edm, final CommonProperty property) {
|
||||
super(edm, property.getName());
|
||||
this.property = property;
|
||||
this.edmTypeInfo = new EdmTypeInfo(property.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullQualifiedName getTypeFQN() {
|
||||
return edmTypeInfo.getFullQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollection() {
|
||||
return edmTypeInfo.isCollection();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ReturnType;
|
||||
import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmReturnType;
|
||||
|
||||
public class EdmReturnTypeImpl extends AbstractEdmReturnType {
|
||||
|
||||
private final ReturnType returnType;
|
||||
|
||||
private final EdmTypeInfo returnTypeInfo;
|
||||
|
||||
public static EdmReturnTypeImpl getInstance(final Edm edm, final ReturnType returnType) {
|
||||
final EdmTypeInfo returnTypeInfo = new EdmTypeInfo(returnType.getType());
|
||||
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.returnTypeInfo = returnTypeInfo;
|
||||
}
|
||||
|
||||
@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 boolean isCollection() {
|
||||
return returnTypeInfo.isCollection();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Singleton;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonNavigationProperty;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonProperty;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ComplexType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.NavigationProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmStructuredTypeHelper;
|
||||
|
||||
public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
|
||||
|
||||
private final Edm edm;
|
||||
|
||||
private final ComplexType complexType;
|
||||
|
||||
private Map<String, EdmProperty> properties;
|
||||
|
||||
private Map<String, EdmNavigationProperty> navigationProperties;
|
||||
|
||||
public EdmStructuredTypeHelperImpl(final Edm edm, final ComplexType complexType) {
|
||||
this.edm = edm;
|
||||
this.complexType = complexType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, EdmProperty> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new LinkedHashMap<String, EdmProperty>();
|
||||
for (CommonProperty property : complexType.getProperties()) {
|
||||
properties.put(property.getName(), new EdmPropertyImpl(edm, property));
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, EdmNavigationProperty> getNavigationProperties() {
|
||||
if (navigationProperties == null) {
|
||||
navigationProperties = new LinkedHashMap<String, EdmNavigationProperty>();
|
||||
for (CommonNavigationProperty navigationProperty : complexType.getNavigationProperties()) {
|
||||
if (navigationProperty instanceof NavigationProperty) {
|
||||
navigationProperties.put(navigationProperty.getName(),
|
||||
new EdmNavigationPropertyImpl(edm, (NavigationProperty) navigationProperty));
|
||||
}
|
||||
}
|
||||
}
|
||||
return navigationProperties;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.TypeDefinition;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmException;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.AbstractEdmTypeDefinition;
|
||||
import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
|
||||
|
||||
public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements EdmTypeDefinition {
|
||||
|
||||
private TypeDefinition typeDefinition;
|
||||
|
||||
private EdmPrimitiveType edmPrimitiveTypeInstance;
|
||||
|
||||
public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
|
||||
final TypeDefinition typeDefinition) {
|
||||
|
||||
super(edm, typeDefinitionName);
|
||||
this.typeDefinition = typeDefinition;
|
||||
// TODO: Should we check for edmNamespace in the underlying type name?
|
||||
try {
|
||||
edmPrimitiveTypeInstance = EdmPrimitiveTypeKind.fromString(
|
||||
typeDefinition.getUnderlyingType()).getEdmPrimitiveTypeInstance();
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@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 Boolean isUnicode() {
|
||||
return typeDefinition.isUnicode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm.v3;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.core.edm.AbstractEdmServiceMetadataImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v3.XMLMetadataImpl;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmSingletonInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
|
||||
|
||||
public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
||||
|
||||
private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V30;
|
||||
|
||||
public EdmServiceMetadataImpl(final XMLMetadataImpl xmlMetadata) {
|
||||
super(xmlMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataServiceVersion() {
|
||||
return SERVICE_VERSION.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmSingletonInfo> getSingletonInfos() {
|
||||
return Collections.<EdmSingletonInfo>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmActionImportInfo> getActionImportInfos() {
|
||||
return Collections.<EdmActionImportInfo>emptyList();
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v3;
|
||||
|
||||
import org.apache.olingo.odata4.client.core.edm.AbstractEdmType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmType;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v3.ComplexTypeImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v3.EntityTypeImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v3.EnumTypeImpl;
|
||||
|
@ -29,7 +30,7 @@ public class EdmTypeImpl extends AbstractEdmType {
|
|||
super(typeExpression);
|
||||
}
|
||||
|
||||
public EdmTypeImpl(final EdmMetadataImpl metadata, final String typeExpression) {
|
||||
public EdmTypeImpl(final XMLMetadata metadata, final String typeExpression) {
|
||||
super(metadata, typeExpression);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm.v4;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ActionImport;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityContainer;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Singleton;
|
||||
import org.apache.olingo.odata4.client.core.edm.AbstractEdmServiceMetadataImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.XMLMetadataImpl;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmSingletonInfo;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmActionImportInfoImpl;
|
||||
import org.apache.olingo.odata4.commons.core.edm.EdmSingletonInfoImpl;
|
||||
|
||||
public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
|
||||
|
||||
private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V40;
|
||||
|
||||
private List<EdmSingletonInfo> singletonInfos;
|
||||
|
||||
private List<EdmActionImportInfo> actionImportInfos;
|
||||
|
||||
public EdmServiceMetadataImpl(final XMLMetadataImpl xmlMetadata) {
|
||||
super(xmlMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataServiceVersion() {
|
||||
return SERVICE_VERSION.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmSingletonInfo> getSingletonInfos() {
|
||||
synchronized (this) {
|
||||
if (singletonInfos == null) {
|
||||
singletonInfos = new ArrayList<EdmSingletonInfo>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
for (Singleton singleton : entityContainer.getSingletons()) {
|
||||
singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return singletonInfos;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmActionImportInfo> getActionImportInfos() {
|
||||
synchronized (this) {
|
||||
if (actionImportInfos == null) {
|
||||
actionImportInfos = new ArrayList<EdmActionImportInfo>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
for (ActionImport actionImport : entityContainer.getActionImports()) {
|
||||
actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return actionImportInfos;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4;
|
||||
|
||||
import org.apache.olingo.odata4.client.core.edm.AbstractEdmType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmType;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.ComplexTypeImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.EntityTypeImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.EnumTypeImpl;
|
||||
|
@ -29,7 +30,7 @@ public class EdmTypeImpl extends AbstractEdmType {
|
|||
super(typeExpression);
|
||||
}
|
||||
|
||||
public EdmTypeImpl(final EdmMetadataImpl metadata, final String typeExpression) {
|
||||
public EdmTypeImpl(final XMLMetadata metadata, final String typeExpression) {
|
||||
super(metadata, typeExpression);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,20 +16,17 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.odata4.client.api.data.EdmSimpleType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.ComplexType;
|
||||
import org.apache.olingo.odata4.client.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.odata4.client.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.client.api.edm.EdmTypeNotFoundException;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.EntityType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.EnumType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractComplexType;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEntityType;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEnumType;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
|
||||
|
||||
/**
|
||||
* Parse type information from metadata into semantic data.
|
||||
|
@ -67,7 +64,7 @@ public abstract class AbstractEdmType implements EdmType {
|
|||
* @param metadata metadata.
|
||||
* @param typeExpression type expression.
|
||||
*/
|
||||
public AbstractEdmType(final EdmMetadata metadata, final String typeExpression) {
|
||||
public AbstractEdmType(final XMLMetadata metadata, final String typeExpression) {
|
||||
this.typeExpression = typeExpression;
|
||||
|
||||
final int collectionStartIdx = typeExpression.indexOf("Collection(");
|
|
@ -29,7 +29,7 @@ public abstract class AbstractMember extends AbstractEdmItem implements Member {
|
|||
private String name;
|
||||
|
||||
@JsonProperty("Value")
|
||||
private Integer value;
|
||||
private String value;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -41,11 +41,11 @@ public abstract class AbstractMember extends AbstractEdmItem implements Member {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(final Integer value) {
|
||||
public void setValue(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,31 +18,25 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.xml;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.math.BigInteger;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonParameter;
|
||||
|
||||
@JsonDeserialize(using = ParameterDeserializer.class)
|
||||
public abstract class AbstractParameter extends AbstractEdmItem implements CommonParameter {
|
||||
|
||||
private static final long serialVersionUID = -4305016554930334342L;
|
||||
|
||||
@JsonProperty(value = "Name", required = true)
|
||||
private String name;
|
||||
|
||||
@JsonProperty(value = "Type", required = true)
|
||||
private String type;
|
||||
|
||||
@JsonProperty(value = "Nullable")
|
||||
private boolean nullable = true;
|
||||
|
||||
@JsonProperty("MaxLength")
|
||||
private String maxLength;
|
||||
private Integer maxLength;
|
||||
|
||||
@JsonProperty("Precision")
|
||||
private BigInteger precision;
|
||||
private Integer precision;
|
||||
|
||||
@JsonProperty("Scale")
|
||||
private BigInteger scale;
|
||||
private Integer scale;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -75,32 +69,32 @@ public abstract class AbstractParameter extends AbstractEdmItem implements Commo
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getMaxLength() {
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLength(final String maxLength) {
|
||||
public void setMaxLength(final Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getPrecision() {
|
||||
public Integer getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrecision(final BigInteger precision) {
|
||||
public void setPrecision(final Integer precision) {
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getScale() {
|
||||
public Integer getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(final BigInteger scale) {
|
||||
public void setScale(final Integer scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,53 +18,40 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.xml;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.math.BigInteger;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.CommonProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.ConcurrencyMode;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.StoreGeneratedPattern;
|
||||
|
||||
@JsonDeserialize(using = PropertyDeserializer.class)
|
||||
public abstract class AbstractProperty extends AbstractEdmItem implements CommonProperty {
|
||||
|
||||
private static final long serialVersionUID = -6004492361142315153L;
|
||||
|
||||
@JsonProperty(value = "Name", required = true)
|
||||
private String name;
|
||||
|
||||
@JsonProperty(value = "Type", required = true)
|
||||
private String type;
|
||||
|
||||
@JsonProperty(value = "Nullable")
|
||||
private boolean nullable = true;
|
||||
|
||||
@JsonProperty(value = "DefaultValue")
|
||||
private String defaultValue;
|
||||
|
||||
@JsonProperty(value = "MaxLength")
|
||||
private String maxLength;
|
||||
private Integer maxLength;
|
||||
|
||||
@JsonProperty(value = "FixedLength")
|
||||
private boolean fixedLength;
|
||||
|
||||
@JsonProperty(value = "Precision")
|
||||
private BigInteger precision;
|
||||
private Integer precision;
|
||||
|
||||
@JsonProperty(value = "Scale")
|
||||
private BigInteger scale;
|
||||
private Integer scale;
|
||||
|
||||
@JsonProperty(value = "Unicode")
|
||||
private boolean unicode = true;
|
||||
|
||||
@JsonProperty(value = "Collation")
|
||||
private String collation;
|
||||
|
||||
@JsonProperty(value = "SRID")
|
||||
private String srid;
|
||||
|
||||
@JsonProperty(value = "ConcurrencyMode")
|
||||
private ConcurrencyMode concurrencyMode;
|
||||
|
||||
@JsonProperty("StoreGeneratedPattern")
|
||||
private StoreGeneratedPattern storeGeneratedPattern = StoreGeneratedPattern.None;
|
||||
|
||||
@Override
|
||||
|
@ -108,12 +95,12 @@ public abstract class AbstractProperty extends AbstractEdmItem implements Common
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getMaxLength() {
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLength(final String maxLength) {
|
||||
public void setMaxLength(final Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
|
@ -128,22 +115,22 @@ public abstract class AbstractProperty extends AbstractEdmItem implements Common
|
|||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getPrecision() {
|
||||
public Integer getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrecision(final BigInteger precision) {
|
||||
public void setPrecision(final Integer precision) {
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getScale() {
|
||||
public Integer getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(final BigInteger scale) {
|
||||
public void setScale(final Integer scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,23 +16,20 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.odata4.client.api.ODataClient;
|
||||
import org.apache.olingo.odata4.client.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Edmx;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmItem;
|
||||
|
||||
/**
|
||||
* Entry point for access information about EDM metadata.
|
||||
*/
|
||||
public abstract class AbstractEdmMetadata extends AbstractEdmItem implements EdmMetadata {
|
||||
public abstract class AbstractXMLMetadata extends AbstractEdmItem implements XMLMetadata {
|
||||
|
||||
private static final long serialVersionUID = -1214173426671503187L;
|
||||
|
||||
|
@ -40,15 +37,8 @@ public abstract class AbstractEdmMetadata extends AbstractEdmItem implements Edm
|
|||
|
||||
protected final Map<String, Schema> schemaByNsOrAlias;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param client OData client
|
||||
* @param inputStream source stream.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public AbstractEdmMetadata(final ODataClient client, final InputStream inputStream) {
|
||||
edmx = client.getDeserializer().toMetadata(inputStream);
|
||||
public AbstractXMLMetadata(final Edmx edmx) {
|
||||
this.edmx = edmx;
|
||||
|
||||
this.schemaByNsOrAlias = new HashMap<String, Schema>();
|
||||
for (Schema schema : edmx.getDataServices().getSchemas()) {
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm.xml;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v3.ParameterMode;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
|
||||
|
||||
public class ParameterDeserializer extends AbstractEdmDeserializer<AbstractParameter> {
|
||||
|
||||
@Override
|
||||
protected AbstractParameter doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
|
||||
throws IOException, JsonProcessingException {
|
||||
|
||||
final AbstractParameter parameter = ODataServiceVersion.V30 == client.getServiceVersion()
|
||||
? new org.apache.olingo.odata4.client.core.edm.xml.v3.ParameterImpl()
|
||||
: new org.apache.olingo.odata4.client.core.edm.xml.v4.ParameterImpl();
|
||||
|
||||
for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
|
||||
final JsonToken token = jp.getCurrentToken();
|
||||
if (token == JsonToken.FIELD_NAME) {
|
||||
if ("Name".equals(jp.getCurrentName())) {
|
||||
parameter.setName(jp.nextTextValue());
|
||||
} else if ("Type".equals(jp.getCurrentName())) {
|
||||
parameter.setType(jp.nextTextValue());
|
||||
} else if ("Nullable".equals(jp.getCurrentName())) {
|
||||
parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||
} else if ("MaxLength".equals(jp.getCurrentName())) {
|
||||
final String maxLenght = jp.nextTextValue();
|
||||
parameter.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght));
|
||||
} else if ("Precision".equals(jp.getCurrentName())) {
|
||||
parameter.setPrecision(Integer.valueOf(jp.nextTextValue()));
|
||||
} else if ("Scale".equals(jp.getCurrentName())) {
|
||||
parameter.setScale(Integer.valueOf(jp.nextTextValue()));
|
||||
} else if ("Mode".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v3.ParameterImpl) parameter).
|
||||
setMode(ParameterMode.valueOf(jp.nextTextValue()));
|
||||
} else if ("SRID".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v4.ParameterImpl) parameter).setSrid(jp.nextTextValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm.xml;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.AnnotationImpl;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.ConcurrencyMode;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.EdmContentKind;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.StoreGeneratedPattern;
|
||||
|
||||
public class PropertyDeserializer extends AbstractEdmDeserializer<AbstractProperty> {
|
||||
|
||||
@Override
|
||||
protected AbstractProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
|
||||
throws IOException, JsonProcessingException {
|
||||
|
||||
final AbstractProperty property = ODataServiceVersion.V30 == client.getServiceVersion()
|
||||
? new org.apache.olingo.odata4.client.core.edm.xml.v3.PropertyImpl()
|
||||
: new org.apache.olingo.odata4.client.core.edm.xml.v4.PropertyImpl();
|
||||
|
||||
for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
|
||||
final JsonToken token = jp.getCurrentToken();
|
||||
if (token == JsonToken.FIELD_NAME) {
|
||||
if ("Name".equals(jp.getCurrentName())) {
|
||||
property.setName(jp.nextTextValue());
|
||||
} else if ("Type".equals(jp.getCurrentName())) {
|
||||
property.setType(jp.nextTextValue());
|
||||
} else if ("Nullable".equals(jp.getCurrentName())) {
|
||||
property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||
} else if ("DefaultValue".equals(jp.getCurrentName())) {
|
||||
property.setDefaultValue(jp.nextTextValue());
|
||||
} else if ("MaxLength".equals(jp.getCurrentName())) {
|
||||
final String maxLenght = jp.nextTextValue();
|
||||
property.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght));
|
||||
} else if ("FixedLength".equals(jp.getCurrentName())) {
|
||||
property.setFixedLength(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||
} else if ("Precision".equals(jp.getCurrentName())) {
|
||||
property.setPrecision(Integer.valueOf(jp.nextTextValue()));
|
||||
} else if ("Scale".equals(jp.getCurrentName())) {
|
||||
property.setScale(Integer.valueOf(jp.nextTextValue()));
|
||||
} else if ("Unicode".equals(jp.getCurrentName())) {
|
||||
property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||
} else if ("Collation".equals(jp.getCurrentName())) {
|
||||
property.setCollation(jp.nextTextValue());
|
||||
} else if ("SRID".equals(jp.getCurrentName())) {
|
||||
property.setSrid(jp.nextTextValue());
|
||||
} else if ("ConcurrencyMode".equals(jp.getCurrentName())) {
|
||||
property.setConcurrencyMode(ConcurrencyMode.valueOf(jp.nextTextValue()));
|
||||
} else if ("StoreGeneratedPattern".equals(jp.getCurrentName())) {
|
||||
property.setStoreGeneratedPattern(StoreGeneratedPattern.valueOf(jp.nextTextValue()));
|
||||
} else if ("FC_SourcePath".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v3.PropertyImpl) property).
|
||||
setFcSourcePath(jp.nextTextValue());
|
||||
} else if ("FC_TargetPath".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v3.PropertyImpl) property).
|
||||
setFcTargetPath(jp.nextTextValue());
|
||||
} else if ("FC_ContentKind".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v3.PropertyImpl) property).
|
||||
setFcContentKind(EdmContentKind.valueOf(jp.nextTextValue()));
|
||||
} else if ("FC_NsPrefix".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v3.PropertyImpl) property).
|
||||
setFcNSPrefix(jp.nextTextValue());
|
||||
} else if ("FC_NsUri".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v3.PropertyImpl) property).
|
||||
setFcNSURI(jp.nextTextValue());
|
||||
} else if ("FC_KeepInContent".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v3.PropertyImpl) property).
|
||||
setFcKeepInContent(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||
} else if ("Annotation".equals(jp.getCurrentName())) {
|
||||
((org.apache.olingo.odata4.client.core.edm.xml.v4.PropertyImpl) property).
|
||||
setAnnotation(jp.readValueAs(AnnotationImpl.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.olingo.odata4.client.core.edm.xml.v3;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v3.ParameterMode;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v3.Parameter;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractParameter;
|
||||
|
||||
|
@ -27,7 +26,6 @@ public class ParameterImpl extends AbstractParameter implements Parameter {
|
|||
|
||||
private static final long serialVersionUID = 7596724999614891358L;
|
||||
|
||||
@JsonProperty("Mode")
|
||||
private ParameterMode mode;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v3;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v3.Property;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractProperty;
|
||||
import org.apache.olingo.odata4.commons.api.edm.constants.EdmContentKind;
|
||||
|
@ -27,68 +26,74 @@ public class PropertyImpl extends AbstractProperty implements Property {
|
|||
|
||||
private static final long serialVersionUID = 6224524803474652100L;
|
||||
|
||||
@JsonProperty("FC_SourcePath")
|
||||
private String fcSourcePath;
|
||||
|
||||
@JsonProperty("FC_TargetPath")
|
||||
private String fcTargetPath;
|
||||
|
||||
@JsonProperty("FC_ContentKind")
|
||||
private EdmContentKind fcContentKind = EdmContentKind.text;
|
||||
|
||||
@JsonProperty("FC_NsPrefix")
|
||||
private String fcNSPrefix;
|
||||
|
||||
@JsonProperty("FC_NsUri")
|
||||
private String fcNSURI;
|
||||
|
||||
@JsonProperty("FC_KeepInContent")
|
||||
private boolean fcKeepInContent = true;
|
||||
|
||||
@Override
|
||||
public String getFcSourcePath() {
|
||||
return fcSourcePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFcSourcePath(final String fcSourcePath) {
|
||||
this.fcSourcePath = fcSourcePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFcTargetPath() {
|
||||
return fcTargetPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFcTargetPath(final String fcTargetPath) {
|
||||
this.fcTargetPath = fcTargetPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmContentKind getFcContentKind() {
|
||||
return fcContentKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFcContentKind(final EdmContentKind fcContentKind) {
|
||||
this.fcContentKind = fcContentKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFcNSPrefix() {
|
||||
return fcNSPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFcNSPrefix(final String fcNSPrefix) {
|
||||
this.fcNSPrefix = fcNSPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFcNSURI() {
|
||||
return fcNSURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFcNSURI(final String fcNSURI) {
|
||||
this.fcNSURI = fcNSURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFcKeepInContent() {
|
||||
return fcKeepInContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFcKeepInContent(final boolean fcKeepInContent) {
|
||||
this.fcKeepInContent = fcKeepInContent;
|
||||
}
|
||||
|
|
|
@ -16,20 +16,17 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v3;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v3;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.ODataClient;
|
||||
import org.apache.olingo.odata4.client.core.edm.AbstractEdmMetadata;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v3.SchemaImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractXMLMetadata;
|
||||
|
||||
public class EdmMetadataImpl extends AbstractEdmMetadata {
|
||||
public class XMLMetadataImpl extends AbstractXMLMetadata {
|
||||
|
||||
private static final long serialVersionUID = -7765327879691528010L;
|
||||
|
||||
public EdmMetadataImpl(final ODataClient client, final InputStream inputStream) {
|
||||
super(client, inputStream);
|
||||
public XMLMetadataImpl(final EdmxImpl edmx) {
|
||||
super(edmx);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -24,7 +24,7 @@ import com.fasterxml.jackson.core.JsonToken;
|
|||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import java.io.IOException;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
|
||||
import org.apache.olingo.odata4.client.core.edm.v4.annotation.DynExprConstructImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.DynExprConstructImpl;
|
||||
|
||||
public class AnnotationDeserializer extends AbstractEdmDeserializer<AnnotationImpl> {
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.apache.olingo.odata4.client.api.edm.xml.v4.Annotation;
|
|||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.ConstExprConstruct;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.DynExprConstruct;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmItem;
|
||||
import org.apache.olingo.odata4.client.core.edm.v4.annotation.ConstExprConstructImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.v4.annotation.DynExprConstructImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.ConstExprConstructImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.DynExprConstructImpl;
|
||||
|
||||
@JsonDeserialize(using = AnnotationDeserializer.class)
|
||||
public class AnnotationImpl extends AbstractEdmItem implements Annotation {
|
||||
|
|
|
@ -59,10 +59,12 @@ public class EntityContainerImpl extends AbstractEntityContainer implements Anno
|
|||
return entitySets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SingletonImpl> getSingletons() {
|
||||
return singletons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingletonImpl getSingleton(final String name) {
|
||||
return getOneByName(name, getSingletons());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Annotation;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.EntitySet;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.NavigationPropertyBinding;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEntitySet;
|
||||
|
||||
public class EntitySetImpl extends AbstractEntitySet implements EntitySet {
|
||||
|
@ -32,8 +33,7 @@ public class EntitySetImpl extends AbstractEntitySet implements EntitySet {
|
|||
|
||||
private AnnotationImpl annotation;
|
||||
|
||||
private final List<NavigationPropertyBindingImpl> navigationPropertyBindings
|
||||
= new ArrayList<NavigationPropertyBindingImpl>();
|
||||
private final List<NavigationPropertyBinding> navigationPropertyBindings = new ArrayList<NavigationPropertyBinding>();
|
||||
|
||||
@Override
|
||||
public boolean isIncludeInServiceDocument() {
|
||||
|
@ -46,7 +46,7 @@ public class EntitySetImpl extends AbstractEntitySet implements EntitySet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<NavigationPropertyBindingImpl> getNavigationPropertyBindings() {
|
||||
public List<NavigationPropertyBinding> getNavigationPropertyBindings() {
|
||||
return navigationPropertyBindings;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Parameter;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractParameter;
|
||||
|
||||
|
@ -26,7 +25,6 @@ public class ParameterImpl extends AbstractParameter implements Parameter {
|
|||
|
||||
private static final long serialVersionUID = -1067642515116697747L;
|
||||
|
||||
@JsonProperty(value = "SRID")
|
||||
private String srid;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.olingo.odata4.client.core.edm.xml.v4;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Annotation;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Property;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractProperty;
|
||||
|
@ -28,7 +27,6 @@ public class PropertyImpl extends AbstractProperty implements Property {
|
|||
|
||||
private static final long serialVersionUID = -5541908235094985412L;
|
||||
|
||||
@JsonProperty("Annotation")
|
||||
private AnnotationImpl annotation;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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.odata4.client.core.edm.xml.v4;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
|
||||
|
||||
public class ReturnTypeDeserializer extends AbstractEdmDeserializer<ReturnTypeImpl> {
|
||||
|
||||
@Override
|
||||
protected ReturnTypeImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
|
||||
throws IOException, JsonProcessingException {
|
||||
|
||||
final ReturnTypeImpl returnType = new ReturnTypeImpl();
|
||||
|
||||
for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
|
||||
final JsonToken token = jp.getCurrentToken();
|
||||
if (token == JsonToken.FIELD_NAME) {
|
||||
if ("Type".equals(jp.getCurrentName())) {
|
||||
returnType.setType(jp.nextTextValue());
|
||||
} else if ("Nullable".equals(jp.getCurrentName())) {
|
||||
returnType.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||
} else if ("MaxLength".equals(jp.getCurrentName())) {
|
||||
final String maxLenght = jp.nextTextValue();
|
||||
returnType.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght));
|
||||
} else if ("Precision".equals(jp.getCurrentName())) {
|
||||
returnType.setPrecision(Integer.valueOf(jp.nextTextValue()));
|
||||
} else if ("Scale".equals(jp.getCurrentName())) {
|
||||
returnType.setScale(Integer.valueOf(jp.nextTextValue()));
|
||||
} else if ("SRID".equals(jp.getCurrentName())) {
|
||||
returnType.setSrid(jp.nextTextValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnType;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,31 +18,25 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.math.BigInteger;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.ReturnType;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmItem;
|
||||
|
||||
@JsonDeserialize(using = ReturnTypeDeserializer.class)
|
||||
public class ReturnTypeImpl extends AbstractEdmItem implements ReturnType {
|
||||
|
||||
private static final long serialVersionUID = -5888231162358116515L;
|
||||
|
||||
@JsonProperty(value = "Type")
|
||||
private String type;
|
||||
|
||||
@JsonProperty(value = "Nullable")
|
||||
private boolean nullable = true;
|
||||
|
||||
@JsonProperty(value = "MaxLength")
|
||||
private String maxLength;
|
||||
private Integer maxLength;
|
||||
|
||||
@JsonProperty(value = "Precision")
|
||||
private BigInteger precision;
|
||||
private Integer precision;
|
||||
|
||||
@JsonProperty(value = "Scale")
|
||||
private BigInteger scale;
|
||||
private Integer scale;
|
||||
|
||||
@JsonProperty(value = "SRID")
|
||||
private String srid;
|
||||
|
||||
@Override
|
||||
|
@ -66,32 +60,32 @@ public class ReturnTypeImpl extends AbstractEdmItem implements ReturnType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getMaxLength() {
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLength(final String maxLength) {
|
||||
public void setMaxLength(final Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getPrecision() {
|
||||
public Integer getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrecision(final BigInteger precision) {
|
||||
public void setPrecision(final Integer precision) {
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getScale() {
|
||||
public Integer getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(final BigInteger scale) {
|
||||
public void setScale(final Integer scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,10 @@ public class SchemaImpl extends AbstractSchema implements Schema, AnnotatedEdmIt
|
|||
return terms;
|
||||
}
|
||||
|
||||
public TypeDefinitionImpl getTypeDefinition(final String name) {
|
||||
return getOneByName(name, getTypeDefinitions());
|
||||
}
|
||||
|
||||
public List<TypeDefinitionImpl> getTypeDefinitions() {
|
||||
return typeDefinitions;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SingletonDeserializer extends AbstractEdmDeserializer<SingletonImpl
|
|||
if ("Name".equals(jp.getCurrentName())) {
|
||||
singleton.setName(jp.nextTextValue());
|
||||
} else if ("Type".equals(jp.getCurrentName())) {
|
||||
singleton.setType(jp.nextTextValue());
|
||||
singleton.setEntityType(jp.nextTextValue());
|
||||
} else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) {
|
||||
jp.nextToken();
|
||||
singleton.getNavigationPropertyBindings().add(
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.olingo.odata4.client.core.edm.xml.v4;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.NavigationPropertyBinding;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Singleton;
|
||||
|
||||
@JsonDeserialize(using = SingletonDeserializer.class)
|
||||
|
@ -30,10 +31,9 @@ public class SingletonImpl extends AbstractAnnotatedEdmItem implements Singleton
|
|||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
private String entityType;
|
||||
|
||||
private final List<NavigationPropertyBindingImpl> navigationPropertyBindings
|
||||
= new ArrayList<NavigationPropertyBindingImpl>();
|
||||
private final List<NavigationPropertyBinding> navigationPropertyBindings = new ArrayList<NavigationPropertyBinding>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -46,17 +46,17 @@ public class SingletonImpl extends AbstractAnnotatedEdmItem implements Singleton
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
public String getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
public void setEntityType(final String entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NavigationPropertyBindingImpl> getNavigationPropertyBindings() {
|
||||
public List<NavigationPropertyBinding> getNavigationPropertyBindings() {
|
||||
return navigationPropertyBindings;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.fasterxml.jackson.core.JsonToken;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
|
||||
|
||||
|
@ -43,18 +42,18 @@ public class TypeDefinitionDeserializer extends AbstractEdmDeserializer<TypeDefi
|
|||
} else if ("UnderlyingType".equals(jp.getCurrentName())) {
|
||||
typeDefinition.setUnderlyingType(jp.nextTextValue());
|
||||
} else if ("MaxLength".equals(jp.getCurrentName())) {
|
||||
typeDefinition.setMaxLength(jp.nextTextValue());
|
||||
typeDefinition.setMaxLength(jp.nextIntValue(0));
|
||||
} else if ("Unicode".equals(jp.getCurrentName())) {
|
||||
typeDefinition.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||
} else if ("Precision".equals(jp.getCurrentName())) {
|
||||
typeDefinition.setPrecision(BigInteger.valueOf(jp.nextLongValue(0L)));
|
||||
typeDefinition.setPrecision(jp.nextIntValue(0));
|
||||
} else if ("Scale".equals(jp.getCurrentName())) {
|
||||
typeDefinition.setScale(BigInteger.valueOf(jp.nextLongValue(0L)));
|
||||
typeDefinition.setScale(jp.nextIntValue(0));
|
||||
} else if ("SRID".equals(jp.getCurrentName())) {
|
||||
typeDefinition.setSrid(jp.nextTextValue());
|
||||
} else if ("Annotation".equals(jp.getCurrentName())) {
|
||||
jp.nextToken();
|
||||
typeDefinition.getAnnotations().add(jp.readValueAs( AnnotationImpl.class));
|
||||
typeDefinition.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.TypeDefinition;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmItem;
|
||||
|
||||
@JsonDeserialize(using = TypeDefinitionDeserializer.class)
|
||||
public class TypeDefinitionImpl extends AbstractEdmItem implements TypeDefinition {
|
||||
|
||||
private static final long serialVersionUID = -5888231162358116515L;
|
||||
|
@ -32,11 +33,11 @@ public class TypeDefinitionImpl extends AbstractEdmItem implements TypeDefinitio
|
|||
|
||||
private String underlyingType;
|
||||
|
||||
private String maxLength;
|
||||
private Integer maxLength;
|
||||
|
||||
private BigInteger precision;
|
||||
private Integer precision;
|
||||
|
||||
private BigInteger scale;
|
||||
private Integer scale;
|
||||
|
||||
private boolean unicode = true;
|
||||
|
||||
|
@ -65,32 +66,32 @@ public class TypeDefinitionImpl extends AbstractEdmItem implements TypeDefinitio
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getMaxLength() {
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLength(final String maxLength) {
|
||||
public void setMaxLength(final Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getPrecision() {
|
||||
public Integer getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrecision(final BigInteger precision) {
|
||||
public void setPrecision(final Integer precision) {
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getScale() {
|
||||
public Integer getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(final BigInteger scale) {
|
||||
public void setScale(final Integer scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,22 +16,17 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.odata4.client.api.ODataClient;
|
||||
import org.apache.olingo.odata4.client.core.edm.AbstractEdmMetadata;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.EdmxImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.ReferenceImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.SchemaImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractXMLMetadata;
|
||||
|
||||
public class EdmMetadataImpl extends AbstractEdmMetadata {
|
||||
public class XMLMetadataImpl extends AbstractXMLMetadata {
|
||||
|
||||
private static final long serialVersionUID = -7765327879691528010L;
|
||||
|
||||
public EdmMetadataImpl(final ODataClient client, final InputStream inputStream) {
|
||||
super(client, inputStream);
|
||||
public XMLMetadataImpl(final EdmxImpl edmx) {
|
||||
super(edmx);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
/**
|
||||
* Groups dynamic expressions that may be provided using element notation or attribute notation.
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.Annotation;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.AnnotatedEdmItem;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
public class AnnotationPath extends AbstractElOrAttrConstruct {
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.util.ArrayList;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.math.BigInteger;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.util.ArrayList;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.ConstExprConstruct;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonLocation;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.DynExprConstruct;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.DynExprConstruct;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.DynExprConstruct;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.ExprConstruct;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmItem;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.ExprConstruct;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.math.BigInteger;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.DynExprConstruct;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
public class LabeledElementReference extends AbstractElOrAttrConstruct {
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
public class NavigationPropertyPath extends AbstractElOrAttrConstruct {
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
public class Path extends AbstractElOrAttrConstruct {
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
public class PropertyPath extends AbstractElOrAttrConstruct {
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.ExprConstruct;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.util.ArrayList;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.apache.olingo.odata4.client.api.edm.xml.v4.annotation.ExprConstruct;
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.client.core.edm.v4.annotation;
|
||||
package org.apache.olingo.odata4.client.core.edm.xml.v4.annotation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
|
|||
import java.io.IOException;
|
||||
import org.apache.olingo.odata4.client.api.ODataClient;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.ReturnTypeImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.v4.annotation.ConstExprConstructImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.ConstExprConstructImpl;
|
||||
|
||||
public abstract class AbstractEdmDeserializer<T> extends JsonDeserializer<T> {
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.InputStream;
|
|||
import org.apache.olingo.odata4.client.api.ODataClient;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractODataDeserializer;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v3.EdmxImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v3.XMLMetadataImpl;
|
||||
|
||||
public class ODataDeserializerImpl extends AbstractODataDeserializer {
|
||||
|
||||
|
@ -32,9 +33,9 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmxImpl toMetadata(final InputStream input) {
|
||||
public XMLMetadataImpl toMetadata(final InputStream input) {
|
||||
try {
|
||||
return getXmlMapper().readValue(input, EdmxImpl.class);
|
||||
return new XMLMetadataImpl(getXmlMapper().readValue(input, EdmxImpl.class));
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Could not parse as Edmx document", e);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ package org.apache.olingo.odata4.client.core.op.impl.v3;
|
|||
|
||||
import java.io.InputStream;
|
||||
import org.apache.olingo.odata4.client.core.ODataV3Client;
|
||||
import org.apache.olingo.odata4.client.core.edm.EdmClientImpl;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractODataReader;
|
||||
import org.apache.olingo.odata4.client.core.edm.v3.EdmMetadataImpl;
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
|
||||
public class ODataReaderImpl extends AbstractODataReader {
|
||||
|
||||
|
@ -32,8 +33,8 @@ public class ODataReaderImpl extends AbstractODataReader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmMetadataImpl readMetadata(final InputStream input) {
|
||||
return new EdmMetadataImpl(client, input);
|
||||
public Edm readMetadata(final InputStream input) {
|
||||
return new EdmClientImpl(client.getDeserializer().toMetadata(input));
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.InputStream;
|
|||
import org.apache.olingo.odata4.client.api.ODataClient;
|
||||
import org.apache.olingo.odata4.client.core.op.impl.AbstractODataDeserializer;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.EdmxImpl;
|
||||
import org.apache.olingo.odata4.client.core.edm.xml.v4.XMLMetadataImpl;
|
||||
|
||||
public class ODataDeserializerImpl extends AbstractODataDeserializer {
|
||||
|
||||
|
@ -32,9 +33,9 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EdmxImpl toMetadata(final InputStream input) {
|
||||
public XMLMetadataImpl toMetadata(final InputStream input) {
|
||||
try {
|
||||
return getXmlMapper().readValue(input, EdmxImpl.class);
|
||||
return new XMLMetadataImpl(getXmlMapper().readValue(input, EdmxImpl.class));
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Could not parse as Edmx document", e);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue