Project: contribution_eevolution_smart_browser
/**********************************************************************
 * This file is part of Adempiere ERP Bazaar                          *  
 * http://www.adempiere.org                                           *  
 *                                                                    *  
 * Copyright (C) Victor Perez                                       *  
 * Copyright (C) Contributors                                         *  
 *                                                                    *  
 * This program is free software; you can redistribute it and/or      *  
 * modify it under the terms of the GNU General Public License        *  
 * as published by the Free Software Foundation; either version 2     *  
 * of the License, or (at your option) any later version.             *  
 *                                                                    *  
 * This program is distributed in the hope that it will be useful,    *  
 * but WITHOUT ANY WARRANTY; without even the implied warranty of     *  
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the       *  
 * GNU General Public License for more details.                       *  
 *                                                                    *  
 * You should have received a copy of the GNU General Public License  *  
 * along with this program; if not, write to the Free Software        *  
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,         *  
 * MA 02110-1301, USA.                                                *  
 *                                                                    *  
 * Contributors:                                                      *  
 *  - Victor Perez ([email protected]  )                * 
 *                                                                    * 
 * Sponsors:                                                          * 
 *  - e-Evolution (http://www.e-evolution.com/)                       * 
 **********************************************************************/
 
package org.eevolution.process; 
 
import java.util.logging.Level; 
 
import org.adempiere.model.MBrowse; 
import org.adempiere.model.MBrowseField; 
import org.adempiere.model.MView; 
import org.adempiere.model.MViewColumn; 
import org.compiere.process.ProcessInfoParameter; 
import org.compiere.process.SvrProcess; 
 
/**
 * Create Browse Field 
 *  @author [email protected], www.e-evolution.com 
 *  @version $Id: $ 
 */
 
public class CreateBrowseField extends SvrProcess 
{  
 /** Record ID */ 
 protected int p_Record_ID = 0;  
 /**
  *  Get Parameters 
  */
 
 protected void prepare () 
 
   
   p_Record_ID = getRecord_ID(); 
  ProcessInfoParameter[] parameters = getParameter(); 
  for (ProcessInfoParameter para: parameters) 
  
   String name = para.getParameterName(); 
   if (para.getParameter() == null
    
   else 
    log.log(Level.SEVERE, "Unknown Parameter: " + name); 
  
 
 
 /**
  *  Process - Generate Export Format 
  * @return info 
  */
 
 @SuppressWarnings("unchecked"
 protected String doIt () throws Exception 
 {  
  MBrowse browse = new MBrowse(getCtx(), p_Record_ID, get_TrxName()); 
  MView view = browse.getAD_View(); 
  int seq = 10
  for(MViewColumn column:view.getViewColumn(view.getAD_View_ID())) 
  {  
   MBrowseField field = MBrowseField.get(browse, column); 
   if(field != null
    continue
    
   field = new MBrowseField(browse, column); 
   field.setAD_Browse_ID(browse.get_ID()); 
   field.setEntityType(browse.getEntityType()); 
   field.setSeqNo(seq); 
   field.saveEx(); 
   seq ++; 
   addLog(column.getColumnName()); 
  }   
  return "@[email protected]"
 
}