27 #include <Ice/ObjectAdapter.h>
28 #include <IceUtil/UUID.h>
32 #include <ArmarXCore/interface/serialization/JSONSerialization.h>
45 useMongoIds(useMongoIds)
58 memoryx::NameList result;
70 result.push_back((*it)->getNS());
86 const ::Ice::Current&
c)
93 const std::string newName = coll->getNS();
101 if (newName == (*it)->getNS())
111 ARMARX_INFO_S << coll->getNS() <<
" collection added to list";
115 ARMARX_INFO_S << coll->getNS() <<
" collection already in list";
128 const ::Ice::Current&
c)
138 const ::Ice::Current&
c)
161 DBStorableData dbEntity;
171 const EntityBasePtr& entity,
172 const Ice::Current&
c)
180 const EntityBasePtr& entity)
195 const Ice::Current&
c)
204 EntityIdList entityIds(entityList.size(),
"");
206 for (
size_t i = 0; i < entityList.size(); i++)
212 catch (
const memoryx::InvalidEntityException& e)
223 const EntityBasePtr& entity,
224 const Ice::Current&
c)
232 const EntityBasePtr& entity)
238 return oldEntity->getId();
256 DBStorableDataList dbEntities;
257 dbEntities.reserve(entityList.size());
259 for (
size_t i = 0; i < entityList.size(); i++)
263 dbEntities.push_back(
dbSerializer->serializeIceObject(entityList[i]));
271 const EntityBasePtr&
update,
272 const ::Ice::Current&
c)
280 const EntityBasePtr&
update)
283 DBStorableData dbEntity;
335 if (entityId.empty() || entityId.size() != 24)
351 ? (*it)->findByMongoId(entityId)
352 : (*it)->findOneByFieldValue(
"_id", entityId);
354 if (!dbEntity.JSON.empty())
369 const Ice::Current&
c)
const
382 CollectionInterfacePrx coll = *it;
389 const DBStorableData dbEntity = coll->findOneByFieldValue(
"name", entityName);
391 if (!dbEntity.JSON.empty())
402 const ::Ice::Current&
c)
const
412 if (entityId.empty())
415 return EntityBasePtr();
429 ? (*it)->findByMongoId(entityId)
430 : (*it)->findOneByFieldValue(
"_id", entityId);
432 if (!dbEntity.JSON.empty())
438 return EntityBasePtr();
443 const ::Ice::Current&
c)
const
461 const DBStorableData dbEntity = (*it)->findOneByFieldValue(
"name", name);
463 if (!dbEntity.JSON.empty())
469 return EntityBasePtr();
474 const ::std::string& attrValue,
475 const ::Ice::Current&
c)
const
477 EntityBaseList result;
478 const std::string fieldName =
"attrs." + attrName +
".value.value";
481 for (CollectionPrxList::const_iterator itColl =
readCollections.begin();
490 const DBStorableDataList dbEntities = (*itColl)->findByFieldValue(fieldName, attrValue);
492 for (DBStorableDataList::const_iterator itEntity = dbEntities.begin();
493 itEntity != dbEntities.end();
500 result.push_back(entity);
510 const NameList& attrValueList,
511 const ::Ice::Current&
c)
const
513 EntityBaseList result;
514 const std::string fieldName =
"attrs." + attrName +
".value.value";
517 for (CollectionPrxList::const_iterator itColl =
readCollections.begin();
526 const DBStorableDataList dbEntities =
527 (*itColl)->findByFieldValueList(fieldName, attrValueList);
529 for (DBStorableDataList::const_iterator itEntity = dbEntities.begin();
530 itEntity != dbEntities.end();
537 result.push_back(entity);
560 result += (*it)->count();
613 const EntityIdList collIds = (*it)->findAllIds();
614 result.insert(result.end(), collIds.begin(), collIds.end());
622 EntityBaseList result;
632 for (
const auto& dbEntity : col->findAll())
638 result.push_back(std::move(entity));
653 result.insert({entity->getId(), std::move(entity)});
663 EntityBasePtr entity;
667 entity = EntityBasePtr::dynamicCast(
dbSerializer->deserializeIceObject(dbEntity));
669 catch (
const armarx::JSONException& ex)
671 entity = EntityBasePtr();
679 const Ice::Current&
c)
const
681 auto entity = getEntityById(
id);
689 EntityMemorySegmentInterfacePrx::uncheckedCast(
c.adapter->createProxy(getIceId()));
691 std::string memName = mem->getMemoryName();
693 MemoryInterfacePrx::checkedCast(
c.adapter->getCommunicator()->stringToProxy(memName));
700 const Ice::Current&
c)
const
702 auto entity = getEntityByName(name);
710 EntityMemorySegmentInterfacePrx::uncheckedCast(
c.adapter->createProxy(getIceId()));
712 std::string memName = mem->getMemoryName();
714 MemoryInterfacePrx::checkedCast(
c.adapter->getCommunicator()->stringToProxy(memName));
721 const EntityAttributeBasePtr& attribute,
722 const Ice::Current&
c)
727 throw EntityNotFoundException();
729 entity->putAttribute(attribute);
730 DBStorableData dbEntity;
742 const EntityAttributeList& attributeMap,
743 const Ice::Current&
c)
748 throw EntityNotFoundException();
750 for (
auto attribute : attributeMap)
752 entity->putAttribute(attribute);
755 DBStorableData dbEntity;
769 this->parentMemory = memory;
775 EntityRefList result;
787 CollectionInterfacePrx prx = *it;
788 const DBStorableDataList
data = prx->findByQuery(query);
790 for (
const DBStorableData& e :
data)
796 auto proxy = EntityMemorySegmentInterfacePrx::uncheckedCast(
799 std::string memName = mem->getMemoryName();
800 auto memoryProxy = MemoryInterfacePrx::checkedCast(
801 c.adapter->getCommunicator()->stringToProxy(memName));
804 result.push_back(ref);