Feature Request [ 1730595 ] Dependant Mandatory Field

This commit is contained in:
kthiemann 2007-06-04 11:04:10 +00:00
parent 30d2e3f962
commit 20e49ecefc
4 changed files with 205 additions and 5 deletions

View File

@ -231,6 +231,7 @@ public class GridField
// Display
Evaluator.parseDepends(list, m_vo.DisplayLogic);
Evaluator.parseDepends(list, m_vo.ReadOnlyLogic);
Evaluator.parseDepends(list, m_vo.MandatoryLogic);
// Lookup
if (m_lookup != null)
Evaluator.parseDepends(list, m_lookup.getValidation());
@ -274,6 +275,15 @@ public class GridField
*/
public boolean isMandatory (boolean checkContext)
{
// Do we have a mandatory rule
if (checkContext && m_vo.MandatoryLogic.length() > 0)
{
boolean retValue = Evaluator.evaluateLogic(this, m_vo.MandatoryLogic);
log.finest(m_vo.ColumnName + " Mandatory(" + m_vo.MandatoryLogic + ") => Mandatory-" + retValue);
if (retValue)
return true;
}
// Not mandatory
if (!m_vo.IsMandatory || isVirtualColumn())
return false;
@ -358,6 +368,7 @@ public class GridField
return false;
}
// Always editable if Active
if (m_vo.ColumnName.equals("Processing")
|| m_vo.ColumnName.equals("PaymentRule")

View File

@ -139,6 +139,8 @@ public class GridFieldVO implements Serializable
vo.AD_Process_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("ReadOnlyLogic"))
vo.ReadOnlyLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("MandatoryLogic"))
vo.MandatoryLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("ObscureType"))
vo.ObscureType = rs.getString (i);
//
@ -378,6 +380,8 @@ public class GridFieldVO implements Serializable
public String Description = "";
/** Help */
public String Help = "";
/** Mandatory Logic */
public String MandatoryLogic = "";
/** Read Only Logic */
public String ReadOnlyLogic = "";
/** Display Obscure */
@ -429,6 +433,8 @@ public class GridFieldVO implements Serializable
Callout = "";
if (ReadOnlyLogic == null)
ReadOnlyLogic = "";
if (MandatoryLogic == null)
MandatoryLogic = "";
// Create Lookup, if not ID
@ -500,6 +506,7 @@ public class GridFieldVO implements Serializable
clone.Description = Description;
clone.Help = Help;
clone.ReadOnlyLogic = ReadOnlyLogic;
clone.MandatoryLogic = MandatoryLogic;
clone.ObscureType = ObscureType;
// Lookup
clone.ValidationCode = ValidationCode;

View File

