use of org.apache.http.NameValuePair in project tdi-studio-se by Talend.
the class paloelement method getFatherPaloelement.
// get father paloelement
public paloelement getFatherPaloelement() throws paloexception {
long identifier = getElementParentIdentifier();
paloelement plElm = null;
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(identifier)));
try {
HttpEntity entity = this.plConn.sendToServer(qparams, "/element/info");
CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
csv.setQuoteChar('"');
while (csv.readNext()) {
if (palohelpers.StringToLong(csv.get(0)) == identifier) {
plElm = new paloelement(this.plConn, this.lDatabaseId, this.iDimensionId, paloElements, palohelpers.StringToLong(csv.get(0)), csv.get(1), palohelpers.StringToInt(csv.get(2)), palohelpers.StringToInt(csv.get(3)), palohelpers.StringToInt(csv.get(4)), palohelpers.StringToInt(csv.get(5)), palohelpers.StringToInt(csv.get(6)), palohelpers.StringToInt(csv.get(7)), palohelpers.StringToIntArray(csv.get(8), palohelpers.StringToInt(csv.get(7))), palohelpers.StringToInt(csv.get(9)), palohelpers.StringToIntArray(csv.get(10), palohelpers.StringToInt(csv.get(9))), palohelpers.StringToDoubleArray(csv.get(11), palohelpers.StringToInt(csv.get(9))));
}
}
csv.close();
entity.consumeContent();
} catch (Exception e) {
throw new paloexception(e.getMessage());
}
return plElm;
}
use of org.apache.http.NameValuePair in project tdi-studio-se by Talend.
the class paloelement method updateElement.
public void updateElement(paloconsolidations plCons, boolean bAddToConsolidation) 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(iDimensionId)));
qparams.add(new BasicNameValuePair("element", String.valueOf(lElementIdentifier)));
String strURLApiCall = "/element/append";
if (!bAddToConsolidation) {
if (plCons != null) {
iElementType = paloelements.ELEMENT_CONSOLIDATION;
}
qparams.add(new BasicNameValuePair("name_element", strElementName));
qparams.add(new BasicNameValuePair("type", String.valueOf(iElementType)));
strURLApiCall = "/element/replace";
}
if (plCons != null) {
qparams.add(new BasicNameValuePair("children", plCons.getConsolidationStringElementIdentifiers()));
qparams.add(new BasicNameValuePair("weights", plCons.getConsolidationStringElementWeights()));
}
try {
HttpEntity entity = this.plConn.sendToServer(qparams, strURLApiCall);
CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
csv.setQuoteChar('"');
csv.readNext();
// System.out.println(csv.getRawRecord());
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());
}
}
use of org.apache.http.NameValuePair in project tdi-studio-se by Talend.
the class paloelement method updateElementConsolidation.
public void updateElementConsolidation(String strElementChildrensId, String strElementChildrenWeights, boolean bReplace) 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(iDimensionId)));
qparams.add(new BasicNameValuePair("element", String.valueOf(lElementIdentifier)));
String strURLApiCall = "/element/append";
if (bReplace) {
strURLApiCall = "/element/replace";
}
iElementType = paloelements.ELEMENT_CONSOLIDATION;
qparams.add(new BasicNameValuePair("type", String.valueOf(iElementType)));
qparams.add(new BasicNameValuePair("children", strElementChildrensId));
qparams.add(new BasicNameValuePair("weights", strElementChildrenWeights));
try {
this.plConn.sendToServerSingleRC(qparams, strURLApiCall);
} catch (Exception e) {
throw new paloexception(e.getMessage());
}
}
use of org.apache.http.NameValuePair in project tdi-studio-se by Talend.
the class paloelements method deleteElement.
public void deleteElement(paloelement paloElemToRemove) throws paloexception {
if (null != paloElemToRemove) {
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("dimension", String.valueOf(this.iDimensionId)));
qparams.add(new BasicNameValuePair("element", String.valueOf(paloElemToRemove.getElementIdentifier())));
plConn.sendToServerSingleRC(qparams, "/element/destroy");
paloElementsIdentifier.remove(paloElemToRemove.getElementIdentifier());
paloElementsList.remove(paloElemToRemove.getName());
}
}
use of org.apache.http.NameValuePair in project tdi-studio-se by Talend.
the class palorule method refreshRuleInfo.
public void refreshRuleInfo() 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("cube", String.valueOf(this.iCubeId)));
qparams.add(new BasicNameValuePair("rule", String.valueOf(this.lIdentifier)));
qparams.add(new BasicNameValuePair("use_identifier", palohelpers.BooleanToString(false)));
try {
HttpEntity entity = this.plConn.sendToServer(qparams, "/rule/info");
CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
csv.setQuoteChar('"');
while (csv.readNext()) {
lIdentifier = palohelpers.StringToInt(csv.get(0));
strDefinition = csv.get(1);
strExtern_Id = csv.get(2);
strComment = csv.get(3);
lTimeStamp = palohelpers.StringToLong(csv.get(4));
bActivated = palohelpers.StringToBoolean(csv.get(5));
}
csv.close();
entity.consumeContent();
} catch (Exception e) {
throw new paloexception(e.getMessage());
}
}
Aggregations