Class RestrictionOperations
This class provides basic restriction handling for Archive lists. It knows the allowable operators
for each column type, can provide a list of them for the SoList system, and can parse a restriction
(that is, the value part of the restriction). It also (re)calculates values that are relative to the
current date/time or some other changeable quantity.
Inheritance
RestrictionOperations
Assembly: SoDataBase.dll
Syntax
public static class RestrictionOperations
Fields
AllOf
Declaration
public const string AllOf = "allOf"
Field Value
IsNotNull
Declaration
public const string IsNotNull = "isNotNull"
Field Value
IsNull
Declaration
public const string IsNull = "isNull"
Field Value
IsPK
Declaration
public const string IsPK = "isPK"
Field Value
NoneOf
Declaration
public const string NoneOf = "noneOf"
Field Value
NotOneOf
Declaration
public const string NotOneOf = "notOneOf"
Field Value
OneOf
Declaration
public const string OneOf = "oneOf"
Field Value
OpEquals
Declaration
public const string OpEquals = "equals"
Field Value
PhoneBegins
Declaration
public const string PhoneBegins = "begins"
Field Value
PhoneContains
Declaration
public const string PhoneContains = "contains"
Field Value
PhoneEquals
Declaration
public const string PhoneEquals = "is"
Field Value
Set
Declaration
public const string Set = "set"
Field Value
ValueHintDelimiter
Declaration
public const string ValueHintDelimiter = ";"
Field Value
Methods
BuildPeriodReturnValues(DateTime[], Int32[])
Combines the two parameter-arrays into a single array, encoded as their datatype.
Declaration
public static string[] BuildPeriodReturnValues(DateTime[] calculatedValues, params int[] inputValues)
Parameters
Type |
Name |
Description |
DateTime[] |
calculatedValues |
|
Int32[] |
inputValues |
|
Returns
CalculateAndValidateNumberOfValues(ArchiveRestrictionInfo, Boolean)
Declaration
public static int CalculateAndValidateNumberOfValues(ArchiveRestrictionInfo restriction, bool throwException)
Parameters
Returns
ConvertOperatorType(String)
Declaration
public static string ConvertOperatorType(string operatorType)
Parameters
Type |
Name |
Description |
String |
operatorType |
|
Returns
CreateListAllRestriction(ArchiveRestrictionInfo, ArchiveSelect, FieldInfo, FieldInfo, FieldInfo)
Handle restrictions for ListAll type columns, which require multiple aliased joins
Declaration
public static void CreateListAllRestriction(ArchiveRestrictionInfo restriction, ArchiveSelect targetQuery, FieldInfo leftField, FieldInfo rightField, FieldInfo valueField)
Parameters
CreateSqlRestriction(ArchiveRestrictionInfo, FieldInfo)
Given a restriction information object and a target database field, create the corresponding
SQL restriction, based on the field's data type, the restriction operator and any relevant values.
NOTE that this method BY DESIGN does not take subrestrictions into account.
Declaration
public static Restriction CreateSqlRestriction(ArchiveRestrictionInfo restriction, FieldInfo targetField)
Parameters
Returns
DatePair(RestrictionOperations.ValueCalculator, FieldInfo)
Declaration
public static Restriction DatePair(RestrictionOperations.ValueCalculator calculator, FieldInfo targetField)
Parameters
Returns
DatePair(String[], FieldInfo)
Declaration
public static Restriction DatePair(string[] values, FieldInfo targetField)
Parameters
Returns
GetExpandedValueHint(RestrictionOperations.OperatorInfo)
Return an expanded value hint (containing default values) for the given operator.
Declaration
public static string GetExpandedValueHint(RestrictionOperations.OperatorInfo operatorInfo)
Parameters
Returns
Type |
Description |
String |
Expanded value hint
|
Remarks
Exceptions
Type |
Condition |
SoIllegalOperationException |
Thrown if the number of placeholders in the value hint does not correspond to the
number of values returned by the value calculator; this is a fairly serious internal inconsistency since
it will propagate to parsing.
|
GetNumRequiredValues(ArchiveRestrictionInfo, Boolean)
Return the number of values required by this restriction, with or without counting calculated values.
The algorithm is based on the ValueHints, and takes both the restriction type and operator into account.
A negative result means 'at least this number' of values.
Declaration
public static int GetNumRequiredValues(ArchiveRestrictionInfo restriction, bool includeCalculatedInCount)
Parameters
Type |
Name |
Description |
ArchiveRestrictionInfo |
restriction |
Restriction to parse
|
Boolean |
includeCalculatedInCount |
Should calculated (read-only) values be included
|
Returns
Type |
Description |
Int32 |
Number of values required; if positive then this is an absoute number, if negative, then the smallest number (more values are legal)
|
GetOperatorInfo(String, String)
Locate the OperatorInfo corresponding to the given operator name and restriction type. If the operator
cannot be found for the given restriction type, try to find it using the static prefix and the
restriction type.
Declaration
public static RestrictionOperations.OperatorInfo GetOperatorInfo(string operatorName, string restrictionType)
Parameters
Type |
Name |
Description |
String |
operatorName |
Operator to find
|
String |
restrictionType |
Rrestriction type, will be used alone and with static prefix
|
Returns
GetOperatorsForType(String)
Return an array of RestrictionOperations.OperatorInfo elements describing valid operators for the given data type.
An array of length 0 is returned if the data type is unknown.
Declaration
public static RestrictionOperations.OperatorInfo[] GetOperatorsForType(string dataType)
Parameters
Type |
Name |
Description |
String |
dataType |
Case-insensitive name of data type
|
Returns
OperatorNameToReporterOperatorName(String, String)
Declaration
public static string OperatorNameToReporterOperatorName(string operatorName, string operatorType)
Parameters
Type |
Name |
Description |
String |
operatorName |
|
String |
operatorType |
|
Returns
PopulateCalculatedRestrictionValues(ArchiveRestrictionInfo)
Take an ArchiveRestrictionInfo, and populate its values. Values that are calculated are set to their
current value (i.e., 'this week' is expanded to two values, denoting the start and end of the week enclosing the time
when the PopulateRestrictionValues was called).
Declaration
public static void PopulateCalculatedRestrictionValues(ArchiveRestrictionInfo restriction)
Parameters
PopulateColumnInfo(String, String, ArchiveRestrictionInfo[])
Populate the ColumnInfo part of an array of ArchiveRestrictionInfo, based on the given provider name. Existing ColumnInfo
objects with nonempty names will be left untouched, others will be populated
Declaration
public static void PopulateColumnInfo(string providerName, string context, params ArchiveRestrictionInfo[] restrictions)
Parameters
Exceptions
PopulateDisplayValues(ArchiveRestrictionInfo[])
Take the current Values of the restrictions, and use them to set the corresponding DisplayValues. This
depends on the restriction types (for instance, lists); operator (such as IsPK), or possibly other
metadata or context.
Declaration
public static void PopulateDisplayValues(params ArchiveRestrictionInfo[] restrictions)
Parameters
ReporterOperatorNameToOperatorName(String, String)
Declaration
public static string ReporterOperatorNameToOperatorName(string reporterOperatorName, string restrictionType)
Parameters
Type |
Name |
Description |
String |
reporterOperatorName |
|
String |
restrictionType |
|
Returns
RestrictionTypeToOperatorType(String)
Declaration
public static string RestrictionTypeToOperatorType(string restrictionType)
Parameters
Type |
Name |
Description |
String |
restrictionType |
|
Returns
SetDefaults(ArchiveRestrictionInfo)
Declaration
public static void SetDefaults(ArchiveRestrictionInfo restriction)
Parameters