[OLINGO-575] Cleanup of TODOs

This commit is contained in:
Christian Amend 2015-03-18 14:35:45 +01:00
parent 5cef4faeb6
commit 3b37d29948
18 changed files with 46 additions and 118 deletions

View File

@ -91,7 +91,6 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> {
}else{ }else{
edm = null; edm = null;
} }
// TODO: check runtime exception or not
if (version.compareTo(ODataServiceVersion.V40) < 0) { if (version.compareTo(ODataServiceVersion.V40) < 0) {
throw new ODataRuntimeException("Only OData V4 or higher supported."); throw new ODataRuntimeException("Only OData V4 or higher supported.");
} }

View File

@ -210,16 +210,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
final String containerNS, final String entitySetName, final AbstractService<?> service) { final String containerNS, final String entitySetName, final AbstractService<?> service) {
final URIBuilder uriBuilder = service.getClient().newURIBuilder(); final URIBuilder uriBuilder = service.getClient().newURIBuilder();
// final Edm edm = service.getClient().getCachedEdm();
final StringBuilder entitySetSegment = new StringBuilder(); final StringBuilder entitySetSegment = new StringBuilder();
//TODO: Container is always default in v4
// if (StringUtils.isNotBlank(containerNS)) {
// final EdmEntityContainer container = edm.getEntityContainer(new FullQualifiedName(containerNS));
// if (!container.isDefault()) {
// entitySetSegment.append(container.getFullQualifiedName().toString()).append('.');
// }
// }
entitySetSegment.append(entitySetName); entitySetSegment.append(entitySetName);
uriBuilder.appendEntitySetSegment(entitySetSegment.toString()); uriBuilder.appendEntitySetSegment(entitySetSegment.toString());

View File

@ -651,25 +651,9 @@ public final class CoreUtils {
return mediaEditLink == null ? URIUtils.getURI(entity.getEditLink(), name) : mediaEditLink.getLink(); return mediaEditLink == null ? URIUtils.getURI(entity.getEditLink(), name) : mediaEditLink.getLink();
} }
public static URI getTargetEntitySetURI( public static URI getTargetEntitySetURI(final EdmEnabledODataClient client, final NavigationProperty property) {
final EdmEnabledODataClient client, final NavigationProperty property) {
// final Edm edm = client.getCachedEdm();
//
// final FullQualifiedName containerName =
// new FullQualifiedName(property.targetSchema(), property.targetContainer());
// final EdmEntityContainer container = edm.getEntityContainer(containerName);
final URIBuilder uriBuilder = client.newURIBuilder(client.getServiceRoot()); final URIBuilder uriBuilder = client.newURIBuilder(client.getServiceRoot());
//TODO: Container can only be default in V4 uriBuilder.appendEntitySetSegment(property.targetEntitySet());
// if (!container.isDefault()) {
// final StringBuilder entitySetSegment = new StringBuilder();
// entitySetSegment.append(container.getFullQualifiedName()).append('.');
// entitySetSegment.append(property.targetEntitySet());
// uriBuilder.appendEntitySetSegment(entitySetSegment.toString());
// } else {
uriBuilder.appendEntitySetSegment(property.targetEntitySet());
// }
return uriBuilder.build(); return uriBuilder.build();
} }
} }

View File

@ -18,11 +18,7 @@
*/ */
package org.apache.olingo.client.core.edm.xml; package org.apache.olingo.client.core.edm.xml;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.edm.provider.Annotation; import org.apache.olingo.commons.api.edm.provider.Annotation;
import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -31,46 +27,4 @@ public class AnnotationImpl extends Annotation {
private static final long serialVersionUID = 5464714417411058033L; private static final long serialVersionUID = 5464714417411058033L;
private String term;
private String qualifier;
private AnnotationExpression annotationExpression;
private final List<Annotation> annotations = new ArrayList<Annotation>();
@Override
public List<Annotation> getAnnotations() {
return annotations;
}
@Override
public String getTerm() {
return term;
}
public AnnotationImpl setTerm(final String term) {
this.term = term;
return this;
}
@Override
public String getQualifier() {
return qualifier;
}
public AnnotationImpl setQualifier(final String qualifier) {
this.qualifier = qualifier;
return this;
}
@Override
public AnnotationExpression getExpression() {
return annotationExpression;
}
public void setAnnotationExpression(final AnnotationExpression annotationExpression) {
this.annotationExpression = annotationExpression;
}
} }

