IDEMPIERE-1603 Copy Info Window Columns from other Info Window's / thanks to Hagiwara Hideaki
This commit is contained in:
parent
4626279112
commit
498a858f3a
|
@ -0,0 +1,19 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- Dec 17, 2013 11:04:16 AM COT
|
||||
-- IDEMPIERE-1603 Copy Info Window Columns from other Info Window's
|
||||
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,Name,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Classname,Value,AD_Client_ID) VALUES ('N',200067,'N','N','32fe7794-53ce-442d-bb40-a132ebcdff7e','4','N','N',0,0,'Y','D','Copy Info Window Columns',0,TO_DATE('2013-12-17 11:04:16','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-12-17 11:04:16','YYYY-MM-DD HH24:MI:SS'),'Y',100,'org.compiere.process.CopyInfoWindowColumns','CopyInfoWindowColumns',0)
|
||||
;
|
||||
|
||||
-- Dec 17, 2013 11:05:01 AM COT
|
||||
INSERT INTO AD_Process_Para (IsRange,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,IsMandatory,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID,AD_Element_ID) VALUES ('N',200073,'989f60c7-012b-4f13-9a15-6118d75a4854','The Info window is used to search and select records as well as display information relevant to the selection.',200067,19,'Y','D','Info Window','AD_InfoWindow_ID','Info and search/select Window',10,'Y',10,'Y',100,TO_DATE('2013-12-17 11:05:01','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-12-17 11:05:01','YYYY-MM-DD HH24:MI:SS'),0,'N',0,3068)
|
||||
;
|
||||
|
||||
-- Dec 17, 2013 11:06:48 AM COT
|
||||
INSERT INTO AD_ToolBarButton (Action,AD_Tab_ID,AD_Process_ID,SeqNo,Name,ComponentName,IsCustomization,AD_Org_ID,Created,CreatedBy,AD_ToolBarButton_ID,Updated,UpdatedBy,IsActive,AD_Client_ID,AD_ToolBarButton_UU) VALUES ('W',842,200067,10,'Copy Info Window Columns','CopyInfoWindowColumns','N',0,TO_DATE('2013-12-17 11:06:48','YYYY-MM-DD HH24:MI:SS'),100,200079,TO_DATE('2013-12-17 11:06:48','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,'c4845d6f-abf8-4419-b7e6-adaec70cebe2')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201312171107_IDEMPIERE-1603.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
-- Dec 17, 2013 11:04:16 AM COT
|
||||
-- IDEMPIERE-1603 Copy Info Window Columns from other Info Window's
|
||||
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,Name,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Classname,Value,AD_Client_ID) VALUES ('N',200067,'N','N','32fe7794-53ce-442d-bb40-a132ebcdff7e','4','N','N',0,0,'Y','D','Copy Info Window Columns',0,TO_TIMESTAMP('2013-12-17 11:04:16','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-12-17 11:04:16','YYYY-MM-DD HH24:MI:SS'),'Y',100,'org.compiere.process.CopyInfoWindowColumns','CopyInfoWindowColumns',0)
|
||||
;
|
||||
|
||||
-- Dec 17, 2013 11:05:01 AM COT
|
||||
INSERT INTO AD_Process_Para (IsRange,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,IsMandatory,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID,AD_Element_ID) VALUES ('N',200073,'989f60c7-012b-4f13-9a15-6118d75a4854','The Info window is used to search and select records as well as display information relevant to the selection.',200067,19,'Y','D','Info Window','AD_InfoWindow_ID','Info and search/select Window',10,'Y',10,'Y',100,TO_TIMESTAMP('2013-12-17 11:05:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-12-17 11:05:01','YYYY-MM-DD HH24:MI:SS'),0,'N',0,3068)
|
||||
;
|
||||
|
||||
-- Dec 17, 2013 11:06:48 AM COT
|
||||
INSERT INTO AD_ToolBarButton ("action",AD_Tab_ID,AD_Process_ID,SeqNo,Name,ComponentName,IsCustomization,AD_Org_ID,Created,CreatedBy,AD_ToolBarButton_ID,Updated,UpdatedBy,IsActive,AD_Client_ID,AD_ToolBarButton_UU) VALUES ('W',842,200067,10,'Copy Info Window Columns','CopyInfoWindowColumns','N',0,TO_TIMESTAMP('2013-12-17 11:06:48','YYYY-MM-DD HH24:MI:SS'),100,200079,TO_TIMESTAMP('2013-12-17 11:06:48','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,'c4845d6f-abf8-4419-b7e6-adaec70cebe2')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201312171107_IDEMPIERE-1603.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/**********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* 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: *
|
||||
* - Hideaki Hagiwara *
|
||||
**********************************************************************/
|
||||
|
||||
package org.compiere.process;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MInfoColumn;
|
||||
import org.compiere.model.MInfoWindow;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.AdempiereSystemError;
|
||||
|
||||
/**
|
||||
* Copy Info Window Columns from other Info Window
|
||||
*
|
||||
* @author Hideaki Hagiwara
|
||||
* @version $Id: CopyInfoWindowColumns v 1.0 2013/12/4
|
||||
*/
|
||||
public class CopyInfoWindowColumns extends SvrProcess
|
||||
{
|
||||
/** Target Info Window */
|
||||
private int p_target_AD_InfoWindow_ID = 0;
|
||||
/** Source Info Window */
|
||||
private int p_source_AD_InfoWindow_ID= 0;
|
||||
|
||||
/** Column Count */
|
||||
private int m_count = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Prepare - e.g., get Parameters.
|
||||
*/
|
||||
protected void prepare ()
|
||||
{
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
if (para[i].getParameter() == null)
|
||||
;
|
||||
else if (name.equals("AD_InfoWindow_ID"))
|
||||
p_source_AD_InfoWindow_ID = para[i].getParameterAsInt();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
p_target_AD_InfoWindow_ID = getRecord_ID();
|
||||
} // prepare
|
||||
|
||||
/**
|
||||
* Process
|
||||
* @return info
|
||||
* @throws Exception
|
||||
*/
|
||||
protected String doIt () throws Exception
|
||||
{
|
||||
if (p_target_AD_InfoWindow_ID == 0)
|
||||
throw new AdempiereSystemError("@NotFound@ @AD_InfoWindow_ID@ " + p_target_AD_InfoWindow_ID);
|
||||
if (p_source_AD_InfoWindow_ID == 0)
|
||||
throw new AdempiereSystemError("@NotFound@ @AD_InfoWindow_ID@ " + p_source_AD_InfoWindow_ID);
|
||||
if (log.isLoggable(Level.INFO)) log.info("Source AD_InfoWindow_ID=" + p_source_AD_InfoWindow_ID
|
||||
+ ", Target AD_InfoWindow_ID=" + p_target_AD_InfoWindow_ID);
|
||||
|
||||
MInfoWindow targetInfoWindow = new MInfoWindow(getCtx(), p_target_AD_InfoWindow_ID, get_TrxName());
|
||||
MInfoColumn[] targetColumns = targetInfoWindow.getInfoColumns();
|
||||
if (targetColumns.length > 0) //Target Info Window must not have columns
|
||||
throw new AdempiereSystemError("Target info window must not have columns");
|
||||
|
||||
MInfoWindow sourceInfoWindow = new MInfoWindow(getCtx(), p_source_AD_InfoWindow_ID, get_TrxName());
|
||||
MInfoColumn[] sourceColumns = sourceInfoWindow.getInfoColumns();
|
||||
|
||||
for (int i = 0; i < sourceColumns.length; i++)
|
||||
{
|
||||
MInfoColumn colTarget = new MInfoColumn(getCtx(),0, get_TrxName());
|
||||
PO.copyValues(sourceColumns[i], colTarget);
|
||||
colTarget.setAD_InfoWindow_ID (targetInfoWindow.getAD_InfoWindow_ID());
|
||||
colTarget.setAD_Org_ID(targetInfoWindow.getAD_Org_ID());
|
||||
colTarget.setEntityType(targetInfoWindow.getEntityType());
|
||||
colTarget.setIsActive(sourceColumns[i].isActive());
|
||||
colTarget.saveEx(get_TrxName());
|
||||
|
||||
m_count++;
|
||||
}
|
||||
|
||||
//
|
||||
return "#" + m_count;
|
||||
} // doIt
|
||||
|
||||
|
||||
} // CopyInfoWindowColumns
|
Loading…
Reference in New Issue