@ -68,13 +68,13 @@ public X_AD_Column (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AD_Table_ID=101 */
public static final int Table_ID=MTable.getTable_ID("AD_Column");
/** TableName=AD_Column */
public static final String Table_Name="AD_Column";
protected static KeyNamePair Model = new KeyNamePair(Table_ID,"AD_Column");
/** AD_Table_ID=101 */
public static final int Table_ID=MTable.getTable_ID(Table_Name);
protected static KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
protected BigDecimal accessLevel = BigDecimal.valueOf(4);
/** AccessLevel
@ -600,6 +600,25 @@ return false;
}
/** Column name IsUpdateable */
public static final String COLUMNNAME_IsUpdateable = "IsUpdateable";
/** Set Mandatory Logic.
@param MandatoryLogic Logic to determine if field is mandatory (applies only when field is not mandatory in general) */
public void setMandatoryLogic (String MandatoryLogic)
{
if (MandatoryLogic != null && MandatoryLogic.length() > 2000)
{
log.warning("Length > 2000 - truncated");
MandatoryLogic = MandatoryLogic.substring(0,1999);
}
set_Value ("MandatoryLogic", MandatoryLogic);
}
/** Get Mandatory Logic.
@return Logic to determine if field is mandatory (applies only when field is not mandatory in general) */
public String getMandatoryLogic()
{
return (String)get_Value("MandatoryLogic");
}
/** Column name MandatoryLogic */
public static final String COLUMNNAME_MandatoryLogic = "MandatoryLogic";
/** Set Name.
@param Name Alphanumeric identifier of the entity */
public void setName (String Name)

View File

@ -0,0 +1,163 @@
SET DEFINE OFF;
INSERT INTO ad_element
(ad_element_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
columnname, entitytype, NAME,
printname
)
VALUES (50074, 0, 0, 'Y',
TO_DATE ('02/26/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('02/26/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'MandatoryLogic', 'D', 'Mandatory Logic',
'Mandatory Logic'
);
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (50218, 0, 0, 'Y',
TO_DATE ('02/26/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('02/26/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Mandatory Logic', 'Logic to determine if field is mandatory (applies only when field is not mandatory in general)',
'Logic to determine if field is mandatory (applies only when field is not mandatory in general).
format := {expression} [{logic} {expression}]<br>
expression := @{context}@{operand}{value} or @{context}@{operand}{value}<br>
logic := {|}|{&}<br>
context := any global or window context <br>
value := strings or numbers<br>
logic operators := AND or OR with the previous result from left to right <br>
operand := eq{=}, gt{&gt;}, le{&lt;}, not{~^!} <br>
Examples: <br>
@AD_Table_ID@=14 | @Language@!GERGER <br>
@PriceLimit@>10 | @PriceList@>@PriceActual@<br>
@Name@>J<br>
Strings may be in single quotes (optional)', 1,
'D', 'MandatoryLogic', 101, 14,
2000, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 50074, 'N',
'N'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype
)
VALUES (50187, 0, 0, 'Y',
TO_DATE ('02/26/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('02/26/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Mandatory Logic', 'Logic to determine if field is mandatory (applies only when field is not mandatory in general)',
'Logic to determine if field is mandatory (applies only when field is not mandatory in general).
format := {expression} [{logic} {expression}]<br>
expression := @{context}@{operand}{value} or @{context}@{operand}{value}<br>
logic := {|}|{&}<br>
context := any global or window context <br>
value := strings or numbers<br>
logic operators := AND or OR with the previous result from left to right <br>
operand := eq{=}, gt{&gt;}, le{&lt;}, not{~^!} <br>
Examples: <br>
@AD_Table_ID@=14 | @Language@!GERGER <br>
@PriceLimit@>10 | @PriceList@>@PriceActual@<br>
@Name@>J<br>
Strings may be in single quotes (optional)',
'Y', 275 ,101,
50218, 'Y', 60, 'N',
'N', 'N', 'N', 'N', 'D'
);
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_element_id) + 1
FROM ad_element
WHERE ad_element_id < 1000000)
WHERE NAME = 'AD_Element';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_column_id) + 1
FROM ad_column
WHERE ad_column_id < 1000000)
WHERE NAME = 'AD_Column';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_field_id) + 1
FROM ad_field
WHERE ad_field_id < 1000000)
WHERE NAME = 'AD_Field';
ALTER TABLE ad_column ADD MandatoryLogic NVARCHAR2(2000);
CREATE OR REPLACE FORCE VIEW AD_FIELD_V AS
SELECT t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID,
f.Name, f.Description, f.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength,
f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly,
f.IsEncrypted AS IsEncryptedField, f.ObscureType,
c.ColumnName, c.ColumnSQL, c.FieldLength, c.VFormat, c.DefaultValue, c.IsKey, c.IsParent,
COALESCE(f.IsMandatory, c.IsMandatory) AS IsMandatory,
c.IsIdentifier, c.IsTranslated, c.AD_Reference_Value_ID,
c.Callout, COALESCE(f.AD_Reference_ID, c.AD_Reference_ID) AS AD_Reference_ID,
c.AD_Val_Rule_ID, c.AD_Process_ID, c.IsAlwaysUpdateable,
c.ReadOnlyLogic, c.MandatoryLogic, c.IsUpdateable, c.IsEncrypted AS IsEncryptedColumn,
c.IsSelectionColumn,
tbl.TableName, c.ValueMin, c.ValueMax,
fg.Name AS FieldGroup, vr.Code AS ValidationCode
FROM AD_Field f
INNER JOIN AD_Tab t ON (f.AD_Tab_ID = t.AD_Tab_ID)
LEFT OUTER JOIN AD_FieldGroup fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID)
LEFT OUTER JOIN AD_Column c ON (f.AD_Column_ID = c.AD_Column_ID)
INNER JOIN AD_Table tbl ON (c.AD_Table_ID = tbl.AD_Table_ID)
INNER JOIN AD_Reference r ON (c.AD_Reference_ID = r.AD_Reference_ID)
LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID)
WHERE f.IsActive = 'Y'
AND c.IsActive = 'Y';
CREATE OR REPLACE FORCE VIEW AD_FIELD_VT AS
SELECT trl.AD_Language, t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID,
trl.Name, trl.Description, trl.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength,
f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly,
f.IsEncrypted AS IsEncryptedField, f.ObscureType,
c.ColumnName, c.ColumnSQL, c.FieldLength, c.VFormat, c.DefaultValue, c.IsKey, c.IsParent,
COALESCE(f.IsMandatory, c.IsMandatory) AS IsMandatory,
c.IsIdentifier, c.IsTranslated, c.AD_Reference_Value_ID,
c.Callout, COALESCE(f.AD_Reference_ID, c.AD_Reference_ID) AS AD_Reference_ID,
c.AD_Val_Rule_ID, c.AD_Process_ID, c.IsAlwaysUpdateable,
c.ReadOnlyLogic, c.MandatoryLogic, c.IsUpdateable, c.IsEncrypted AS IsEncryptedColumn, c.IsSelectionColumn,
tbl.TableName, c.ValueMin, c.ValueMax,
fgt.Name AS FieldGroup, vr.Code AS ValidationCode
FROM AD_Field f
INNER JOIN AD_Field_Trl trl ON (f.AD_Field_ID = trl.AD_Field_ID)
INNER JOIN AD_Tab t ON (f.AD_Tab_ID = t.AD_Tab_ID)
LEFT OUTER JOIN AD_FieldGroup_Trl fgt ON
(f.AD_FieldGroup_ID = fgt.AD_FieldGroup_ID AND trl.AD_Language=fgt.AD_Language)
LEFT OUTER JOIN AD_Column c ON (f.AD_Column_ID = c.AD_Column_ID)
INNER JOIN AD_Table tbl ON (c.AD_Table_ID = tbl.AD_Table_ID)
INNER JOIN AD_Reference r ON (c.AD_Reference_ID = r.AD_Reference_ID)
LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID)
WHERE f.IsActive = 'Y'
AND c.IsActive = 'Y';
COMMIT ;