------------------------------------------------------------------------------
| 149 | |
| 150 | //------------------------------------------------------------------------------ |
| 151 | int vtkSQLDatabaseTableSource::RequestData( |
| 152 | vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) |
| 153 | { |
| 154 | if (this->Implementation->URL.empty()) |
| 155 | return 1; |
| 156 | |
| 157 | if (this->Implementation->QueryString.empty()) |
| 158 | return 1; |
| 159 | |
| 160 | if (!this->PedigreeIdArrayName) |
| 161 | { |
| 162 | vtkErrorMacro(<< "You must specify a pedigree id array name."); |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | if (!this->Implementation->Database) |
| 167 | { |
| 168 | this->Implementation->Database = |
| 169 | vtkSQLDatabase::CreateFromURL(this->Implementation->URL.c_str()); |
| 170 | if (!this->Implementation->Database) |
| 171 | { |
| 172 | vtkErrorMacro(<< "Error creating database using URL: " << this->Implementation->URL); |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | if (!this->Implementation->Database->Open(this->Implementation->Password.c_str())) |
| 177 | { |
| 178 | this->Implementation->Database->Delete(); |
| 179 | this->Implementation->Database = nullptr; |
| 180 | |
| 181 | vtkErrorMacro(<< "Error opening database: " << this->Implementation->URL); |
| 182 | return 0; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | if (!this->Implementation->Query) |
| 187 | { |
| 188 | this->Implementation->Query = this->Implementation->Database->GetQueryInstance(); |
| 189 | if (!this->Implementation->Query) |
| 190 | { |
| 191 | vtkErrorMacro(<< "Internal error creating query instance."); |
| 192 | return 0; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | // Set Progress Text |
| 197 | this->SetProgressText("DatabaseTableSource"); |
| 198 | |
| 199 | // I have a database: 5% progress |
| 200 | this->UpdateProgress(.05); |
| 201 | |
| 202 | this->Implementation->Query->SetQuery(this->Implementation->QueryString.c_str()); |
| 203 | if (!this->Implementation->Query->Execute()) |
| 204 | { |
| 205 | vtkErrorMacro(<< "Error executing query: " << this->Implementation->QueryString); |
| 206 | return 0; |
| 207 | } |
| 208 |
nothing calls this directly
no test coverage detected