Difference between revisions of "DataCacheSpecification class"

From Catglobe Wiki
Jump to: navigation, search
Line 1: Line 1:
=== '''DataCacheSpecification : Represents a Data Cache specification.''' ===
+
{{CGscriptClass_Template
 
+
|Name=<nowiki>DataCacheSpecification</nowiki>
&nbsp;
+
|Description=<nowiki>Represents a DataCache specification.</nowiki>
 
+
|Constructors=
==== <span style="color:#a52a2a;">'''Constructors'''</span> ====
+
{{CGscriptConstructors_Template|Description=<nowiki>Instanciate a new instance using the current context datacache</nowiki>}}
 
+
{{CGscriptConstructors_Template|Parameters=
*<span style="color:#000000;">'''()''' - Instanciate a new instance using the current datacache context.</span>  
+
{{CGscriptParameters_Template|Type=number|Name=<nowiki>ResourceId</nowiki>|Description=<nowiki>Resource Id of the DataCache</nowiki>}}
*<span style="color:#000000;">'''(number ResourceId)''' - Instanciate a new instance using the resource id of a datacache</span>  
+
|Description=<nowiki>Instanciate a new instance using the resource id of a datacache</nowiki>}}
*<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>  
+
{{CGscriptConstructors_Template|Parameters=
 
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>ResourceId</nowiki>|Description=<nowiki>Resource name of the new DataCache</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>Questionnaire Ids</nowiki>|Description=<nowiki>List of Questionnaires to use in the creation. Must all belong to same template</nowiki>}}
==== <span style="color:#a52a2a;">'''Methods'''</span> ====
+
|Description=<nowiki>Create a new datacache using quick setup</nowiki>}}
 
+
|Methods=
*<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>  
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AddFilter</nowiki>|Parameters=
*<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>  
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filterQuestionLabel</nowiki>|Description=<nowiki>Question to apply filter to. If empty, then clear current filters</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>filterValue</nowiki>|Description=<nowiki>Value of the filter</nowiki>}}
*<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>  
+
|Description=<nowiki>Add a filter to the DataCache</nowiki>}}
*<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>  
+
{{CGscriptMethods_Template|ReturnType=AnyType|Name=<nowiki>EvalWhere</nowiki>|Parameters=
*<span style="color:#000000;">'''Empty MakeContext()''' - Make the current Data Cache as the DCS Context</span>  
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>whereExpression</nowiki>|Description=<nowiki>The expression to execute. It must contain 'where' and NOT start with a equal sign, and have 1 and only one semicolon in it</nowiki>}}
*<span style="color:#000000;">'''Empty Save()''' - Save the Data Cache but not REBUILD the Data Cache.</span>  
+
|Description=<nowiki>Evaluate a single where expression up against the current DataCache</nowiki>}}
*<span style="color:#000000;">'''string ToString()''' - The string representation of the object.</span>  
+
{{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>EvalWhere</nowiki>|Parameters=
 
+
{{CGscriptParameters_Template|Type=Dictionary|Name=<nowiki>whereExpressions</nowiki>|Description=<nowiki>The expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it</nowiki>}}
==== <span style="color:#a52a2a;">'''Properties'''</span> ====
+
|Description=<nowiki>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.</nowiki>}}
 
