private boolean importReportLineSource() { // Primero, debemos actualizar el valor de las lineas de informe con el id del reportLine String sql = "update i_reportlineset set pa_reportline_id= ( select rl.pa_reportline_id from pa_reportline rl, pa_reportlineset rls where rl.pa_reportlineset_id=rls.pa_reportlineset_id and rl.name=trim(i_reportlineset.name) and rls.name=trim(i_reportlineset.rls_name) and rl.ad_client_id=i_reportlineset.ad_client_id and rl.ad_org_id=i_reportlineset.ad_org_id and rls.ad_client_id=i_reportlineset.ad_client_id and rls.ad_org_id=i_reportlineset.ad_org_id) where isReportSource='Y'"; // String sql = "update i_reportlineset ir set ir.pa_reportline_id= ( select rl.pa_reportline_id // from pa_reportline rl where rl.pa_reportlineset_id=ir.pa_reportlineset_id and // rl.name=trim(ir.name) and rl.ad_client_id=ir.ad_client_id and rl.ad_org_id=ir.ad_org_id) // where ir.isReportSource='Y'"; if (DB.executeUpdate(sql, trxName) == -1) { log.log(Level.SEVERE, "Error actualizado el pa_reportline_id de las fuentes"); return false; } // Establecemos la cuenta sql = "update i_reportlineset as ir set c_elementvalue_id= ( select ev.c_elementvalue_id from c_elementvalue ev where ev.issummary='Y' and ev.value=trim(ir.ev_value) and ev.ad_org_id=ir.ad_org_id) where ir.isReportSource='Y' and ir.ev_value is not null and ir.c_elementvalue_id is null and ir.rs_elementType='AC'"; if (DB.executeUpdate(sql, trxName) == -1) { log.log(Level.SEVERE, "Error actualizado el c_elementvalue_id de las fuentes"); return false; } sql = "update i_reportlineset as ir set i_isimported='E', i_errorMsg='fuente invalida' where ir.isReportSource='Y' and (ir.c_elementvalue_id is null or ir.c_elementvalue_id=0) and ir.rs_elementtype='AC' and (ir.pa_reportline_id is null or ir.pa_reportline_id=0)"; if (DB.executeUpdate(sql, trxName) == -1) { log.log(Level.SEVERE, "Error marcando fuentes erroneas."); return false; } sql = "select * from i_reportlineset as ir where ir.isReportSource='Y' and ir.I_isImported='N' and ir.rs_elementtype='AC'"; try { PreparedStatement pstmt = DB.prepareStatement(sql, trxName); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { X_PA_ReportSource r = new X_PA_ReportSource(getCtx(), 0, trxName); X_I_ReportLineSet ir = new X_I_ReportLineSet(getCtx(), rs, trxName); r.set_TrxName(trxName); r.setElementType(r.ELEMENTTYPE_Account); r.setC_ElementValue_ID(ir.getC_ElementValue_ID()); if (ir.getEv_Value().trim().equals("395")) { log.log(Level.SEVERE, "PA_ReportLine_ID: " + ir.getPA_ReportLine_ID()); } r.setPA_ReportLine_ID(ir.getPA_ReportLine_ID()); if (r.save(trxName) == false) { log.log( Level.SEVERE, "Error creando las fuentes del informe:" + ir.getEv_Value() + ": " + r.getPA_ReportLine_ID()); return false; } ir.setPA_ReportSource_ID(r.getPA_ReportSource_ID()); ir.setI_IsImported(true); if (ir.save(trxName) == false) { log.log( Level.SEVERE, "Error guardando el PA_ReportSource_ID en la tabla de importacion."); return false; } } } catch (SQLException e) { log.log(Level.SEVERE, "Error recorriendo las lineas de fuente."); return false; } return true; }