Search in sources :

Example 1 with ValueWithStructField

use of io.jans.orm.cloud.spanner.model.ValueWithStructField in project jans by JanssenProject.

the class SpannerOperationServiceImpl method applyParametersBinding.

private void applyParametersBinding(Statement.Builder builder, ConvertedExpression expression) throws IncompatibleTypeException {
    if (expression == null) {
        return;
    }
    Map<String, ValueWithStructField> queryParameters = expression.queryParameters();
    for (Entry<String, ValueWithStructField> queryParameterEntry : queryParameters.entrySet()) {
        String attributeName = queryParameterEntry.getKey();
        ValueWithStructField valueWithStructField = queryParameterEntry.getValue();
        ValueBinder<Builder> valueBinder = builder.bind(attributeName);
        setMutationBuilderValue(valueBinder, valueWithStructField.getStructField(), true, valueWithStructField.getValue());
    }
}
Also used : WriteBuilder(com.google.cloud.spanner.Mutation.WriteBuilder) Builder(com.google.cloud.spanner.Statement.Builder) ValueWithStructField(io.jans.orm.cloud.spanner.model.ValueWithStructField)

Example 2 with ValueWithStructField

use of io.jans.orm.cloud.spanner.model.ValueWithStructField in project jans by JanssenProject.

the class SpannerFilterConverter method buildVariableExpression.

private Expression buildVariableExpression(TableMapping tableMapping, String attributeName, Object attribyteValue, Map<String, ValueWithStructField> queryParameters) throws SearchException {
    StructField structField = getStructField(tableMapping, attributeName);
    String usedAttributeName = attributeName;
    int idx = 0;
    while (queryParameters.containsKey(usedAttributeName) && (idx < 100)) {
        usedAttributeName = attributeName + Integer.toString(idx++);
    }
    queryParameters.put(usedAttributeName, new ValueWithStructField(attribyteValue, structField));
    return new UserVariable(usedAttributeName);
}
Also used : ValueWithStructField(io.jans.orm.cloud.spanner.model.ValueWithStructField) StructField(com.google.cloud.spanner.Type.StructField) UserVariable(net.sf.jsqlparser.expression.UserVariable) ValueWithStructField(io.jans.orm.cloud.spanner.model.ValueWithStructField)

Example 3 with ValueWithStructField

use of io.jans.orm.cloud.spanner.model.ValueWithStructField in project jans by JanssenProject.

the class SpannerFilterConverter method convertToSqlFilter.

public ConvertedExpression convertToSqlFilter(TableMapping tableMapping, Filter genericFilter, Map<String, PropertyAnnotation> propertiesAnnotationsMap, Function<? super Filter, Boolean> processor, boolean skipAlias) throws SearchException {
    Map<String, ValueWithStructField> queryParameters = new HashMap<>();
    Map<String, Join> joinTables = new HashMap<>();
    ConvertedExpression convertedExpression = convertToSqlFilterImpl(tableMapping, genericFilter, propertiesAnnotationsMap, queryParameters, joinTables, processor, skipAlias);
    return convertedExpression;
}
Also used : HashMap(java.util.HashMap) ConvertedExpression(io.jans.orm.cloud.spanner.model.ConvertedExpression) Join(net.sf.jsqlparser.statement.select.Join) ValueWithStructField(io.jans.orm.cloud.spanner.model.ValueWithStructField)

Aggregations

ValueWithStructField (io.jans.orm.cloud.spanner.model.ValueWithStructField)3 WriteBuilder (com.google.cloud.spanner.Mutation.WriteBuilder)1 Builder (com.google.cloud.spanner.Statement.Builder)1 StructField (com.google.cloud.spanner.Type.StructField)1 ConvertedExpression (io.jans.orm.cloud.spanner.model.ConvertedExpression)1 HashMap (java.util.HashMap)1 UserVariable (net.sf.jsqlparser.expression.UserVariable)1 Join (net.sf.jsqlparser.statement.select.Join)1