source: branches/work_311/output/RoleTable.cpp @ 524

Revision 524, 3.1 KB checked in by jls17, 6 years ago (diff)
  • changed most of the GetURL calls to use the new URLLink functionality instead
Line 
1//Copyright (C) 2009 Stefan Nerlich | stefan.nerlich@hotmail.com
2//
3//This file is part of ARInside.
4//
5//    ARInside is free software: you can redistribute it and/or modify
6//    it under the terms of the GNU General Public License as published by
7//    the Free Software Foundation, version 2 of the License.
8//
9//    ARInside is distributed in the hope that it will be useful,
10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12//    GNU General Public License for more details.
13//
14//    You should have received a copy of the GNU General Public License
15//    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
16
17#include "stdafx.h"
18#include "RoleTable.h"
19#include "URLLink.h"
20
21using namespace OUTPUT;
22using namespace rapidjson;
23
24CRoleTable::CRoleTable(CARInside &arIn)
25: CObjectTable("roleList", "TblObjectList")
26{
27        this->pInside = &arIn;
28
29        tbl.AddColumn(25, "Role Name");
30        tbl.AddColumn(5, "RoleID");
31        tbl.AddColumn(30, "Application");       
32        tbl.AddColumn(20, "Modified");
33        tbl.AddColumn(20, "By");
34}
35
36CRoleTable::~CRoleTable(void)
37{
38}
39
40void CRoleTable::AddRow(CARRole &role, int rootLevel)
41{
42        CTableRow tblRow("");
43        tblRow.AddCell( CTableCell(URLLink(role, rootLevel)));
44        tblRow.AddCell( CTableCell(role.GetRoleId()));
45        tblRow.AddCell( CTableCell(this->pInside->LinkToContainer(role.GetApplicationName(), rootLevel)));
46        tblRow.AddCell( CTableCell(CUtil::DateTimeToHTMLString(role.GetTimestamp())));
47        tblRow.AddCell( CTableCell(this->pInside->LinkToUser(role.GetLastChanged(), rootLevel)));
48        this->tbl.AddRow(tblRow);
49}
50
51void CRoleTable::AddRowJson(CARRole &role, int rootLevel)
52{
53        if (!role.Exists()) return;
54
55        CARContainer app(role.GetApplicationName());
56
57        CPageParams roleDetailPage(PAGE_DETAILS, &role);
58        CPageParams appDetailPage(PAGE_DETAILS, &app);
59        Document::AllocatorType &alloc = doc.GetAllocator();
60
61        Value roleRow;
62        roleRow.SetArray();
63
64        // now build the needed temporary variables
65        string strName = role.GetName();
66        string strAppName = role.GetApplicationName();
67        string strModifiedDate = CUtil::DateTimeToString(role.GetTimestamp());
68        string strLink = CWebUtil::GetRelativeURL(rootLevel, roleDetailPage);
69        string strAppLink = (app.Exists() ? CWebUtil::GetRelativeURL(rootLevel, appDetailPage) : "");
70
71        Value valName(strName.c_str(), static_cast<SizeType>(strName.size()), alloc);
72        Value valAppName(strAppName.c_str(), static_cast<SizeType>(strAppName.size()), alloc);
73        Value valModifiedDate(strModifiedDate.c_str(), static_cast<SizeType>(strModifiedDate.size()), alloc);
74        Value valLink(strLink.c_str(), static_cast<SizeType>(strLink.size()), alloc);
75        Value valAppLink(strAppLink.c_str(), static_cast<SizeType>(strAppLink.size()), alloc);
76
77        // add everything to the row
78        roleRow.PushBack(role.GetRoleId(), alloc);
79        roleRow.PushBack(valName, alloc);
80        roleRow.PushBack(valAppName, alloc);
81        roleRow.PushBack(valModifiedDate, alloc);
82        roleRow.PushBack(role.GetLastChanged(), alloc);
83        roleRow.PushBack(valLink, alloc);
84        roleRow.PushBack(valAppLink, alloc);
85
86        // add the row to the document
87        doc.PushBack(roleRow, alloc);   
88
89}
Note: See TracBrowser for help on using the repository browser.