[OLINGO-209] open type is both for complex and entity types
This commit is contained in:
parent
a6817f32f8
commit
251742312a
|
@ -57,9 +57,9 @@ import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
|||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmImpl;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdm;
|
||||
|
||||
public class EdmClientImpl extends AbstractEdmImpl {
|
||||
public class EdmClientImpl extends AbstractEdm {
|
||||
|
||||
private final ODataServiceVersion version;
|
||||
|
||||
|
|
|
@ -64,4 +64,9 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
|
|||
return helper.getNavigationProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenType() {
|
||||
return helper.isOpenType();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,14 +61,11 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private final EntityType entityType;
|
||||
|
||||
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);
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,7 +80,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
|
|||
|
||||
@Override
|
||||
public boolean isOpenType() {
|
||||
return entityType.isOpenType();
|
||||
return helper.isOpenType();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ import org.apache.olingo.commons.api.edm.EdmFunction;
|
|||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmSchemaImpl;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmSchema;
|
||||
|
||||
public class EdmSchemaImpl extends AbstractEdmSchemaImpl {
|
||||
public class EdmSchemaImpl extends AbstractEdmSchema {
|
||||
|
||||
private final ODataServiceVersion version;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
|||
import org.apache.olingo.client.api.edm.xml.CommonNavigationProperty;
|
||||
import org.apache.olingo.client.api.edm.xml.CommonProperty;
|
||||
import org.apache.olingo.client.api.edm.xml.ComplexType;
|
||||
import org.apache.olingo.client.api.edm.xml.EntityType;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.NavigationProperty;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
|
||||
|
@ -69,4 +70,14 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
|
|||
}
|
||||
return navigationProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenType() {
|
||||
return complexType instanceof org.apache.olingo.client.api.edm.xml.v4.ComplexType
|
||||
? ((org.apache.olingo.client.api.edm.xml.v4.ComplexType) complexType).isOpenType()
|
||||
: complexType instanceof EntityType
|
||||
? ((EntityType) complexType).isOpenType()
|
||||
: false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,13 +54,6 @@ public interface EdmEntityType extends EdmStructuredType {
|
|||
*/
|
||||
boolean hasStream();
|
||||
|
||||
/**
|
||||
* Indicates if the entity type is an open type.
|
||||
*
|
||||
* @return <code>true</code> if the entity type is open
|
||||
*/
|
||||
boolean isOpenType();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -79,4 +79,11 @@ public interface EdmStructuredType extends EdmType {
|
|||
* @return true if this type is compatible to the testType ( i.e. this type is a subtype of targetType )
|
||||
*/
|
||||
boolean compatibleTo(EdmType targetType);
|
||||
|
||||
/**
|
||||
* Indicates if the entity type is an open type.
|
||||
*
|
||||
* @return <code>true</code> if the entity type is open
|
||||
*/
|
||||
boolean isOpenType();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
|||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
||||
public abstract class AbstractEdmImpl implements Edm {
|
||||
public abstract class AbstractEdm implements Edm {
|
||||
|
||||
private final Map<FullQualifiedName, EdmEntityContainer> entityContainers =
|
||||
new HashMap<FullQualifiedName, EdmEntityContainer>();
|
|
@ -31,7 +31,7 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
|
|||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
||||
public abstract class AbstractEdmSchemaImpl implements EdmSchema {
|
||||
public abstract class AbstractEdmSchema implements EdmSchema {
|
||||
|
||||
protected final String namespace;
|
||||
|
||||
|
@ -51,7 +51,7 @@ public abstract class AbstractEdmSchemaImpl implements EdmSchema {
|
|||
|
||||
private EdmEntityContainer entityContainer;
|
||||
|
||||
public AbstractEdmSchemaImpl(String namespace, String alias) {
|
||||
public AbstractEdmSchema(String namespace, String alias) {
|
||||
this.namespace = namespace;
|
||||
this.alias = alias;
|
||||
}
|
|
@ -35,15 +35,18 @@ import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
|
|||
public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements EdmStructuredType {
|
||||
|
||||
protected EdmStructuredType baseType;
|
||||
|
||||
protected FullQualifiedName baseTypeName;
|
||||
|
||||
private List<String> propertyNames;
|
||||
|
||||
private List<String> navigationPropertyNames;
|
||||
|
||||
public AbstractEdmStructuredType(
|
||||
final Edm edm,
|
||||
final FullQualifiedName typeName,
|
||||
final EdmTypeKind kind,
|
||||
final FullQualifiedName baseTypeName) {
|
||||
final Edm edm,
|
||||
final FullQualifiedName typeName,
|
||||
final EdmTypeKind kind,
|
||||
final FullQualifiedName baseTypeName) {
|
||||
|
||||
super(edm, typeName, kind);
|
||||
this.baseTypeName = baseTypeName;
|
||||
|
@ -54,7 +57,7 @@ public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements E
|
|||
protected abstract Map<String, EdmProperty> getProperties();
|
||||
|
||||
protected abstract Map<String, EdmNavigationProperty> getNavigationProperties();
|
||||
|
||||
|
||||
protected abstract void checkBaseType();
|
||||
|
||||
@Override
|
||||
|
@ -125,7 +128,7 @@ public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements E
|
|||
throw new EdmException("Target type must not be null");
|
||||
}
|
||||
while (!sourceType.getName().equals(targetType.getName())
|
||||
|| !sourceType.getNamespace().equals(targetType.getNamespace())) {
|
||||
|| !sourceType.getNamespace().equals(targetType.getNamespace())) {
|
||||
|
||||
sourceType = sourceType.getBaseType();
|
||||
if (sourceType == null) {
|
||||
|
@ -135,4 +138,5 @@ public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements E
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,4 +28,7 @@ public interface EdmStructuredTypeHelper {
|
|||
Map<String, EdmProperty> getProperties();
|
||||
|
||||
Map<String, EdmNavigationProperty> getNavigationProperties();
|
||||
|
||||
boolean isOpenType();
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
|
|||
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmImpl;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdm;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -260,7 +260,7 @@ public class EdmImplCachingTest {
|
|||
edm = new LocalEdm();
|
||||
}
|
||||
|
||||
private class LocalEdm extends AbstractEdmImpl {
|
||||
private class LocalEdm extends AbstractEdm {
|
||||
|
||||
@Override
|
||||
public EdmEntityContainer createEntityContainer(final FullQualifiedName fqn) {
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
|
|||
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmImpl;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdm;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -158,7 +158,7 @@ public class EdmImplCallCreateTest {
|
|||
edm = new LocalEdm();
|
||||
}
|
||||
|
||||
private class LocalEdm extends AbstractEdmImpl {
|
||||
private class LocalEdm extends AbstractEdm {
|
||||
|
||||
@Override
|
||||
public EdmEntityContainer createEntityContainer(final FullQualifiedName fqn) {
|
||||
|
|
|
@ -33,7 +33,7 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
|
|||
private final EdmStructuredTypeHelper helper;
|
||||
|
||||
public static EdmComplexTypeImpl getInstance(
|
||||
final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
|
||||
final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
|
||||
|
||||
final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, name, complexType);
|
||||
return instance;
|
||||
|
@ -54,4 +54,9 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
|
|||
return helper.getNavigationProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenType() {
|
||||
return helper.isOpenType();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
|
|||
|
||||
@Override
|
||||
public boolean isOpenType() {
|
||||
return entityType.isOpenType();
|
||||
return helper.isOpenType();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
|
|||
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmImpl;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdm;
|
||||
import org.apache.olingo.server.api.edm.provider.Action;
|
||||
import org.apache.olingo.server.api.edm.provider.AliasInfo;
|
||||
import org.apache.olingo.server.api.edm.provider.ComplexType;
|
||||
|
@ -49,7 +49,7 @@ import org.apache.olingo.server.api.edm.provider.Parameter;
|
|||
import org.apache.olingo.server.api.edm.provider.Schema;
|
||||
import org.apache.olingo.server.api.edm.provider.TypeDefinition;
|
||||
|
||||
public class EdmProviderImpl extends AbstractEdmImpl {
|
||||
public class EdmProviderImpl extends AbstractEdm {
|
||||
|
||||
private final EdmProvider provider;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.olingo.commons.api.edm.EdmEnumType;
|
|||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmSchemaImpl;
|
||||
import org.apache.olingo.commons.core.edm.AbstractEdmSchema;
|
||||
import org.apache.olingo.server.api.edm.provider.Action;
|
||||
import org.apache.olingo.server.api.edm.provider.ComplexType;
|
||||
import org.apache.olingo.server.api.edm.provider.EdmProvider;
|
||||
|
@ -40,7 +40,7 @@ import org.apache.olingo.server.api.edm.provider.Function;
|
|||
import org.apache.olingo.server.api.edm.provider.Schema;
|
||||
import org.apache.olingo.server.api.edm.provider.TypeDefinition;
|
||||
|
||||
public class EdmSchemaImpl extends AbstractEdmSchemaImpl {
|
||||
public class EdmSchemaImpl extends AbstractEdmSchema {
|
||||
|
||||
private final Schema schema;
|
||||
private final Edm edm;
|
||||
|
|
|
@ -64,10 +64,16 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
|
|||
if (structuredType.getNavigationProperties() != null) {
|
||||
for (NavigationProperty navigationProperty : structuredType.getNavigationProperties()) {
|
||||
navigationProperties.put(navigationProperty.getName(),
|
||||
new EdmNavigationPropertyImpl(edm, navigationProperty));
|
||||
new EdmNavigationPropertyImpl(edm, navigationProperty));
|
||||
}
|
||||
}
|
||||
}
|
||||
return navigationProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenType() {
|
||||
return structuredType.isOpenType();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue