All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PrintManager.cpp
Go to the documentation of this file.
1 // Terralib Data Source Info tool
2 #include <PrintManager.h>
3 
4 bool PrintManager::init(std::string dstype,std::string connstr)
5 {
6  return m_dsi.init(dstype, connstr);
7 }
8 
9 void PrintManager::printAllInfo(bool pkDetails, bool fkDetails, bool ukDetails, bool idxDetails, bool ccDetails)
10 {
11  printHeader();
13  printCatalog(pkDetails, fkDetails, ukDetails, idxDetails, ccDetails);
14 }
15 
17 {
18  printHeader();
19 
20  std::ostringstream output;
21 
22  std::vector<std::string*> names = m_dsi.getDataSetNameList();
23 
24  output << "DataSets:" << std::endl;
25 
26  for(unsigned int i = 0; i < names.size(); i++)
27  output << " " << *names[i] << std::endl;
28 
29  output << std::endl;
30 
31  std::cout << output.str() << std::endl;
32 }
33 
35 {
36 
37  std::ostringstream output;
38 
40 
41  output << "DataSource:" << std::endl << std::endl;
42 
43  if(!dsh.name.empty())
44  {
45  output << " " << dsh.name << std::endl;
46  }
47 
48  output << " " << dsh.type << std::endl;
49 
50  std::cout << output.str() << std::endl;
51 
52 }
53 
54 void PrintManager::printCatalog(bool pkDetails, bool fkDetails, bool ukDetails, bool idxDetails, bool ccDetails)
55 {
56  std::vector<std::string*> vecDataSetName = m_dsi.getDataSetNameList();
57 
58  if(!vecDataSetName.empty())
59  {
60 
61  std::cout << "Catalog:" << std::endl;
62  std::cout << "--------" << std::endl << std::endl;
63 
64  for(unsigned int i = 0; i < vecDataSetName.size(); i++)
65  {
66  printDataSetInfo(*vecDataSetName[i], pkDetails, fkDetails, ukDetails, idxDetails, ccDetails);
67  }
68  }
69 
70 }
71 
73 {
74  std::ostringstream output;
75 
76  std::map<std::string, std::string> mapCap = m_dsi.getCapabilities();
77 
78  if(!mapCap.empty())
79  {
80  output << "Capabilities:" << std::endl << std::endl;
81 
82  std::map<std::string, std::string>::iterator it = mapCap.begin();
83 
84  while(it != mapCap.end())
85  {
86  output << " " << it->first << " = " << it->second << std::endl;
87 
88  ++it;
89  }
90 
91  std::cout << output.str() << std::endl;
92  }
93 }
94 
96 {
97  std::ostringstream output;
98 
99  output << " " << pk.name << std::endl;
100 
101  for(unsigned int i = 0; i < pk.porperties.size(); i++)
102  {
103  output << " " << pk.porperties[i] << std::endl;
104  }
105 
106  std::cout << output.str();
107 
108 }
109 
111 {
112  std::ostringstream output;
113 
114  output << " " << fk.name << std::endl;
115 
116  for(unsigned int i = 0; i < fk.porperties.size(); i++)
117  {
118  output << " " << fk.porperties[i] << std::endl;
119  }
120 
121  std::cout << output.str();
122 }
123 
125 {
126  std::ostringstream output;
127 
128  output << " " << uk.name << std::endl;
129 
130  for(unsigned int i = 0; i < uk.porperties.size(); i++)
131  {
132  output << " " << uk.porperties[i] << std::endl;
133  }
134 
135  std::cout << output.str();
136 }
137 
139 {
140  std::ostringstream output;
141 
142  output << " " << idx.name << " | " << idx.type << std::endl;
143 
144  for(unsigned int i = 0; i < idx.porperties.size(); i++)
145  {
146  output << " " << idx.porperties[i] << std::endl;
147  }
148 
149  std::cout << output.str();
150 }
151 
153 {
154  std::ostringstream output;
155 
156  output << " " << cc.name << std::endl;
157  output << " " << cc.expression << std::endl;
158 
159  std::cout << output.str();
160 }
161 
163 {
164  std::ostringstream params;
165 
166  std::map<std::string, std::vector<std::string>> mapParams = m_dsi.getDataSourceParameters(dsType);
167 
168  std::map<std::string, std::vector<std::string>>::iterator it = mapParams.begin();
169 
170  params << "Data Source Parameters" << std::endl;
171  params << "----------------------" << std::endl << std::endl;
172 
173  while(it != mapParams.end())
174  {
175  params << it->first << std::endl;
176 
177  for(unsigned int i = 0; i < it->second.size(); i++)
178  {
179  params << " " << it->second[i] << std::endl;
180  }
181 
182  params << std::endl;
183 
184  ++it;
185  }
186 
187  std::cout << std::endl << params.str() << std::endl;
188 }
189 
190 void PrintManager::printDataSetInfo(std::vector<std::string> dataSetNameList, bool pkDetails, bool fkDetails, bool ukDetails, bool idxDetails, bool ccDetails)
191 {
192  for(unsigned int i = 0; i < dataSetNameList.size(); i++)
193  {
194  printDataSetInfo(dataSetNameList[i], pkDetails, fkDetails, ukDetails, idxDetails, ccDetails);
195  }
196 }
197 
198 void PrintManager::printDataSetInfo(std::string dataSetName, bool pkDetails, bool fkDetails, bool ukDetails, bool idxDetails, bool ccDetails)
199 {
200  DataSetStruct ds = m_dsi.getDataSetInfo(dataSetName);
201 
202  std::cout << ds.name << std::endl;
203 
204  std::cout << " Has Primary Key: " << (ds.hasPk ? "true" : "false") << std::endl;
205  if(pkDetails && ds.hasPk)
206  {
208  }
209 
210  std::cout << " Number of Foreign Keys: " << ds.vecFkInfo.size() << std::endl;
211  if(fkDetails)
212  {
213  for(unsigned int j = 0; j < ds.vecFkInfo.size(); j++)
214  {
215  printFKDetails(ds.vecFkInfo[j]);
216  }
217  }
218 
219  std::cout << " Number of Unique Keys: " << ds.vecUkInfo.size() << std::endl;
220  if(ukDetails)
221  {
222  for(unsigned int j = 0; j < ds.vecUkInfo.size(); j++)
223  {
224  printUKDetails(ds.vecUkInfo[j]);
225  }
226  }
227 
228  std::cout << " Number of Indexes: " << ds.vecIdxInfo.size() << std::endl;
229  if(idxDetails)
230  {
231  for(unsigned int j = 0; j < ds.vecIdxInfo.size(); j++)
232  {
234  }
235  }
236 
237  std::cout << " Number of Check Constraints: " << ds.vecCcInfo.size() << std::endl;
238  if(ccDetails)
239  {
240  for(unsigned int j = 0; j < ds.vecCcInfo.size(); j++)
241  {
242  printCCDetails(ds.vecCcInfo[j]);
243  }
244  }
245 
246  std::cout << std::endl;
247 }
void printUKDetails(struct UKInfo uk)
Print Unique Key Details.
Struct that stores information about a index using the most common data types.
Definition: DSInfo.h:207
Struct that stores information about a data source header.
Definition: DSInfo.h:240
bool init(std::string dstype, std::string connstr)
Init the application.
Definition: DSInfo.cpp:11
std::vector< std::string > porperties
Foreign Key Properties in a string vector.
Definition: DSInfo.h:192
std::vector< UKInfo > vecUkInfo
Unique Key struct vector.
Definition: DSInfo.h:232
std::vector< std::string > porperties
Unique Key Properties in a string vector.
Definition: DSInfo.h:201
bool init(std::string dstype, std::string connstr)
Init.
Definition: PrintManager.cpp:4
std::string type
Data Source Type.
Definition: DSInfo.h:243
DataSetStruct getDataSetInfo(std::string dataSetName)
Get specific Data Set information.
Definition: DSInfo.cpp:183
void printCapabilities()
Print Data Source Capabilities.
std::vector< std::string > porperties
Primary Key Properties in a string vector.
Definition: DSInfo.h:183
Struct that stores information about a check constraint using the most common data types...
Definition: DSInfo.h:217
std::vector< std::string > porperties
Index Properties in a string vector.
Definition: DSInfo.h:211
std::vector< IdxInfo > vecIdxInfo
Index struct vector.
Definition: DSInfo.h:233
void printHeader()
Print Data Source Header.
void printFKDetails(struct FKInfo fk)
Print Foreign Key Details.
std::string type
Index Type.
Definition: DSInfo.h:210
void printCCDetails(struct CCInfo cc)
Print Check Constraint Details.
std::string name
Index Name.
Definition: DSInfo.h:209
Struct that stores information about a primary key using the most common data types.
Definition: DSInfo.h:180
std::string name
Primary Key Name.
Definition: DSInfo.h:182
void printCatalog(bool pkDetails, bool fkDetails, bool ukDetails, bool idxDetails, bool ccDetails)
Print Data Source Catalog.
void printIdxDetails(struct IdxInfo idx)
Index Details.
void printDataSetInfo(std::vector< std::string > dataSetNameList, bool pkDetails, bool fkDetails, bool ukDetails, bool idxDetails, bool ccDetails)
Print Data Set Informations.
DataSourceHeader getDataSourceHeader()
Get the Data Source Header.
Definition: DSInfo.cpp:252
std::string expression
Check Constraint Expression.
Definition: DSInfo.h:220
std::map< std::string, std::string > getCapabilities()
Get the Data Source Capabilities.
Definition: DSInfo.cpp:266
std::vector< CCInfo > vecCcInfo
Check Constraint struct vector.
Definition: DSInfo.h:234
Struct that stores information about a data set using the most common data types. ...
Definition: DSInfo.h:226
std::string name
Check Constraint Name.
Definition: DSInfo.h:219
void printPKDetails(struct PKInfo pk)
Print Primary Key Details.
void printDataSetNameList()
Print Data Set Name List.
Struct that stores information about a unique key using the most common data types.
Definition: DSInfo.h:198
void printAllInfo(bool pkDetails, bool fkDetails, bool ukDetails, bool idxDetails, bool ccDetails)
Print All Data Source Informations.
Definition: PrintManager.cpp:9
std::map< std::string, std::vector< std::string > > getDataSourceParameters(std::string dataSourceType)
Get Data Source Types connection parameters.
Definition: DSInfo.cpp:278
std::string name
Foreign Key Name.
Definition: DSInfo.h:191
Informations printing manager.
DSInfo m_dsi
DSInfo object.
Definition: PrintManager.h:190
std::vector< std::string * > getDataSetNameList()
Get all Data Sets names.
Definition: DSInfo.cpp:209
std::string name
Data Source Name.
Definition: DSInfo.h:242
std::vector< FKInfo > vecFkInfo
Foreign Key struct vector.
Definition: DSInfo.h:231
Struct that stores information about a foreign key using the most common data types.
Definition: DSInfo.h:189
bool hasPk
If has Primary key.
Definition: DSInfo.h:229
void printDataSourceParameters(std::string dsType)
Print Data Source Parameters.
std::string name
Unique Key Name.
Definition: DSInfo.h:200
std::string name
Data Set Name.
Definition: DSInfo.h:228
PKInfo pkInfo
Primary Key struct.
Definition: DSInfo.h:230