use of org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind in project teiid by teiid.
the class DocumentNode method getKeyPredicateExpression.
private static org.apache.olingo.server.api.uri.queryoption.expression.Expression getKeyPredicateExpression(UriParameter key, OData odata, Column column) {
org.apache.olingo.server.api.uri.queryoption.expression.Expression expr = key.getExpression();
if (expr == null) {
EdmPrimitiveTypeKind primitiveTypeKind = ODataTypeManager.odataType(column.getRuntimeType());
expr = new LiteralImpl(key.getText(), odata.createPrimitiveTypeInstance(primitiveTypeKind));
}
return expr;
}
use of org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind in project teiid by teiid.
the class ODataTypeManager method convertToODataURIValue.
public static String convertToODataURIValue(Object val, String odataType) throws EdmPrimitiveTypeException {
if (val == null) {
// is this correct? //$NON-NLS-1$
return "null";
}
if (odataType.startsWith("Edm.")) {
// $NON-NLS-1$
odataType = odataType.substring(4);
}
if (val instanceof GeometryType) {
Geometry g;
try {
g = GeometryUtils.getGeometry((GeometryType) val);
} catch (FunctionExecutionException e1) {
throw new EdmPrimitiveTypeException(e1.getMessage(), e1);
}
StringWriter sw = new StringWriter();
// $NON-NLS-1$
sw.write("geometry'SRID=");
sw.write(String.valueOf(g.getSRID()));
// $NON-NLS-1$
sw.write(";");
ODataWKTWriter writer = new ODataWKTWriter();
try {
writer.write(g, sw);
} catch (IOException e) {
throw new TeiidRuntimeException(e);
}
// $NON-NLS-1$
sw.write("'");
return sw.toString();
}
EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(odataType);
String value = EdmPrimitiveTypeFactory.getInstance(kind).valueToString(val, true, null, null, Integer.MAX_VALUE, true);
if (kind == EdmPrimitiveTypeKind.String) {
return EdmString.getInstance().toUriLiteral(value);
}
return value;
}
use of org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind in project teiid by teiid.
the class ODataSchemaBuilder method buildFunction.
static void buildFunction(String schemaName, Procedure proc, ArrayList<CsdlComplexType> complexTypes, ArrayList<CsdlFunction> functions, ArrayList<CsdlFunctionImport> functionImports, CsdlSchema csdlSchema) {
CsdlFunction edmFunction = new CsdlFunction();
edmFunction.setName(proc.getName());
edmFunction.setBound(false);
ArrayList<CsdlParameter> params = new ArrayList<CsdlParameter>();
for (ProcedureParameter pp : proc.getParameters()) {
EdmPrimitiveTypeKind odataType = ODataTypeManager.odataType(pp.getRuntimeType());
if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) {
edmFunction.setReturnType(new CsdlReturnType().setType(odataType.getFullQualifiedName()).setCollection(DataTypeManager.isArrayType(pp.getRuntimeType())));
continue;
}
if (pp.getType().equals(ProcedureParameter.Type.In) || pp.getType().equals(ProcedureParameter.Type.InOut)) {
CsdlParameter parameter = buildParameter(pp, odataType);
addOperationParameterAnnotations(pp, parameter, csdlSchema);
params.add(parameter);
}
}
edmFunction.setParameters(params);
// add a complex type for return resultset.
ColumnSet<Procedure> returnColumns = proc.getResultSet();
if (returnColumns != null) {
CsdlComplexType complexType = buildComplexType(proc, returnColumns, csdlSchema);
complexTypes.add(complexType);
FullQualifiedName odataType = new FullQualifiedName(schemaName, complexType.getName());
edmFunction.setReturnType((new CsdlReturnType().setType(odataType).setCollection(true)));
}
CsdlFunctionImport functionImport = new CsdlFunctionImport();
functionImport.setName(proc.getName()).setFunction(new FullQualifiedName(schemaName, proc.getName()));
addOperationAnnotations(proc, edmFunction, csdlSchema);
functions.add(edmFunction);
functionImports.add(functionImport);
}
use of org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind in project teiid by teiid.
the class ODataSchemaBuilder method buildAction.
static void buildAction(String schemaName, Procedure proc, ArrayList<CsdlComplexType> complexTypes, ArrayList<CsdlAction> actions, ArrayList<CsdlActionImport> actionImports, CsdlSchema csdlSchema) {
CsdlAction edmAction = new CsdlAction();
edmAction.setName(proc.getName());
edmAction.setBound(false);
ArrayList<CsdlParameter> params = new ArrayList<CsdlParameter>();
for (ProcedureParameter pp : proc.getParameters()) {
EdmPrimitiveTypeKind odatatype = ODataTypeManager.odataType(pp.getRuntimeType());
if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) {
edmAction.setReturnType(new CsdlReturnType().setType(odatatype.getFullQualifiedName()).setCollection(DataTypeManager.isArrayType(pp.getRuntimeType())));
continue;
}
if (pp.getType().equals(ProcedureParameter.Type.In) || pp.getType().equals(ProcedureParameter.Type.InOut)) {
CsdlParameter parameter = buildParameter(pp, odatatype);
addOperationParameterAnnotations(pp, parameter, csdlSchema);
params.add(parameter);
}
}
edmAction.setParameters(params);
// add a complex type for return resultset.
ColumnSet<Procedure> returnColumns = proc.getResultSet();
if (returnColumns != null) {
CsdlComplexType complexType = buildComplexType(proc, returnColumns, csdlSchema);
complexTypes.add(complexType);
edmAction.setReturnType((new CsdlReturnType().setType(new FullQualifiedName(schemaName, complexType.getName())).setCollection(true)));
}
CsdlActionImport actionImport = new CsdlActionImport();
actionImport.setName(proc.getName()).setAction(new FullQualifiedName(schemaName, proc.getName()));
addOperationAnnotations(proc, edmAction, csdlSchema);
actions.add(edmAction);
actionImports.add(actionImport);
}
Aggregations