1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #ifndef _U2_MYSQL_DBI_UTILS_H_
23 #define _U2_MYSQL_DBI_UTILS_H_
24 
25 #include <QString>
26 
27 #include <U2Core/U2Type.h>
28 #include <U2Core/global.h>
29 
30 namespace U2 {
31 
32 class MysqlDbi;
33 class MysqlModificationAction;
34 class U2OpStatus;
35 
36 class U2FORMATS_EXPORT MysqlDbiUtils {
37 public:
38     /** Creates an URL that contains authentification information */
39     static QString createAuthDbiUrl(const QString &userName, const QString &password, const QString &host, int port, const QString &dbName);
40 
41     static QString createAuthDbiUrl(const QString &userName, const QString &password, const QString &dbUrl);
42 
43     static bool parseAuthDbiUrl(const QString &url, QString &userName, QString &password, QString &host, int &port, QString &dbName);
44 
45     static U2DbiId createDbiUrl(const QString &host, int port, const QString &dbName);
46 
47     static bool parseDbiUrl(const U2DbiId &dbiId, QString &host, int &port, QString &dbName);
48 
49     static bool isDbInitialized(const U2DbiRef &dbiRef, U2OpStatus &os);
50 
51     /**
52      * Updates the object name and increments the version.
53      * The changes are tracked if it is needed.
54      * Applies all changes to @object too.
55      */
56     static void renameObject(MysqlDbi *dbi, U2Object &object, const QString &newName, U2OpStatus &os);
57     static void renameObject(MysqlModificationAction &updateAction, MysqlDbi *dbi, U2Object &object, const QString &newName, U2OpStatus &os);
58 
59     static void upgrade(const U2DbiRef &dbiRef, U2OpStatus &os);
60 };
61 
62 }  // namespace U2
63 
64 #endif  // _U2_MYSQL_DBI_UTILS_H_
65