[OLINGO-62] Further implementation

This commit is contained in:
Christian Amend 2013-12-06 15:39:56 +01:00
parent 2e622040d1
commit 7b1726a2f9
8 changed files with 83 additions and 13 deletions

View File

@ -50,13 +50,16 @@ public abstract class EdmBindingTargetImpl extends EdmNamedImpl implements EdmBi
Target providerTarget = binding.getTarget(); Target providerTarget = binding.getTarget();
EdmEntityContainer entityContainer = edm.getEntityContainer(providerTarget.getEntityContainer()); EdmEntityContainer entityContainer = edm.getEntityContainer(providerTarget.getEntityContainer());
if (entityContainer == null) { if (entityContainer == null) {
throw new EdmException("Can´t find entity container with name: " + providerTarget.getEntityContainer()); throw new EdmException("Cant find entity container with name: " + providerTarget.getEntityContainer());
} }
bindingTarget = entityContainer.getEntitySet(providerTarget.getTargetName()); String targetName = providerTarget.getTargetName();
bindingTarget = entityContainer.getEntitySet(targetName);
if (bindingTarget == null) { if (bindingTarget == null) {
bindingTarget = entityContainer.getSingleton(providerTarget.getTargetName()); bindingTarget = entityContainer.getSingleton(targetName);
if (bindingTarget != null) { if (bindingTarget != null) {
break; break;
}else{
throw new EdmException("Cant find target with name: " + targetName);
} }
} else { } else {
break; break;

View File

@ -42,7 +42,7 @@ public class EdmComplexTypeImpl extends EdmStructuralTypeImpl implements EdmComp
if (baseTypeName != null) { if (baseTypeName != null) {
baseType = edm.getComplexType(baseTypeName); baseType = edm.getComplexType(baseTypeName);
if (baseType == null) { if (baseType == null) {
throw new EdmException("Can<EFBFBD>t find base type with name: " + baseTypeName + " for complex type: " + getName()); throw new EdmException("Cant find base type with name: " + baseTypeName + " for complex type: " + getName());
} }
} }
return baseType; return baseType;

View File

@ -26,7 +26,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmNamed;
import org.apache.olingo.commons.api.edm.EdmSingleton; import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.helper.EntityContainerInfo; import org.apache.olingo.commons.api.edm.helper.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.helper.FullQualifiedName; import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;

View File

@ -86,6 +86,7 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit
if (baseType != null) { if (baseType != null) {
return entityBaseType.getKeyPropertyRefs(); return entityBaseType.getKeyPropertyRefs();
} else { } else {
//TODO: Cache
return new ArrayList<EdmKeyPropertyRef>(keyPropertyRefs.values()); return new ArrayList<EdmKeyPropertyRef>(keyPropertyRefs.values());
} }
} }
@ -105,7 +106,7 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit
if (baseTypeName != null) { if (baseTypeName != null) {
baseType = edm.getEntityType(baseTypeName); baseType = edm.getEntityType(baseTypeName);
if (baseType == null) { if (baseType == null) {
throw new EdmException("Can<EFBFBD>t find base type with name: " + baseTypeName + " for entity type: " + getName()); throw new EdmException("Cant find base type with name: " + baseTypeName + " for entity type: " + getName());
} }
} }
return baseType; return baseType;

View File

@ -0,0 +1,38 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.commons.core.edm.provider;
import org.apache.olingo.commons.api.edm.EdmMember;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
public class EdmMemberImpl extends EdmNamedImpl implements EdmMember {
private final EnumMember member;
public EdmMemberImpl(EdmProviderImpl edm, EnumMember member) {
super(edm, member.getName());
this.member = member;
}
@Override
public String getValue() {
return member.getValue();
}
}

View File

