IDEMPIERE-460 Support for overriding reference key on web service field and allowing scripting support for ctx variable.

This commit is contained in:
Deepak Pansheriya 2013-03-29 14:53:10 +05:30
parent 6956b186a9
commit 285f89db5d
5 changed files with 175 additions and 14 deletions

View File

@ -0,0 +1,37 @@
-- Mar 26, 2013 12:07:36 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Column (AD_Reference_Value_ID,IsSyncDatabase,IsAlwaysUpdateable,IsEncrypted,Version,AD_Column_ID,AD_Table_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,AD_Val_Rule_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,SeqNoSelection) VALUES (4,'N','N','N',0,210215,53166,'U','N','N','N',0,'N',10,'N',18,115,'N',121,'N','Y','965ef095-ae2e-47cf-a376-d4c0768389b4','Y','AD_Reference_Value_ID','Required to specify, if data type is Table or List','The Reference Value indicates where the reference values are stored. It must be specified if the data type is Table or List. ','Reference Key','Y',100,TO_DATE('2013-03-26 00:07:34','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2013-03-26 00:07:34','YYYY-MM-DD HH24:MI:SS'),100,0,'N',0)
;
-- Mar 26, 2013 12:07:36 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210215 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Mar 26, 2013 12:07:44 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
ALTER TABLE WS_WebServiceFieldInput ADD AD_Reference_Value_ID NUMBER(10) DEFAULT NULL
;
-- Mar 26, 2013 12:08:01 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Field (AD_Tab_ID,IsEncrypted,AD_Column_ID,DisplayLength,IsSameLine,IsHeading,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,EntityType,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES (53189,'N',210215,10,'N','N','Y',201895,'N','The Reference Value indicates where the reference values are stored. It must be specified if the data type is Table or List. ','U','Required to specify, if data type is Table or List','Reference Key','N','Y','1113ff58-7523-4a3e-bf5c-36d22e14e959',100,0,TO_DATE('2013-03-26 00:08:00','YYYY-MM-DD HH24:MI:SS'),0,100,TO_DATE('2013-03-26 00:08:00','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Mar 26, 2013 12:08:01 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201895 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Mar 26, 2013 12:15:20 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
UPDATE AD_Field SET XPosition=4, ColumnSpan=2,Updated=TO_DATE('2013-03-26 00:15:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201895
;
-- Mar 26, 2013 12:18:40 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
UPDATE AD_Column SET MandatoryLogic=NULL,Updated=TO_DATE('2013-03-26 00:18:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=1000004
;
SELECT register_migration_script('201303290245_IDEMPIERE-460-LookupOverride.sql') FROM dual
;

View File

@ -0,0 +1,38 @@
-- Mar 26, 2013 12:07:36 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Column (AD_Reference_Value_ID,IsSyncDatabase,IsAlwaysUpdateable,IsEncrypted,Version,AD_Column_ID,AD_Table_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,AD_Val_Rule_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton,SeqNoSelection) VALUES (4,'N','N','N',0,210215,53166,'U','N','N','N',0,'N',10,'N',18,115,'N',121,'N','Y','965ef095-ae2e-47cf-a376-d4c0768389b4','Y','AD_Reference_Value_ID','Required to specify, if data type is Table or List','The Reference Value indicates where the reference values are stored. It must be specified if the data type is Table or List. ','Reference Key','Y',100,TO_TIMESTAMP('2013-03-26 00:07:34','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2013-03-26 00:07:34','YYYY-MM-DD HH24:MI:SS'),100,0,'N',0)
;
-- Mar 26, 2013 12:07:36 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=210215 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Mar 26, 2013 12:07:44 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
ALTER TABLE WS_WebServiceFieldInput ADD COLUMN AD_Reference_Value_ID NUMERIC(10) DEFAULT NULL
;
-- Mar 26, 2013 12:08:01 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Field (AD_Tab_ID,IsEncrypted,AD_Column_ID,DisplayLength,IsSameLine,IsHeading,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,EntityType,Description,Name,IsFieldOnly,IsDisplayed,AD_Field_UU,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive) VALUES (53189,'N',210215,10,'N','N','Y',201895,'N','The Reference Value indicates where the reference values are stored. It must be specified if the data type is Table or List. ','U','Required to specify, if data type is Table or List','Reference Key','N','Y','1113ff58-7523-4a3e-bf5c-36d22e14e959',100,0,TO_TIMESTAMP('2013-03-26 00:08:00','YYYY-MM-DD HH24:MI:SS'),0,100,TO_TIMESTAMP('2013-03-26 00:08:00','YYYY-MM-DD HH24:MI:SS'),'Y')
;
-- Mar 26, 2013 12:08:01 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=201895 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Mar 26, 2013 12:15:20 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
UPDATE AD_Field SET XPosition=4, ColumnSpan=2,Updated=TO_TIMESTAMP('2013-03-26 00:15:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201895
;
-- Mar 26, 2013 12:18:40 AM IST
-- IDEMPIERE-460 Adding Lookup override for web service
UPDATE AD_Column SET MandatoryLogic=NULL,Updated=TO_TIMESTAMP('2013-03-26 00:18:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=1000004
;
SELECT register_migration_script('201303290245_IDEMPIERE-460-LookupOverride.sql') FROM dual
;

View File

@ -1,6 +1,6 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* Product: iDempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
@ -21,8 +21,8 @@ import java.sql.Timestamp;
import org.compiere.util.KeyNamePair;
/** Generated Interface for WS_WebServiceFieldInput
* @author Adempiere (generated)
* @version Release 3.6.0LTS
* @author iDempiere (generated)
* @version Release 1.0a
*/
public interface I_WS_WebServiceFieldInput
{
@ -92,6 +92,21 @@ public interface I_WS_WebServiceFieldInput
public org.compiere.model.I_AD_Reference getAD_Reference() throws RuntimeException;
/** Column name AD_Reference_Value_ID */
public static final String COLUMNNAME_AD_Reference_Value_ID = "AD_Reference_Value_ID";
/** Set Reference Key.
* Required to specify, if data type is Table or List
*/
public void setAD_Reference_Value_ID (int AD_Reference_Value_ID);
/** Get Reference Key.
* Required to specify, if data type is Table or List
*/
public int getAD_Reference_Value_ID();
public org.compiere.model.I_AD_Reference getAD_Reference_Value() throws RuntimeException;
/** Column name ColumnName */
public static final String COLUMNNAME_ColumnName = "ColumnName";
@ -194,6 +209,15 @@ public interface I_WS_WebServiceFieldInput
/** Get Web Service Field Input */
public int getWS_WebServiceFieldInput_ID();
/** Column name WS_WebServiceFieldInput_UU */
public static final String COLUMNNAME_WS_WebServiceFieldInput_UU = "WS_WebServiceFieldInput_UU";
/** Set WS_WebServiceFieldInput_UU */
public void setWS_WebServiceFieldInput_UU (String WS_WebServiceFieldInput_UU);
/** Get WS_WebServiceFieldInput_UU */
public String getWS_WebServiceFieldInput_UU();
/** Column name WS_WebServiceType_ID */
public static final String COLUMNNAME_WS_WebServiceType_ID = "WS_WebServiceType_ID";

View File

@ -1,6 +1,6 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* Product: iDempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
@ -22,15 +22,15 @@ import java.util.Properties;
import org.compiere.util.KeyNamePair;
/** Generated Model for WS_WebServiceFieldInput
* @author Adempiere (generated)
* @version Release 3.6.0LTS - $Id$ */
* @author iDempiere (generated)
* @version Release 1.0a - $Id$ */
public class X_WS_WebServiceFieldInput extends PO implements I_WS_WebServiceFieldInput, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20121118L;
private static final long serialVersionUID = 20130326L;
/** Standard Constructor */
public X_WS_WebServiceFieldInput (Properties ctx, int WS_WebServiceFieldInput_ID, String trxName)
@ -127,6 +127,34 @@ public class X_WS_WebServiceFieldInput extends PO implements I_WS_WebServiceFiel
return ii.intValue();
}
public org.compiere.model.I_AD_Reference getAD_Reference_Value() throws RuntimeException
{
return (org.compiere.model.I_AD_Reference)MTable.get(getCtx(), org.compiere.model.I_AD_Reference.Table_Name)
.getPO(getAD_Reference_Value_ID(), get_TrxName()); }
/** Set Reference Key.
@param AD_Reference_Value_ID
Required to specify, if data type is Table or List
*/
public void setAD_Reference_Value_ID (int AD_Reference_Value_ID)
{
if (AD_Reference_Value_ID < 1)
set_Value (COLUMNNAME_AD_Reference_Value_ID, null);
else
set_Value (COLUMNNAME_AD_Reference_Value_ID, Integer.valueOf(AD_Reference_Value_ID));
}
/** Get Reference Key.
@return Required to specify, if data type is Table or List
*/
public int getAD_Reference_Value_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Reference_Value_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set DB Column Name.
@param ColumnName
Name of the column in the database
@ -233,6 +261,19 @@ public class X_WS_WebServiceFieldInput extends PO implements I_WS_WebServiceFiel
{
return new KeyNamePair(get_ID(), String.valueOf(getWS_WebServiceFieldInput_ID()));
}
/** Set WS_WebServiceFieldInput_UU.
@param WS_WebServiceFieldInput_UU WS_WebServiceFieldInput_UU */
public void setWS_WebServiceFieldInput_UU (String WS_WebServiceFieldInput_UU)
{
set_Value (COLUMNNAME_WS_WebServiceFieldInput_UU, WS_WebServiceFieldInput_UU);
}
/** Get WS_WebServiceFieldInput_UU.
@return WS_WebServiceFieldInput_UU */
public String getWS_WebServiceFieldInput_UU ()
{
return (String)get_Value(COLUMNNAME_WS_WebServiceFieldInput_UU);
}
public I_WS_WebServiceType getWS_WebServiceType() throws RuntimeException
{

View File

@ -46,6 +46,7 @@ import org.apache.xmlbeans.StringEnumAbstractBase.Table;
import org.compiere.model.Lookup;
import org.compiere.model.MColumn;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MRefTable;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
@ -1010,7 +1011,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
}
} // createUpdateData
private void setValueAccordingToClass(PO po, POInfo poinfo, DataField field, int idxcol) {
private void setValueAccordingToClass(PO po, POInfo poinfo, DataField field, int idxcol,X_WS_WebServiceFieldInput fieldInput) {
CompiereService m_cs = getCompiereService();
// Evaluate the type of the column and assign a proper variable
Class<?> columnClass = poinfo.getColumnClass(idxcol);
@ -1018,8 +1019,22 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
String strValue = field.getVal();
String lookupValue = field.getLval();
if (lookupValue != null && !"".equals(lookupValue)) {
Lookup lookup = poinfo.getColumnLookup(idxcol);
Lookup lookup = null;
if(fieldInput.getAD_Reference_Value_ID()>0)
{
try{
lookup = MLookupFactory.get(m_cs.getCtx(),0,poinfo.getAD_Column_ID(poinfo.getColumnName(idxcol)),fieldInput.getAD_Reference_ID(),null,poinfo.getColumnName(idxcol),fieldInput.getAD_Reference_Value_ID(),false,null);
}catch (Exception e) {
throw new IdempiereServiceFault("Exception in resolving overridden lookup ", new QName(
"LookupResolutionFailed"));
}
}
else
{
lookup = poinfo.getColumnLookup(idxcol);
}
if (lookup == null) {
throw new IdempiereServiceFault(field.getColumn() + " is not lookup column. Pass Value in val element ", new QName(
"LookupResolutionFailed"));
@ -1104,7 +1119,13 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
if (fieldInput.getAD_Column_ID() == 0 && fieldInput.getColumnName() != null) {
String varName = fieldInput.getColumnName();
Class<?> columnClass = getVariableType(varName, fieldInput.getAD_Reference_ID());
Object objVal = convertToObj(field.getVal(),columnClass,varName);
Object objVal = null;
String val = field.getVal();
if(val!=null && val.charAt(0) == '@')
objVal = parseVariable(field.getVal(), po, poinfo, requestCtx);
else
objVal = convertToObj(field.getVal(),columnClass,varName);
requestCtx.put(varName, objVal);
} else{
@ -1117,7 +1138,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
+ ": input column " + field.getColumn() + " does not exist");
} else {
try {
setValueAccordingToClass(po, poinfo, field, idxcol);
setValueAccordingToClass(po, poinfo, field, idxcol,fieldInput);
} catch (IdempiereServiceFault e) {
log.log(Level.WARNING, "Error setting value", e);
return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue()