OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DashboardDescriptor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cstdint>
20 #include <regex>
21 #include <string>
22 #include "../Shared/sqldefs.h"
23 
30 static const std::string SYSTEM_ROLE_TAG("#dash_system_role");
31 
33  int32_t dashboardId;
34  std::string dashboardName;
36  std::string dashboardState;
37  std::string imageHash;
38  std::string updateTime;
39  std::string dashboardMetadata;
40  int32_t userId;
41  std::string user;
43 };
44 
45 inline std::string generate_dashboard_system_rolename(const std::string& db_id,
46  const std::string& dash_id) {
47  return db_id + "_" + dash_id + SYSTEM_ROLE_TAG;
48 }
49 
50 inline std::vector<std::string> parse_underlying_dashboard_objects(
51  const std::string& meta) {
53  std::regex extract_objects_expr(".*table\":\"(.*?)\"");
54  std::smatch match;
55  if (std::regex_search(meta, match, extract_objects_expr)) {
56  const std::string list = match[1];
57  std::vector<std::string> dash_objects;
58  std::regex individual_objects_expr(R"(\w+)");
59  std::sregex_iterator iter(list.begin(), list.end(), individual_objects_expr);
60  std::sregex_iterator end;
61  while (iter != end) {
62  dash_objects.push_back((*iter)[0]);
63  ++iter;
64  }
65  return dash_objects;
66  }
67  return {};
68 }
std::string dashboardSystemRoleName
std::vector< std::string > parse_underlying_dashboard_objects(const std::string &meta)
static const std::string SYSTEM_ROLE_TAG("#dash_system_role")
specifies the content in-memory of a row in the dashboard
std::string generate_dashboard_system_rolename(const std::string &db_id, const std::string &dash_id)