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_SQLITE_ATTRIBUTE_DBI_H_ 23 #define _U2_SQLITE_ATTRIBUTE_DBI_H_ 24 25 #include "SQLiteDbi.h" 26 27 namespace U2 { 28 29 class SQLiteAttributeDbi : public U2AttributeDbi, public SQLiteChildDBICommon { 30 public: 31 SQLiteAttributeDbi(SQLiteDbi *dbi); 32 33 /** Returns all attribute names available in the database */ 34 virtual QStringList getAvailableAttributeNames(U2OpStatus &os); 35 36 /** Returns all attribute ids for the given object */ 37 virtual QList<U2DataId> getObjectAttributes(const U2DataId &objectId, const QString &name, U2OpStatus &os); 38 39 /** Returns all attribute ids for the given object */ 40 virtual QList<U2DataId> getObjectPairAttributes(const U2DataId &objectId, const U2DataId &childId, const QString &name, U2OpStatus &os); 41 42 /** Loads int64 attribute by id */ 43 virtual U2IntegerAttribute getIntegerAttribute(const U2DataId &attributeId, U2OpStatus &os); 44 45 /** Loads real64 attribute by id */ 46 virtual U2RealAttribute getRealAttribute(const U2DataId &attributeId, U2OpStatus &os); 47 48 /** Loads String attribute by id */ 49 virtual U2StringAttribute getStringAttribute(const U2DataId &attributeId, U2OpStatus &os); 50 51 /** Loads byte attribute by id */ 52 virtual U2ByteArrayAttribute getByteArrayAttribute(const U2DataId &attributeId, U2OpStatus &os); 53 54 /** Sorts all objects in database according to U2DbiSortConfig provided */ 55 virtual QList<U2DataId> sort(const U2DbiSortConfig &sc, qint64 offset, qint64 count, U2OpStatus &os); 56 57 /** 58 Removes attributes from database 59 Requires U2DbiFeature_WriteAttribute feature support 60 */ 61 virtual void removeAttributes(const QList<U2DataId> &attributeIds, U2OpStatus &os); 62 63 /** 64 Removes all attributes associated with the object 65 Requires U2DbiFeature_WriteAttribute feature support 66 */ 67 virtual void removeObjectAttributes(const U2DataId &objectId, U2OpStatus &os); 68 69 /** 70 Creates int64 attribute in database. ObjectId must be already set in attribute and present in the same database 71 Requires U2DbiFeature_WriteAttribute feature support 72 */ 73 virtual void createIntegerAttribute(U2IntegerAttribute &a, U2OpStatus &os); 74 75 /** 76 Creates real64 attribute in database. ObjectId must be already set in attribute and present in the same database 77 Requires U2DbiFeature_WriteAttribute feature support 78 */ 79 virtual void createRealAttribute(U2RealAttribute &a, U2OpStatus &os); 80 81 /** 82 Creates String attribute in database. ObjectId must be already set in attribute and present in the same database 83 Requires U2DbiFeature_WriteAttribute feature support 84 */ 85 virtual void createStringAttribute(U2StringAttribute &a, U2OpStatus &os); 86 87 /** 88 Creates Byte attribute in database. ObjectId must be already set in attribute and present in the same database 89 Requires U2DbiFeature_WriteAttribute feature support 90 */ 91 virtual void createByteArrayAttribute(U2ByteArrayAttribute &a, U2OpStatus &os); 92 93 virtual void initSqlSchema(U2OpStatus &os); 94 95 private: 96 qint64 createAttribute(U2Attribute &attr, U2DataType type, SQLiteTransaction &t, U2OpStatus &os); 97 98 QString buildSelectAttributeQuery(const QString &attributeTable); 99 100 void readAttribute(SQLiteReadQuery &q, U2Attribute &attr); 101 }; 102 103 } // namespace U2 104 105 #endif 106