Search in sources :

Example 21 with CSVReader

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

the class palorules method addRule.

/**
     * Adds a rule to the given cube
     * 
     * 
     * @param The rule definition
     * @param Identifier flag
     * @param An external Id
     * @param The comment for this rule
     * @param Acitvation flag
     * @return The added palorule
     */
public palorule addRule(String strRuleDefinition, boolean bUseIdentifier, String strExtern_Id, String strComment, boolean bActivate) throws paloexception {
    palorule plRule = null;
    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("cube", String.valueOf(this.iCubeId)));
    qparams.add(new BasicNameValuePair("definition", strRuleDefinition));
    qparams.add(new BasicNameValuePair("activate", palohelpers.BooleanToString(bActivate)));
    qparams.add(new BasicNameValuePair("external_identifier", strExtern_Id));
    qparams.add(new BasicNameValuePair("comment", strComment));
    qparams.add(new BasicNameValuePair("use_identifier", palohelpers.BooleanToString(bUseIdentifier)));
    try {
        HttpEntity entity = this.plConn.sendToServer(qparams, "/rule/create");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        while (csv.readNext()) {
            // System.out.println(csv.getRawRecord());
            plRule = new palorule(plConn, lDatabaseId, iCubeId, palohelpers.StringToInt(csv.get(0)), csv.get(1), csv.get(2), csv.get(3), palohelpers.StringToLong(csv.get(4)), palohelpers.StringToBoolean(csv.get(5)));
            paloRules.add(plRule);
        }
        csv.close();
        entity.consumeContent();
        return plRule;
    } 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 22 with CSVReader

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

the class palodimension method clear.

public void clear() throws paloexception {
    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)));
    try {
        HttpEntity entity = this.plConn.sendToServer(qparams, "/dimension/clear");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        csv.readNext();
        this.strDimensionName = csv.get(1);
        this.iDimensionId = Integer.valueOf(csv.get(0));
        this.iAssocDimension = palohelpers.StringToInt(csv.get(7));
        this.iAttributCube = palohelpers.StringToInt(csv.get(8));
        this.iRightsCube = palohelpers.StringToInt(csv.get(9));
        this.iNumberOfElements = palohelpers.StringToInt(csv.get(2));
        this.iMaximumLevel = palohelpers.StringToInt(csv.get(3));
        this.iMaximumIndent = palohelpers.StringToInt(csv.get(4));
        this.iMaximumDepth = palohelpers.StringToInt(csv.get(5));
        this.iDimensionToken = palohelpers.StringToInt(csv.get(10));
        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 23 with CSVReader

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

the class paloelement method refreshElementInfo.

public void refreshElementInfo() throws paloexception {
    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("element", String.valueOf(this.lElementIdentifier)));
    try {
        HttpEntity entity = this.plConn.sendToServer(qparams, "/element/info");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        while (csv.readNext()) {
            this.lElementIdentifier = palohelpers.StringToLong(csv.get(0));
            this.strElementName = csv.get(1);
            this.iElementPosition = palohelpers.StringToInt(csv.get(2));
            this.iElementLevel = palohelpers.StringToInt(csv.get(3));
            this.iElementIndent = palohelpers.StringToInt(csv.get(4));
            this.iElementDepth = palohelpers.StringToInt(csv.get(5));
            this.iElementType = palohelpers.StringToInt(csv.get(6));
            this.iElementNumOfParents = palohelpers.StringToInt(csv.get(7));
            this.iArrElementParents = palohelpers.StringToIntArray(csv.get(8), palohelpers.StringToInt(csv.get(7)));
            this.iElementNumOfChildren = palohelpers.StringToInt(csv.get(9));
            this.iArrElementChildren = palohelpers.StringToIntArray(csv.get(10), palohelpers.StringToInt(csv.get(9)));
            this.dArrElementChildrenWeights = palohelpers.StringToDoubleArray(csv.get(11), palohelpers.StringToInt(csv.get(9)));
        }
        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 24 with CSVReader

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

the class palodatamulti method setData.

public void setData(palocube plCube, int SPLASH_MODE, boolean bAddValue, boolean bUseEventProcessor) throws paloexception {
    StringBuilder sbCoordinates = new StringBuilder();
    StringBuilder sbValues = new StringBuilder();
    int iPos = 0;
    for (int i = 0; i < iCurrentPos; i++) {
        // for(palodatavalue plValue : this.lstPaloValues){
        palodatavalue plValue = getDataValue(i);
        if (iPos > 0) {
            sbCoordinates.append(":");
            sbValues.append(":");
        }
        sbCoordinates.append(plValue.getCoordinatesString());
        if (palodatavalue.PALO_NUMERIC == plValue.getType()) {
            sbValues.append(plValue.getDoubleValue());
        } else {
            sbValues.append(plValue.getStringValue());
        }
        iPos++;
    }
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("database", String.valueOf(this.lDatabaseId)));
    qparams.add(new BasicNameValuePair("cube", String.valueOf(plCube.getCubeId())));
    qparams.add(new BasicNameValuePair("paths", sbCoordinates.toString()));
    qparams.add(new BasicNameValuePair("values", sbValues.toString()));
    qparams.add(new BasicNameValuePair("add", palohelpers.BooleanToString(bAddValue)));
    qparams.add(new BasicNameValuePair("event_processor", palohelpers.BooleanToString(bUseEventProcessor)));
    qparams.add(new BasicNameValuePair("splash", String.valueOf(SPLASH_MODE)));
    try {
        HttpEntity entity = this.plConn.sendToServer(qparams, "/cell/replace_bulk");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        csv.readNext();
        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 25 with CSVReader

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

the class palodata method getValue.

public palodatavalue getValue(long[] lDimensionElementIdentifierArray) throws paloexception {
    List qparams = new ArrayList();
    qparams.add(new BasicNameValuePair("sid", plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("database", String.valueOf(lDatabaseId)));
    qparams.add(new BasicNameValuePair("cube", String.valueOf(plCube.getCubeId())));
    StringBuilder sbCoordinates = new StringBuilder();
    int iPos = 0;
    long[] al;
    int j = (al = lDimensionElementIdentifierArray).length;
    for (int i = 0; i < j; i++) {
        long lDimensionElementIdentifier = al[i];
        if (iPos > 0) {
            sbCoordinates.append(",");
        }
        sbCoordinates.append(lDimensionElementIdentifier);
        iPos++;
    }
    qparams.add(new BasicNameValuePair("path", sbCoordinates.toString()));
    palodatavalue rcDataValue = null;
    try {
        HttpEntity entity = plConn.sendToServer(qparams, "/cell/value");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        while (csv.readNext()) {
            if (palohelpers.StringToInt(csv.get(0)) == 1) {
                if (palohelpers.StringToInt(csv.get(1)) > 0) {
                    rcDataValue = new palodatavalue(palohelpers.StringToDouble(csv.get(2)));
                } else {
                    rcDataValue = new palodatavalue(0.0D);
                }
            } else if (palohelpers.StringToInt(csv.get(0)) == 0) {
                rcDataValue = new palodatavalue(csv.get(2));
            }
        }
        csv.close();
        entity.consumeContent();
        return rcDataValue;
    } catch (Exception e) {
        throw new paloexception(e.getMessage());
    }
}
Also used : HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) 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