-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgshanacolumntypethread.cpp
76 lines (65 loc) · 2.54 KB
/
qgshanacolumntypethread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/***************************************************************************
qgshanacolumntypethread.cpp
--------------------------------------
Date : 31-05-2019
Copyright : (C) SAP SE
Author : Maxim Rylov
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
#include "qgshanacolumntypethread.h"
#include "qgshanaconnection.h"
#include "qgshanaconnectionpool.h"
#include "qgshanautils.h"
#include "qgsmessagelog.h"
#include "qgslogger.h"
QgsHanaColumnTypeThread::QgsHanaColumnTypeThread( const QString &connName, const QgsDataSourceUri &uri, bool allowGeometrylessTables, bool userTablesOnly )
: mConnectionName( connName )
, mUri( uri )
, mAllowGeometrylessTables( allowGeometrylessTables )
, mUserTablesOnly( userTablesOnly )
{
// Make sure the meta type is registered only once
static int initialized = qRegisterMetaType<QgsHanaLayerProperty>( "QgsHanaLayerProperty" );
Q_UNUSED( initialized )
}
void QgsHanaColumnTypeThread::run()
{
QgsHanaConnectionRef conn( mUri );
if ( conn.isNull() )
{
QgsDebugMsg( "Connection failed: " + mUri.connectionInfo( false ) );
return;
}
emit progressMessage( tr( "Retrieving tables of %1." ).arg( mConnectionName ) );
QVector<QgsHanaLayerProperty> layerProperties = conn->getLayers(
mUri.schema(),
mAllowGeometrylessTables,
mUserTablesOnly );
if ( layerProperties.isEmpty() )
return;
const int totalLayers = layerProperties.size();
emit progress( 0, totalLayers );
for ( int i = 0; i < totalLayers; ++i )
{
if ( isInterruptionRequested() )
break;
QgsHanaLayerProperty &layerProperty = layerProperties[i];
emit progress( i, totalLayers );
emit progressMessage( tr( "Scanning column %1.%2.%3…" )
.arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) );
conn->readLayerInfo( layerProperty );
emit setLayerType( layerProperty );
}
emit progress( 0, 0 );
if ( isInterruptionRequested() )
emit progressMessage( tr( "Table retrieval stopped." ) );
else
emit progressMessage( tr( "Table retrieval finished." ) );
}