[OLINGO-209] open type is both for complex and entity types

This commit is contained in:
Francesco Chicchiriccò 2014-04-03 11:12:22 +02:00
parent a6817f32f8
commit 251742312a
18 changed files with 66 additions and 35 deletions

View File

@ -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;

View File

@ -64,4 +64,9 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
return helper.getNavigationProperties();
}
@Override
public boolean isOpenType() {
return helper.isOpenType();
}
}

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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)
*

View File

@ -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();
}

View File

@ -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>();

View File

@ -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;
}

View File

@ -35,8 +35,11 @@ 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(
@ -135,4 +138,5 @@ public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements E
return true;
}
}

View File

@ -28,4 +28,7 @@ public interface EdmStructuredTypeHelper {
Map<String, EdmProperty> getProperties();
Map<String, EdmNavigationProperty> getNavigationProperties();
boolean isOpenType();
}

View File

@ -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) {

View File

@ -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) {

View File

@ -54,4 +54,9 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
return helper.getNavigationProperties();
}
@Override
public boolean isOpenType() {
return helper.isOpenType();
}
}

View File

@ -90,7 +90,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
@Override
public boolean isOpenType() {
return entityType.isOpenType();
return helper.isOpenType();
}
}

View File

@ -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;

View File

@ -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;

View File

@ -70,4 +70,10 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
}
return navigationProperties;
}
@Override
public boolean isOpenType() {
return structuredType.isOpenType();
}
}