1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| public int validerPrestations(int in_codePrestataire, Vector in_prestations) throws FonctionnelEntrepriseException, SystemEntrepriseException {
OracleCallableStatement cstmt = null;
// OracleConnectionProxy connProxy = null;
OracleConnection oconn = null;
//DataSource objDS = null;
//Connection conn = null;
int l_nbLignRet = 0;
try {
// Recuperation de la connexion
// On recupere une PhysicalConnection sur la Connection, sinon on obtient
// un ClassCastException dans le code du driver Oracle, a la creation
// du StructDescriptor.
/* OC
connProxy = (OracleConnectionProxy) getConnection(ORACLE_FIDELIA_JDBC);
conn = connProxy.getPhysicalConnection();
*/
/* J3A
conn = getConnection(ORACLE_FIDELIA_JDBC);*/
InitialContext objInitialContext = new InitialContext();
Object connection = null;
DataSource objDS = (DataSource) objInitialContext.lookup("jdbc/FIDELIAEXTRANET");
Connection objCon = objDS.getConnection();
oconn = (OracleConnection)WSJdbcUtil.getNativeConnection(( WSJdbcConnection)connection);
/*ArrayDescriptor alVarrayChar = ArrayDescriptor.createDescriptor("type_array", oconn );
ARRAY queryCondition = new ARRAY(alVarrayChar, oc, conditionArray);*/
// *** Creation du tableau de prestations a valider ***
Struct[] prestations = new Struct[in_prestations.size()];
// Descripteur de la structure Prestation
StructDescriptor prestationDesc = StructDescriptor.createDescriptor("REC_VAL", oconn);
// Parcours de la collection de prestations a valider
Enumeration enum = in_prestations.elements();
int i = 0;
while (enum.hasMoreElements()) {
// Creation d'une structure Prestation
PrestationAValider l_prestation = (PrestationAValider) enum.nextElement();
Object[] prestation_attributes = new Object[7];
prestation_attributes[0] = new CHAR(l_prestation.getReferencePrestation(), CHARACTER_SET);
prestation_attributes[1] = new NUMBER(l_prestation.getCoutReel());
prestation_attributes[2] = new CHAR(l_prestation.getNumeroFacture(), CHARACTER_SET);// NO_FACT = numero facture
prestation_attributes[3] = new CHAR(l_prestation.getMotif(), CHARACTER_SET);// CHOIX = motif
prestation_attributes[4] = new CHAR(l_prestation.getCommentaire(), CHARACTER_SET);
prestation_attributes[5] = new NUMBER(l_prestation.getComplementMotif());// NUM8 = complementMotif
prestation_attributes[6] = new CHAR(l_prestation.getCodeValidation(), CHARACTER_SET);// ETAT = codeValidation
Struct prestation = new STRUCT(prestationDesc, objCon, prestation_attributes);
// Ajout de la structure au tableau des prestations a valider
prestations[i] = prestation;
i++;
}
// Description du tableau des prestations a valider
ArrayDescriptor array_desc = ArrayDescriptor.createDescriptor("LISTE_VAL",objCon);
Array array = new ARRAY(array_desc, objCon, prestations);
// *** Construction de la query ***
cstmt = (OracleCallableStatement) objCon.prepareCall(APPEL_TRAITELISTEVAL);
cstmt.setInt(1, in_codePrestataire);
cstmt.setInt(2, in_prestations.size());
cstmt.setArray(3, array);
cstmt.registerOutParameter(4, Types.CHAR);
cstmt.registerOutParameter(5, Types.CHAR);
cstmt.registerOutParameter(6, Types.INTEGER);
// *** Execution de la procedure ***
cstmt.execute();
// *** Gestion des erreurs ***
checkRetour("JDBCDossierServiceImpl.validerPrestations(" + in_codePrestataire + ")", cstmt.getString(4), cstmt.getString(5));
// *** Lecture du resultat ***
l_nbLignRet = cstmt.getInt(6);
} catch (FonctionnelEntrepriseException e) {
throw e;
} catch (Exception e) {
throw new SystemEntrepriseException("JDBCDossierServiceImpl.validerPrestations(" + in_codePrestataire + ") : [" + e.getMessage() + "]", e);
} finally {
// C'est le connProxy que l'on ferme, surtout pas la connexion physique !
finalizeJDBC(cstmt, /*OC connProxy*/oconn);
}
return l_nbLignRet;
}
} |
Partager