View File

@ -223,7 +223,6 @@ public class MetadataTest extends AbstractTest {
final Function productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0); final Function productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0);
assertNotNull(productsByRating.getParameter("Rating")); assertNotNull(productsByRating.getParameter("Rating"));
assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType()); assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType());
// assertEquals("Collection(ODataDemo.Product)", productsByRating.getReturnType().getType());
assertEquals("ODataDemo.Product", productsByRating.getReturnType().getType()); assertEquals("ODataDemo.Product", productsByRating.getReturnType().getType());
assertTrue(productsByRating.getReturnType().isCollection()); assertTrue(productsByRating.getReturnType().isCollection());

View File

@ -64,4 +64,9 @@ public interface EdmOperation extends EdmType, EdmAnnotatable {
*/ */
Boolean isBindingParameterTypeCollection(); Boolean isBindingParameterTypeCollection();
/**
* @return the entity set path as a String or null if not present
*/
String getEntitySetPath();
} }

View File

@ -18,23 +18,30 @@
*/ */
package org.apache.olingo.commons.api.edm.provider; package org.apache.olingo.commons.api.edm.provider;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression; import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression;
public class Annotation extends AbstractEdmItem implements Annotatable{ public class Annotation extends AbstractEdmItem implements Annotatable {
private static final long serialVersionUID = -7137313445729486860L; private static final long serialVersionUID = -7137313445729486860L;
private String term; private String term;
// Target should be a target path
// private String targetPath;
private String qualifier; private String qualifier;
private AnnotationExpression expression; private List<Annotation> annotation = new ArrayList<Annotation>();
private List<Annotation> annotation; private AnnotationExpression annotationExpression;
public AnnotationExpression getExpression() {
return annotationExpression;
}
public void setAnnotationExpression(final AnnotationExpression annotationExpression) {
this.annotationExpression = annotationExpression;
}
public String getTerm() { public String getTerm() {
return term; return term;
@ -54,27 +61,17 @@ public class Annotation extends AbstractEdmItem implements Annotatable{
return this; return this;
} }
public AnnotationExpression getExpression() { // public List<Annotation> getAnnotation() {
return expression; // return annotation;
} // }
public Annotation setExpression(final AnnotationExpression expression) { public Annotation setAnnotations(final List<Annotation> annotation) {
this.expression = expression;
return this;
}
public List<Annotation> getAnnotation() {
return annotation;
}
public Annotation setAnnotation(final List<Annotation> annotation) {
this.annotation = annotation; this.annotation = annotation;
return this; return this;
} }
@Override @Override
public List<Annotation> getAnnotations() { public List<Annotation> getAnnotations() {
// TODO Auto-generated method stub return annotation;
return null;
} }
} }

View File

@ -55,7 +55,6 @@ public class EnumType extends AbstractEdmItem implements Named, Annotatable {
return this; return this;
} }
//TODO: Underlying type has a default
public String getUnderlyingType() { public String getUnderlyingType() {
if(underlyingType != null){ if(underlyingType != null){
return underlyingType.getFullQualifiedNameAsString(); return underlyingType.getFullQualifiedNameAsString();

View File

@ -34,7 +34,6 @@ public class Property extends AbstractEdmItem implements Named, Annotatable{
private boolean collection; private boolean collection;
// TODO: Mimetype and mapping what here
private String mimeType; private String mimeType;
private Mapping mapping; private Mapping mapping;

View File

@ -60,6 +60,6 @@ public class PropertyImpl extends AbstractValuable implements Property {
@Override @Override
public boolean isNull() { public boolean isNull() {
return getValue() == null || "Edm.Null".equals(type); // TODO: improve return getValue() == null || "Edm.Null".equals(type);
} }
} }

View File

@ -96,4 +96,9 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation {
public List<EdmAnnotation> getAnnotations() { public List<EdmAnnotation> getAnnotations() {
return helper.getAnnotations(); return helper.getAnnotations();
} }
@Override
public String getEntitySetPath(){
return operation.getEntitySetPath();
}
} }

View File

@ -340,7 +340,7 @@ public class EdmProviderImpl extends AbstractEdm {
} }
} }
//TODO: Check implementation //TODO: Check Provider annotations implementation
@Override @Override
protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) { protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) {
try { try {

View File

@ -49,7 +49,6 @@ public interface FixedFormatSerializer {
InputStream primitiveValue(EdmPrimitiveType type, Object value, PrimitiveValueSerializerOptions options) InputStream primitiveValue(EdmPrimitiveType type, Object value, PrimitiveValueSerializerOptions options)
throws SerializerException; throws SerializerException;
// TODO: Return type
/** /**
* Serializes a batch response * Serializes a batch response
* @param batchResponses * @param batchResponses

View File

@ -185,7 +185,6 @@ public class BatchParserCommon {
public static void consumeBlankLine(final List<Line> remainingMessage, final boolean isStrict) public static void consumeBlankLine(final List<Line> remainingMessage, final boolean isStrict)
throws BatchDeserializerException { throws BatchDeserializerException {
// TODO is \r\n to strict?
if (remainingMessage.size() > 0 && remainingMessage.get(0).toString().matches("\\s*(\r\n|\n)\\s*")) { if (remainingMessage.size() > 0 && remainingMessage.get(0).toString().matches("\\s*(\r\n|\n)\\s*")) {
remainingMessage.remove(0); remainingMessage.remove(0);
} else { } else {

View File

@ -60,7 +60,7 @@ public class FixedFormatSerializerImpl implements FixedFormatSerializer {
} }
} }
// TODO: Signature // TODO: Signature refactoring for writeBatchResponse
@Override @Override
public InputStream batchResponse(final List<ODataResponsePart> batchResponses, final String boundary) public InputStream batchResponse(final List<ODataResponsePart> batchResponses, final String boundary)
throws BatchSerializerException { throws BatchSerializerException {

View File

@ -79,7 +79,6 @@ public class ODataJsonSerializer implements ODataSerializer {
CircleStreamBuffer buffer; CircleStreamBuffer buffer;
JsonGenerator gen = null; JsonGenerator gen = null;
// TODO: move stream initialization into separate method
try { try {
buffer = new CircleStreamBuffer(); buffer = new CircleStreamBuffer();
gen = new JsonFactory().createGenerator(buffer.getOutputStream()) gen = new JsonFactory().createGenerator(buffer.getOutputStream())
@ -89,10 +88,6 @@ public class ODataJsonSerializer implements ODataSerializer {
gen.close(); gen.close();
// TODO: Check correct stream handling
// writer.flush();
// buffer.closeWrite();
return buffer.getInputStream(); return buffer.getInputStream();
} catch (final IOException e) { } catch (final IOException e) {

View File

@ -116,6 +116,7 @@ public class MetadataDocumentXmlSerializer {
private final static String NS_EDMX = "http://docs.oasis-open.org/odata/ns/edmx"; private final static String NS_EDMX = "http://docs.oasis-open.org/odata/ns/edmx";
private final static String NS_EDM = "http://docs.oasis-open.org/odata/ns/edm"; private final static String NS_EDM = "http://docs.oasis-open.org/odata/ns/edm";
private static final String XML_ENTITY_SET_PATH = "EntitySetPath";
private final ServiceMetadata serviceMetadata; private final ServiceMetadata serviceMetadata;
private final Map<String, String> namespaceToAlias = new HashMap<String, String>(); private final Map<String, String> namespaceToAlias = new HashMap<String, String>();
@ -124,6 +125,8 @@ public class MetadataDocumentXmlSerializer {
this.serviceMetadata = serviceMetadata; this.serviceMetadata = serviceMetadata;
} }
// TODO: Annotations in metadata document
public void writeMetadataDocument(final XMLStreamWriter writer) throws XMLStreamException { public void writeMetadataDocument(final XMLStreamWriter writer) throws XMLStreamException {
writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0"); writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
writer.setPrefix(PREFIX_EDMX, NS_EDMX); writer.setPrefix(PREFIX_EDMX, NS_EDMX);
@ -263,7 +266,6 @@ public class MetadataDocumentXmlSerializer {
} }
writer.writeAttribute(XML_INCLUDE_IN_SERVICE_DOCUMENT, "" + functionImport.isIncludeInServiceDocument()); writer.writeAttribute(XML_INCLUDE_IN_SERVICE_DOCUMENT, "" + functionImport.isIncludeInServiceDocument());
// TODO: Annotations
writer.writeEndElement(); writer.writeEndElement();
} }
} }
@ -274,7 +276,6 @@ public class MetadataDocumentXmlSerializer {
writer.writeStartElement(XML_ACTION_IMPORT); writer.writeStartElement(XML_ACTION_IMPORT);
writer.writeAttribute(XML_NAME, actionImport.getName()); writer.writeAttribute(XML_NAME, actionImport.getName());
writer.writeAttribute(XML_ACTION, getAliasedFullQualifiedName(actionImport.getUnboundAction(), false)); writer.writeAttribute(XML_ACTION, getAliasedFullQualifiedName(actionImport.getUnboundAction(), false));
// TODO: Annotations
writer.writeEndElement(); writer.writeEndElement();
} }
} }
@ -287,7 +288,6 @@ public class MetadataDocumentXmlSerializer {
writer.writeAttribute(XML_ENTITY_TYPE, getAliasedFullQualifiedName(singleton.getEntityType(), false)); writer.writeAttribute(XML_ENTITY_TYPE, getAliasedFullQualifiedName(singleton.getEntityType(), false));
appendNavigationPropertyBindings(writer, singleton); appendNavigationPropertyBindings(writer, singleton);
// TODO: Annotations
writer.writeEndElement(); writer.writeEndElement();
} }
@ -312,7 +312,6 @@ public class MetadataDocumentXmlSerializer {
writer.writeAttribute(XML_ENTITY_TYPE, getAliasedFullQualifiedName(entitySet.getEntityType(), false)); writer.writeAttribute(XML_ENTITY_TYPE, getAliasedFullQualifiedName(entitySet.getEntityType(), false));
appendNavigationPropertyBindings(writer, entitySet); appendNavigationPropertyBindings(writer, entitySet);
// TODO: Annotations
writer.writeEndElement(); writer.writeEndElement();
} }
} }
@ -322,7 +321,9 @@ public class MetadataDocumentXmlSerializer {
for (EdmFunction function : functions) { for (EdmFunction function : functions) {
writer.writeStartElement(XML_FUNCTION); writer.writeStartElement(XML_FUNCTION);
writer.writeAttribute(XML_NAME, function.getName()); writer.writeAttribute(XML_NAME, function.getName());
// TODO: EntitySetPath if (function.getEntitySetPath() != null) {
writer.writeAttribute(XML_ENTITY_SET_PATH, function.getEntitySetPath());
}
writer.writeAttribute(XML_IS_BOUND, "" + function.isBound()); writer.writeAttribute(XML_IS_BOUND, "" + function.isBound());
writer.writeAttribute(XML_IS_COMPOSABLE, "" + function.isComposable()); writer.writeAttribute(XML_IS_COMPOSABLE, "" + function.isComposable());
@ -373,6 +374,9 @@ public class MetadataDocumentXmlSerializer {
for (EdmAction action : actions) { for (EdmAction action : actions) {
writer.writeStartElement(XML_ACTION); writer.writeStartElement(XML_ACTION);
writer.writeAttribute(XML_NAME, action.getName()); writer.writeAttribute(XML_NAME, action.getName());
if (action.getEntitySetPath() != null) {
writer.writeAttribute(XML_ENTITY_SET_PATH, action.getEntitySetPath());
}
writer.writeAttribute(XML_IS_BOUND, "" + action.isBound()); writer.writeAttribute(XML_IS_BOUND, "" + action.isBound());
appendOperationParameters(writer, action); appendOperationParameters(writer, action);
@ -425,7 +429,7 @@ public class MetadataDocumentXmlSerializer {
writer.writeAttribute(XML_BASE_TYPE, getAliasedFullQualifiedName(complexType.getBaseType(), false)); writer.writeAttribute(XML_BASE_TYPE, getAliasedFullQualifiedName(complexType.getBaseType(), false));
} }
if(complexType.isAbstract()) { if (complexType.isAbstract()) {
writer.writeAttribute(ABSTRACT, TRUE); writer.writeAttribute(ABSTRACT, TRUE);
} }

View File

@ -61,7 +61,6 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
CircleStreamBuffer buffer; CircleStreamBuffer buffer;
XMLStreamWriter xmlStreamWriter = null; XMLStreamWriter xmlStreamWriter = null;
// TODO: move stream initialization into separate method
try { try {
buffer = new CircleStreamBuffer(); buffer = new CircleStreamBuffer();
xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET); xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET);