public static void migrateDownloads(Properties ctx){
  String sql="SELECT COUNT(*) FROM M_ProductDownload";
  int no=DB.getSQLValue(null,sql);
  if (no > 0)   return;
  int count=0;
  sql="SELECT AD_Client_ID, AD_Org_ID, M_Product_ID, Name, DownloadURL " + "FROM M_Product " + "WHERE DownloadURL IS NOT NULL";
  PreparedStatement pstmt=null;
  try {
    pstmt=DB.prepareStatement(sql,null);
    ResultSet rs=pstmt.executeQuery();
    while (rs.next()) {
      int AD_Client_ID=rs.getInt(1);
      int AD_Org_ID=rs.getInt(2);
      int M_Product_ID=rs.getInt(3);
      String Name=rs.getString(4);
      String DownloadURL=rs.getString(5);
      MProductDownload pdl=new MProductDownload(ctx,0,null);
      pdl.setClientOrg(AD_Client_ID,AD_Org_ID);
      pdl.setM_Product_ID(M_Product_ID);
      pdl.setName(Name);
      pdl.setDownloadURL(DownloadURL);
      if (pdl.save()) {
        count++;
        String sqlUpdate="UPDATE M_Product SET DownloadURL = NULL WHERE M_Product_ID=" + M_Product_ID;
        int updated=DB.executeUpdate(sqlUpdate,null);
        if (updated != 1)         s_log.warning("Product not updated");
      }
 else       s_log.warning("Product Download not created M_Product_ID=" + M_Product_ID);
    }
    rs.close();
    pstmt.close();
    pstmt=null;
  }
 catch (  Exception e) {
    s_log.log(Level.SEVERE,sql,e);
  }
  try {
    if (pstmt != null)     pstmt.close();
    pstmt=null;
  }
 catch (  Exception e) {
    pstmt=null;
  }
  s_log.info("#" + count);
}

public static void migrateDownloads ( Properties ctx ) { String sql = "SELECT COUNT(*) FROM M_ProductDownload" ; int no = DB . getSQLValue ( null , sql ) ; if ( no > 0 ) return ; int count = 0 ; sql = "SELECT AD_Client_ID, AD_Org_ID, M_Product_ID, Name, DownloadURL " + "FROM M_Product " + "WHERE DownloadURL IS NOT NULL" ; PreparedStatement pstmt = null ; try { pstmt = DB . prepareStatement ( sql , null ) ; ResultSet rs = pstmt . executeQuery ( ) ; while ( rs . next ( ) ) { int AD_Client_ID = rs . getInt ( 1 ) ; int AD_Org_ID = rs . getInt ( 2 ) ; int M_Product_ID = rs . getInt ( 3 ) ; String Name = rs . getString ( 4 ) ; String DownloadURL = rs . getString ( 5 ) ; MProductDownload pdl = new MProductDownload ( ctx , 0 , null ) ; pdl . setClientOrg ( AD_Client_ID , AD_Org_ID ) ; pdl . setM_Product_ID ( M_Product_ID ) ; pdl . setName ( Name ) ; pdl . setDownloadURL ( DownloadURL ) ; if ( pdl . save ( ) ) { count ++ ; String sqlUpdate = "UPDATE M_Product SET DownloadURL = NULL WHERE M_Product_ID=" + M_Product_ID ; int updated = DB . executeUpdate ( sqlUpdate , null ) ; if ( updated != 1 ) s_log . warning ( "Product not updated" ) ; } else s_log . warning ( "Product Download not created M_Product_ID=" + M_Product_ID ) ; } rs . close ( ) ; pstmt . close ( ) ; pstmt = null ; } catch ( Exception e ) { s_log . log ( Level . SEVERE , sql , e ) ; } try { if ( pstmt != null ) pstmt . close ( ) ; pstmt = null ; } catch ( Exception e ) { pstmt = null ; } s_log . info ( "#" + count ) ; }
migrate download urls ( 2 . 5 . 2c )
