Category oCat = new Category(sCategoryGUID);
// Delete any child category first
// New for v2.1
DBSubset oChlds = oCat.getChilds(oConn);
int iChilds = oChlds.getRowCount();
for (int c=0; c<iChilds; c++)
Category.delete(oConn, oChlds.getString(0,c));
Statement oStmt;
Product oProd;
DBSubset oObjs = oCat.getObjects(oConn);
int iObjs = oObjs.getRowCount();
boolean bRetVal;
// recorre los objetos de esta categoría y los borra
for (int o=0; o<iObjs; o++) {
switch (oObjs.getInt(1, o)) {
case com.knowgate.training.AcademicCourse.ClassId:
// los cursos academicos no se borran cuando se borra la categoria
// pero si se borran sus productos asociados en la tienda
case com.knowgate.hipergate.Product.ClassId:
oProd = new Product(oObjs.getString(0, o));
if (oProd.exists(oConn)) {
oProd.delete(oConn);
}
break;
case com.knowgate.crm.DistributionList.ClassId:
com.knowgate.crm.DistributionList.delete(oConn, oObjs.getString(0, o));
break;
case com.knowgate.crm.Company.ClassId:
com.knowgate.crm.Company.delete(oConn, oObjs.getString(0, o));
break;
case com.knowgate.forums.NewsGroup.ClassId:
com.knowgate.forums.NewsGroup.delete(oConn, oObjs.getString(0, o));
break;
case com.knowgate.hipergate.Image.ClassId:
Image oImg = new com.knowgate.hipergate.Image(oConn, oObjs.getString(0, o));
oImg.delete(oConn);
break;
case com.knowgate.hipermail.DBMimeMessage.ClassId:
com.knowgate.hipermail.DBMimeMessage.delete(oConn, sCategoryGUID, oObjs.getString(0, o));
break;
case com.knowgate.acl.PasswordRecord.ClassId:
com.knowgate.acl.PasswordRecord.delete(oConn, oObjs.getString(0, o));
break;
}
} // next (o)
oObjs = null;
if (DBBind.exists(oConn, DB.k_mime_msgs, "U")) {
oObjs = new DBSubset(DB.k_mime_msgs, DB.gu_mimemsg, DB.gu_category + "='" + sCategoryGUID + "'", 1000);
iObjs = oObjs.load(oConn);
if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
PreparedStatement oDlte = oConn.prepareStatement("SELECT k_sp_del_mime_msg(?)");
ResultSet oRSet;
for (int m=0; m<iObjs; m++) {
oDlte.setString(1, oObjs.getString(0,m));
oRSet = oDlte.executeQuery();
oRSet.close();
}
oDlte.close();
}
else {
CallableStatement oCall = oConn.prepareCall("{ call k_sp_del_mime_msg(?) }");
for (int m=0; m<iObjs; m++) {
oCall.setString(1, oObjs.getString(0,m));
oCall.execute();
}
oCall.close();
}
} // fi (exists(k_mime_msgs))