25 #include <ArmarXCore/interface/core/Log.h>
32 std::cout <<
"onInitComponent" << std::endl;
54 std::cout <<
"onConnectComponent" << std::endl;
58 dataBasePrx = getProxy<CommonStorageInterfacePrx>(
"CommonStorage");
60 CollectionInterfacePrx actionCollectionPrx =
61 dataBasePrx->requestCollection(
"workmem.actions");
64 DBStorableData action1;
66 "{\"name\":\"put\", params: ['what', 'where'], prereq: [{pred: 'isIn', params: ['what', 'hand'] }], \
67 effects: [{pred: 'isOn', params: ['what', 'where'] }] }";
68 const std::string action1ID = actionCollectionPrx->insert(action1);
70 ARMARX_INFO <<
"Inserted action1 with ID = " << action1ID;
72 DBStorableData action2;
73 action2.JSON =
"{name: 'take', params: ['what'], prereq: [], effects: [{pred: 'isIn', "
74 "params: ['what', 'hand'] }] }";
75 actionCollectionPrx->save(action2);
78 action2.JSON =
"{\"name\": \"take\", params: [], prereq: [], effects: [] }";
79 actionCollectionPrx->saveWithUserKey(action2,
"name");
87 catch (InvalidMongoIdException& e)
89 ARMARX_ERROR <<
"Failed to fetch action by id: " << e.reason;
92 const std::string findQuery =
"{name: 'take'}";
93 DBStorableDataList actions = actionCollectionPrx->findByQuery(findQuery);
95 for (DBStorableDataList::const_iterator it = actions.begin(); it != actions.end(); ++it)
97 ARMARX_INFO <<
"Found action by name: " << it->JSON;
104 const std::string remQuery =
"{name: 'put'}";
105 ARMARX_INFO <<
"Removing action by query: " << remQuery;
106 actionCollectionPrx->removeByQuery(remQuery);
108 dataBasePrx->releaseCollection(actionCollectionPrx);
110 GridFileInterfacePrx filePrx = dataBasePrx->getFileProxyByName(
"workmem",
"Cup.iv");
114 ARMARX_INFO <<
"Got file of size: " << filePrx->getFileSize();
115 dataBasePrx->releaseFileProxy(filePrx);