43 return entity ? entity->getId() :
"";
49 return entity ? entity->getName() :
"";
61 this->entity = entity;
71 memoryx::EntityAttributeBasePtr newAttr)
73 if (!oldAttr || !newAttr)
78 int size = oldAttr->size();
79 int newSize = newAttr->size();
81 for (
int i = 0; i < size; ++i)
84 armarx::VariantPtr::dynamicCast(oldAttr->getValueAt(i));
90 oldDocId = oldMongoRef->getClass<
MongoDBRef>()->docId;
98 armarx::VariantPtr::dynamicCast(newAttr->getValueAt(i));
99 newDocId = newMongoRef->get<
MongoDBRef>()->docId;
102 if (i >= newSize || (!oldDocId.empty() && newDocId != oldDocId))
104 ARMARX_INFO_S <<
"Removing old file: " << oldAttr->getName();
118 int size = attr->size();
119 for (
int i = 0; i < size; ++i)
121 armarx::VariantPtr oldMongoRef = armarx::VariantPtr::dynamicCast(attr->getValueAt(i));
123 std::string oldDocId;
127 oldDocId = oldMongoRef->getClass<
MongoDBRef>()->docId;
128 if (!oldDocId.empty())
139 bool preserveOriginalFName )
const
141 std::string result =
"";
146 getEntity()->getAttribute(attrName), result, preserveOriginalFName);
~AbstractEntityWrapper() override
EntityBasePtr getEntity() const
Get the stored name of the stored entity.
std::string getName() const
Get the name of the stored entity.
void setEntity(const EntityBasePtr &entity)
Replace the stored entity with a new one.
std::string getId() const
Get the identifier of the stored entity.
AbstractFileEntityWrapper(GridFileManagerPtr fileManager)
GridFileManagerPtr fileManager
std::string cacheAttributeFile(const std::string &attrName, bool preserveOriginalFName=false) const
void cleanUpAttributeFiles(EntityAttributeBasePtr oldAttr, EntityAttributeBasePtr newAttr)
cleanUpAttributeFiles compares the files attached to the two given attributes and removes the files o...
void removeAttributeFiles(const memoryx::EntityAttributeBasePtr &attr)
removes all files of an attribute from the gridfs
Represents a cross-database reference to a document in MongoDB.
IceInternal::Handle< Variant > VariantPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr