Show / Hide Table of Contents

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
Object
RestrictionOperations
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.ArchiveLists
Assembly: SoDataBase.dll
Syntax
public static class RestrictionOperations
Remarks

The remarks on the static constructor document the naming conventions for the reflection-based method lookup, that controls much of the functionality of this class.

Fields

AllOf

Declaration
public const string AllOf = "allOf"
Field Value
Type Description
String

IsNotNull

Declaration
public const string IsNotNull = "isNotNull"
Field Value
Type Description
String

IsNull

Declaration
public const string IsNull = "isNull"
Field Value
Type Description
String

IsPK

Declaration
public const string IsPK = "isPK"
Field Value
Type Description
String

NoneOf

Declaration
public const string NoneOf = "noneOf"
Field Value
Type Description
String

NotOneOf

Declaration
public const string NotOneOf = "notOneOf"
Field Value
Type Description
String

OneOf

Declaration
public const string OneOf = "oneOf"
Field Value
Type Description
String

OpEquals

Declaration
public const string OpEquals = "equals"
Field Value
Type Description
String

PhoneBegins

Declaration
public const string PhoneBegins = "begins"
Field Value
Type Description
String

PhoneContains

Declaration
public const string PhoneContains = "contains"
Field Value
Type Description
String

PhoneEquals

Declaration
public const string PhoneEquals = "is"
Field Value
Type Description
String

Set

Declaration
public const string Set = "set"
Field Value
Type Description
String

ValueHintDelimiter

Declaration
public const string ValueHintDelimiter = ";"
Field Value
Type Description
String

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
Type Description
String[]

CalculateAndValidateNumberOfValues(ArchiveRestrictionInfo, Boolean)

Declaration
public static int CalculateAndValidateNumberOfValues(ArchiveRestrictionInfo restriction, bool throwException)
Parameters
Type Name Description
ArchiveRestrictionInfo restriction
Boolean throwException
Returns
Type Description
Int32

ConvertOperatorType(String)

Declaration
public static string ConvertOperatorType(string operatorType)
Parameters
Type Name Description
String operatorType
Returns
Type Description
String

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
Type Name Description
ArchiveRestrictionInfo restriction
ArchiveSelect targetQuery
FieldInfo leftField
FieldInfo rightField
FieldInfo valueField

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
Type Name Description
ArchiveRestrictionInfo restriction

Restriction to parse

FieldInfo targetField

Target field in database

Returns
Type Description
Restriction
Remarks

The implementation of this method must be able to handle all known operators. If you add an operator, you need to add its handling by declaring a method with the following signature:

public Restriction Parse[OperatorName]( ArchiveRestrictionInfo restriction, FieldInfo targetField )

Substitute the name of your operator for the [OperatorName] above. Since operator names do not have to be unique across data type, you need to check the data type of the FieldInfo and be prepared to accept any meaningful type. The method lookup is reflection-based and you do not have to anything except declare the parse method.

DatePair(RestrictionOperations.ValueCalculator, FieldInfo)

Declaration
public static Restriction DatePair(RestrictionOperations.ValueCalculator calculator, FieldInfo targetField)
Parameters
Type Name Description
RestrictionOperations.ValueCalculator calculator
FieldInfo targetField
Returns
Type Description
Restriction

DatePair(String[], FieldInfo)

Declaration
public static Restriction DatePair(string[] values, FieldInfo targetField)
Parameters
Type Name Description
String[] values
FieldInfo targetField
Returns
Type Description
Restriction

GetExpandedValueHint(RestrictionOperations.OperatorInfo)

Return an expanded value hint (containing default values) for the given operator.

Declaration
public static string GetExpandedValueHint(RestrictionOperations.OperatorInfo operatorInfo)
Parameters
Type Name Description
RestrictionOperations.OperatorInfo operatorInfo

Operator information

Returns
Type Description
String

Expanded value hint

Remarks

This method invokes the appropriate ValueCalculator method to calculate values, such as "next week". Some operators do not have such values defined (or meaningful), in those cases the original value hint is returned unchanged.

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
Type Description
RestrictionOperations.OperatorInfo

Operator information, or null

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
Type Description
RestrictionOperations.OperatorInfo[]

Array of operators, or empty array

OperatorNameToReporterOperatorName(String, String)

Declaration
public static string OperatorNameToReporterOperatorName(string operatorName, string operatorType)
Parameters
Type Name Description
String operatorName
String operatorType
Returns
Type Description
String

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
Type Name Description
ArchiveRestrictionInfo restriction

restriction to populate

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
Type Name Description
String providerName

Name of archive provider to use

String context
ArchiveRestrictionInfo[] restrictions

Restrictions to populate

Exceptions
Type Condition
SoIllegalOperationException

Thrown if a restriction name does not match any column name of the given provider

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
Type Name Description
ArchiveRestrictionInfo[] restrictions

Restrictions to inspect and update

ReporterOperatorNameToOperatorName(String, String)

Declaration
public static string ReporterOperatorNameToOperatorName(string reporterOperatorName, string restrictionType)
Parameters
Type Name Description
String reporterOperatorName
String restrictionType
Returns
Type Description
String

RestrictionTypeToOperatorType(String)

Declaration
public static string RestrictionTypeToOperatorType(string restrictionType)
Parameters
Type Name Description
String restrictionType
Returns
Type Description
String

SetDefaults(ArchiveRestrictionInfo)

Declaration
public static void SetDefaults(ArchiveRestrictionInfo restriction)
Parameters
Type Name Description
ArchiveRestrictionInfo restriction
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top