Search in sources :

Example 11 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class ExpNodePredicate method bind.

@Override
public void bind(JaqyResultSet rs, JaqyInterpreter interpreter) throws Exception {
    m_vm = new VariableManager(interpreter.getVariableManager());
    m_vm.setVariable(RS_VAR, rs);
    m_exp.bind(rs, m_vm, interpreter);
}
Also used : VariableManager(com.teradata.jaqy.VariableManager)

Example 12 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class ExpNodeProject method bind.

@Override
public void bind(JaqyResultSet rs, JaqyInterpreter interpreter) throws Exception {
    m_vm = new VariableManager(interpreter.getVariableManager());
    m_vm.setVariable(ExpNodePredicate.RS_VAR, rs);
    for (ExpNode exp : m_expList) exp.bind(rs, m_vm, interpreter);
}
Also used : VariableManager(com.teradata.jaqy.VariableManager) ExpNode(com.teradata.jaqy.utils.exp.ExpNode)

Example 13 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class ClientRSUtils method setSortNull.

public static void setSortNull(JaqyInterpreter interpreter, boolean nullSort) {
    VariableManager vm = interpreter.getVariableManager();
    vm.setVariable(NULLSORT_VAR, Boolean.valueOf(nullSort));
}
Also used : VariableManager(com.teradata.jaqy.VariableManager)

Example 14 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class S3Utils method getS3Client.

public static AmazonS3 getS3Client(JaqyInterpreter interpreter) {
    VariableManager vm = interpreter.getVariableManager();
    Variable clientVar = vm.getVariable(S3CLIENT_VAR);
    if (clientVar != null) {
        Object o = clientVar.get();
        if (o instanceof AmazonS3)
            return (AmazonS3) o;
    }
    // now we need to setup a new client.
    AmazonS3ClientBuilder builder = getS3Builder(interpreter);
    // check if we need to set up the access / secret key
    String access = null;
    String secret = null;
    {
        Variable var = vm.getVariable(S3ACCESS_VAR);
        if (var != null) {
            Object o = var.get();
            if (o != null)
                access = o.toString();
        }
    }
    {
        Variable var = vm.getVariable(S3SECRET_VAR);
        if (var != null) {
            Object o = var.get();
            if (o != null)
                secret = o.toString();
        }
    }
    if (access != null && secret != null) {
        /*
			 * When both access and secret are null, we are using the default
			 * values (i.e. from credential file or env variables etc).
			 * 
			 * When both are set, then we override the default settings (and
			 * subsequent uses).
			 */
        if (access.length() == 0 && secret.length() == 0) {
            /*
				 * This is for accessing publicly accessible buckets.
				 */
            builder.withCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()));
        } else {
            builder.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(access, secret)));
        }
    }
    AmazonS3 client = builder.build();
    // now save the client to s3client variable
    if (clientVar == null) {
        clientVar = new Variable() {

            private AmazonS3 m_client;

            @Override
            public Object get() {
                return m_client;
            }

            @Override
            public boolean set(Object value) {
                if (value != null && !(value instanceof AmazonS3))
                    return false;
                m_client = (AmazonS3) value;
                return true;
            }

            @Override
            public String getName() {
                return S3CLIENT_VAR;
            }
        };
    }
    clientVar.set(client);
    vm.setVariable(clientVar);
    return client;
}
Also used : VariableManager(com.teradata.jaqy.VariableManager) AmazonS3(com.amazonaws.services.s3.AmazonS3) AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) Variable(com.teradata.jaqy.interfaces.Variable) AmazonS3ClientBuilder(com.amazonaws.services.s3.AmazonS3ClientBuilder) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Aggregations

VariableManager (com.teradata.jaqy.VariableManager)14 ExpNode (com.teradata.jaqy.utils.exp.ExpNode)5 Globals (com.teradata.jaqy.Globals)4 JaqyInterpreter (com.teradata.jaqy.JaqyInterpreter)4 Variable (com.teradata.jaqy.interfaces.Variable)4 Test (org.junit.Test)4 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)2 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1