Merge lp:~renatofilho/qtorganizer5-eds/fix-1262296 into lp:qtorganizer5-eds
- fix-1262296
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Robert Bruce Park |
Approved revision: | 37 |
Merged at revision: | 26 |
Proposed branch: | lp:~renatofilho/qtorganizer5-eds/fix-1262296 |
Merge into: | lp:qtorganizer5-eds |
Diff against target: |
193 lines (+70/-16) 3 files modified
qorganizer/qorganizer-eds-engine.cpp (+22/-14) qorganizer/qorganizer-eds-saverequestdata.cpp (+4/-1) tests/unittest/event-test.cpp (+44/-1) |
To merge this branch: | bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1262296 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Gustavo Pichorim Boiko (community) | Approve | ||
Review via email: mp+200435@code.launchpad.net |
Commit message
Fixed create items without collection id.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:27
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:28
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:29
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:30
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:31
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:32
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:33
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:34
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:35
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
Looks good!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Robert Bruce Park (robru) wrote : | # |
The jenkins failure looks like a merge conflict, can you rebase this on trunk?
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:36
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:37
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:37
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'qorganizer/qorganizer-eds-engine.cpp' |
2 | --- qorganizer/qorganizer-eds-engine.cpp 2014-01-05 18:18:32 +0000 |
3 | +++ qorganizer/qorganizer-eds-engine.cpp 2014-01-07 12:59:42 +0000 |
4 | @@ -162,6 +162,7 @@ |
5 | |
6 | GSList *events = 0; |
7 | events = g_slist_append(events, comp); |
8 | + |
9 | data->appendResults(data->parent()->parseEvents(data->collection(), events, false)); |
10 | g_slist_free(events); |
11 | } |
12 | @@ -243,11 +244,9 @@ |
13 | QOrganizerManager::Error *error) |
14 | { |
15 | qDebug() << Q_FUNC_INFO; |
16 | - QOrganizerItemIdFilter filter; |
17 | - filter.setIds(itemIds); |
18 | |
19 | - QOrganizerItemFetchRequest *req = new QOrganizerItemFetchRequest(this); |
20 | - req->setFilter(filter); |
21 | + QOrganizerItemFetchByIdRequest *req = new QOrganizerItemFetchByIdRequest(this); |
22 | + req->setIds(itemIds); |
23 | req->setFetchHint(fetchHint); |
24 | |
25 | startRequest(req); |
26 | @@ -256,9 +255,9 @@ |
27 | if (error) { |
28 | *error = req->error(); |
29 | } |
30 | - // TODO implement correct reply for errorMap |
31 | + |
32 | if (errorMap) { |
33 | - *errorMap = QMap<int, QOrganizerManager::Error>(); |
34 | + *errorMap = req->errorMap(); |
35 | } |
36 | req->deleteLater(); |
37 | return req->items(); |
38 | @@ -346,7 +345,7 @@ |
39 | qDebug() << Q_FUNC_INFO; |
40 | QString collectionId = data->nextCollection(); |
41 | |
42 | - if (collectionId.isEmpty() && data->end()) { |
43 | + if (collectionId.isNull() && data->end()) { |
44 | data->finish(); |
45 | delete data; |
46 | return; |
47 | @@ -357,17 +356,20 @@ |
48 | createItems = false; |
49 | items = data->takeItemsToUpdate(); |
50 | } |
51 | + |
52 | if (items.isEmpty()) { |
53 | saveItemsAsyncStart(data); |
54 | + return; |
55 | } |
56 | |
57 | - if (collectionId.isNull() && createItems) { |
58 | + if (collectionId.isEmpty() && createItems) { |
59 | collectionId = data->parent()->d->m_sourceRegistry->defaultCollection().id().toString(); |
60 | + qDebug() << "Use default collection to save item with empty collection:" << collectionId; |
61 | } |
62 | |
63 | EClient *client = data->parent()->d->m_sourceRegistry->client(collectionId); |
64 | if (!client) { |
65 | - qWarning() << "Trying to save items with invalid collection"; |
66 | + qWarning() << "Trying to save items with invalid collection" << collectionId; |
67 | Q_FOREACH(const QOrganizerItem &i, items) { |
68 | data->appendResult(i, QOrganizerManager::InvalidCollectionError); |
69 | } |
70 | @@ -454,18 +456,22 @@ |
71 | data->appendResult(i, QOrganizerManager::UnspecifiedError); |
72 | } |
73 | } else { |
74 | + QString currentCollectionId = data->currentCollection(); |
75 | + if (currentCollectionId.isEmpty()) { |
76 | + currentCollectionId = data->parent()->defaultCollection(0).id().toString(); |
77 | + } |
78 | QList<QOrganizerItem> items = data->workingItems(); |
79 | for(uint i=0, iMax=g_slist_length(uids); i < iMax; i++) { |
80 | QOrganizerItem &item = items[i]; |
81 | const gchar *uid = static_cast<const gchar*>(g_slist_nth_data(uids, i)); |
82 | |
83 | - QOrganizerEDSCollectionEngineId *edsCollectionId = new QOrganizerEDSCollectionEngineId(data->currentCollection()); |
84 | - item.setCollectionId(QOrganizerCollectionId(edsCollectionId)); |
85 | - |
86 | - QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(data->currentCollection(), |
87 | + QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(currentCollectionId, |
88 | QString::fromUtf8(uid)); |
89 | item.setId(QOrganizerItemId(eid)); |
90 | item.setGuid(QString::fromUtf8(uid)); |
91 | + |
92 | + QOrganizerEDSCollectionEngineId *edsCollectionId = new QOrganizerEDSCollectionEngineId(currentCollectionId); |
93 | + item.setCollectionId(QOrganizerCollectionId(edsCollectionId)); |
94 | } |
95 | g_slist_free_full(uids, g_free); |
96 | data->appendResults(items); |
97 | @@ -589,7 +595,9 @@ |
98 | QOrganizerCollection QOrganizerEDSEngine::defaultCollection(QOrganizerManager::Error* error) |
99 | { |
100 | qDebug() << Q_FUNC_INFO; |
101 | - *error = QOrganizerManager::NoError; |
102 | + if (error) { |
103 | + *error = QOrganizerManager::NoError; |
104 | + } |
105 | return d->m_sourceRegistry->defaultCollection(); |
106 | } |
107 | |
108 | |
109 | === modified file 'qorganizer/qorganizer-eds-saverequestdata.cpp' |
110 | --- qorganizer/qorganizer-eds-saverequestdata.cpp 2013-12-11 13:16:50 +0000 |
111 | +++ qorganizer/qorganizer-eds-saverequestdata.cpp 2014-01-07 12:59:42 +0000 |
112 | @@ -31,6 +31,9 @@ |
113 | // map items by collection |
114 | Q_FOREACH(const QOrganizerItem &i, request<QOrganizerItemSaveRequest>()->items()) { |
115 | QString collectionId = i.collectionId().toString(); |
116 | + if (collectionId == QStringLiteral("qtorganizer:::")) { |
117 | + collectionId = QStringLiteral(""); |
118 | + } |
119 | QList<QOrganizerItem> li = m_items[collectionId]; |
120 | li << i; |
121 | m_items.insert(collectionId, li); |
122 | @@ -62,7 +65,7 @@ |
123 | QString SaveRequestData::nextCollection() |
124 | { |
125 | if (m_items.isEmpty()) { |
126 | - m_currentCollection = QString(); |
127 | + m_currentCollection = QString(QString::null); |
128 | m_currentItems.clear(); |
129 | } else { |
130 | m_currentCollection = m_items.keys().first(); |
131 | |
132 | === modified file 'tests/unittest/event-test.cpp' |
133 | --- tests/unittest/event-test.cpp 2014-01-05 18:18:32 +0000 |
134 | +++ tests/unittest/event-test.cpp 2014-01-07 12:59:42 +0000 |
135 | @@ -271,6 +271,45 @@ |
136 | QCOMPARE(items.count(), 0); |
137 | } |
138 | |
139 | + void testCreateEventWithoutCollection() |
140 | + { |
141 | + static QString displayLabelValue = QStringLiteral("event without collection"); |
142 | + static QString descriptionValue = QStringLiteral("event without collection"); |
143 | + |
144 | + QOrganizerEvent event; |
145 | + event.setStartDateTime(QDateTime(QDate(2013, 9, 3), QTime(0,30,0))); |
146 | + event.setDisplayLabel(displayLabelValue); |
147 | + event.setDescription(descriptionValue); |
148 | + |
149 | + QtOrganizer::QOrganizerManager::Error error; |
150 | + QMap<int, QtOrganizer::QOrganizerManager::Error> errorMap; |
151 | + QList<QOrganizerItem> items; |
152 | + items << event; |
153 | + bool saveResult = m_engine->saveItems(&items, |
154 | + QList<QtOrganizer::QOrganizerItemDetail::DetailType>(), |
155 | + &errorMap, |
156 | + &error); |
157 | + |
158 | + QVERIFY(saveResult); |
159 | + QCOMPARE(error, QOrganizerManager::NoError); |
160 | + QVERIFY(errorMap.isEmpty()); |
161 | + QVERIFY(!items[0].id().isNull()); |
162 | + |
163 | + // append new item to be removed after the test |
164 | + appendToRemove(items[0].id()); |
165 | + |
166 | + // check if item was created on the default collection |
167 | + QOrganizerItemFetchHint hint; |
168 | + |
169 | + QList<QOrganizerItemId> ids; |
170 | + ids << items[0].id(); |
171 | + qDebug() << "Check for item id:" << ids; |
172 | + items = m_engine->items(ids, hint, 0, 0); |
173 | + QCOMPARE(items.count(), 1); |
174 | + QOrganizerCollection collection = m_engine->defaultCollection(0); |
175 | + QCOMPARE(items[0].collectionId(), collection.id()); |
176 | + } |
177 | + |
178 | void testCreateMultipleItemsWithSameCollection() |
179 | { |
180 | static QString displayLabelValue = QStringLiteral("Multiple Item:%1"); |
181 | @@ -363,7 +402,11 @@ |
182 | |
183 | // This item will cause error, because the collection ID is invalid |
184 | QOrganizerEvent ev; |
185 | - ev.setCollectionId(QOrganizerCollectionId::fromString("1386259057.30874.6@qorganizer")); |
186 | + QOrganizerEDSCollectionEngineId *edsCollectionId = new QOrganizerEDSCollectionEngineId("XXXXXX"); |
187 | + QOrganizerCollectionId cid(edsCollectionId); |
188 | + QVERIFY(!cid.isNull()); |
189 | + QCOMPARE(cid.toString(), QStringLiteral("qtorganizer:eds::XXXXXX")); |
190 | + ev.setCollectionId(cid); |
191 | ev.setStartDateTime(QDateTime(QDate(2013, 10, 2), QTime(0,30,0))); |
192 | ev.setDisplayLabel(displayLabelValue.arg(2)); |
193 | ev.setDescription(descriptionValue.arg(2)); |
FAILED: Continuous integration, rev:26 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-ci/ 64/ jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- amd64-ci/ 51/console jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- armhf-ci/ 51/console jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- i386-ci/ 51/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtorganizer 5-eds-ci/ 64/rebuild
http://