OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Project.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <cstdint>
5#include <vector>
6#include <bsoncxx/json.hpp>
7#include <bsoncxx/types.hpp>
8
9#include "User.h"
10#include "Group.h"
11#include "MongoUserFunctions.h"
12#include "MongoGroupFunctions.h"
13
15{
16
17public:
18 Project(const bsoncxx::v_noabi::document::view& _view, mongocxx::client& _userClient)
19 {
20 _id = _view["_id"].get_oid().value;
21 name = std::string(_view["project_name"].get_utf8().value.data());
22
23 roleName = std::string(_view["project_role_name"].get_utf8().value.data());
24 collectionName = std::string(_view["collection_name"].get_utf8().value.data());
25 createdOn = _view["created_on"].get_date();
26
27 std::string userId = std::string(_view["created_by"].get_utf8().value.data());
28
30
31 auto groupsArr = _view["groups"].get_array().value;
32
33 for (const auto& groupId : groupsArr)
34 {
35 std::string currId = std::string(groupId.get_utf8().value.data());
36
37 Group currentGroup = MongoGroupFunctions::getGroupDataById(currId, _userClient);
38 groups.push_back(currentGroup);
39 }
40 }
41 Project() = default;
42
43 bsoncxx::oid _id;
44 std::string name = "";
45 std::string type = "";
46 std::string roleName ="";
47 std::string collectionName = "";
48 bsoncxx::types::b_date createdOn{ std::chrono::system_clock::now() };
50 std::vector<Group> groups{};
51 int version = -1;
52 bsoncxx::types::b_date lastAccessedOn{ std::chrono::system_clock::now() };
53
54
55};
56
Definition Group.h:20
Definition Project.h:15
bsoncxx::types::b_date createdOn
Definition Project.h:48
std::string collectionName
Definition Project.h:47
std::vector< Group > groups
Definition Project.h:50
std::string roleName
Definition Project.h:46
bsoncxx::oid _id
Definition Project.h:43
std::string name
Definition Project.h:44
bsoncxx::types::b_date lastAccessedOn
Definition Project.h:52
Project(const bsoncxx::v_noabi::document::view &_view, mongocxx::client &_userClient)
Definition Project.h:18
int version
Definition Project.h:51
Project()=default
User creatingUser
Definition Project.h:49
std::string type
Definition Project.h:45
Definition User.h:20
Group getGroupDataById(std::string groupId, mongocxx::client &userClient)
Definition MongoGroupFunctions.cpp:202
User getUserDataThroughId(std::string userId, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:225