Difference between revisions of "DataCacheSpecification class"
(Created page with "<p style="color:#000099; font-size:14px;"><strong>DataCacheSpecification : Represents a Data Cache specification.</strong></p> <p> </p> <p> <span style="color:#a52a2a;"><...") |
|||
Line 1: | Line 1: | ||
− | + | === '''DataCacheSpecification : Represents a Data Cache specification.''' === | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | | ||
+ | |||
+ | ==== <span style="color:#a52a2a;">'''Constructors'''</span> ==== | ||
+ | |||
+ | *<span style="color:#000000;">'''()''' - Instanciate a new instance using the current datacache context.</span> | ||
+ | *<span style="color:#000000;">'''(number ResourceId)''' - Instanciate a new instance using the resource id of a datacache</span> | ||
+ | *<span style="color:#000000;">'''(string ResourceName, array QuestionnaireIds)''' - Create a new datacache using quick setup. QuestionnaireIds is an array of Questionnaire Ids to use in the creation. Must all belong to same questionnaire template.</span> | ||
+ | |||
+ | ==== <span style="color:#a52a2a;">'''Methods'''</span> ==== | ||
+ | |||
+ | *<span style="color: rgb(0, 0, 0);">'''Empty AddFilter(string filterQuestionLabel, string filterValue)''' - Add a filter to the DataCache.</span><span style="color: rgb(0, 0, 0);"> filterQuestionLabel is Question to apply filter to. If empty, then clear current filters.</span> <span style="color: rgb(0, 0, 0);">filterValue is Value of the filter.</span> | ||
+ | *<span style="color: rgb(0, 0, 0);">'''AnyType EvalWhere(string whereExpression)''' - Evaluate a single where expression up against the current DataCache. whereExpression is an expression to execute. It must contain 'where' and NOT start with a equal sign, and have 1 and only one semicolon in it.</span> | ||
+ | *<span style="color: rgb(0, 0, 0);">'''Dictionary EvalWhere(Dictionary whereExpressions)''' - Evaluate a number of where expressions up against the current DataCache. If there are 2 or more expressions, the result is cached. Context weight and filters are ignored. whereExpressions are expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it.</span> | ||
+ | *<span style="color: rgb(0, 0, 0);">'''Dictionary EvalWhere(Dictionary whereExpressions, string weight)''' - Evaluate a number of where expressions up against the current DataCache using a weight. If there are 2 or more expressions, the result is cached. Context weight and filters are ignored. whereExpressions are expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it. weight is column name of the weight to use in filter.</span> | ||
+ | *<span style="color:#000000;">'''Empty MakeContext()''' - Make the current Data Cache as the DCS Context</span> | ||
+ | *<span style="color:#000000;">'''Empty Save()''' - Save the Data Cache but not REBUILD the Data Cache.</span> | ||
+ | *<span style="color:#000000;">'''string ToString()''' - The string representation of the object.</span> | ||
+ | |||
+ | ==== <span style="color:#a52a2a;">'''Properties'''</span> ==== | ||
+ | |||
+ | *<span style="color:#000000;">'''bool AutoUpdate HasGetter HasSetter''' - Get/Set Auto Update</span> | ||
+ | *<span style="color:#000000;">'''bool BuildWithWeight HasGetter HasSetter''' - Get/Set if the DataCache should be built using weights</span> | ||
+ | *<span style="color:#000000;">'''number CachedRecords HasGetter''' - How many records does the DataCache currently hold</span> | ||
+ | *<span style="color:#000000;">'''array ColumnNames HasGetter''' - List of Column names</span> | ||
+ | *<span style="color:#000000;">'''bool Completed HasGetter HasSetter''' - Get/Set include completed</span> | ||
+ | *<span style="color:#000000;">'''bool Deleted HasGetter HasSetter''' - Get/Set include deleted</span> | ||
+ | *<span style="color:#000000;">'''string Description HasGetter HasSetter''' - Get/Set description of the DataCache</span> | ||
+ | *<span style="color:#000000;">'''bool Disabled HasGetter HasSetter''' - Get/Set include disabled</span> | ||
+ | *<span style="color:#000000;">'''bool InterviewFailed HasGetter HasSetter''' - Get/Set include marked as interview failed</span> | ||
+ | *<span style="color:#000000;">'''bool InterviewSucceeded HasGetter HasSetter''' - Get/Set include marked as interview succeeded</span> | ||
+ | *<span style="color:#000000;">'''bool IsOutOfDate HasGetter''' - Does the DataCache need to be rebuilt to have the correct content</span> | ||
+ | *<span style="color:#000000;">'''string Language HasGetter HasSetter''' - Get/Set the iso code used in building the items that depend on a specific language</span> | ||
+ | *<span style="color:#000000;">'''DateTime LastUpdated HasGetter''' - Time of the last rebuild</span> | ||
+ | *<span style="color:#000000;">'''string Name HasGetter HasSetter''' - Name of the DataCache resource</span> | ||
+ | *<span style="color:#000000;">'''bool Normal HasGetter HasSetter''' - Get/Set include normal</span> | ||
+ | *<span style="color:#000000;">'''bool NotStarted HasGetter HasSetter''' - Get/Set include those not yet started</span> | ||
+ | *<span style="color:#000000;">'''bool OutsideTarget HasGetter HasSetter''' - Get/Set include those marked outside target</span> | ||
+ | *<span style="color:#000000;">'''bool Partly HasGetter HasSetter''' - Get/Set include partly completed</span> | ||
+ | *<span style="color:#000000;">'''array QuestionnaireIds HasGetter''' - List of the questionnaires used in the DataCache</span> | ||
+ | *<span style="color:#000000;">'''number QuestionnaireTemplateId HasGetter''' - The resource id of the questionnaire template used in the DataCache</span> | ||
+ | *<span style="color:#000000;">'''bool QuotaFull HasGetter HasSetter''' - Get/Set include those with full quota</span> | ||
+ | *<span style="color:#000000;">'''number ResourceId HasGetter''' - The Id of the DataCache</span> | ||
+ | *<span style="color:#000000;">'''bool Test HasGetter HasSetter''' - Get/Set include those marked as test</span> | ||
+ | *<span style="color:#000000;">'''number UpdateFrequence HasGetter HasSetter''' - Get/Set Update Frequence in minutes</span> | ||
+ | *<span style="color:#000000;">'''string ObjectTypeName HasGetter''' - The name of the type of object</span> | ||
+ | *<span style="color:#000000;">'''TypeInformation TypeInformation HasGetter''' - Get information about this class</span> | ||
+ | |||
+ | | ||
+ | |||
+ | ==== <span style="color:#a52a2a;">'''Examples'''</span> ==== | ||
+ | |||
+ | <span style="color:#a52a2a;">'''Ex1:'''</span> | ||
+ | <source lang="javascript">DCS_use(37244952); // set DCS context | ||
+ | string e1 = "count() where S_Age == [1] && M_Travel == [1,2];"; | ||
+ | Dictionary d = | ||
+ | { | ||
+ | "exp1": "count() where S_Age == [1] && M_Travel == [1,2];", | ||
+ | "exp2": "count() where S_Age == [2] && M_Travel == [1];" | ||
+ | }; | ||
+ | print(DCS_evaluateWhereExpression(e1)); // 68 | ||
+ | DataCacheSpecification dcs = new DataCacheSpecification(); // Represent a DCS which is used as current DCS context | ||
+ | print(dcs.EvalWhere(e1)); // 68 | ||
+ | print(dcs.EvalWhere(d)); // {"exp1": 68, "exp2": 46}</source> | ||
+ | <span style="color:#a52a2a;">'''Ex2:'''</span> | ||
+ | <source lang="javascript">string e1 = "count() where S_Age == [1] && M_Travel == [1,2];"; | ||
+ | Dictionary d = | ||
+ | { | ||
+ | "exp1": "count() where S_Age == [1] && M_Travel == [1,2];", | ||
+ | "exp2": "count() where S_Age == [2] && M_Travel == [1];" | ||
+ | }; | ||
+ | DataCacheSpecification dcs = new DataCacheSpecification(37244952); // Represents a DCS which has Resource Id: 37244952 | ||
+ | print(dcs.EvalWhere(e1)); // 68 | ||
+ | print(dcs.EvalWhere(d)); // {"exp1": 68, "exp2": 46} | ||
+ | dcs.MakeContext(); // or you can use DCS_use(RID) instead | ||
+ | print(DCS_evaluateWhereExpression(e1)); // without the previous statement (dcs.MakeContext();), you will get error at this line because there is no DCS context is set, so you can not use DCS_evaluateWhereExpression(e1) | ||
+ | dcs.Partly = false; // Not include the partly completed QASs | ||
+ | dcs.NotStarted = false; // Not include the not started QASs | ||
+ | dcs.Save(); // Must save to make the above statements applied on DCS, but this statement does not REBUILD the DCS</source><br> | ||
+ | | ||
[[Category:Data_Types_Literals_and_Variables]] | [[Category:Data_Types_Literals_and_Variables]] |
Revision as of 09:30, 14 September 2011
Contents
DataCacheSpecification : Represents a Data Cache specification.
Constructors
- () - Instanciate a new instance using the current datacache context.
- (number ResourceId) - Instanciate a new instance using the resource id of a datacache
- (string ResourceName, array QuestionnaireIds) - Create a new datacache using quick setup. QuestionnaireIds is an array of Questionnaire Ids to use in the creation. Must all belong to same questionnaire template.
Methods
- Empty AddFilter(string filterQuestionLabel, string filterValue) - Add a filter to the DataCache. filterQuestionLabel is Question to apply filter to. If empty, then clear current filters. filterValue is Value of the filter.
- AnyType EvalWhere(string whereExpression) - Evaluate a single where expression up against the current DataCache. whereExpression is an expression to execute. It must contain 'where' and NOT start with a equal sign, and have 1 and only one semicolon in it.
- Dictionary EvalWhere(Dictionary whereExpressions) - Evaluate a number of where expressions up against the current DataCache. If there are 2 or more expressions, the result is cached. Context weight and filters are ignored. whereExpressions are expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it.
- Dictionary EvalWhere(Dictionary whereExpressions, string weight) - Evaluate a number of where expressions up against the current DataCache using a weight. If there are 2 or more expressions, the result is cached. Context weight and filters are ignored. whereExpressions are expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it. weight is column name of the weight to use in filter.
- Empty MakeContext() - Make the current Data Cache as the DCS Context
- Empty Save() - Save the Data Cache but not REBUILD the Data Cache.
- string ToString() - The string representation of the object.
Properties
- bool AutoUpdate HasGetter HasSetter - Get/Set Auto Update
- bool BuildWithWeight HasGetter HasSetter - Get/Set if the DataCache should be built using weights
- number CachedRecords HasGetter - How many records does the DataCache currently hold
- array ColumnNames HasGetter - List of Column names
- bool Completed HasGetter HasSetter - Get/Set include completed
- bool Deleted HasGetter HasSetter - Get/Set include deleted
- string Description HasGetter HasSetter - Get/Set description of the DataCache
- bool Disabled HasGetter HasSetter - Get/Set include disabled
- bool InterviewFailed HasGetter HasSetter - Get/Set include marked as interview failed
- bool InterviewSucceeded HasGetter HasSetter - Get/Set include marked as interview succeeded
- bool IsOutOfDate HasGetter - Does the DataCache need to be rebuilt to have the correct content
- string Language HasGetter HasSetter - Get/Set the iso code used in building the items that depend on a specific language
- DateTime LastUpdated HasGetter - Time of the last rebuild
- string Name HasGetter HasSetter - Name of the DataCache resource
- bool Normal HasGetter HasSetter - Get/Set include normal
- bool NotStarted HasGetter HasSetter - Get/Set include those not yet started
- bool OutsideTarget HasGetter HasSetter - Get/Set include those marked outside target
- bool Partly HasGetter HasSetter - Get/Set include partly completed
- array QuestionnaireIds HasGetter - List of the questionnaires used in the DataCache
- number QuestionnaireTemplateId HasGetter - The resource id of the questionnaire template used in the DataCache
- bool QuotaFull HasGetter HasSetter - Get/Set include those with full quota
- number ResourceId HasGetter - The Id of the DataCache
- bool Test HasGetter HasSetter - Get/Set include those marked as test
- number UpdateFrequence HasGetter HasSetter - Get/Set Update Frequence in minutes
- string ObjectTypeName HasGetter - The name of the type of object
- TypeInformation TypeInformation HasGetter - Get information about this class
Examples
Ex1:
DCS_use(37244952); // set DCS context
string e1 = "count() where S_Age == [1] && M_Travel == [1,2];";
Dictionary d =
{
"exp1": "count() where S_Age == [1] && M_Travel == [1,2];",
"exp2": "count() where S_Age == [2] && M_Travel == [1];"
};
print(DCS_evaluateWhereExpression(e1)); // 68
DataCacheSpecification dcs = new DataCacheSpecification(); // Represent a DCS which is used as current DCS context
print(dcs.EvalWhere(e1)); // 68
print(dcs.EvalWhere(d)); // {"exp1": 68, "exp2": 46}
Ex2:
string e1 = "count() where S_Age == [1] && M_Travel == [1,2];";
Dictionary d =
{
"exp1": "count() where S_Age == [1] && M_Travel == [1,2];",
"exp2": "count() where S_Age == [2] && M_Travel == [1];"
};
DataCacheSpecification dcs = new DataCacheSpecification(37244952); // Represents a DCS which has Resource Id: 37244952
print(dcs.EvalWhere(e1)); // 68
print(dcs.EvalWhere(d)); // {"exp1": 68, "exp2": 46}
dcs.MakeContext(); // or you can use DCS_use(RID) instead
print(DCS_evaluateWhereExpression(e1)); // without the previous statement (dcs.MakeContext();), you will get error at this line because there is no DCS context is set, so you can not use DCS_evaluateWhereExpression(e1)
dcs.Partly = false; // Not include the partly completed QASs
dcs.NotStarted = false; // Not include the not started QASs
dcs.Save(); // Must save to make the above statements applied on DCS, but this statement does not REBUILD the DCS