26 #include <ArmarXCore/interface/serialization/JSONSerialization.h>
30 #include <IceUtil/UUID.h>
31 #include <Ice/ObjectAdapter.h>
43 useMongoIds(useMongoIds)
55 memoryx::NameList result;
65 result.push_back((*it)->getNS());
85 const std::string newName = coll->getNS();
91 if (newName == (*it)->getNS())
101 ARMARX_INFO_S << coll->getNS() <<
" collection added to list";
105 ARMARX_INFO_S << coll->getNS() <<
" collection already in list";
136 const ::Ice::Current&
c)
144 DBStorableData dbEntity;
181 EntityIdList entityIds(entityList.size(),
"");
183 for (
size_t i = 0; i < entityList.size(); i++)
189 catch (
const memoryx::InvalidEntityException& e)
211 return oldEntity->getId();
229 DBStorableDataList dbEntities;
230 dbEntities.reserve(entityList.size());
232 for (
size_t i = 0; i < entityList.size(); i++)
236 dbEntities.push_back(
dbSerializer->serializeIceObject(entityList[i]));
253 DBStorableData dbEntity;
264 const ::Ice::Current&
c)
303 if (entityId.empty() || entityId.size() != 24)
317 (*it)->findByMongoId(entityId) : (*it)->findOneByFieldValue(
"_id", entityId);
319 if (!dbEntity.JSON.empty())
344 CollectionInterfacePrx coll = *it;
351 const DBStorableData dbEntity = coll->findOneByFieldValue(
"name", entityName);
353 if (!dbEntity.JSON.empty())
364 const ::Ice::Current&
c)
const
373 if (entityId.empty())
376 return EntityBasePtr();
388 (*it)->findByMongoId(entityId) : (*it)->findOneByFieldValue(
"_id", entityId);
390 if (!dbEntity.JSON.empty())
396 return EntityBasePtr();
400 const ::Ice::Current&
c)
const
415 const DBStorableData dbEntity = (*it)->findOneByFieldValue(
"name", name);
417 if (!dbEntity.JSON.empty())
423 return EntityBasePtr();
429 EntityBaseList result;
430 const std::string fieldName =
"attrs." + attrName +
".value.value";
440 const DBStorableDataList dbEntities = (*itColl)->findByFieldValue(fieldName, attrValue);
442 for (DBStorableDataList::const_iterator itEntity = dbEntities.begin(); itEntity != dbEntities.end(); ++itEntity)
448 result.push_back(entity);
459 EntityBaseList result;
460 const std::string fieldName =
"attrs." + attrName +
".value.value";
470 const DBStorableDataList dbEntities = (*itColl)->findByFieldValueList(fieldName, attrValueList);
472 for (DBStorableDataList::const_iterator itEntity = dbEntities.begin(); itEntity != dbEntities.end(); ++itEntity)
478 result.push_back(entity);
501 result += (*it)->count();
547 const EntityIdList collIds = (*it)->findAllIds();
548 result.insert(result.end(), collIds.begin(), collIds.end());
556 EntityBaseList result;
566 for (
const auto& dbEntity : col->findAll())
572 result.push_back(std::move(entity));
586 result.insert({entity->getId(), std::move(entity)});
595 EntityBasePtr entity;
599 entity = EntityBasePtr::dynamicCast(
dbSerializer->deserializeIceObject(dbEntity));
601 catch (
const armarx::JSONException& ex)
603 entity = EntityBasePtr();
614 auto entity = getEntityById(
id);
621 auto proxy = EntityMemorySegmentInterfacePrx::uncheckedCast(
c.adapter->createProxy(getIceId()));
623 std::string memName = mem->getMemoryName();
624 auto memoryProxy = MemoryInterfacePrx::checkedCast(
c.adapter->getCommunicator()->stringToProxy(memName));
635 auto entity = getEntityByName(name);
642 auto proxy = EntityMemorySegmentInterfacePrx::uncheckedCast(
c.adapter->createProxy(getIceId()));
644 std::string memName = mem->getMemoryName();
645 auto memoryProxy = MemoryInterfacePrx::checkedCast(
c.adapter->getCommunicator()->stringToProxy(memName));
661 throw EntityNotFoundException();
663 entity->putAttribute(attribute);
664 DBStorableData dbEntity;
679 throw EntityNotFoundException();
681 for (
auto attribute : attributeMap)
683 entity->putAttribute(attribute);
686 DBStorableData dbEntity;
699 this->parentMemory = memory;
704 EntityRefList result;
714 CollectionInterfacePrx prx = *it;
715 const DBStorableDataList
data = prx->findByQuery(query);
717 for (
const DBStorableData& e :
data)
723 auto proxy = EntityMemorySegmentInterfacePrx::uncheckedCast(
c.adapter->createProxy(
getIceId()));
725 std::string memName = mem->getMemoryName();
726 auto memoryProxy = MemoryInterfacePrx::checkedCast(
c.adapter->getCommunicator()->stringToProxy(memName));
732 result.push_back(ref);