Difference between revisions of "DataCacheSpecification class"

From Catglobe Wiki
Jump to: navigation, search
(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:
<p style="color:#000099; font-size:14px;"><strong>DataCacheSpecification : Represents a Data Cache specification.</strong></p>
+
=== '''DataCacheSpecification&nbsp;: Represents a Data Cache specification.''' ===
<p>
 
&nbsp;</p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Constructors</strong></span></p>
 
<ul>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>()</strong> - Instanciate a new instance using the current datacache context.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>(number ResourceId)</strong> - Instanciate a new instance using the resource id of a datacache</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>(string ResourceName, array QuestionnaireIds)</strong> - 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></li>
 
</ul>
 
<p>
 
<span style="color:#a52a2a;"><strong>Methods</strong></span></p>
 
<ul>
 
<li style="color:#000000;">
 
<span style="color: rgb(0, 0, 0);"><strong>Empty AddFilter(string filterQuestionLabel, string filterValue)</strong> - 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></li>
 
<li style="color:#000000;">
 
<span style="color: rgb(0, 0, 0);"><strong>AnyType EvalWhere(string whereExpression)</strong> - Evaluate a single where expression up against the current DataCache. whereExpression is an expression to execute. It must contain &#39;where&#39; and NOT start with a equal sign, and have 1 and only one semicolon in it.</span></li>
 
<li style="color:#000000;">
 
<span style="color: rgb(0, 0, 0);"><strong>Dictionary EvalWhere(Dictionary whereExpressions)</strong> - 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 &#39;where&#39; and MAY start with a equal sign, and have 1 and only one semicolon in it.</span></li>
 
<li style="color:#000000;">
 
<span style="color: rgb(0, 0, 0);"><strong>Dictionary EvalWhere(Dictionary whereExpressions, string weight)</strong> - 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 &#39;where&#39; 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></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>Empty MakeContext()</strong> - Make the current Data Cache as the DCS Context</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>Empty Save()</strong> - Save the Data Cache but not REBUILD the Data Cache.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>string ToString()</strong> - The string representation of the object.</span></li>
 
</ul>
 
<p>
 
<span style="color:#a52a2a;"><strong>Properties</strong></span></p>
 
<ul>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool AutoUpdate HasGetter HasSetter</strong> - Get/Set Auto Update</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool BuildWithWeight HasGetter HasSetter</strong> - Get/Set if the DataCache should be built using weights</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>number CachedRecords HasGetter</strong>&nbsp; - How many records does the DataCache currently hold</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>array ColumnNames HasGetter</strong>&nbsp; - List of Column names</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Completed HasGetter HasSetter</strong> - Get/Set include completed</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Deleted HasGetter HasSetter</strong> - Get/Set include deleted</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>string Description HasGetter HasSetter</strong> - Get/Set description of the DataCache</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Disabled HasGetter HasSetter</strong> - Get/Set include disabled</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool InterviewFailed HasGetter HasSetter</strong> - Get/Set include marked as interview failed</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool InterviewSucceeded HasGetter HasSetter</strong> - Get/Set include marked as interview succeeded</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool IsOutOfDate HasGetter</strong>&nbsp; - Does the DataCache need to be rebuilt to have the correct content</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>string Language HasGetter HasSetter</strong> - Get/Set the iso code used in building the items that depend on a specific language</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>DateTime LastUpdated HasGetter</strong>&nbsp; - Time of the last rebuild</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>string Name HasGetter HasSetter</strong> - Name of the DataCache resource</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Normal HasGetter HasSetter</strong> - Get/Set include normal</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool NotStarted HasGetter HasSetter</strong> - Get/Set include those not yet started</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool OutsideTarget HasGetter HasSetter</strong> - Get/Set include those marked outside target</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Partly HasGetter HasSetter</strong> - Get/Set include partly completed</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>array QuestionnaireIds HasGetter</strong>&nbsp; - List of the questionnaires used in the DataCache</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>number QuestionnaireTemplateId HasGetter</strong>&nbsp; - The resource id of the questionnaire template used in the DataCache</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool QuotaFull HasGetter HasSetter</strong> - Get/Set include those with full quota</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>number ResourceId HasGetter</strong>&nbsp; - The Id of the DataCache</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Test HasGetter HasSetter</strong> - Get/Set include those marked as test</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>number UpdateFrequence HasGetter HasSetter</strong> - Get/Set Update Frequence in minutes</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>string ObjectTypeName HasGetter</strong>&nbsp; - The name of the type of object</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>TypeInformation TypeInformation HasGetter</strong>&nbsp; - Get information about this class</span></li>
 
</ul>
 
<p>
 
&nbsp;</p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Examples</strong></span></p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Ex1:</strong></span></p>
 
<p>
 
DCS_use(37244952);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;"> //&nbsp; set DCS context</span></p>
 
<p>
 
string e1 = &quot;count() where S_Age == [1] &amp;&amp; M_Travel == [1,2];&quot;;</p>
 
<p>
 
Dictionary d =</p>
 
<p>
 
{</p>
 
<p>
 
&nbsp;&nbsp; &quot;exp1&quot;: &quot;count() where S_Age == [1] &amp;&amp; M_Travel == [1,2];&quot;,</p>
 
<p>
 
&nbsp;&nbsp; &quot;exp2&quot;: &quot;count() where S_Age == [2] &amp;&amp; M_Travel == [1];&quot;</p>
 
<p>
 
};</p>
 
<p>
 
print(DCS_evaluateWhereExpression(e1));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#006400;">//&nbsp; 68</span></p>
 
<p>
 
DataCacheSpecification dcs = new DataCacheSpecification();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">//&nbsp; Represent a DCS which is used as current DCS context</span></p>
 
<p>
 
print(dcs.EvalWhere(e1));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <span style="color:#006400;">//&nbsp; 68</span></p>
 
<p>
 
print(dcs.EvalWhere(d));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp;//&nbsp; {&quot;exp1&quot;: 68, &quot;exp2&quot;: 46}</span></p>
 
<p>
 
&nbsp;</p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Ex2:</strong></span></p>
 
<p>
 
string e1 = &quot;count() where S_Age == [1] &amp;&amp; M_Travel == [1,2];&quot;;</p>
 
<p>
 
Dictionary d =</p>
 
<p>
 
{</p>
 
<p>
 
&nbsp;&nbsp; &quot;exp1&quot;: &quot;count() where S_Age == [1] &amp;&amp; M_Travel == [1,2];&quot;,</p>
 
<p>
 
&nbsp;&nbsp; &quot;exp2&quot;: &quot;count() where S_Age == [2] &amp;&amp; M_Travel == [1];&quot;</p>
 
<p>
 
};</p>
 
<p>
 
DataCacheSpecification dcs = new DataCacheSpecification(37244952);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#006400;">//&nbsp; Represents a DCS which has Resource Id: 37244952</span></p>
 
<p>
 
print(dcs.EvalWhere(e1));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;"> //&nbsp; 68</span></p>
 
<p>
 
print(dcs.EvalWhere(d));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; {&quot;exp1&quot;: 68, &quot;exp2&quot;: 46}</span></p>
 
<p>
 
dcs.MakeContext();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#006400;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; or you can use DCS_use(RID) instead</span></p>
 
<p>
 
print(DCS_evaluateWhereExpression(e1));&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;"><span style="font-size: 10px;">&nbsp; //&nbsp; 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)</span></span></p>
 
<p>
 
dcs.Partly = false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;"> //&nbsp; Not include the partly completed QASs</span></p>
 
<p>
 
dcs.NotStarted = false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp; //&nbsp; Not include the not started QASs</span></p>
 
<p>
 
dcs.Save();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp; //&nbsp; Must save to make the above statements applied on DCS, but this statement does not REBUILD the DCS</span></p>
 
<p>
 
&nbsp;</p>
 
  
 +
&nbsp;
 +
 +
==== <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'''&nbsp; - How many records does the DataCache currently hold</span>
 +
*<span style="color:#000000;">'''array ColumnNames HasGetter'''&nbsp; - 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'''&nbsp; - 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'''&nbsp; - 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'''&nbsp; - List of the questionnaires used in the DataCache</span>
 +
*<span style="color:#000000;">'''number QuestionnaireTemplateId HasGetter'''&nbsp; - 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'''&nbsp; - 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'''&nbsp; - The name of the type of object</span>
 +
*<span style="color:#000000;">'''TypeInformation TypeInformation HasGetter'''&nbsp; - Get information about this class</span>
 +
 +
&nbsp;
 +
 +
==== <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>
 +
&nbsp;
  
 
[[Category:Data_Types_Literals_and_Variables]]
 
[[Category:Data_Types_Literals_and_Variables]]

Revision as of 09:30, 14 September 2011

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