#include "data/access/StorageAccessProxy.h" #include "data/graph/Graph.h" #include "data/location/TokenLocationCollection.h" #include "data/location/TokenLocationFile.h" #include "utility/logging/logging.h" #include "utility/file/FileInfo.h" #include "utility/messaging/type/MessageShowErrors.h" #include "utility/TimePoint.h" StorageAccessProxy::StorageAccessProxy() : m_subject(nullptr) { } StorageAccessProxy::~StorageAccessProxy() { } bool StorageAccessProxy::hasSubject() const { if (m_subject) { return true; } LOG_ERROR("StorageAccessProxy has no subject."); return false; } void StorageAccessProxy::setSubject(StorageAccess* subject) { m_subject = subject; setErrorFilter(m_errorFilter); } Id StorageAccessProxy::getNodeIdForFileNode(const FilePath& filePath) const { if (hasSubject()) { return m_subject->getNodeIdForFileNode(filePath); } return 0; } Id StorageAccessProxy::getNodeIdForNameHierarchy(const NameHierarchy& nameHierarchy) const { if (hasSubject()) { return m_subject->getNodeIdForNameHierarchy(nameHierarchy); } return 0; } std::vector StorageAccessProxy::getNodeIdsForNameHierarchies(const std::vector nameHierarchies) const { if (hasSubject()) { return m_subject->getNodeIdsForNameHierarchies(nameHierarchies); } return std::vector(); } NameHierarchy StorageAccessProxy::getNameHierarchyForNodeId(Id id) const { if (hasSubject()) { return m_subject->getNameHierarchyForNodeId(id); } return NameHierarchy(); } std::vector StorageAccessProxy::getNameHierarchiesForNodeIds(const std::vector nodeIds) const { if (hasSubject()) { return m_subject->getNameHierarchiesForNodeIds(nodeIds); } return std::vector(); } Node::NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const { if (hasSubject()) { return m_subject->getNodeTypeForNodeWithId(id); } return Node::NODE_NON_INDEXED; } bool StorageAccessProxy::checkNodeExistsByName(const std::string& serializedName) const { if (hasSubject()) { return m_subject->checkNodeExistsByName(serializedName); } return false; } Id StorageAccessProxy::getIdForEdge( Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy ) const { if (hasSubject()) { return m_subject->getIdForEdge(type, fromNameHierarchy, toNameHierarchy); } return 0; } StorageEdge StorageAccessProxy::getEdgeById(Id edgeId) const { if (hasSubject()) { return m_subject->getEdgeById(edgeId); } return StorageEdge(); } bool StorageAccessProxy::checkEdgeExists(Id edgeId) const { if (hasSubject()) { return m_subject->checkEdgeExists(edgeId); } return false; } std::shared_ptr StorageAccessProxy::getFullTextSearchLocations( const std::string &searchTerm, bool caseSensitive) const { if (hasSubject()) { return m_subject->getFullTextSearchLocations(searchTerm, caseSensitive); } return std::make_shared(); } std::vector StorageAccessProxy::getAutocompletionMatches(const std::string& query) const { if (hasSubject()) { return m_subject->getAutocompletionMatches(query); } return std::vector(); } std::vector StorageAccessProxy::getSearchMatchesForTokenIds(const std::vector& tokenIds) const { if (hasSubject()) { return m_subject->getSearchMatchesForTokenIds(tokenIds); } return std::vector(); } std::shared_ptr StorageAccessProxy::getGraphForAll() const { if (hasSubject()) { return m_subject->getGraphForAll(); } return std::make_shared(); } std::shared_ptr StorageAccessProxy::getGraphForActiveTokenIds(const std::vector& tokenIds, bool* isActiveNamespace) const { if (hasSubject()) { return m_subject->getGraphForActiveTokenIds(tokenIds, isActiveNamespace); } return std::make_shared(); } std::vector StorageAccessProxy::getActiveTokenIdsForId(Id tokenId, Id* delcarationId) const { if (hasSubject()) { return m_subject->getActiveTokenIdsForId(tokenId, delcarationId); } return std::vector(); } std::vector StorageAccessProxy::getNodeIdsForLocationIds(const std::vector& locationIds) const { if (hasSubject()) { return m_subject->getNodeIdsForLocationIds(locationIds); } return std::vector(); } std::shared_ptr StorageAccessProxy::getTokenLocationsForTokenIds( const std::vector& tokenIds) const { if (hasSubject()) { return m_subject->getTokenLocationsForTokenIds(tokenIds); } return std::make_shared(); } std::shared_ptr StorageAccessProxy::getTokenLocationsForLocationIds( const std::vector& locationIds) const { if (hasSubject()) { return m_subject->getTokenLocationsForLocationIds(locationIds); } return std::make_shared(); } std::shared_ptr StorageAccessProxy::getTokenLocationsForFile(const std::string& filePath) const { if (hasSubject()) { return m_subject->getTokenLocationsForFile(filePath); } return std::make_shared(""); } std::shared_ptr StorageAccessProxy::getTokenLocationsForLinesInFile( const std::string& filePath, uint firstLineNumber, uint lastLineNumber ) const { if (hasSubject()) { return m_subject->getTokenLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber); } return std::make_shared(""); } std::shared_ptr StorageAccessProxy::getCommentLocationsInFile(const FilePath& filePath) const { if (hasSubject()) { return m_subject->getCommentLocationsInFile(filePath); } return std::make_shared(""); } std::shared_ptr StorageAccessProxy::getFileContent(const FilePath& filePath) const { if (hasSubject()) { return m_subject->getFileContent(filePath); } return nullptr; } FileInfo StorageAccessProxy::getFileInfoForFilePath(const FilePath& filePath) const { if (hasSubject()) { return m_subject->getFileInfoForFilePath(filePath); } return FileInfo(); } std::vector StorageAccessProxy::getFileInfosForFilePaths(const std::vector& filePaths) const { if (hasSubject()) { return m_subject->getFileInfosForFilePaths(filePaths); } return std::vector(); } StorageStats StorageAccessProxy::getStorageStats() const { if (hasSubject()) { return m_subject->getStorageStats(); } return StorageStats(); } ErrorCountInfo StorageAccessProxy::getErrorCount() const { if (hasSubject()) { return m_subject->getErrorCount(); } return ErrorCountInfo(); } std::vector StorageAccessProxy::getErrors() const { if (hasSubject()) { return m_subject->getErrors();; } return std::vector(); } std::shared_ptr StorageAccessProxy::getErrorTokenLocations(std::vector* errors) const { if (hasSubject()) { return m_subject->getErrorTokenLocations(errors); } return std::make_shared(); } Id StorageAccessProxy::addNodeBookmark(const NodeBookmark& bookmark) { if (hasSubject()) { return m_subject->addNodeBookmark(bookmark); } return -1; } Id StorageAccessProxy::addEdgeBookmark(const EdgeBookmark& bookmark) { if (hasSubject()) { return m_subject->addEdgeBookmark(bookmark); } return -1; } Id StorageAccessProxy::addBookmarkCategory(const BookmarkCategory& category) { if (hasSubject()) { return m_subject->addBookmarkCategory(category); } return -1; } std::vector StorageAccessProxy::getAllNodeBookmarks() const { if (hasSubject()) { return m_subject->getAllNodeBookmarks(); } return std::vector(); } NodeBookmark StorageAccessProxy::getNodeBookmarkById(const Id bookmarkId) const { if (hasSubject()) { return m_subject->getNodeBookmarkById(bookmarkId); } return NodeBookmark(); } bool StorageAccessProxy::checkNodeBookmarkExistsByTokens(const std::vector& tokenNames) const { if (hasSubject()) { return m_subject->checkNodeBookmarkExistsByTokens(tokenNames); } return false; } void StorageAccessProxy::removeNodeBookmark(Id id) { if (hasSubject()) { m_subject->removeNodeBookmark(id); } } void StorageAccessProxy::editNodeBookmark(const NodeBookmark& bookmark) { if (hasSubject()) { m_subject->editNodeBookmark(bookmark); } } std::vector StorageAccessProxy::getAllEdgeBookmarks() const { if (hasSubject()) { return m_subject->getAllEdgeBookmarks(); } return std::vector(); } EdgeBookmark StorageAccessProxy::getEdgeBookmarkById(const Id bookmarkId) const { if (hasSubject()) { return m_subject->getEdgeBookmarkById(bookmarkId); } return EdgeBookmark(); } bool StorageAccessProxy::checkEdgeBookmarkExistsByTokens(const std::vector& tokenNames) const { if (hasSubject()) { return m_subject->checkEdgeBookmarkExistsByTokens(tokenNames); } return false; } void StorageAccessProxy::removeEdgeBookmark(Id id) { if (hasSubject()) { m_subject->removeEdgeBookmark(id); } } void StorageAccessProxy::editEdgeBookmark(const EdgeBookmark& bookmark) { if (hasSubject()) { m_subject->editEdgeBookmark(bookmark); } } std::vector StorageAccessProxy::getAllBookmarkCategories() const { if (hasSubject()) { return m_subject->getAllBookmarkCategories(); } return std::vector(); } bool StorageAccessProxy::checkBookmarkCategoryExists(const std::string& name) const { if (hasSubject()) { return m_subject->checkBookmarkCategoryExists(name); } return false; } void StorageAccessProxy::removeBookmarkCategory(Id id) { if (hasSubject()) { m_subject->removeBookmarkCategory(id); } } void StorageAccessProxy::setErrorFilter(const ErrorFilter& filter) { StorageAccess::setErrorFilter(filter); if (hasSubject()) { m_subject->setErrorFilter(filter); } } void StorageAccessProxy::handleMessage(MessageErrorFilterChanged* message) { setErrorFilter(message->errorFilter); MessageShowErrors(getErrorCount()).dispatch(); }