9#include <imtbase/IObjectCollectionIterator.h>
19class CCollectionRepresentationConverter
29 template<
typename RequestInfo,
typename Representation>
32 const RequestInfo& requestInfo,
33 Representation& representationObject,
34 QString& errorMessage);
36 template<
typename RequestInfo,
typename Representation>
37 static bool FillTypeId(
39 const RequestInfo& requestInfo,
40 Representation& representationObject,
41 QString& errorMessage);
43 template<
typename RequestInfo,
typename Representation>
46 const RequestInfo& requestInfo,
47 Representation& representationObject,
48 QString& errorMessage);
50 template<
typename RequestInfo,
typename Representation>
51 static bool FillAddedTime(
53 const RequestInfo& requestInfo,
54 Representation& representationObject,
55 QString& errorMessage);
57 template<
typename RequestInfo,
typename Representation>
58 static bool FillLastModifiedTime(
60 const RequestInfo& requestInfo,
61 Representation& representationObject,
62 QString& errorMessage);
64 template<
typename Interface>
65 static bool GetDocument(
const Interface* document,
const istd::IChangeable& data, QString& errorMessage);
67 template<
typename Interface>
68 static bool CheckArgumentsId(
const Interface& arguments, QString& errorMessage);
76 QDateTime retVal = objectCollectionIterator.
GetElementInfo(QByteArrayLiteral(
"TimeStamp")).toDateTime();
77 if (retVal.isValid()) {
79 retVal.setTimeSpec(Qt::UTC);
88 QDateTime retVal = objectCollectionIterator.
GetElementInfo(QByteArrayLiteral(
"Added")).toDateTime();
89 if (retVal.isValid()) {
91 retVal.setTimeSpec(Qt::UTC);
98template<
typename RequestInfo,
typename Representation>
99inline bool CCollectionRepresentationConverter::FillTypeId(
101 const RequestInfo& requestInfo,
102 Representation& representationObject,
105 if (requestInfo.items.isTypeIdRequested){
106 representationObject.typeId = objectCollectionIterator.
GetObjectTypeId();
113template<
typename RequestInfo,
typename Representation>
114inline bool CCollectionRepresentationConverter::FillId(
116 const RequestInfo& requestInfo,
117 Representation& representationObject,
120 if (requestInfo.items.isIdRequested) {
121 representationObject.id = objectCollectionIterator.
GetObjectId();
128template<
typename RequestInfo,
typename Representation>
129inline bool CCollectionRepresentationConverter::FillName(
131 const RequestInfo& requestInfo,
132 Representation& representationObject,
135 if (requestInfo.items.isNameRequested) {
136 representationObject.name = objectCollectionIterator.
GetElementInfo(
"Name").toString();
143template<
typename RequestInfo,
typename Representation>
144inline bool CCollectionRepresentationConverter::FillAddedTime(
146 const RequestInfo& requestInfo,
147 Representation& representationObject,
150 if (requestInfo.items.isAddedRequested) {
151 QDateTime addedTime = objectCollectionIterator.
GetElementInfo(
"Added").toDateTime();
152 addedTime.setTimeSpec(Qt::UTC);
154 QString added = addedTime.toLocalTime().toString(
"dd.MM.yyyy hh:mm:ss");
155 representationObject.added = added;
162template<
typename RequestInfo,
typename Representation>
163inline bool CCollectionRepresentationConverter::FillLastModifiedTime(
165 const RequestInfo& requestInfo,
166 Representation& representationObject,
169 if (requestInfo.items.isLastModifiedRequested) {
170 QDateTime lastModifiedTime = objectCollectionIterator.
GetElementInfo(
"TimeStamp").toDateTime();
171 lastModifiedTime.setTimeSpec(Qt::UTC);
173 QString lastModified = lastModifiedTime.toLocalTime().toString(
"dd.MM.yyyy hh:mm:ss");
174 representationObject.lastModified = lastModified;
181template<
typename Interface>
182inline bool CCollectionRepresentationConverter::GetDocument(
183 const Interface* document,
184 const istd::IChangeable& data,
185 QString& errorMessage)
187 document =
dynamic_cast<const Interface*
>(&data);
189 if (document ==
nullptr) {
190 errorMessage = QObject::tr(
"Invalid document");
199template<
typename Interface>
200inline bool CCollectionRepresentationConverter::CheckArgumentsId(
201 const Interface& arguments,
202 QString& errorMessage)
204 if (!arguments.input.Version_1_0 || !arguments.input.Version_1_0->id) {
205 errorMessage = QObject::tr(
"Version 1.0 of the GQL request arguments is missing");
virtual QVariant GetElementInfo(int infoType) const =0
virtual QByteArray GetObjectId() const =0
virtual QByteArray GetObjectTypeId() const =0