log.debug("ID="+groupVO.getId()+" || "+groupVO.getGroupName());
ResultSet rset = null;
rset = pStmt.executeQuery();
if( rset.next() ){
if(rset.getInt(1)>0){
DAOException daox = new DAOException ("Database Error");
daox.setMessageKey(IErrorMessageKeys.KEY_ERROR_DUPLICATE_GROUP);
throw daox;
}
}
sql = qManager.getUpdateGroupQuery(dbType);
log.debug(sql);
pStmt = con.prepareStatement( sql );
pStmt.setString( 1, groupVO.getGroupName() );
pStmt.setString( 2, groupVO.getGroupDesc() );
pStmt.setString( 3, groupVO.getId());
pStmt.executeUpdate();
//first delete old users
sql = qManager.getDeleteGroupUserQuery(dbType);
pStmt = con.prepareStatement( sql );
pStmt.setString( 1, groupVO.getId());
pStmt.executeUpdate();
this.createSearchContent(con,dbType, groupVO, "TBL_GROUP", "GROUP_ID");
String[] userIds = EEMSUtil.convertToArray(groupVO.getUserNames(),IConstants.EEMS_DELIMITER);
if(userIds!=null)
{
sql = qManager.getFindCreateUserGroupQuery(dbType);
pStmt = con.prepareStatement( sql );
log.debug(sql);
for (int i=0; i<userIds.length;i++)
{
if(userIds[i]!= null)
{
log.debug("userID " + userIds[i]);
log.debug("groupid "+groupVO.getId());
pStmt.setString( 1, userIds[i].trim() );
pStmt.setString( 2, groupVO.getId() );
pStmt.executeUpdate();
log.debug("user-group added" + i);
}
}
}
log.debug("inserted...and updated");
con.commit();
}
catch(SQLException ex)
{
try
{
con.rollback();
}
catch (SQLException e)
{
// TODO Auto-generated catch block
log.error("Error GroupDAO SQLException:" + e);
}
DAOException daox = new DAOException ("Database Error");
daox.setMessageKey(IErrorMessageKeys.KEY_DATABASE_ERROR);
throw daox;
}
finally
{
try
{
if(pStmt != null) pStmt.close();
this.releaseConnection(con);
}
catch (SQLException e)
{
// TODO Auto-generated catch block
log.error("Error GroupDAO SQLException:" + e);
DAOException daox = new DAOException ("FATAL Error");
daox.setMessageKey(IErrorMessageKeys.KEY_FATAL_ERROR);
throw daox;
}
}