+
{{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>EvalWhere</nowiki>|Parameters=
*<span style="color:#000000;">'''bool AutoUpdate HasGetter HasSetter''' - Get/Set Auto Update</span>  
+
{{CGscriptParameters_Template|Type=Dictionary|Name=<nowiki>whereExpressions</nowiki>|Description=<nowiki>The expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>weight</nowiki>|Description=<nowiki>Column name of the weight to use in filter</nowiki>}}
*<span style="color:#000000;">'''bool BuildWithWeight HasGetter HasSetter''' - Get/Set if the DataCache should be built using weights</span>  
+
|Description=<nowiki>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.</nowiki>}}
*<span style="color:#000000;">'''number CachedRecords HasGetter'''&nbsp; - How many records does the DataCache currently hold</span>  
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>MakeContext</nowiki>|Description=<nowiki>Make the current DataCache the context DataCache</nowiki>}}
*<span style="color:#000000;">'''array ColumnNames HasGetter'''&nbsp; - List of Column names</span>  
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Save</nowiki>|Description=<nowiki>Save the DataCache</nowiki>}}
*<span style="color:#000000;">'''bool Completed HasGetter HasSetter''' - Get/Set include completed</span>  
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}}
*<span style="color:#000000;">'''bool Deleted HasGetter HasSetter''' - Get/Set include deleted</span>  
+
|Properties=
*<span style="color:#000000;">'''string Description HasGetter HasSetter''' - Get/Set description of the DataCache</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>AutoUpdate</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set Auto Update</nowiki>}}
*<span style="color:#000000;">'''bool Disabled HasGetter HasSetter''' - Get/Set include disabled</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>BuildWithWeight</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set if the DataCache should be built using weights</nowiki>}}
*<span style="color:#000000;">'''bool InterviewFailed HasGetter HasSetter''' - Get/Set include marked as interview failed</span>  
+
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>CachedRecords</nowiki>|HasGetter=1|Description=<nowiki>How many records does the DataCache currently hold</nowiki>}}
*<span style="color:#000000;">'''bool InterviewSucceeded HasGetter HasSetter''' - Get/Set include marked as interview succeeded</span>  
+
{{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>ColumnNames</nowiki>|HasGetter=1|Description=<nowiki>List of Column names</nowiki>}}
*<span style="color:#000000;">'''bool IsOutOfDate HasGetter'''&nbsp; - Does the DataCache need to be rebuilt to have the correct content</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Completed</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include completed</nowiki>}}
*<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>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Deleted</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include deleted</nowiki>}}
*<span style="color:#000000;">'''DateTime LastUpdated HasGetter'''&nbsp; - Time of the last rebuild</span>  
+
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Description</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set description of the DataCache</nowiki>}}
*<span style="color:#000000;">'''string Name HasGetter HasSetter''' - Name of the DataCache resource</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Disabled</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include disabled</nowiki>}}
*<span style="color:#000000;">'''bool Normal HasGetter HasSetter''' - Get/Set include normal</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>InterviewFailed</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include marked as interview failed</nowiki>}}
*<span style="color:#000000;">'''bool NotStarted HasGetter HasSetter''' - Get/Set include those not yet started</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>InterviewSucceeded</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include marked as interview succeeded</nowiki>}}
*<span style="color:#000000;">'''bool OutsideTarget HasGetter HasSetter''' - Get/Set include those marked outside target</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IsOutOfDate</nowiki>|HasGetter=1|Description=<nowiki>Does the DataCache need to be rebuilt to have the correct content</nowiki>}}
*<span style="color:#000000;">'''bool Partly HasGetter HasSetter''' - Get/Set include partly completed</span>  
+
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Language</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the iso code used in building the items that depend on a specific language</nowiki>}}
*<span style="color:#000000;">'''array QuestionnaireIds HasGetter'''&nbsp; - List of the questionnaires used in the DataCache</span>  
+
{{CGscriptProperties_Template|ReturnType=DateTime|Name=<nowiki>LastUpdated</nowiki>|HasGetter=1|Description=<nowiki>Time of the last rebuild</nowiki>}}
*<span style="color:#000000;">'''number QuestionnaireTemplateId HasGetter'''&nbsp; - The resource id of the questionnaire template used in the DataCache</span>  
+
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Name of the DataCache resource</nowiki>}}
*<span style="color:#000000;">'''bool QuotaFull HasGetter HasSetter''' - Get/Set include those with full quota</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Normal</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include normal</nowiki>}}
*<span style="color:#000000;">'''number ResourceId HasGetter'''&nbsp; - The Id of the DataCache</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>NotStarted</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include those not yet started</nowiki>}}
*<span style="color:#000000;">'''bool Test HasGetter HasSetter''' - Get/Set include those marked as test</span>  
+
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
*<span style="color:#000000;">'''number UpdateFrequence HasGetter HasSetter''' - Get/Set Update Frequence in minutes</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>OutsideTarget</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include those marked outside target</nowiki>}}
*<span style="color:#000000;">'''string ObjectTypeName HasGetter'''&nbsp; - The name of the type of object</span>  
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Partly</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include partly completed</nowiki>}}
*<span style="color:#000000;">'''TypeInformation TypeInformation HasGetter'''&nbsp; - Get information about this class</span>  
+
{{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>QuestionnaireIds</nowiki>|HasGetter=1|Description=<nowiki>List of the questionnaires used in the DataCache</nowiki>}}
 
