496 bool success(true); |
496 bool success(true); |
497 foreach(int i, entryIdList) { |
497 foreach(int i, entryIdList) { |
498 QSqlQuery query(db); |
498 QSqlQuery query(db); |
499 query.prepare( |
499 query.prepare( |
500 "SELECT ENTRY_ID, EN_TEXT, EN_DESCRIPTION, EN_TYPE_NAME, EN_FLAGS, EN_ROLE, EN_UID, \ |
500 "SELECT ENTRY_ID, EN_TEXT, EN_DESCRIPTION, EN_TYPE_NAME, EN_FLAGS, EN_ROLE, EN_UID, \ |
501 ICON_ID, IC_BITMAP_ID, IC_MASK_ID, IC_SKINMAJOR_ID, IC_SKINMINOR_ID, IC_FILENAME \ |
501 ICON_ID, IC_FILENAME, IC_SKIN_ID, IC_APP_ID \ |
502 FROM CA_ENTRY LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID WHERE ENTRY_ID = ?"); |
502 FROM CA_ENTRY LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID WHERE ENTRY_ID = ?"); |
503 query.addBindValue(i); |
503 query.addBindValue(i); |
504 |
504 |
505 success = query.exec(); |
505 success = query.exec(); |
506 if (success && query.next()) { |
506 if (success && query.next()) { |
520 query.record().indexOf("EN_FLAGS")).toUInt())); |
520 query.record().indexOf("EN_FLAGS")).toUInt())); |
521 |
521 |
522 CaIconDescription icon; |
522 CaIconDescription icon; |
523 CaObjectAdapter::setId(icon, |
523 CaObjectAdapter::setId(icon, |
524 query.value(query.record().indexOf("ICON_ID")).toInt()); |
524 query.value(query.record().indexOf("ICON_ID")).toInt()); |
525 icon.setBitmapId(query.value(query.record().indexOf( |
525 |
526 "IC_BITMAP_ID")).toInt()); |
|
527 icon.setMaskId(query.value(query.record().indexOf( |
|
528 "IC_MASK_ID")).toInt()); |
|
529 icon.setSkinMajorId(query.value(query.record().indexOf( |
|
530 "IC_SKINMAJOR_ID")).toInt()); |
|
531 icon.setSkinMinorId(query.value(query.record().indexOf( |
|
532 "IC_SKINMINOR_ID")).toInt()); |
|
533 icon.setFilename(query.value(query.record().indexOf( |
526 icon.setFilename(query.value(query.record().indexOf( |
534 "IC_FILENAME")).toString()); |
527 "IC_FILENAME")).toString()); |
|
528 icon.setSkinId(query.value(query.record().indexOf( |
|
529 "IC_SKIN_ID")).toString()); |
|
530 icon.setApplicationId(query.value(query.record().indexOf( |
|
531 "IC_APP_ID")).toString()); |
535 entry->setIconDescription(icon); |
532 entry->setIconDescription(icon); |
536 |
533 |
537 // attributes |
534 // attributes |
538 // UID as attribute |
535 // UID as attribute |
539 if (query.value(query.record().indexOf("EN_UID")).toString().length() |
536 if (query.value(query.record().indexOf("EN_UID")).toString().length() |
618 whereStatement.append(","); |
614 whereStatement.append(","); |
619 } |
615 } |
620 whereStatement.append(") "); |
616 whereStatement.append(") "); |
621 } |
617 } |
622 |
618 |
|
619 QString whereAttributes; |
|
620 if (query.attributes().count()) { |
|
621 QMap<QString, QString> attributes = query.attributes(); |
|
622 QMapIterator<QString, QString> atrIt(attributes); |
|
623 int j = 1; |
|
624 while (atrIt.hasNext()) { |
|
625 atrIt.next(); |
|
626 |
|
627 // at1.AT_NAME = 'Attribute_Name_1' AND at1.AT_VALUE = 'Attribute_VALUE_1' |
|
628 whereAttributes.append(" AND ").append( |
|
629 " at").append(QString().setNum(j)).append(".AT_NAME = \'").append( |
|
630 atrIt.key()).append("\' ").append( |
|
631 " AND ").append( |
|
632 " at").append(QString().setNum(j)).append(".AT_VALUE = \'").append( |
|
633 atrIt.value()).append("\' "); |
|
634 |
|
635 j++; |
|
636 } |
|
637 whereStatement.append(whereAttributes); |
|
638 |
|
639 } |
|
640 |
|
641 whereStatement.append(" GROUP BY ENTRY_ID "); |
|
642 |
|
643 QString leftJoins; |
|
644 if (query.attributes().count()) { |
|
645 for (int j=1; j<=query.attributes().count(); j++) { |
|
646 // LEFT JOIN CA_ATTRIBUTE as at1 ON ENTRY_ID = at1.AT_ENTRY_ID |
|
647 leftJoins.append( |
|
648 " LEFT JOIN CA_ATTRIBUTE as at").append(QString().setNum(j)).append( |
|
649 " ON ENTRY_ID = at").append(QString().setNum(j)).append(" .AT_ENTRY_ID "); |
|
650 } |
|
651 } |
|
652 |
623 QSqlQuery sqlquery(db); |
653 QSqlQuery sqlquery(db); |
624 if (query.parentId() == 0) { |
654 if (query.parentId() == 0) { |
625 // sort |
655 // sort |
626 QString queryString("SELECT ENTRY_ID from CA_ENTRY where 1=1 "); |
656 QString queryString("SELECT ENTRY_ID from CA_ENTRY "); |
|
657 queryString.append(leftJoins); |
|
658 queryString.append(" where 1=1 "); |
627 queryString.append(whereStatement); |
659 queryString.append(whereStatement); |
|
660 |
628 modifyQueryForSortOrder(queryString, query, false); |
661 modifyQueryForSortOrder(queryString, query, false); |
629 if (query.count() > 0) |
662 if (query.count() > 0) |
630 queryString.append(" LIMIT ").append(query.count()); |
663 queryString.append(" LIMIT ").append(query.count()); |
631 qDebug() << "CaServicePrivate::getEntryIds query text: " |
664 qDebug() << "CaServicePrivate::getEntryIds query text: " |
632 << queryString; |
665 << queryString; |
637 sourceIdList << sqlquery.value(sqlquery.record().indexOf( |
670 sourceIdList << sqlquery.value(sqlquery.record().indexOf( |
638 "ENTRY_ID")).toInt(); |
671 "ENTRY_ID")).toInt(); |
639 } |
672 } |
640 } |
673 } |
641 } else { |
674 } else { |
642 QString |
675 |
643 queryString( |
676 QString queryString("SELECT ENTRY_ID FROM CA_ENTRY "); |
644 "SELECT ENTRY_ID FROM CA_ENTRY \ |
677 QString queryString2(" LEFT JOIN CA_GROUP_ENTRY ON GE_ENTRY_ID = ENTRY_ID WHERE GE_GROUP_ID = ? "); |
645 LEFT JOIN CA_GROUP_ENTRY ON GE_ENTRY_ID = ENTRY_ID WHERE GE_GROUP_ID = ? "); |
678 queryString2.append(whereStatement); |
646 queryString.append(whereStatement); |
679 queryString.append(leftJoins); |
|
680 queryString.append(queryString2); |
|
681 |
647 modifyQueryForSortOrder(queryString, query, true); |
682 modifyQueryForSortOrder(queryString, query, true); |
648 if (query.count() > 0) |
683 if (query.count() > 0) |
649 queryString.append(" LIMIT ").append(query.count()); |
684 queryString.append(" LIMIT ").append(query.count()); |
650 qDebug() << "CaServicePrivate::getEntryIds query text: " |
685 qDebug() << "CaServicePrivate::getEntryIds query text: " |
651 << queryString; |
686 << queryString; |
803 queryString.append(" DESC "); |
838 queryString.append(" DESC "); |
804 } |
839 } |
805 |
840 |
806 } |
841 } |
807 |
842 |
808 /*! |
843 //---------------------------------------------------------------------------- |
809 //TODO: |
844 // |
810 */ |
845 //---------------------------------------------------------------------------- |
811 bool CaClientProxy::setIconInDb(CaEntry *entryClone) const |
846 bool CaClientProxy::setIconInDb(CaEntry *entryClone) const |
812 { |
847 { |
813 //set icon information into db |
848 //set icon information into db |
814 QSqlQuery query(dbConnection()); |
849 QSqlQuery query(dbConnection()); |
815 query.prepare( |
850 query.prepare( |
816 "SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = :IC_FILENAME \ |
851 "SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = :IC_FILENAME" |
817 AND IC_BITMAP_ID = :IC_BITMAP_ID \ |
852 " AND IC_SKIN_ID = :IC_SKIN_ID" |
818 AND IC_MASK_ID = :IC_MASK_ID \ |
853 " AND IC_APP_ID = :IC_APP_ID"); |
819 AND IC_SKINMAJOR_ID = :IC_SKINMAJOR_ID \ |
|
820 AND IC_SKINMINOR_ID = :IC_SKINMINOR_ID"); |
|
821 query.bindValue(":IC_FILENAME", |
854 query.bindValue(":IC_FILENAME", |
822 entryClone->iconDescription().filename()); |
855 entryClone->iconDescription().filename()); |
823 query.bindValue(":IC_BITMAP_ID", |
856 query.bindValue(":IC_SKIN_ID", |
824 entryClone->iconDescription().bitmapId()); |
857 entryClone->iconDescription().filename()); |
825 query.bindValue(":IC_MASK_ID", entryClone->iconDescription().maskId()); |
858 query.bindValue(":IC_APP_ID", |
826 query.bindValue(":IC_SKINMAJOR_ID", |
859 entryClone->iconDescription().filename()); |
827 entryClone->iconDescription().skinMajorId()); |
860 |
828 query.bindValue(":IC_SKINMINOR_ID", |
|
829 entryClone->iconDescription().skinMinorId()); |
|
830 |
861 |
831 bool success = query.exec(); |
862 bool success = query.exec(); |
832 if (success && query.next()) { |
863 if (success && query.next()) { |
833 qDebug() << "query.executedQuery() : " << query.executedQuery(); |
864 qDebug() << "query.executedQuery() : " << query.executedQuery(); |
834 int iconId = query.value(query.record().indexOf("ICON_ID")).toInt(); |
865 int iconId = query.value(query.record().indexOf("ICON_ID")).toInt(); |
835 qDebug() << "iconId = " << iconId; |
866 qDebug() << "iconId = " << iconId; |
836 CaIconDescription iconDescription = entryClone->iconDescription(); |
867 CaIconDescription iconDescription = entryClone->iconDescription(); |
837 if (iconId <= 0 && (iconDescription.filename() != "" |
868 if (iconId <= 0 |
838 || iconDescription.bitmapId() != 0 || iconDescription.maskId() != 0 |
869 && (!iconDescription.filename().isEmpty() |
839 || iconDescription.skinMajorId() != 0 |
870 || !iconDescription.skinId().isEmpty() |
840 || iconDescription.skinMinorId() != 0)) { |
871 || !iconDescription.applicationId().isEmpty())) { |
841 query.prepare( |
872 query.prepare( |
842 "INSERT INTO CA_ICON \ |
873 "INSERT INTO CA_ICON" |
843 (IC_FILENAME,IC_BITMAP_ID,IC_MASK_ID,IC_SKINMAJOR_ID,IC_SKINMINOR_ID) \ |
874 " (IC_FILENAME, IC_SKIN_ID, IC_APP_ID)" |
844 VALUES ( ? , ? , ? , ? , ? )"); |
875 " VALUES ( ? , ? , ? , ? , ? )"); |
845 query.addBindValue(iconDescription.filename()); |
876 query.addBindValue(iconDescription.filename()); |
846 query.addBindValue(iconDescription.bitmapId()); |
877 query.addBindValue(iconDescription.skinId()); |
847 query.addBindValue(iconDescription.maskId()); |
878 query.addBindValue(iconDescription.applicationId()); |
848 query.addBindValue(iconDescription.skinMajorId()); |
|
849 query.addBindValue(iconDescription.skinMinorId()); |
|
850 success = query.exec(); |
879 success = query.exec(); |
851 qDebug() << query.executedQuery(); |
880 qDebug() << query.executedQuery(); |
852 iconId = query.lastInsertId().toInt(); |
881 iconId = query.lastInsertId().toInt(); |
853 } |
882 } |
854 CaObjectAdapter::setId(iconDescription, iconId); |
883 CaObjectAdapter::setId(iconDescription, iconId); |
855 entryClone->setIconDescription(iconDescription); |
884 entryClone->setIconDescription(iconDescription); |
856 } |
885 } |
857 return success; |
886 return success; |
858 } |
887 } |
859 |
888 |
860 /*! |
889 //---------------------------------------------------------------------------- |
861 //TODO: |
890 // |
862 */ |
891 //---------------------------------------------------------------------------- |
863 bool CaClientProxy::setEntryInDb(CaEntry *entryClone) const |
892 bool CaClientProxy::setEntryInDb(CaEntry *entryClone) const |
864 { |
893 { |
865 QSqlQuery query(dbConnection()); |
894 QSqlQuery query(dbConnection()); |
866 bool isNewEntry(entryClone->id() <= 0); |
895 bool isNewEntry(entryClone->id() <= 0); |
867 QString |
896 QString |