otsdaq  3.06.00
TableViewColumnInfo.cc
1 #include "otsdaq/TableCore/TableViewColumnInfo.h"
2 
3 #include "otsdaq/Macros/CoutMacros.h"
4 #include "otsdaq/Macros/StringMacros.h"
5 
6 #include <iostream>
7 #include <sstream>
8 #include <stdexcept>
9 
10 #include "otsdaq/TableCore/TableView.h"
11 
12 using namespace ots;
13 
14 // clang-format off
15 
17 const std::string TableViewColumnInfo::TYPE_UID = "UID";
18 
19 const std::string TableViewColumnInfo::TYPE_DATA = "Data";
20 const std::string TableViewColumnInfo::TYPE_UNIQUE_DATA = "UniqueData";
21 const std::string TableViewColumnInfo::TYPE_UNIQUE_GROUP_DATA = "UniqueGroupData";
22 const std::string TableViewColumnInfo::TYPE_MULTILINE_DATA = "MultilineData";
23 const std::string TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA = "FixedChoiceData";
24 const std::string TableViewColumnInfo::TYPE_BITMAP_DATA = "BitMap";
25 
26 const std::string TableViewColumnInfo::TYPE_ON_OFF = "OnOff";
27 const std::string TableViewColumnInfo::TYPE_TRUE_FALSE = "TrueFalse";
28 const std::string TableViewColumnInfo::TYPE_YES_NO = "YesNo";
29 
30 const std::string TableViewColumnInfo::TYPE_START_CHILD_LINK = "ChildLink";
31 const std::string TableViewColumnInfo::TYPE_START_CHILD_LINK_UID = "ChildLinkUID";
32 const std::string TableViewColumnInfo::TYPE_START_CHILD_LINK_GROUP_ID = "ChildLinkGroupID";
33 const std::string TableViewColumnInfo::TYPE_START_GROUP_ID = "GroupID";
34 const std::string TableViewColumnInfo::TYPE_COMMENT = "Comment";
35 const std::string TableViewColumnInfo::TYPE_AUTHOR = "Author";
36 const std::string TableViewColumnInfo::TYPE_TIMESTAMP = "Timestamp";
39 const std::string TableViewColumnInfo::DATATYPE_NUMBER = "NUMBER";
40 const std::string TableViewColumnInfo::DATATYPE_STRING = "STRING";
41 const std::string TableViewColumnInfo::DATATYPE_TIME = "TIMESTAMP WITH TIMEZONE";
42 
43 const std::string TableViewColumnInfo::TYPE_VALUE_YES = "Yes";
44 const std::string TableViewColumnInfo::TYPE_VALUE_NO = "No";
45 const std::string TableViewColumnInfo::TYPE_VALUE_TRUE = "True";
46 const std::string TableViewColumnInfo::TYPE_VALUE_FALSE = "False";
47 const std::string TableViewColumnInfo::TYPE_VALUE_ON = "On";
48 const std::string TableViewColumnInfo::TYPE_VALUE_OFF = "Off";
49 
50 const std::string TableViewColumnInfo::DATATYPE_STRING_DEFAULT = "DEFAULT";
51 const std::string TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT = "No comment.";
52 const std::string TableViewColumnInfo::DATATYPE_COMMENT_OLD_DEFAULT = "No Comment";
53 const std::string TableViewColumnInfo::DATATYPE_BOOL_DEFAULT = "0";
54 const std::string TableViewColumnInfo::DATATYPE_NUMBER_DEFAULT = "0";
55 
56 const std::string TableViewColumnInfo::DATATYPE_NUMBER_MIN_DEFAULT = "";
57 const std::string TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT = "";
58 
59 const std::string TableViewColumnInfo::DATATYPE_TIME_DEFAULT = "0";
60 const std::string TableViewColumnInfo::DATATYPE_LINK_DEFAULT = "NO_LINK";
61 
62 const std::string TableViewColumnInfo::COL_NAME_STATUS = "Status";
63 const std::string TableViewColumnInfo::COL_NAME_ENABLED = "Enabled";
64 const std::string TableViewColumnInfo::COL_NAME_PRIORITY = "Priority";
65 const std::string TableViewColumnInfo::COL_NAME_COMMENT = "CommentDescription";
66 const std::string TableViewColumnInfo::COL_NAME_AUTHOR = "Author";
67 const std::string TableViewColumnInfo::COL_NAME_CREATION = "RecordInsertionTime";
68 
69 // clang-format on
70 
71 //==============================================================================
75 TableViewColumnInfo::TableViewColumnInfo(const std::string& type,
76  const std::string& name,
77  const std::string& storageName,
78  const std::string& dataType,
79  const std::string* defaultValue,
80  const std::string& dataChoicesCSV,
81  const std::string* minValue,
82  const std::string* maxValue,
83  std::string* capturedExceptionString)
84  : type_(type)
85  , name_(name)
86  , storageName_(storageName)
87  , dataType_(/*convert antiquated*/ dataType == "VARCHAR2" ? DATATYPE_STRING
88  : dataType)
89  , defaultValue_(defaultValue ? *defaultValue
90  : getDefaultDefaultValue(type_, dataType_))
91  , // if default pointer, take input default value
92  dataChoices_(getDataChoicesFromString(dataChoicesCSV))
93  , minValue_(minValue ? ((*minValue) == "null" ? "" : (*minValue))
94  : getMinDefaultValue(dataType_))
95  , // there was a time during JS GUI development when "null" was being injected into data files rather than empty strings. Because this member variable is
96  // constant, this is the single cleansing point.
97  maxValue_(maxValue ? ((*maxValue) == "null" ? "" : (*maxValue))
98  : getMaxDefaultValue(dataType_))
99  , // there was a time during JS GUI development when "null" was being injected into data files rather than empty strings. Because this member variable is
100  // constant, this is the single cleansing point.
101  bitMapInfoP_(nullptr)
102 {
103  //keep lightweight because tables+columns get copied around a lot
104 
105  // verify type
106  if((type_ != TYPE_UID) && (type_ != TYPE_DATA) && (type_ != TYPE_UNIQUE_DATA) &&
107  (type_ != TYPE_UNIQUE_GROUP_DATA) && (type_ != TYPE_MULTILINE_DATA) &&
108  (type_ != TYPE_FIXED_CHOICE_DATA) && (type_ != TYPE_BITMAP_DATA) &&
109  (type_ != TYPE_ON_OFF) && (type_ != TYPE_TRUE_FALSE) && (type_ != TYPE_YES_NO) &&
110  (type_ != TYPE_COMMENT) && (type_ != TYPE_AUTHOR) && (type_ != TYPE_TIMESTAMP) &&
112  {
113  __SS__ << "The type for column " << name_ << " is " << type_
114  << ", while the only accepted types are: " << TYPE_DATA << " "
115  << TYPE_UNIQUE_DATA << " " << TYPE_UNIQUE_GROUP_DATA << " "
116  << TYPE_MULTILINE_DATA << " " << TYPE_FIXED_CHOICE_DATA << " " << TYPE_UID
117  << " " << TYPE_ON_OFF << " " << TYPE_TRUE_FALSE << " " << TYPE_YES_NO
118  << " " << TYPE_START_CHILD_LINK << "-* " << TYPE_START_CHILD_LINK_UID
119  << "-* " << TYPE_START_CHILD_LINK_GROUP_ID << "-* " << TYPE_START_GROUP_ID
120  << "-* " << std::endl;
121  if(capturedExceptionString)
122  *capturedExceptionString = ss.str();
123  else
124  __SS_THROW__;
125  }
126  else if(capturedExceptionString)
127  *capturedExceptionString = ""; // indicates no error found
128 
129  // enforce that type only
130  // allows letters, numbers, dash, underscore
131  for(unsigned int i = 0; i < type_.size(); ++i)
132  if(!((type_[i] >= 'A' && type_[i] <= 'Z') ||
133  (type_[i] >= 'a' && type_[i] <= 'z') ||
134  (type_[i] >= '0' && type_[i] <= '9') ||
135  (type_[i] == '-' || type_[i] == '_' || type_[i] == '.' || type_[i] == ' ')))
136  {
137  __SS__ << "The column type for column " << name_ << " is '" << type_
138  << "'. Column types must contain only letters, numbers, "
139  << "dashes, underscores, periods, and spaces." << std::endl;
140  if(capturedExceptionString)
141  *capturedExceptionString += ss.str();
142  else
143  __SS_THROW__;
144  }
145 
146  // verify data type
147  if((dataType_ != DATATYPE_NUMBER) && (dataType_ != DATATYPE_STRING) &&
148  (dataType_ != DATATYPE_TIME))
149  {
150  __SS__ << "The data type for column " << name_ << " is " << dataType_
151  << ", while the only accepted types are: " << DATATYPE_NUMBER << " "
152  << DATATYPE_STRING << " " << DATATYPE_TIME << std::endl;
153  if(capturedExceptionString)
154  *capturedExceptionString += ss.str();
155  else
156  __SS_THROW__;
157  }
158 
159  if(type_ == TYPE_BITMAP_DATA && dataType_ != DATATYPE_STRING)
160  {
161  __SS__ << "The data type for column " << name_ << " is '" << dataType_
162  << "'. Bitmap columns must have a data type of '" << DATATYPE_STRING
163  << "'." << std::endl;
164  if(capturedExceptionString)
165  *capturedExceptionString += ss.str();
166  else
167  __SS_THROW__;
168  }
169 
170  if(dataType_.size() == 0)
171  {
172  __SS__ << "The data type for column " << name_ << " is '" << dataType_
173  << "'. Data types must contain at least 1 character." << std::endl;
174  if(capturedExceptionString)
175  *capturedExceptionString += ss.str();
176  else
177  __SS_THROW__;
178  }
179 
180  // enforce that data type only
181  // allows letters, numbers, dash, underscore
182  for(unsigned int i = 0; i < dataType_.size(); ++i)
183  if(!((dataType_[i] >= 'A' && dataType_[i] <= 'Z') ||
184  (dataType_[i] >= 'a' && dataType_[i] <= 'z') ||
185  (dataType_[i] >= '0' && dataType_[i] <= '9') ||
186  (dataType_[i] == '-' || dataType_[i] == '_' || dataType_[i] == ' ')))
187  {
188  __SS__ << "The data type for column " << name_ << " is '" << dataType_
189  << "'. Data types must contain only letters, numbers, "
190  << "dashes, underscores, and spaces." << std::endl;
191  if(capturedExceptionString)
192  *capturedExceptionString += ss.str();
193  else
194  __SS_THROW__;
195  }
196 
197  if(name_.size() == 0)
198  {
199  __SS__ << "There is a column named " << name_
200  << "'. Column names must contain at least 1 character." << std::endl;
201  if(capturedExceptionString)
202  *capturedExceptionString += ss.str();
203  else
204  __SS_THROW__;
205  }
206 
207  // enforce that col name only
208  // allows letters, numbers, dash, underscore
209  for(unsigned int i = 0; i < name_.size(); ++i)
210  if(!((name_[i] >= 'A' && name_[i] <= 'Z') ||
211  (name_[i] >= 'a' && name_[i] <= 'z') ||
212  (name_[i] >= '0' && name_[i] <= '9') ||
213  (name_[i] == '-' || name_[i] == '_')))
214  {
215  __SS__ << "There is a column named " << name_
216  << "'. Column names must contain only letters, numbers, "
217  << "dashes, and underscores." << std::endl;
218  if(capturedExceptionString)
219  *capturedExceptionString += ss.str();
220  else
221  __SS_THROW__;
222  }
223 
224  if(storageName_.size() == 0)
225  {
226  __SS__ << "The storage name for column " << name_ << " is '" << storageName_
227  << "'. Storage names must contain at least 1 character." << std::endl;
228  if(capturedExceptionString)
229  *capturedExceptionString += ss.str();
230  else
231  __SS_THROW__;
232  }
233 
234  // enforce that col storage name only
235  // allows capital letters, numbers, dash, underscore
236  for(unsigned int i = 0; i < storageName_.size(); ++i)
237  if(!((storageName_[i] >= 'A' && storageName_[i] <= 'Z') ||
238  (storageName_[i] >= '0' && storageName_[i] <= '9') ||
239  (storageName_[i] == '-' || storageName_[i] == '_')))
240  {
241  __SS__ << "The storage name for column " << name_ << " is '" << storageName_
242  << "'. Storage names must contain only capital letters, numbers,"
243  << "dashes, and underscores." << std::endl;
244  if(capturedExceptionString)
245  *capturedExceptionString += ss.str();
246  else
247  __SS_THROW__;
248  }
249 
250  try
251  {
252  extractBitMapInfo();
253  }
254  catch(std::runtime_error& e)
255  {
256  if(capturedExceptionString)
257  *capturedExceptionString += e.what();
258  else
259  throw;
260  }
261 } //end TableViewColumnInfo() constructor
262 
263 //==============================================================================
264 std::vector<std::string> TableViewColumnInfo::getDataChoicesFromString(
265  const std::string& dataChoicesCSV) const
266 {
267  std::vector<std::string> dataChoices;
268  // build data choices vector from URI encoded data
269  //__COUT__ << "dataChoicesCSV " << dataChoicesCSV << std::endl;
270  {
271  std::istringstream f(dataChoicesCSV);
272  std::string s;
273  while(getline(f, s, ','))
274  dataChoices.push_back(StringMacros::decodeURIComponent(s));
275  // for(const auto &dc: dataChoices_)
276  // __COUT__ << dc << std::endl;
277  }
278  return dataChoices;
279 } // end getDataChoicesFromString()
280 
281 //==============================================================================
282 void TableViewColumnInfo::extractBitMapInfo()
283 {
284  // create BitMapInfo if this is a bitmap column
285  if(type_ == TYPE_BITMAP_DATA)
286  {
287  if(bitMapInfoP_)
288  delete bitMapInfoP_;
289  bitMapInfoP_ = new BitMapInfo();
290 
291  // extract bitMapInfo parameters:
292  // must match TableEditor js handling:
293 
294  // [ //types => 0:string, 1:bool (default no),
295  // //2:bool (default yes), 3:color
296  //
297  // 0 0,//"Number of Rows",
298  // 1 0,//"Number of Columns",
299  // 2 0,//"Cell Bit-field Size",
300  // 3 0,//"Min-value Allowed",
301  // 4 0,//"Max-value Allowed",
302  // 5 0,//"Value step-size Allowed",
303  // 6 0,//"Display Aspect H:W",
304  // 7 3,//"Min-value Cell Color",
305  // 8 3,//"Mid-value Cell Color",
306  // 9 3,//"Max-value Cell Color",
307  // 10 3,//"Absolute Min-value Cell Color",
308  // 11 3,//"Absolute Max-value Cell Color",
309  // 12 1,//"Display Rows in Ascending Order",
310  // 13 2,//"Display Columns in Ascending Order",
311  // 14 1,//"Snake Double Rows",
312  // 15 1,//"Snake Double Columns",
313  // 16 1,//"Allow Floating Point",
314  // 17 0 //"Value Map to Strings"
315  // ];
316 
317  if(dataChoices_.size() < 16)
318  {
319  __SS__ << "The Bit-Map data parameters for column " << name_
320  << " should be size 16, but is size " << dataChoices_.size()
321  << ". Bit-Map parameters should be e.g. rows, cols, cellBitSize, and "
322  "min, "
323  "mid, max color, etc."
324  << std::endl;
325  __SS_THROW__;
326  }
327  if(dataChoices_.size() > 18)
328  {
329  __SS__ << "The Bit-Map data parameters for column " << name_
330  << " should be size 18, but is size " << dataChoices_.size()
331  << ". Bit-Map parameters should be e.g. rows, cols, cellBitSize, and "
332  "min, "
333  "mid, max color, etc."
334  << std::endl;
335  __SS_THROW__;
336  }
337 
338  sscanf(dataChoices_[0].c_str(), "%u", &(bitMapInfoP_->numOfRows_));
339  sscanf(dataChoices_[1].c_str(), "%u", &(bitMapInfoP_->numOfColumns_));
340  sscanf(dataChoices_[2].c_str(), "%u", &(bitMapInfoP_->cellBitSize_));
341 
342  sscanf(dataChoices_[3].c_str(), "%lu", &(bitMapInfoP_->minValue_));
343  sscanf(dataChoices_[4].c_str(), "%lu", &(bitMapInfoP_->maxValue_));
344  sscanf(dataChoices_[5].c_str(), "%lu", &(bitMapInfoP_->stepValue_));
345 
346  bitMapInfoP_->aspectRatio_ = dataChoices_[6];
347  bitMapInfoP_->minColor_ = dataChoices_[7];
348  bitMapInfoP_->midColor_ = dataChoices_[8];
349  bitMapInfoP_->maxColor_ = dataChoices_[9];
350  bitMapInfoP_->absMinColor_ = dataChoices_[10];
351  bitMapInfoP_->absMaxColor_ = dataChoices_[11];
352 
353  bitMapInfoP_->rowsAscending_ = dataChoices_[12] == "Yes" ? 1 : 0;
354  bitMapInfoP_->colsAscending_ = dataChoices_[13] == "Yes" ? 1 : 0;
355  bitMapInfoP_->snakeRows_ = dataChoices_[14] == "Yes" ? 1 : 0;
356  bitMapInfoP_->snakeCols_ = dataChoices_[15] == "Yes" ? 1 : 0;
357 
358  bitMapInfoP_->snakeCols_ = dataChoices_[15] == "Yes" ? 1 : 0;
359  if(dataChoices_.size() > 16)
360  bitMapInfoP_->floatingPoint_ = dataChoices_[16] == "Yes" ? 1 : 0;
361  if(dataChoices_.size() > 17)
362  bitMapInfoP_->mapToStrings_ = dataChoices_[17];
363 
364  if(bitMapInfoP_->floatingPoint_ &&
365  bitMapInfoP_->cellBitSize_ != 32) //check floating point
366  {
367  __SS__ << "Illegal Bit-Map data parameters for column " << name_
368  << " - if floating point is allowed, the Bit-field size must be 32."
369  << std::endl;
370  __SS_THROW__;
371  }
372 
373  if(bitMapInfoP_->mapToStrings_ != "" &&
374  bitMapInfoP_->mapToStrings_ != TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
375  {
376  if(bitMapInfoP_->floatingPoint_)
377  {
378  __SS__ << "Illegal Bit-Map data parameters for column " << name_
379  << " - if floating point is allowed, then Value Map to Strings "
380  "must be empty or set to 'DEFAULT.' "
381  << "Please disable floating point or clear the Value Map to "
382  "Strings value."
383  << std::endl;
384  __SS_THROW__;
385  }
386  bitMapInfoP_->mapsToStrings_ = true;
387  }
388  else
389  bitMapInfoP_->mapsToStrings_ = false;
390  }
391 } //end extractBitMapInfo()
392 
393 //==============================================================================
395 TableViewColumnInfo::TableViewColumnInfo(void) {}
396 
397 //==============================================================================
398 TableViewColumnInfo::TableViewColumnInfo(
399  const TableViewColumnInfo& c) // copy constructor because of bitmap pointer
400  : type_(c.type_)
401  , name_(c.name_)
402  , storageName_(c.storageName_)
403  , dataType_(c.dataType_)
404  , defaultValue_(c.defaultValue_)
405  , dataChoices_(c.dataChoices_)
406  , minValue_(c.minValue_)
407  , maxValue_(c.maxValue_)
408  , bitMapInfoP_(nullptr)
409 {
410  // extract bitmap info if necessary
411  extractBitMapInfo();
412 } // end copy constructor
413 
414 //==============================================================================
416  const TableViewColumnInfo&) // assignment operator because of bitmap pointer
417 {
418  __COUT__ << "OPERATOR= COPY CONSTRUCTOR " << std::endl;
419  // Note: Members of the ConfigurationTree are declared constant.
420  // (Refer to comments at top of class declaration for solutions)
421  // So this operator cannot work.. SO I am going to crash just in case it is
422  // called by mistake
423  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
424  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
425  "and initialize another TableViewColumnInfo, rather than assigning to "
426  "an existing TableViewColumnInfo. Crashing now."
427  << std::endl;
428  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
429  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
430  "and initialize another TableViewColumnInfo, rather than assigning to "
431  "an existing TableViewColumnInfo. Crashing now."
432  << std::endl;
433  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
434  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
435  "and initialize another TableViewColumnInfo, rather than assigning to "
436  "an existing TableViewColumnInfo. Crashing now."
437  << std::endl;
438  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
439  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
440  "and initialize another TableViewColumnInfo, rather than assigning to "
441  "an existing TableViewColumnInfo. Crashing now."
442  << std::endl;
443  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
444  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
445  "and initialize another TableViewColumnInfo, rather than assigning to "
446  "an existing TableViewColumnInfo. Crashing now."
447  << std::endl;
448 
449  __COUT__ << StringMacros::stackTrace() << __E__;
450  exit(0);
451  // TableViewColumnInfo* retColInfo = new TableViewColumnInfo();
452  // retColInfo->type_ = c.type_;
453  // retColInfo->name_ = c.name_;
454  // retColInfo->storageName_ = c.storageName_;
455  // retColInfo->dataType_ = c.dataType_;
456  // retColInfo->dataChoices_ = c.dataChoices_;
457  // retColInfo->bitMapInfoP_ = 0;
458 
459  // extract bitmap info if necessary
460  // retColInfo->extractBitMapInfo();
461 
462  extractBitMapInfo();
463  return *this; //*retColInfo;
464 } // end assignment operator
465 
466 //==============================================================================
467 TableViewColumnInfo::~TableViewColumnInfo(void)
468 {
469  if(bitMapInfoP_)
470  delete bitMapInfoP_;
471 } //end destructor
472 
473 //==============================================================================
474 const std::string& TableViewColumnInfo::getType(void) const { return type_; }
475 
476 //==============================================================================
478 const std::string& TableViewColumnInfo::getDefaultValue(void) const
479 {
480  return defaultValue_;
481 }
482 const std::string& TableViewColumnInfo::getMinValue(void) const { return minValue_; }
483 const std::string& TableViewColumnInfo::getMaxValue(void) const { return maxValue_; }
484 
485 //==============================================================================
489  const std::string& type, const std::string& dataType)
490 {
491  if(dataType == TableViewColumnInfo::DATATYPE_STRING)
492  {
493  if(type == TableViewColumnInfo::TYPE_ON_OFF ||
494  type == TableViewColumnInfo::TYPE_TRUE_FALSE ||
495  type == TableViewColumnInfo::TYPE_YES_NO)
496  return (
497  TableViewColumnInfo::DATATYPE_BOOL_DEFAULT); // default to OFF, NO, FALSE
498  else if(TableViewColumnInfo::isChildLink(type)) // call static version
499  return (TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
500  else if(type == TableViewColumnInfo::TYPE_COMMENT)
501  return (TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT);
502  else
503  return (TableViewColumnInfo::DATATYPE_STRING_DEFAULT);
504  }
505  else if(dataType == TableViewColumnInfo::DATATYPE_NUMBER)
506  return (TableViewColumnInfo::DATATYPE_NUMBER_DEFAULT);
507  else if(dataType == TableViewColumnInfo::DATATYPE_TIME)
508  return (TableViewColumnInfo::DATATYPE_TIME_DEFAULT);
509  else
510  {
511  __SS__ << "\tUnrecognized View data type: " << dataType << std::endl;
512  __COUT_ERR__ << "\n" << ss.str();
513  __SS_THROW__;
514  }
515 } // end getDefaultDefaultValue()
516 
517 //==============================================================================
519 const std::string& TableViewColumnInfo::getMinDefaultValue(const std::string& dataType)
520 {
521  if(dataType == TableViewColumnInfo::DATATYPE_STRING)
522  return (TableViewColumnInfo::
523  DATATYPE_NUMBER_MIN_DEFAULT); // default to OFF, NO, FALSE
524 
525  else if(dataType == TableViewColumnInfo::DATATYPE_NUMBER)
526  {
527  return (TableViewColumnInfo::DATATYPE_NUMBER_MIN_DEFAULT);
528  }
529 
530  else if(dataType == TableViewColumnInfo::DATATYPE_TIME)
531  return (TableViewColumnInfo::DATATYPE_NUMBER_MIN_DEFAULT);
532  else
533  {
534  __SS__ << "\tUnrecognized View data type: " << dataType << std::endl;
535  __COUT_ERR__ << "\n" << ss.str();
536  __SS_THROW__;
537  }
538 }
539 
540 //==============================================================================
542 const std::string& TableViewColumnInfo::getMaxDefaultValue(const std::string& dataType)
543 {
544  if(dataType == TableViewColumnInfo::DATATYPE_STRING)
545  return (TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT);
546 
547  else if(dataType == TableViewColumnInfo::DATATYPE_NUMBER)
548  {
549  return (TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT);
550  }
551  else if(dataType == TableViewColumnInfo::DATATYPE_TIME)
552  return (TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT);
553  else
554  {
555  __SS__ << "\tUnrecognized View data type: " << dataType << std::endl;
556  __COUT_ERR__ << "\n" << ss.str();
557  __SS_THROW__;
558  }
559 }
560 
561 //==============================================================================
562 std::vector<std::string> TableViewColumnInfo::getAllTypesForGUI(void)
563 {
564  std::vector<std::string> all;
565  all.push_back(TYPE_DATA);
566  all.push_back(TYPE_UNIQUE_DATA);
567  all.push_back(TYPE_UNIQUE_GROUP_DATA);
568  all.push_back(TYPE_FIXED_CHOICE_DATA);
569  all.push_back(TYPE_MULTILINE_DATA);
570  all.push_back(TYPE_BITMAP_DATA);
571  all.push_back(TYPE_ON_OFF);
572  all.push_back(TYPE_TRUE_FALSE);
573  all.push_back(TYPE_YES_NO);
574  all.push_back(TYPE_START_CHILD_LINK_UID);
575  all.push_back(TYPE_START_CHILD_LINK_GROUP_ID);
576  all.push_back(TYPE_START_CHILD_LINK);
577  all.push_back(TYPE_START_GROUP_ID);
578  return all;
579 } // end getAllTypesForGUI()
580 
581 //==============================================================================
582 std::vector<std::string> TableViewColumnInfo::getAllDataTypesForGUI(void)
583 {
584  std::vector<std::string> all;
585  all.push_back(DATATYPE_STRING);
586  all.push_back(DATATYPE_NUMBER);
587  all.push_back(DATATYPE_TIME);
588  return all;
589 }
590 
591 //==============================================================================
593 std::map<std::pair<std::string, std::string>, std::string>
595 {
596  std::map<std::pair<std::string, std::string>, std::string> all;
597  all[std::pair<std::string, std::string>(DATATYPE_NUMBER, "*")] =
598  DATATYPE_NUMBER_DEFAULT;
599  all[std::pair<std::string, std::string>(DATATYPE_TIME, "*")] = DATATYPE_TIME_DEFAULT;
600 
601  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_ON_OFF)] =
602  DATATYPE_BOOL_DEFAULT;
603  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_TRUE_FALSE)] =
604  DATATYPE_BOOL_DEFAULT;
605  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_YES_NO)] =
606  DATATYPE_BOOL_DEFAULT;
607 
608  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_START_CHILD_LINK)] =
609  DATATYPE_LINK_DEFAULT;
610  all[std::pair<std::string, std::string>(DATATYPE_STRING, "*")] =
611  DATATYPE_STRING_DEFAULT;
612  return all;
613 }
615 //==============================================================================
618 {
619  return (type_ == TYPE_ON_OFF || type_ == TYPE_TRUE_FALSE || type_ == TYPE_YES_NO);
620 } // end isBoolType()
621 
622 //==============================================================================
625 {
626  return (dataType_ == DATATYPE_NUMBER);
627 } // end isBoolType()
628 
629 //==============================================================================
630 const std::string& TableViewColumnInfo::getName(void) const { return name_; }
631 
632 //==============================================================================
633 const std::string& TableViewColumnInfo::getStorageName(void) const
634 {
635  return storageName_;
636 }
637 
638 //==============================================================================
639 const std::string& TableViewColumnInfo::getDataType(void) const { return dataType_; }
640 
641 //==============================================================================
642 const std::vector<std::string>& TableViewColumnInfo::getDataChoices(void) const
643 {
644  return dataChoices_;
645 }
646 
647 //==============================================================================
651 {
652  if(bitMapInfoP_)
653  return *bitMapInfoP_;
654 
655  // throw error at this point!
656  {
657  __SS__ << "getBitMapInfo request for non-BitMap column of type: " << getType()
658  << std::endl;
659  __COUT_ERR__ << "\n" << ss.str();
660  __SS_THROW__;
661  }
662 }
663 
664 //==============================================================================
668 bool TableViewColumnInfo::isChildLink(const std::string& type)
669 {
670  return (type.find(TYPE_START_CHILD_LINK) == 0 &&
671  type.length() > TYPE_START_CHILD_LINK.length() &&
672  type[TYPE_START_CHILD_LINK.length()] == '-');
673 }
674 
675 //==============================================================================
680 {
681  return (type_.find(TYPE_START_CHILD_LINK) == 0 &&
682  type_.length() > TYPE_START_CHILD_LINK.length() &&
683  type_[TYPE_START_CHILD_LINK.length()] == '-');
684 }
685 
686 //==============================================================================
691 {
692  return (type_.find(TYPE_START_CHILD_LINK_UID) == 0 &&
693  type_.length() > TYPE_START_CHILD_LINK_UID.length() &&
694  type_[TYPE_START_CHILD_LINK_UID.length()] == '-');
695 }
696 
697 //==============================================================================
702 {
703  return (type_.find(TYPE_START_CHILD_LINK_GROUP_ID) == 0 &&
704  type_.length() > TYPE_START_CHILD_LINK_GROUP_ID.length() &&
705  type_[TYPE_START_CHILD_LINK_GROUP_ID.length()] == '-');
706 }
707 
708 //==============================================================================
713 {
714  return (type_.find(TYPE_START_GROUP_ID) == 0 &&
715  type_.length() > TYPE_START_GROUP_ID.length() &&
716  type_[TYPE_START_GROUP_ID.length()] == '-');
717 }
718 
719 //==============================================================================
721 bool TableViewColumnInfo::isUID(void) const { return (type_ == TYPE_UID); }
722 
723 //==============================================================================
726 {
727  // note: +1 to skip '-'
728  if(isChildLink())
729  return type_.substr(TYPE_START_CHILD_LINK.length() + 1);
730  else if(isChildLinkUID())
731  return type_.substr(TYPE_START_CHILD_LINK_UID.length() + 1);
732  else if(isChildLinkGroupID())
733  return type_.substr(TYPE_START_CHILD_LINK_GROUP_ID.length() + 1);
734  else if(isGroupID())
735  return type_.substr(TYPE_START_GROUP_ID.length() + 1);
736  else
737  {
738  __SS__
739  << ("Requesting a Link Index from a column that is not a child link member!")
740  << std::endl;
741  __COUT_ERR__ << ss.str();
742  __SS_THROW__;
743  }
744 }
static const std::string DATATYPE_NUMBER
static std::map< std::pair< std::string, std::string >, std::string > getAllDefaultsForGUI(void)
map of datatype,type to default value
std::string getChildLinkIndex(void) const
getChildLinkIndex
TableViewColumnInfo & operator=(const TableViewColumnInfo &c)
assignment operator because of bitmap pointer
bool isUID(void) const
isUID
static const std::string & getDefaultDefaultValue(const std::string &type, const std::string &dataType)
static const std::string TYPE_UID
NOTE: Do NOT put '-' in static const TYPEs because it will mess up javascript handling in the web gui...
static const std::string & getMaxDefaultValue(const std::string &dataType)
function to get max default value
const BitMapInfo & getBitMapInfo(void) const
uses dataChoices CSV fields if type is TYPE_BITMAP_DATA
static const std::string & getMinDefaultValue(const std::string &dataType)
function to get min default value
bool isBoolType(void) const
TODO check if min and max values need a function called getallminmaxforgui or something like that for...
bool isNumberDataType(void) const
isNumberDataType
bool isChildLinkGroupID(void) const
const std::string & getDefaultValue(void) const
returns the configued default value value for this particular column
defines used also by OtsConfigurationWizardSupervisor
static std::string decodeURIComponent(const std::string &data)
static std::string stackTrace(void)
< uses dataChoices CSV fields if type is TYPE_BITMAP_DATA