Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

DataCacheSpecification class

From Catglobe Wiki
Revision as of 08:30, 14 September 2011 by Tungocman (talk | contribs)

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