public ArrayList<Document> addDocumentsToInvoices(AtrilSession oSes)
throws DmsException {
Log.out.debug("Begin DepositToZespedBridge.addSidesToInvoices("+String.valueOf(lDepositId)+")");
ArrayList<Document> aSides = new ArrayList<Document>();
JDCConnection oCon = null;
PreparedStatement oStm = null;
try {
oCon = DAO.getConnection("DepositToZespedBridge");
oCon.setAutoCommit(false);
oStm = oCon.prepareStatement("UPDATE Documento SET fkIdDocPadre=? WHERE IdDoc=?");
Dms oDms = oSes.getDms();
TaxPayer txpy = new TaxPayer(oDms, sTaxPayerId);
Invoices invs = txpy.invoices(oSes);
Document oDepo = oDms.getDocument(String.valueOf(lDepositId));
for (Document oDdoc : oDepo.children()) {
Log.out.debug("getting sides for document "+oDdoc.id());
NodeList<Document> oChlds = oDdoc.children();
Invoice[] aInvs = invs.create(oSes, sUid, sFlavor, sTaxPayerId, sBiller, sRecipient, oChlds.size());
int i = 0;
for (Document oSide : oChlds) {
Invoice oInvc = aInvs[i++];
oStm.setLong(1, Long.parseLong(oInvc.id()));
oStm.setLong(2, Long.parseLong(oSide.id()));
Log.out.debug("UPDATE documento SET fkIdDocPadre="+oInvc.id()+" WHERE IdDoc="+oSide.id());
oStm.executeUpdate();
aSides.add(oSide);
ThumbnailCreator.createThumbnailFor(oInvc.id(), oSide.id());
}
oCon.commit();
}
oStm.close();
oStm=null;
oCon.close();
oCon=null;
} catch (SQLException sqle) {
Log.out.debug("SQLException "+sqle.getMessage());
throw new DmsException(sqle.getMessage(), sqle);
} finally {
try {
if (oCon!=null) {
if (!oCon.isClosed()) {
if (oStm!=null) oStm.close();
oCon.rollback();
oCon.close("DepositToZespedBridge");
}
}
} catch (SQLException ignore) { Log.out.debug("SQLException "+ignore.getMessage()); }
}