Hi i need to put data from JSON object(take from a http request) to table of database and in a list...how can i do that??
$scope.chiamataUno = function() {
var authdata = Base64.encode("xxx" + ":" + "xxx");
$http.defaults.headers.common["Authorization"] = "Basic " + authdata;
$http.get('http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1').success(function(response) {
console.log(response);
$rootScope.risposta = response;
$rootScope.responseJSON = JSON.stringify($scope.risposta);
var newArray = [];
for(var i=0;i<response.queueElements.length;i++){
newObject = {
caseFolderId:response.queueElements[i].caseFolderId,
caseTaskId:response.queueElements[i].caseTaskId,
stepName:response.queueElements[i].stepName,
columns:response.queueElements[i].columns,
DV_Caseidentifier_for_eni_OdA: response.queueElements[i].columns.DV_Caseidentifier_for_eni_OdA,
DV_EBELP_ODA: response.queueElements[i].columns.DV_EBELP_ODA,
DV_EINDT_ODA: response.queueElements[i].columns.DV_EINDT_ODA,
DV_MATNR_TXZ01_POS_ODA: response.queueElements[i].columns.DV_MATNR_TXZ01_POS_ODA,
DV_NAMECL_POS_ODA: response.queueElements[i].columns.DV_NAMECL_POS_ODA,
DV_NETPR_WAERS_POS_ODA: response.queueElements[i].columns.DV_NETPR_WAERS_POS_ODA,
DV_PEINH_POS: response.queueElements[i].columns.DV_PEINH_POS,
DV_MENGE_MEINS_POS_ODA: response.queueElements[i].columns.DV_MENGE_MEINS_POS_ODA
};
newArray.push(newObject);
console.log("dettaglio " + newObject.DV_MENGE_MEINS_POS_ODA + " " + newObject.stepName + " " + newObject.DV_EINDT_ODA);
$rootScope.newObjectJSON = JSON.stringify(newObject);
if(newObject.length > 0) {
for(var i = 0; i < newObject.length; i++) {
var queryOdl = "INSERT INTO Tabella_OdL (caseTaskId, caseFolderId, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA) VALUES (?,?,?,?,?,?,?,?,?,?) WHERE stepName = 'Item details'";
$cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId, newObject.caseTaskId,newObject.stepName,newObject.DV_Caseidentifier_for_eni_OdA,newObject.DV_EBELP_ODA,newObject.DV_EINDT_ODA,newObject.DV_MATNR_TXZ01_POS_ODA,newObject.DV_NAMECL_POS_ODA,newObject.DV_NETPR_WAERS_POS_ODA,newObject.DV_PEINH_POS,newObject.DV_MENGE_MEINS_POS_ODA]);
console.log("insert ODL");
}
}else{
console.log("nessun oggetto");
}
$scope.newObject = newObject;
$rootScope.allODLJSON = JSON.stringify($scope.newObject);
var allODLJSON = $rootScope.allODLJSON;
console.log("json newObject" + allODLJSON);
}
})
.error(function(response) {
alert("ERROR");
});
}