com.sap.cds.impl.PreparedCqnStmt Maven / Gradle / Ivy
/************************************************************************
* © 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
************************************************************************/
package com.sap.cds.impl;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableList;
import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;
import java.io.Reader;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
import com.sap.cds.CdsDataStoreException;
import com.sap.cds.CdsMissingValueException;
import com.sap.cds.impl.parser.token.Jsonizer;
import com.sap.cds.ql.CdsDataException;
import com.sap.cds.ql.cqn.CqnSelectListItem;
import com.sap.cds.ql.cqn.CqnStructuredTypeRef;
import com.sap.cds.ql.impl.ExpandProcessor;
import com.sap.cds.reflect.CdsBaseType;
import com.sap.cds.reflect.CdsEntity;
import com.sap.cds.reflect.CdsStructuredType;
import com.sap.cds.util.CdsTypeUtils;
public class PreparedCqnStmt implements PreparedCqnStatement {
private final CqnStructuredTypeRef ref;
private final CdsStructuredType targetType;
private final String nativeStatement;
private final List selectListItems;
private final List expands;
private final List excluding;
private final List params;
private PreparedCqnStmt(CqnStructuredTypeRef ref, CdsStructuredType targetType, String nativeStatement,
List selectListItems, List expands, List excluding, List parameters) {
this.ref = ref;
this.targetType = targetType;
this.nativeStatement = nativeStatement;
this.params = parameters;
this.selectListItems = selectListItems;
this.expands = expands;
this.excluding = excluding;
}
public static PreparedCqnStmt create(String nativeStatement, List selectListItems,
List expands, List excluding, List parameters, CqnStructuredTypeRef ref,
CdsStructuredType targetType) {
return new PreparedCqnStmt(ref, targetType, nativeStatement, selectListItems, expands, excluding, parameters);
}
public static PreparedCqnStmt createUpdate(String nativeStatement, List parameters,
CqnStructuredTypeRef ref, CdsEntity entity) {
return new PreparedCqnStmt(ref, entity, nativeStatement, emptyList(), emptyList(), emptyList(), parameters);
}
protected String toNative() {
return nativeStatement;
}
public List selectListItems() {
return unmodifiableList(selectListItems);
}
public List expands() {
return expands;
}
public List excluding() {
return unmodifiableList(excluding);
}
@SuppressWarnings("unchecked")
public T targetType() {
return (T) targetType;
}
public CqnStructuredTypeRef ref() {
return ref;
}
@Override
public String toString() {
return nativeStatement;
}
public abstract static class Parameter {
protected CdsBaseType type;
public abstract Object get(Map cqnParameters);
public abstract String name();
public Optional
© 2015 - 2024 Weber Informatics LLC | Privacy Policy