+
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>QuestionnaireTemplateId</nowiki>|HasGetter=1|Description=<nowiki>The resource id of the questionnaire template used in the DataCache</nowiki>}}
&nbsp;
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>QuotaFull</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include those with full quota</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>ResourceId</nowiki>|HasGetter=1|Description=<nowiki>The Id of the DataCache</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Test</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set include those marked as test</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>UpdateFrequence</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set Update Frequence in minutes</nowiki>}}
 +
}}
  
 
==== <span style="color:#a52a2a;">'''Examples'''</span> ====
 
==== <span style="color:#a52a2a;">'''Examples'''</span> ====

Revision as of 09:42, 22 September 2011

DataCacheSpecification



Represents a DataCache specification.

Constructors

  • () - Instanciate a new instance using the current context datacache
  • (number ResourceId "Resource Id of the DataCache") - Instanciate a new instance using the resource id of a datacache
  • (string ResourceId "Resource name of the new DataCache", array Questionnaire Ids "List of Questionnaires to use in the creation. Must all belong to same template") - Create a new datacache using quick setup

Methods

  • Empty AddFilter(string filterQuestionLabel "Question to apply filter to. If empty, then clear current filters", string filterValue "Value of the filter") - Add a filter to the DataCache
  • AnyType EvalWhere(string whereExpression "The expression to execute. It must contain 'where' and NOT start with a equal sign, and have 1 and only one semicolon in it") - Evaluate a single where expression up against the current DataCache
  • Dictionary EvalWhere(Dictionary whereExpressions "The expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it") - 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.
  • Dictionary EvalWhere(Dictionary whereExpressions "The expressions to execute. They must contain 'where' and MAY start with a equal sign, and have 1 and only one semicolon in it", string weight "Column name of the weight to use in filter") - 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.
  • Empty MakeContext() - Make the current DataCache the context DataCache
  • Empty Save() - Save the DataCache
  • string ToString() - The string representation of the object.

Properties

  • bool AutoUpdate { get; set; } - Get/Set Auto Update
  • bool BuildWithWeight { get; set; } - Get/Set if the DataCache should be built using weights
  • number CachedRecords { get; } - How many records does the DataCache currently hold
  • array ColumnNames { get; } - List of Column names
  • bool Completed { get; set; } - Get/Set include completed
  • bool Deleted { get; set; } - Get/Set include deleted
  • string Description { get; set; } - Get/Set description of the DataCache
  • bool Disabled { get; set; } - Get/Set include disabled
  • bool InterviewFailed { get; set; } - Get/Set include marked as interview failed
  • bool InterviewSucceeded { get; set; } - Get/Set include marked as interview succeeded
  • bool IsOutOfDate { get; } - Does the DataCache need to be rebuilt to have the correct content
  • string Language { get; set; } - Get/Set the iso code used in building the items that depend on a specific language
  • DateTime LastUpdated { get; } - Time of the last rebuild
  • string Name { get; set; } - Name of the DataCache resource
  • bool Normal { get; set; } - Get/Set include normal
  • bool NotStarted { get; set; } - Get/Set include those not yet started
  • string ObjectTypeName { get; } - The name of the type of object.
  • bool OutsideTarget { get; set; } - Get/Set include those marked outside target
  • bool Partly { get; set; } - Get/Set include partly completed
  • array QuestionnaireIds { get; } - List of the questionnaires used in the DataCache
  • number QuestionnaireTemplateId { get; } - The resource id of the questionnaire template used in the DataCache
  • bool QuotaFull { get; set; } - Get/Set include those with full quota
  • number ResourceId { get; } - The Id of the DataCache
  • bool Test { get; set; } - Get/Set include those marked as test
  • TypeInformation TypeInformation { get; } - Get information about this class.
  • number UpdateFrequence { get; set; } - Get/Set Update Frequence in minutes


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