Author: dmacvicar Date: Fri Jun 8 14:12:19 2007 New Revision: 5701 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5701&view=rev Log: - cached Patch implementation - querying for containers - duplicate attr between resobject and patch (size) Added: trunk/libzypp/zypp/repo/cached/PatchImpl.cc trunk/libzypp/zypp/repo/cached/PatchImpl.h Modified: trunk/libzypp/zypp/CMakeLists.txt trunk/libzypp/zypp/cache/ResolvableQuery.cc trunk/libzypp/zypp/cache/ResolvableQuery.h trunk/libzypp/zypp/detail/PatchImplIf.cc trunk/libzypp/zypp/detail/PatchImplIf.h trunk/libzypp/zypp/detail/ResObjectImplIf.h trunk/libzypp/zypp/repo/cached/PackageImpl.cc trunk/libzypp/zypp/repo/cached/PackageImpl.h Modified: trunk/libzypp/zypp/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/CMakeLists.txt (original) +++ trunk/libzypp/zypp/CMakeLists.txt Fri Jun 8 14:12:19 2007 @@ -1081,11 +1081,13 @@ SET( zypp_repository_cached_SRCS repo/cached/RepoImpl.cc repo/cached/PackageImpl.cc + repo/cached/PatchImpl.cc ) SET( zypp_repository_cached_HEADERS repo/cached/RepoImpl.h repo/cached/PackageImpl.h + repo/cached/PatchImpl.h ) SET( zypp_repository_data_SRCS Modified: trunk/libzypp/zypp/cache/ResolvableQuery.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/ResolvableQuery.cc?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/cache/ResolvableQuery.cc (original) +++ trunk/libzypp/zypp/cache/ResolvableQuery.cc Fri Jun 8 14:12:19 2007 @@ -104,6 +104,28 @@ } + bool queryBooleanAttribute( const data::RecordId &record_id, + const std::string &klass, + const std::string &name ) + { + sqlite3_connection con((_dbdir + "zypp.db").asString().c_str()); + return ( queryNumericAttributeInternal( con, record_id, klass, name) != 0 ); + } + + template <class _Container> _Container + queryStringContainerAttribute( const data::RecordId &record_id, + const std::string &klass, + const std::string &name ) + { + sqlite3_connection con((_dbdir + "zypp.db").asString().c_str()); + string all = queryStringAttributeInternal( con, record_id, klass, name); + _Container words; + + str::split( all, std::back_inserter(words) ); + return words; + } + + int queryNumericAttribute( const data::RecordId &record_id, const std::string &klass, const std::string &name ) @@ -129,7 +151,7 @@ return cmd.executeint(); } - + TranslatedText queryTranslatedStringAttributeInternal( sqlite3_connection &con, const data::RecordId &record_id, const std::string &klass, Modified: trunk/libzypp/zypp/cache/ResolvableQuery.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/ResolvableQuery.h?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/cache/ResolvableQuery.h (original) +++ trunk/libzypp/zypp/cache/ResolvableQuery.h Fri Jun 8 14:12:19 2007 @@ -128,6 +128,24 @@ const std::string &klass, const std::string &name ); + /** + * Queries for a specific container attribute + * in a resolvable. + * + * \param record_id Resolvable cache id + * \param klass Attribute Class + * \param name Attribute Name + * + * \return the attribute or a empty + * \ref _Container if no record is found. + */ + template<class _Container> + _Container queryStringContainerAttribute( const data::RecordId &record_id, + const std::string &klass, + const std::string &name ); + + + private: /** Implementation. */ class Impl; Modified: trunk/libzypp/zypp/detail/PatchImplIf.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/detail/PatchImplIf.cc?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/detail/PatchImplIf.cc (original) +++ trunk/libzypp/zypp/detail/PatchImplIf.cc Fri Jun 8 14:12:19 2007 @@ -38,9 +38,6 @@ bool PatchImplIf::affects_pkg_manager() const { return false; } - ByteCount PatchImplIf::size() const - { return ByteCount(); } - bool PatchImplIf::interactive() const { if ( reboot_needed() Modified: trunk/libzypp/zypp/detail/PatchImplIf.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/detail/PatchImplIf.h?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/detail/PatchImplIf.h (original) +++ trunk/libzypp/zypp/detail/PatchImplIf.h Fri Jun 8 14:12:19 2007 @@ -51,8 +51,7 @@ virtual bool reboot_needed() const PURE_VIRTUAL; /** Does the patch affect the package manager itself? */ virtual bool affects_pkg_manager() const PURE_VIRTUAL; - /** */ - virtual ByteCount size() const; + /** Is the patch installation interactive? (does it need user input?) */ virtual bool interactive() const PURE_VIRTUAL; /** The list of all atoms building the patch */ Modified: trunk/libzypp/zypp/detail/ResObjectImplIf.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/detail/ResObjectImplIf.h?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/detail/ResObjectImplIf.h (original) +++ trunk/libzypp/zypp/detail/ResObjectImplIf.h Fri Jun 8 14:12:19 2007 @@ -15,6 +15,7 @@ #include <list> #include <string> +#include "zypp/base/Deprecated.h" #include "zypp/detail/ResImplTraits.h" #include "zypp/detail/ResObjectFactory.h" @@ -101,7 +102,7 @@ virtual Date installtime() const; /** Id used inside ZMD */ - virtual ZmdId zmdid() const PURE_VIRTUAL; + ZYPP_DEPRECATED virtual ZmdId zmdid() const PURE_VIRTUAL; //@} public: Modified: trunk/libzypp/zypp/repo/cached/PackageImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/PackageImpl.cc?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/cached/PackageImpl.cc (original) +++ trunk/libzypp/zypp/repo/cached/PackageImpl.cc Fri Jun 8 14:12:19 2007 @@ -33,12 +33,8 @@ /** Default ctor */ PackageImpl::PackageImpl (const data::RecordId &id, cached::RepoImpl::Ptr repository_r) - : _repository (repository_r) - , _install_only(false) - , _size_installed(0) - , _size_archive(0) - , _data_loaded(false) - , _id(id) + : _repository (repository_r), + _id(id) {} Repository @@ -47,34 +43,46 @@ return _repository->selfRepository(); } -/** Package summary */ +/////////////////////////////////////////////////// +// ResObject Attributes +/////////////////////////////////////////////////// + TranslatedText PackageImpl::summary() const { return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "summary" ); } -/** Package description */ TranslatedText PackageImpl::description() const { return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "description" ); } -PackageGroup PackageImpl::group() const +TranslatedText PackageImpl::insnotify() const { - return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "group" ); + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "insnotify" ); } -Pathname PackageImpl::location() const +TranslatedText PackageImpl::delnotify() const { - return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "group" ); + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "delnotify" ); +} + +TranslatedText PackageImpl::licenseToConfirm() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "licenseToConfirm" ); +} + +Vendor PackageImpl::vendor() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "ResObject", "vendor" ); } + ByteCount PackageImpl::size() const { return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "size" ); } -/** */ ByteCount PackageImpl::archivesize() const { return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "archivesize" ); @@ -85,16 +93,140 @@ return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" ); } +Date PackageImpl::buildtime() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "buildtime" ); +} + +Date PackageImpl::installtime() const +{ + return Date(); +} + unsigned PackageImpl::repositoryMediaNr() const { return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "repositoryMediaNr" ); } -Vendor PackageImpl::vendor() const +////////////////////////////////////////// +// DEPRECATED +////////////////////////////////////////// + +Source_Ref PackageImpl::source() const { - return "suse"; + return Source_Ref::noSource; } +unsigned PackageImpl::sourceMediaNr() const +{ + return 1; +} + +CheckSum PackageImpl::checksum() const +{ + return CheckSum(); +} + +std::string PackageImpl::buildhost() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "buildhost" ); +} + +std::string PackageImpl::distribution() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "distribution" ); +} + +Label PackageImpl::license() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "license" ); +} + +std::string PackageImpl::packager() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "packager" ); +} + +PackageGroup PackageImpl::group() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "group" ); +} + +PackageImpl::Keywords PackageImpl::keywords() const +{ + return _repository->resolvableQuery().queryStringContainerAttribute< PackageImpl::Keywords >( _id, "Package", "keywords" ); +} + +Changelog PackageImpl::changelog() const +{ + return Changelog(); +} + +Pathname PackageImpl::location() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "location" ); +} + +std::string PackageImpl::url() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "url" ); +} + +std::string PackageImpl::os() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "operatingSystem" ); +} + +Text PackageImpl::prein() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "prein" ); +} + +Text PackageImpl::postin() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "postin" ); +} + +Text PackageImpl::preun() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "preun" ); +} + +Text PackageImpl::postun() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "postun" ); +} + +ByteCount PackageImpl::sourcesize() const +{ + return ByteCount(); +} + +DiskUsage PackageImpl::diskusage() const +{ + return DiskUsage(); +} + +list<string> PackageImpl::authors() const +{ + return _repository->resolvableQuery().queryStringContainerAttribute< list<string> >( _id, "Package", "authors" ); +} + +std::liststd::string PackageImpl::filenames() const +{ + return std::liststd::string(); +} + +// std::list<DeltaRpm> PackageImpl::deltaRpms() const +// { +// return std::list<DeltaRpm>(); +// } +// +// std::list<PatchRpm> PackageImpl::patchRpms() const +// { +// return std::list<PatchRpm>(); +// } + ///////////////////////////////////////////////////////////////// } } } // namespace zypp::repo::cached /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/repo/cached/PackageImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/PackageImpl.h?rev=5701&r1=5700&r2=5701&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/cached/PackageImpl.h (original) +++ trunk/libzypp/zypp/repo/cached/PackageImpl.h Fri Jun 8 14:12:19 2007 @@ -33,28 +33,49 @@ virtual TranslatedText summary() const; virtual TranslatedText description() const; + virtual TranslatedText insnotify() const; + virtual TranslatedText delnotify() const; + virtual TranslatedText licenseToConfirm() const; + virtual Vendor vendor() const; virtual ByteCount size() const; - virtual PackageGroup group() const; virtual ByteCount archivesize() const; - virtual Pathname location() const; virtual bool installOnly() const; - virtual Repository repository() const; + virtual Date buildtime() const; + virtual Date installtime() const; + + virtual Source_Ref source() const; + virtual unsigned sourceMediaNr() const; + + // PACKAGE + virtual CheckSum checksum() const; + virtual std::string buildhost() const; + virtual std::string distribution() const; + virtual Label license() const; + virtual std::string packager() const; + virtual PackageGroup group() const; + virtual Keywords keywords() const; + virtual Changelog changelog() const; + virtual Pathname location() const; + virtual std::string url() const; + virtual std::string os() const; + virtual Text prein() const; + virtual Text postin() const; + virtual Text preun() const; + virtual Text postun() const; + virtual ByteCount sourcesize() const; + virtual DiskUsage diskusage() const; + virtual std::liststd::string authors() const; + virtual std::liststd::string filenames() const; + /*virtual std::list<DeltaRpm> deltaRpms() const; + virtual std::list<PatchRpm> patchRpms() const; + */ virtual unsigned repositoryMediaNr() const; - virtual Vendor vendor() const; + + virtual Repository repository() const; + protected: repo::cached::RepoImpl::Ptr _repository; - TranslatedText _summary; - TranslatedText _description; - PackageGroup _group; - Pathname _location; - bool _install_only; - unsigned _media_nr; - - ByteCount _size_installed; - ByteCount _size_archive; - - bool _data_loaded; data::RecordId _id; }; ///////////////////////////////////////////////////////////////// Added: trunk/libzypp/zypp/repo/cached/PatchImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/PatchImpl.cc?rev=5701&view=auto ============================================================================== --- trunk/libzypp/zypp/repo/cached/PatchImpl.cc (added) +++ trunk/libzypp/zypp/repo/cached/PatchImpl.cc Fri Jun 8 14:12:19 2007 @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zmd/backend/dbrepository/PatchImpl.h + * +*/ + +#include "zypp/TranslatedText.h" +#include "zypp/base/String.h" +#include "zypp/base/Logger.h" +#include "zypp/repo/RepositoryImpl.h" +#include "PatchImpl.h" + + +using namespace std; +using namespace zypp::detail; +using namespace::zypp::repo; + +/////////////////////////////////////////////////////////////////// +namespace zypp { namespace repo { namespace cached { + +/////////////////////////////////////////////////////////////////// +// +// CLASS NAME : PatchImpl +// +/////////////////////////////////////////////////////////////////// + +/** Default ctor +*/ +PatchImpl::PatchImpl (const data::RecordId &id, cached::RepoImpl::Ptr repository_r) + : _repository (repository_r), + _id(id) +{} + +Repository +PatchImpl::repository() const +{ + return _repository->selfRepository(); +} + +/////////////////////////////////////////////////// +// ResObject Attributes +/////////////////////////////////////////////////// + +TranslatedText PatchImpl::summary() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "summary" ); +} + +TranslatedText PatchImpl::description() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "description" ); +} + +TranslatedText PatchImpl::insnotify() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "insnotify" ); +} + +TranslatedText PatchImpl::delnotify() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "delnotify" ); +} + +TranslatedText PatchImpl::licenseToConfirm() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "licenseToConfirm" ); +} + +Vendor PatchImpl::vendor() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "ResObject", "vendor" ); +} + + +ByteCount PatchImpl::size() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "size" ); +} + +ByteCount PatchImpl::archivesize() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "archivesize" ); +} + +bool PatchImpl::installOnly() const +{ + return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" ); +} + +Date PatchImpl::buildtime() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "buildtime" ); +} + +Date PatchImpl::installtime() const +{ + return Date(); +} + +////////////////////////////////////////// +// DEPRECATED +////////////////////////////////////////// + +Source_Ref PatchImpl::source() const +{ + return Source_Ref::noSource; +} + +unsigned PatchImpl::sourceMediaNr() const +{ + return 1; +} + +////////////////////////////////////////// +// PATCH +///////////////////////////////////////// + +std::string PatchImpl::id() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Patch", "id" ); +} + +Date PatchImpl::timestamp() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "Patch", "timestamp" ); +} + +std::string PatchImpl::category() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Patch", "category" ); +} + +bool PatchImpl::reboot_needed() const +{ + return _repository->resolvableQuery().queryBooleanAttribute( _id, "Patch", "rebootNeeded" ); +} + +bool PatchImpl::affects_pkg_manager() const +{ + return _repository->resolvableQuery().queryBooleanAttribute( _id, "Patch", "affectsPkgManager" ); +} + +bool PatchImpl::interactive() const +{ + return _repository->resolvableQuery().queryBooleanAttribute( _id, "Patch", "interactive" ); +} + +PatchImpl::AtomList PatchImpl::all_atoms() const +{ + return PatchImpl::AtomList(); +} + +///////////////////////////////////////////////////////////////// +} } } // namespace zypp::repo::cached +/////////////////////////////////////////////////////////////////// + Added: trunk/libzypp/zypp/repo/cached/PatchImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/PatchImpl.h?rev=5701&view=auto ============================================================================== --- trunk/libzypp/zypp/repo/cached/PatchImpl.h (added) +++ trunk/libzypp/zypp/repo/cached/PatchImpl.h Fri Jun 8 14:12:19 2007 @@ -0,0 +1,70 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +#ifndef zypp_repo_cached_PatchImpl_H +#define zypp_repo_cached_PatchImpl_H + +#include "zypp/detail/PatchImpl.h" +#include "zypp/repo/cached/RepoImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// +namespace repo +{ ///////////////////////////////////////////////////////////////// +namespace cached +{ ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : PatchImpl + // + class PatchImpl : public detail::PatchImplIf + { + public: + + PatchImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); + + virtual TranslatedText summary() const; + virtual TranslatedText description() const; + virtual TranslatedText insnotify() const; + virtual TranslatedText delnotify() const; + virtual TranslatedText licenseToConfirm() const; + virtual Vendor vendor() const; + virtual ByteCount size() const; + virtual ByteCount archivesize() const; + virtual bool installOnly() const; + virtual Date buildtime() const; + virtual Date installtime() const; + + virtual Source_Ref source() const; + virtual unsigned sourceMediaNr() const; + + // PATCH + virtual std::string id() const; + virtual Date timestamp() const; + virtual std::string category() const; + virtual bool reboot_needed() const; + virtual bool affects_pkg_manager() const; + virtual bool interactive() const; + virtual AtomList all_atoms() const; + + virtual Repository repository() const; + + protected: + repo::cached::RepoImpl::Ptr _repository; + data::RecordId _id; + }; + ///////////////////////////////////////////////////////////////// +} // namespace cached +} // namespace repository +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H + -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org