33 #include <IceUtil/UUID.h>
34 #include <Ice/ObjectAdapter.h>
35 #include <Ice/Connection.h>
47 std::unique_lock lock(tokenMutex);
49 if (!lockToken.empty() &&
c.ctx.count(
"token") > 0 &&
c.ctx.at(
"token") == lockToken)
58 std::unique_lock lock(tokenMutex);
60 if (!lockToken.empty() &&
c.ctx.count(
"token") > 0 &&
c.ctx.at(
"token") == lockToken)
69 EntityBasePtr entity = getEntityById(
id);
72 throw EntityNotFoundException();
75 json->setIceObject(
"entity", entity);
76 return json->asString(
true);
81 auto comp = [](
const EntityBasePtr & e1,
const EntityBasePtr & e2)
83 return e1->getId() < e2->getId();
86 std::set<EntityBasePtr, decltype(comp)> result(comp);
87 std::set<EntityBasePtr, decltype(comp)> searchList(comp);
88 EntityPtr root = EntityPtr::dynamicCast(getEntityById(
id,
c));
89 searchList.insert(root);
91 auto all = getAllEntities(
c);
92 std::string attribName =
"parentEntityRefs";
94 while (!searchList.empty())
96 EntityPtr curParent = EntityPtr::dynamicCast(*searchList.begin());
97 auto curParentRef = getEntityRefById(curParent->getId(),
c);
98 searchList.erase(searchList.begin());
99 for (EntityBasePtr& entity :
all)
101 if (!entity->hasAttribute(attribName,
c))
105 auto attr = entity->getAttribute(attribName,
c);
106 for (
int i = 0; i < attr->size(); ++i)
109 if (ref->equals(curParentRef))
111 ARMARX_INFO_S << ref->entityName <<
" is parent of " << entity->getName();
112 if (result.count(entity) == 0)
114 searchList.insert(entity);
116 result.insert(entity);
122 if (!includeMetaEntities)
124 EntityBaseList filteredResult;
125 std::copy_if(result.begin(), result.end(), std::back_inserter(filteredResult),
126 [](
const EntityBasePtr & entity)
128 return !entity->isMetaEntity();
130 return filteredResult;
132 return EntityBaseList(result.begin(), result.end());
138 auto entity = getEntityByName(entityName);
145 return EntityBaseList();
155 lockToken = lock->token = IceUtil::generateUUID();
158 lock->segment = EntityMemorySegmentInterfacePrx::uncheckedCast(
c.adapter->createProxy(
c.id));
179 throw InvalidLockTokenException();
199 throw InvalidLockTokenException();
218 throw InvalidLockTokenException();
243 ARMARX_WARNING_S <<
"Segment lock of segment '" << getSegmentName() <<
"' did not receive keep-alive in time (" << age.toMilliSecondsDouble() <<
" ms, interval: " <<
keepAliveCheckTask->getInterval() <<
" ) - unlocking segment";
273 segment->unlockSegmentWithToken(this->token);
296 segment->keepLockAlive(this->token);