@@ -81,7 +81,49 @@ void MongoDBLoader::loadAnnotations(Poco::MongoDB::Connection &connection,
81
81
82
82
void MongoDBLoader::loadAnnotationAttributes (
83
83
Poco::MongoDB::Connection &connection,
84
- std::shared_ptr<Annotation> annotation) {}
84
+ std::shared_ptr<Annotation> annotation) {
85
+ Poco::MongoDB::Cursor cursor (dbname, " annotation_attributes" );
86
+ cursor.query ().selector ().add (" annotation" , (long )annotation->getId ());
87
+
88
+ Poco::MongoDB::ResponseMessage &response = cursor.next (connection);
89
+ while (1 ) {
90
+ for (Poco::MongoDB::Document::Vector::const_iterator it =
91
+ response.documents ().begin ();
92
+ it != response.documents ().end (); ++it) {
93
+ unsigned long id = (*it)->get <long >(" id" );
94
+ std::string name = (*it)->get <std::string>(" name" );
95
+ std::string type = (*it)->get <std::string>(" type" );
96
+ std::string value = (*it)->get <std::string>(" value" );
97
+
98
+ AttributeType t = AttributeTypeFromString (type);
99
+ std::shared_ptr<Attribute> a = std::make_shared<Attribute>(id, t, name);
100
+ std::shared_ptr<AttributeValue> av;
101
+ switch (t) {
102
+ case AttributeType::STRING:
103
+ av = std::make_shared<AttributeValue>(value);
104
+ break ;
105
+ case AttributeType::INTEGER:
106
+ av = std::make_shared<AttributeValue>(std::stol (value));
107
+ break ;
108
+ case AttributeType::FLOAT:
109
+ av = std::make_shared<AttributeValue>(std::stod (value));
110
+ break ;
111
+ case AttributeType::BOOLEAN:
112
+ av = std::make_shared<AttributeValue>(value == " true" ||
113
+ value == " True" );
114
+ break ;
115
+ default :
116
+ av = std::make_shared<AttributeValue>(value);
117
+ };
118
+ a->setValue (av);
119
+ annotation->addAttribute (a);
120
+ }
121
+ if (response.cursorID () == 0 ) {
122
+ break ;
123
+ }
124
+ response = cursor.next (connection);
125
+ };
126
+ }
85
127
86
128
void MongoDBLoader::loadClasses (Poco::MongoDB::Connection &connection,
87
129
Session *session) {
@@ -105,7 +147,49 @@ void MongoDBLoader::loadClasses(Poco::MongoDB::Connection &connection,
105
147
}
106
148
107
149
void MongoDBLoader::loadObjectAttributes (Poco::MongoDB::Connection &connection,
108
- std::shared_ptr<Object> object) {}
150
+ std::shared_ptr<Object> object) {
151
+ Poco::MongoDB::Cursor cursor (dbname, " object_attributes" );
152
+ cursor.query ().selector ().add (" object" , (long )object->getId ());
153
+
154
+ Poco::MongoDB::ResponseMessage &response = cursor.next (connection);
155
+ while (1 ) {
156
+ for (Poco::MongoDB::Document::Vector::const_iterator it =
157
+ response.documents ().begin ();
158
+ it != response.documents ().end (); ++it) {
159
+ unsigned long id = (*it)->get <long >(" id" );
160
+ std::string name = (*it)->get <std::string>(" name" );
161
+ std::string type = (*it)->get <std::string>(" type" );
162
+ std::string value = (*it)->get <std::string>(" value" );
163
+
164
+ AttributeType t = AttributeTypeFromString (type);
165
+ std::shared_ptr<Attribute> a = std::make_shared<Attribute>(id, t, name);
166
+ std::shared_ptr<AttributeValue> av;
167
+ switch (t) {
168
+ case AttributeType::STRING:
169
+ av = std::make_shared<AttributeValue>(value);
170
+ break ;
171
+ case AttributeType::INTEGER:
172
+ av = std::make_shared<AttributeValue>(std::stol (value));
173
+ break ;
174
+ case AttributeType::FLOAT:
175
+ av = std::make_shared<AttributeValue>(std::stod (value));
176
+ break ;
177
+ case AttributeType::BOOLEAN:
178
+ av = std::make_shared<AttributeValue>(value == " true" ||
179
+ value == " True" );
180
+ break ;
181
+ default :
182
+ av = std::make_shared<AttributeValue>(value);
183
+ };
184
+ a->setValue (av);
185
+ object->addAttribute (a);
186
+ }
187
+ if (response.cursorID () == 0 ) {
188
+ break ;
189
+ }
190
+ response = cursor.next (connection);
191
+ };
192
+ }
109
193
110
194
void MongoDBLoader::loadObjects (Poco::MongoDB::Connection &connection,
111
195
Session *session) {
0 commit comments