@ -18,7 +18,10 @@
******************************************************************************/ ******************************************************************************/
package org.apache.olingo.commons.core.edm.provider; package org.apache.olingo.commons.core.edm.provider;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmOperation; import org.apache.olingo.commons.api.edm.EdmOperation;
@ -27,37 +30,63 @@ import org.apache.olingo.commons.api.edm.EdmReturnType;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.helper.FullQualifiedName; import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.Operation; import org.apache.olingo.commons.api.edm.provider.Operation;
import org.apache.olingo.commons.api.edm.provider.Parameter;
public class EdmOperationImpl extends EdmTypeImpl implements EdmOperation { public class EdmOperationImpl extends EdmTypeImpl implements EdmOperation {
private final Map<String, EdmParameter> parameters = new HashMap<String, EdmParameter>();
private final Operation operation;
private EdmReturnType returnType;
private List<String> parameterNames;
public EdmOperationImpl(final EdmProviderImpl edm, final FullQualifiedName name, final Operation operation, public EdmOperationImpl(final EdmProviderImpl edm, final FullQualifiedName name, final Operation operation,
final EdmTypeKind kind) { final EdmTypeKind kind) {
super(edm, name, kind); super(edm, name, kind);
this.operation = operation;
List<Parameter> providerParameters = operation.getParameters();
if (providerParameters != null) {
for (Parameter parameter : providerParameters) {
parameters.put(parameter.getName(), new EdmParameterImpl(edm, parameter));
}
}
} }
@Override @Override
public EdmParameter getParameter(final String name) { public EdmParameter getParameter(final String name) {
return null; return parameters.get(name);
} }
@Override @Override
public List<String> getParameterNames() { public List<String> getParameterNames() {
return null; if (parameterNames == null) {
parameterNames = new ArrayList<String>();
List<Parameter> providerParameters = operation.getParameters();
if (providerParameters != null) {
for (Parameter parameter : providerParameters) {
parameterNames.add(parameter.getName());
}
}
}
return parameterNames;
} }
@Override @Override
public EdmEntitySet getReturnedEntitySet(final EdmEntitySet bindingParameterEntitySet, final String path) { public EdmEntitySet getReturnedEntitySet(final EdmEntitySet bindingParameterEntitySet, final String path) {
//TODO: What here?
return null; return null;
} }
@Override @Override
public EdmReturnType getReturnType() { public EdmReturnType getReturnType() {
return null; if (returnType == null) {
returnType = new EdmReturnTypeImpl(edm, operation.getReturnType());
}
return returnType;
} }
@Override @Override
public boolean isBound() { public boolean isBound() {
return false; return operation.isBound();
} }
} }

View File

@ -46,7 +46,7 @@ public class EdmParameterImpl extends EdmElementImpl implements EdmParameter {
if (kind != null) { if (kind != null) {
typeImpl = kind.getEdmPrimitiveTypeInstance(); typeImpl = kind.getEdmPrimitiveTypeInstance();
} else { } else {
throw new EdmException("Can<EFBFBD>t find type with name: " + typeName); throw new EdmException("Cant find type with name: " + typeName);
} }
} else { } else {
typeImpl = edm.getComplexType(typeName); typeImpl = edm.getComplexType(typeName);
@ -57,7 +57,7 @@ public class EdmParameterImpl extends EdmElementImpl implements EdmParameter {
if (typeImpl == null) { if (typeImpl == null) {
typeImpl = edm.getTypeDefinition(typeName); typeImpl = edm.getTypeDefinition(typeName);
if (typeImpl == null) { if (typeImpl == null) {
throw new EdmException("Can<EFBFBD>t find type with name: " + typeName); throw new EdmException("Cant find type with name: " + typeName);
} }
} }
} }

View File

@ -58,7 +58,7 @@ public class EdmReturnTypeImpl implements EdmReturnType {
if (typeImpl == null) { if (typeImpl == null) {
typeImpl = edm.getTypeDefinition(typeName); typeImpl = edm.getTypeDefinition(typeName);
if (typeImpl == null) { if (typeImpl == null) {
throw new EdmException("Can<EFBFBD>t find type with name: " + typeName); throw new EdmException("Cant find type with name: " + typeName);
} }
} }
} }