Search in sources :

Example 1 with CSVReader

use of com.talend.csv.CSVReader in project tdi-studio-se by Talend.

the class palocubes method createCube.

public palocube createCube(String strCubeName, String[] strArrDimensions, int iType) throws paloexception {
    palodimensions plDIMs = plDB.getDimensions(iType);
    StringBuilder sbDimensionsToCreate = new StringBuilder();
    int iPos = 0;
    for (String strDimensionName : strArrDimensions) {
        if (iPos > 0) {
            sbDimensionsToCreate.append(",");
        }
        palodimension plDIM = plDIMs.getDimension(strDimensionName);
        if (null == plDIM) {
            sbDimensionsToCreate.append("-1");
        } else {
            sbDimensionsToCreate.append(plDIMs.getDimension(strDimensionName).getDimensionId());
        }
        iPos++;
    }
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", this.plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("database", String.valueOf(this.plDB.getDatabaseId())));
    qparams.add(new BasicNameValuePair("new_name", strCubeName));
    qparams.add(new BasicNameValuePair("type", String.valueOf(iType)));
    qparams.add(new BasicNameValuePair("dimensions", sbDimensionsToCreate.toString()));
    try {
        palocube plCube = null;
        HttpEntity entity = this.plConn.sendToServer(qparams, "/cube/create");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        while (csv.readNext()) {
            // System.out.println(csv.getRawRecord());
            plCube = new palocube(plConn, plDB.getDatabaseId(), palohelpers.StringToInt(csv.get(0)), csv.get(1), palohelpers.StringToInt(csv.get(2)), palohelpers.StringToIntArray(csv.get(3), palohelpers.StringToInt(csv.get(2))), palohelpers.StringToLong(csv.get(4)), palohelpers.StringToLong(csv.get(5)), palohelpers.StringToInt(csv.get(6)), palohelpers.StringToInt(csv.get(7)), palohelpers.StringToInt(csv.get(8)));
            paloCubes.add(plCube);
        }
        csv.close();
        entity.consumeContent();
        return plCube;
    } catch (Exception e) {
        throw new paloexception(e.getMessage());
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) ArrayList(java.util.ArrayList) BasicNameValuePair(org.apache.http.message.BasicNameValuePair)

Example 2 with CSVReader

use of com.talend.csv.CSVReader in project tdi-studio-se by Talend.

the class palodatabase method rename.

public void rename(String strNewName) throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", this.plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("database", String.valueOf(this.lDatabaseId)));
    qparams.add(new BasicNameValuePair("new_name", strNewName));
    try {
        HttpEntity entity = this.plConn.sendToServer(qparams, "/database/rename");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        csv.readNext();
        this.strDatabaseName = csv.get(1);
        this.iNumberOfDimensions = Integer.valueOf(csv.get(2));
        this.iNumberOfCubes = Integer.valueOf(csv.get(3));
        this.iStatus = Integer.valueOf(csv.get(4));
        this.iType = Integer.valueOf(csv.get(5));
        csv.close();
        entity.consumeContent();
    } catch (Exception e) {
        throw new paloexception(e.getMessage());
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 3 with CSVReader

use of com.talend.csv.CSVReader in project tdi-studio-se by Talend.

the class palodatabases method createDatabase.

public palodatabase createDatabase(String strDatabaseName) throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", this.plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("new_name", strDatabaseName));
    try {
        HttpEntity entity = this.plConn.sendToServer(qparams, "/database/create");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        csv.readNext();
        palodatabase plDB = new palodatabase(this.plConn, csv.get(1), Long.parseLong(csv.get(0)), Integer.valueOf(csv.get(2)), Integer.valueOf(csv.get(3)), Integer.valueOf(csv.get(4)), Integer.valueOf(csv.get(5)), "");
        csv.close();
        entity.consumeContent();
        plDB.refreshDatabaseInfo();
        paloDatabases.add(plDB);
        return plDB;
    } catch (Exception e) {
        throw new paloexception(e.getMessage());
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 4 with CSVReader

use of com.talend.csv.CSVReader in project tdi-studio-se by Talend.

the class palodimension method rename.

public void rename(String strDimensionNewName) throws paloexception {
    if (null != strDimensionNewName && strDimensionNewName.length() > 0 && !strDimensionName.equals(strDimensionNewName)) {
        List<NameValuePair> qparams = new ArrayList<NameValuePair>();
        qparams.add(new BasicNameValuePair("sid", this.plConn.getPaloToken()));
        qparams.add(new BasicNameValuePair("database", String.valueOf(lDatabaseId)));
        qparams.add(new BasicNameValuePair("dimension", String.valueOf(this.iDimensionId)));
        qparams.add(new BasicNameValuePair("new_name", strDimensionNewName));
        try {
            HttpEntity entity = this.plConn.sendToServer(qparams, "/dimension/rename");
            CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
            csv.setQuoteChar('"');
            csv.readNext();
            this.strDimensionName = csv.get(1);
            csv.close();
            entity.consumeContent();
        } catch (Exception e) {
            throw new paloexception(e.getMessage());
        }
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 5 with CSVReader

use of com.talend.csv.CSVReader in project tdi-studio-se by Talend.

the class paloconnection method logout.

// Logouts the current palo User
public void logout() throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", this.strToken));
    try {
        HttpEntity entity = sendToServer(qparams, "/server/logout");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        // CsvReader csv = new CsvReader(sendToServer(qparams, "/server/logout").getContent(),
        // Charset.defaultCharset());
        csv.setQuoteChar('"');
        csv.readNext();
        csv.close();
        entity.consumeContent();
    // paloHttpClient.getConnectionManager().shutdown();
    } catch (Exception e) {
        throw new paloexception(e.getMessage());
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Aggregations

CSVReader (com.talend.csv.CSVReader)29 HttpEntity (org.apache.http.HttpEntity)29 ArrayList (java.util.ArrayList)27 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)27 NameValuePair (org.apache.http.NameValuePair)25 LinkedList (java.util.LinkedList)2 List (java.util.List)2 URI (java.net.URI)1 Hashtable (java.util.Hashtable)1 Iterator (java.util.Iterator)1 HttpResponse (org.apache.http.HttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1