Mailinglist Archive: zypp-commit (204 mails)

< Previous Next >
[zypp-commit] r5659 - in /trunk/libzypp: devel/devel.jkupec/ zypp/data/ zypp2/cache/ zypp2/repo/cached/
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Sun, 03 Jun 2007 23:11:45 -0000
  • Message-id: <20070603231145.A00B69C944@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Mon Jun  4 01:11:45 2007
New Revision: 5659

URL: http://svn.opensuse.org/viewcvs/zypp?rev=5659&view=rev
Log:
- storing almost all resolvable data
- cleaned-up ResolvableDataConsumer interface

Added:
    trunk/libzypp/devel/devel.jkupec/dbqueries.sql
Modified:
    trunk/libzypp/devel/devel.jkupec/CMakeLists.txt
    trunk/libzypp/zypp/data/ResolvableDataConsumer.h
    trunk/libzypp/zypp2/cache/CacheStore.cpp
    trunk/libzypp/zypp2/cache/CacheStore.h
    trunk/libzypp/zypp2/cache/ResolvableQuery.cc
    trunk/libzypp/zypp2/cache/ResolvableQuery.h
    trunk/libzypp/zypp2/repo/cached/PackageImpl.cc

Modified: trunk/libzypp/devel/devel.jkupec/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/CMakeLists.txt?rev=5659&r1=5658&r2=5659&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/CMakeLists.txt (original)
+++ trunk/libzypp/devel/devel.jkupec/CMakeLists.txt Mon Jun  4 01:11:45 2007
@@ -1,5 +1,3 @@
-INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
-
 ADD_DEFINITIONS(-DSRC_DIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\")
 
 #ADD_EXECUTABLE(sourcedownload sourcedownload.cc)
@@ -24,4 +22,3 @@
 
 ADD_EXECUTABLE( bridge ${bridge_SRCS} )
 TARGET_LINK_LIBRARIES( bridge zypp zypp2)
-

Added: trunk/libzypp/devel/devel.jkupec/dbqueries.sql
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/dbqueries.sql?rev=5659&view=auto
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/dbqueries.sql (added)
+++ trunk/libzypp/devel/devel.jkupec/dbqueries.sql Mon Jun  4 01:11:45 2007
@@ -0,0 +1,43 @@
+-- what kinds of resolvables have been read?
+select * from types where class = 'kind';
+
+-- what languages have been encountered?
+select * from types where class = 'lang';
+
+-- what architectures have been read?
+select * from types where class = 'arch';
+
+-- what types of dependencies have been encountered?
+select * from types where class = 'deptype';
+
+-- ----------------------------------------------------------------------------
+
+-- how many packages have been read?
+select count(*) from resolvables r, types t where t.class = 'kind' and t.name = 'package' and t.id = r.kind;
+
+-- print resolvable kind -> count table
+select t.name, count(*) from resolvables r, types t where t.class = 'kind' and t.id = r.kind group by t.name;
+
+-- what patches have been read? print id, name, and version
+select r.id, r.name, r.version from resolvables r, types t where t.class = 'kind' and t.name = 'patch' and t.id = r.kind;
+
+-- ----------------------------------------------------------------------------
+
+-- print all text and numeric attributes of resolvable with id = 2
+select a.weak_resolvable_id "res-id", t.class "attr-class", t.name "attr-name", a.text "value"
+  from text_attributes a, types t
+  where t.id = a.attr_id and a.weak_resolvable_id = 2
+union
+select a.weak_resolvable_id "res-id", t.class "attr-class", t.name "attr-name", a.value "value"
+  from numeric_attributes a, types t
+  where t.id = a.attr_id and a.weak_resolvable_id = 2
+order by t.class
+
+-- print all named dependencies of resolvable with id = 2
+select dt.name "dtype", kt.name "kind", n.name "name", rt.name "rel", c.version "version"
+  from named_capabilities c, types dt, types kt, types rt, names n
+  where c.dependency_type = dt.id
+    and c.refers_kind= kt.id
+    and c.relation = rt.id
+    and c.name_id = n.id
+    and resolvable_id = 2;

Modified: trunk/libzypp/zypp/data/ResolvableDataConsumer.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableDataConsumer.h?rev=5659&r1=5658&r2=5659&view=diff
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableDataConsumer.h (original)
+++ trunk/libzypp/zypp/data/ResolvableDataConsumer.h Mon Jun  4 01:11:45 2007
@@ -28,14 +28,14 @@
     ResolvableDataConsumer();
     virtual ~ResolvableDataConsumer();
 
-    virtual void consumePackage( const data::RecordId &repository_id, data::Package_Ptr ) = 0;
-    virtual void consumeSourcePackage( const data::RecordId &repository_id, data::SrcPackage_Ptr ) = 0;
-    virtual void consumeProduct( const data::RecordId &repository_id, data::Product_Ptr ) = 0;
-    virtual void consumePatch( const data::RecordId &repository_id, data::Patch_Ptr ) = 0;
+    virtual void consumePackage( const data::RecordId &repository_id, const data::Package_Ptr &) = 0;
+    virtual void consumeSourcePackage( const data::RecordId &repository_id, const data::SrcPackage_Ptr &) = 0;
+    virtual void consumeProduct( const data::RecordId &repository_id, const data::Product_Ptr &) = 0;
+    virtual void consumePatch( const data::RecordId &repository_id, const data::Patch_Ptr &) = 0;
     virtual void consumePackageAtom( const data::RecordId &repository_id, const data::PackageAtom_Ptr & ) = 0;
-    virtual void consumeMessage( const data::RecordId &repository_id, data::Message_Ptr ) = 0;
-    virtual void consumeScript( const data::RecordId &repository_id, data::Script_Ptr ) = 0;
-    virtual void consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr ) = 0;
+    virtual void consumeMessage( const data::RecordId &repository_id, const data::Message_Ptr &) = 0;
+    virtual void consumeScript( const data::RecordId &repository_id, const data::Script_Ptr &) = 0;
+    virtual void consumePattern( const data::RecordId &repository_id, const data::Pattern_Ptr &) = 0;
 
     virtual void consumeChangelog( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const Changelog & ) = 0;
     virtual void consumeFilelist( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const data::Filenames & ) = 0;

Modified: trunk/libzypp/zypp2/cache/CacheStore.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.cpp?rev=5659&r1=5658&r2=5659&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.cpp (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.cpp Mon Jun  4 01:11:45 2007
@@ -97,6 +97,19 @@
 
     count_shared_cmd.reset( new sqlite3_command( con, "select count(id) from resolvables where shared_id=:rid;" ));
 
+    insert_patchrpm_cmd.reset( new sqlite3_command (con,
+      "insert into patch_packages (media_nr, location, checksum, download_size, build_time) "
+      "values (:media_nr, :location, :checksum, :download_size, :build_time);" ));
+    insert_deltarpm_cmd.reset( new sqlite3_command (con,
+      "insert into delta_packages (media_nr, location, checksum, download_size, build_time, "
+        "baseversion_version, baseversion_release, baseversion_epoch, baseversion_checksum, "
+        "baseversion_build_time, baseversion_sequence_info) "
+      "values (:media_nr, :location, :checksum, :download_size, :build_time, "
+        ":baseversion_version, :baseversion_release, :baseversion_epoch, :baseversion_checksum, "
+        ":baseversion_build_time, :baseversion_sequence_info);" ));
+    append_patch_baseversion_cmd.reset( new sqlite3_command (con,
+      "insert into patch_packages_baseversions (patch_package_id, version, release, epoch) "
+      "values (:patch_package_id, :version, :release, :epoch)" ));
 
 
     // disable autocommit
@@ -157,6 +170,10 @@
 
   sqlite3_command_ptr count_shared_cmd;
 
+  sqlite3_command_ptr insert_patchrpm_cmd;
+  sqlite3_command_ptr insert_deltarpm_cmd;
+  sqlite3_command_ptr append_patch_baseversion_cmd;
+
   map<string, RecordId> name_cache;
   map< pair<string,string>, RecordId> type_cache;
   int name_cache_hits;
@@ -185,19 +202,24 @@
   _pimpl->con.executenonquery("COMMIT;");
 }
 
-void CacheStore::consumeResObject( const data::RecordId &rid, data::ResObject_Ptr res )
+void CacheStore::appendResObjectAttributes( const data::RecordId &rid,
+                                            const data::ResObject_Ptr & res )
 {
   appendTranslatedStringAttribute( rid, "ResObject", "description", res->description );
   appendTranslatedStringAttribute( rid, "ResObject", "summary", res->summary );
   appendNumericAttribute( rid, "ResObject", "installedSize", res->installedSize );
   appendNumericAttribute( rid, "ResObject", "buildTime", res->buildTime );
+  appendBooleanAttribute( rid, "ResObject", "installOnly", res->installOnly );
+  appendStringAttribute( rid, "ResObject", "vendor", res->vendor );
+  appendTranslatedStringAttribute( rid, "ResObject", "licenseToConfirm", res->licenseToConfirm );
+  appendTranslatedStringAttribute( rid, "ResObject", "insnotify", res->insnotify );
+  appendTranslatedStringAttribute( rid, "ResObject", "delnotify", res->delnotify );
 }
 
-void CacheStore::consumePackage( const RecordId &repository_id, data::Package_Ptr package )
-{
-  RecordId pkgid = appendResolvable( repository_id, ResTraits<Package>::kind, NVRA( package->name, package->edition, package->arch ), package->deps );
-  consumeResObject( pkgid, package );
 
+void CacheStore::appendPackageBaseAttributes( const RecordId & pkgid,
+                                              const data::Packagebase_Ptr & package )
+{
   appendStringAttribute( pkgid, "Package", "checksum", package->repositoryLocation.fileChecksum.checksum() );
   appendStringAttribute( pkgid, "Package", "buildhost", package->buildhost );
   appendStringAttribute( pkgid, "Package", "distribution", package->distribution );
@@ -215,15 +237,40 @@
   appendStringAttribute( pkgid, "Package", "location", package->repositoryLocation.filePath.asString() );
 }
 
-void CacheStore::consumeSourcePackage( const data::RecordId &repository_id, data::SrcPackage_Ptr srcpackage )
+void CacheStore::consumePackage( const RecordId & repository_id,
+                                 const data::Package_Ptr & package )
 {
+  RecordId pkgid = appendResolvable( repository_id, ResTraits<Package>::kind,
+      NVRA( package->name, package->edition, package->arch ), package->deps );
+  appendResObjectAttributes( pkgid, package );
+  appendPackageBaseAttributes( pkgid, package );
+}
+
+void CacheStore::consumeSourcePackage( const data::RecordId & repository_id,
+                                       const data::SrcPackage_Ptr & package )
+{
+  RecordId pkgid = appendResolvable( repository_id, ResTraits<SrcPackage>::kind,
+      NVRA( package->name, package->edition, package->arch ), package->deps );
+  appendResObjectAttributes( pkgid, package );
+  appendPackageBaseAttributes( pkgid, package );
 #warning TBD
 }
 
-void CacheStore::consumePatch( const data::RecordId &repository_id, data::Patch_Ptr patch)
+void CacheStore::consumePatch( const data::RecordId & repository_id,
+                               const data::Patch_Ptr & patch)
 {
-  RecordId id = appendResolvable( repository_id, ResTraits<Patch>::kind, NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
-  consumeResObject( id, patch );
+  RecordId id = appendResolvable(
+      repository_id, ResTraits<Patch>::kind,
+      NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
+
+  appendResObjectAttributes( id, patch );
+
+  // patch attributes
+  appendNumericAttribute( id, "Patch", "timestamp",         patch->timestamp );
+  appendStringAttribute(  id, "Patch", "category",          patch->category );
+  appendBooleanAttribute( id, "Patch", "rebootNeeded",      patch->rebootNeeded );
+  appendBooleanAttribute( id, "Patch", "affectsPkgManager", patch->affectsPkgManager );
+
 
   DBG << "got patch " << patch->name << ", atoms: ";
   // cosume atoms
@@ -262,45 +309,95 @@
   DBG << endl;
 }
 
-void CacheStore::consumePackageAtom( const data::RecordId &repository_id, const data::PackageAtom_Ptr & atom )
+void CacheStore::consumePackageAtom( const data::RecordId & repository_id,
+                                     const data::PackageAtom_Ptr & atom )
 {
-  RecordId id = appendResolvable( repository_id, ResTraits<Atom>::kind, NVRA( atom->name, atom->edition, atom->arch ), atom->deps );
-  consumeResObject( id, atom );
+  RecordId id = appendResolvable( repository_id, ResTraits<Atom>::kind,
+      NVRA( atom->name, atom->edition, atom->arch ), atom->deps );
+  appendResObjectAttributes( id, atom );
+  appendPackageBaseAttributes( id, atom );
+
+  for (set<data::PatchRpm_Ptr>::const_iterator p = atom->patchRpms.begin();
+       p != atom->patchRpms.end(); ++p)
+    appendPatchRpm(*p);
+
+  for (set<data::DeltaRpm_Ptr>::const_iterator d = atom->deltaRpms.begin();
+       d != atom->deltaRpms.end(); ++d)
+    appendDeltaRpm(*d);
 }
 
-void CacheStore::consumeMessage( const data::RecordId &repository_id, data::Message_Ptr message )
+void CacheStore::consumeMessage( const data::RecordId & repository_id,
+                                 const data::Message_Ptr & message )
 {
-  RecordId id = appendResolvable( repository_id, ResTraits<Message>::kind, NVRA( message->name, message->edition, message->arch ), message->deps );
-  consumeResObject( id, message );
+  RecordId id = appendResolvable( repository_id, ResTraits<Message>::kind,
+      NVRA( message->name, message->edition, message->arch ), message->deps );
+  appendResObjectAttributes( id, message );
+
+  appendTranslatedStringAttribute( id, "Message", "text", message->text );
 }
 
-void CacheStore::consumeScript( const data::RecordId &repository_id, data::Script_Ptr script )
+void CacheStore::consumeScript( const data::RecordId & repository_id,
+                                const data::Script_Ptr & script )
 {
-  RecordId id = appendResolvable( repository_id, ResTraits<Script>::kind, NVRA( script->name, script->edition, script->arch ), script->deps );
-  consumeResObject( id, script );
+  RecordId id = appendResolvable( repository_id, ResTraits<Script>::kind,
+      NVRA( script->name, script->edition, script->arch ), script->deps );
+  appendResObjectAttributes( id, script );
+
+  appendStringAttribute( id, "Script", "doScript", script->doScript );
+  appendStringAttribute( id, "Script", "doScriptLocation", script->doScriptLocation.filePath.asString() );
+  appendStringAttribute( id, "Script", "doScriptChecksum", script->doScriptLocation.fileChecksum.checksum() );
+  //! \todo what about checksum type?
+  appendStringAttribute( id, "Script", "undoScript", script->undoScript );
+  appendStringAttribute( id, "Script", "undoScriptLocation", script->undoScriptLocation.filePath.asString() );
+  appendStringAttribute( id, "Script", "undoScriptChecksum", script->undoScriptLocation.fileChecksum.checksum() );
+  //! \todo what about checksum type?
 }
 
-void CacheStore::consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr pattern )
+void CacheStore::consumePattern( const data::RecordId & repository_id,
+                                 const data::Pattern_Ptr & pattern )
 {
-  RecordId id = appendResolvable( repository_id, ResTraits<Pattern>::kind, NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
-  consumeResObject( id, pattern );
+  RecordId id = appendResolvable( repository_id, ResTraits<Pattern>::kind,
+      NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
+  appendResObjectAttributes( id, pattern );
+
+  appendBooleanAttribute( id, "Pattern", "isDefault", pattern->isDefault );
+  appendBooleanAttribute( id, "Pattern", "userVisible", pattern->userVisible );
+  appendTranslatedStringAttribute( id, "Pattern", "category", pattern->category );
+  appendStringAttribute( id, "Pattern", "icon", pattern->icon );
+  appendStringAttribute( id, "Pattern", "order", pattern->order );
 }
 
-void CacheStore::consumeProduct( const data::RecordId &repository_id, data::Product_Ptr product )
+void CacheStore::consumeProduct( const data::RecordId & repository_id,
+                                 const data::Product_Ptr & product )
 {
-  RecordId id = appendResolvable( repository_id, ResTraits<Product>::kind, NVRA( product->name, product->edition, product->arch ), product->deps );
-  consumeResObject( id, product );
+  RecordId id = appendResolvable( repository_id, ResTraits<Product>::kind,
+      NVRA( product->name, product->edition, product->arch ), product->deps );
+  appendResObjectAttributes( id, product );
+
+  appendTranslatedStringAttribute( id, "Product", "shortName", product->shortName );
+  appendTranslatedStringAttribute( id, "Product", "longName", product->longName );
+  //! \todo std::list<std::string> flags;
+  appendStringAttribute( id, "Pattern", "releasenotesUrl", product->releasenotesUrl.asString() );
+  //! \todo std::list<Url> updateUrls;
+  //! \todo std::list<Url> extraUrls;
+  //! \todo std::list<Url> optionalUrls;
+  appendStringAttribute( id, "Pattern", "distributionName", product->distributionName );
+  appendStringAttribute( id, "Pattern", "distributionEdition", product->distributionEdition.asString() );
 }
 
-void CacheStore::consumeChangelog( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const Changelog & changelog )
+void CacheStore::consumeChangelog( const data::RecordId & repository_id,
+                                   const data::Resolvable_Ptr & resolvable,
+                                   const Changelog & changelog )
 {
   // TODO
-  // maybe consumeChangelog(const data::RecordId & resolvable_id, Changelog changelog) will
+  // maybe appendChangelog(const data::RecordId & resolvable_id, Changelog changelog) will
   // be needed for inserting the changelog using in-memory record id of corresponding
   // resolvable. (first, we'll see how fast is the inserting without remembering those ids)
 }
 
-void CacheStore::consumeFilelist( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const data::Filenames & filenames )
+void CacheStore::consumeFilelist( const data::RecordId & repository_id,
+                                  const data::Resolvable_Ptr & resolvable,
+                                  const data::Filenames & filenames )
 {
   // TODO
   // maybe consumeFilelist(const data::RecordId & resolvable_id, data::Filenames &) will
@@ -308,9 +405,9 @@
 }
 
 RecordId CacheStore::appendResolvable( const RecordId &repository_id,
-                                             const Resolvable::Kind &kind,
-                                             const NVRA &nvra,
-                                             const data::Dependencies &deps )
+                                       const Resolvable::Kind &kind,
+                                       const NVRA &nvra,
+                                       const data::Dependencies &deps )
 {
   _pimpl->append_resolvable_cmd->bind( ":name", nvra.name );
   _pimpl->append_resolvable_cmd->bind( ":version", nvra.edition.version() );
@@ -508,6 +605,59 @@
 }
 
 
+/** \todo lookupOrAppend ? */
+RecordId CacheStore::appendPatchRpm(const data::PatchRpm_Ptr & prpm)
+{
+  RecordId id;
+
+  //! \todo what's this? _pimpl->insert_patchrpm_cmd->bind(":media_nr", ???);
+  _pimpl->insert_patchrpm_cmd->bind(":location", prpm->location.filePath.asString());
+  _pimpl->insert_patchrpm_cmd->bind(":checksum", prpm->location.fileChecksum.checksum());
+  _pimpl->insert_patchrpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(prpm->location.fileSize));
+  _pimpl->insert_patchrpm_cmd->bind(":build_time", prpm->buildTime.asSeconds());
+  _pimpl->insert_patchrpm_cmd->executenonquery();
+
+  id = _pimpl->con.insertid();
+
+  for (set<data::BaseVersion_Ptr>::const_iterator bv = prpm->baseVersions.begin();
+       bv != prpm->baseVersions.end(); ++bv)
+  {
+    _pimpl->append_patch_baseversion_cmd->bind(":patch_package_id", id);
+    _pimpl->append_patch_baseversion_cmd->bind(":version", (*bv)->edition.version());
+    _pimpl->append_patch_baseversion_cmd->bind(":release", (*bv)->edition.release());
+    _pimpl->append_patch_baseversion_cmd->bind(":epoch", (int) (*bv)->edition.epoch());
+    _pimpl->append_patch_baseversion_cmd->executenonquery();
+  }

+  return id;
+}
+
+
+/** \todo lookupOrAppend ? */
+RecordId CacheStore::appendDeltaRpm(const data::DeltaRpm_Ptr & drpm)
+{
+  RecordId id;
+
+  //! \todo what's this? _pimpl->insert_deltarpm_cmd->bind(":media_nr", ???);
+  _pimpl->insert_deltarpm_cmd->bind(":location", drpm->location.filePath.asString());
+  _pimpl->insert_deltarpm_cmd->bind(":checksum", drpm->location.fileChecksum.checksum());
+  _pimpl->insert_deltarpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(drpm->location.fileSize));
+  _pimpl->insert_deltarpm_cmd->bind(":build_time", drpm->buildTime.asSeconds());
+
+  _pimpl->insert_deltarpm_cmd->bind(":baseversion_version", drpm->baseVersion.edition.version());
+  _pimpl->insert_deltarpm_cmd->bind(":baseversion_release", drpm->baseVersion.edition.release());
+  _pimpl->insert_deltarpm_cmd->bind(":baseversion_epoch", (int) drpm->baseVersion.edition.epoch());
+  _pimpl->insert_deltarpm_cmd->bind(":baseversion_build_time", drpm->baseVersion.buildTime.asSeconds());
+  _pimpl->insert_deltarpm_cmd->bind(":baseversion_checksum", drpm->baseVersion.checkSum.checksum());
+  _pimpl->insert_deltarpm_cmd->bind(":baseversion_sequence_info", drpm->baseVersion.sequenceInfo);
+
+  _pimpl->insert_deltarpm_cmd->executenonquery();
+  id = _pimpl->con.insertid();
+
+  return id;
+}
+
+
 // RecordId CacheStore::appendDependencyEntry( const RecordId &resolvable_id, zypp::Dep deptype, const Resolvable::Kind &refers )
 // {
 //   //DBG << "rid: " << resolvable_id << " deptype: " << deptype << " " << "refers: " << refers << endl;
@@ -744,6 +894,15 @@
   _pimpl->set_shared_flag_cmd->executenonquery();
 }
 
+void CacheStore::appendBooleanAttribute( const data::RecordId & resolvable_id,
+                                         const std::string & klass,
+                                         const std::string & name,
+                                         bool value)
+{
+  RecordId type_id = lookupOrAppendType( klass, name );
+  appendNumericAttribute( resolvable_id, type_id, value ? 1 : 0 );
+}
+
 void CacheStore::appendNumericAttribute( const data::RecordId &resolvable_id,
                                          const std::string &klass,
                                          const std::string &name,
@@ -786,7 +945,11 @@
                                                    const std::string &name,
                                                    const std::string &text )
 {
-  RecordId lang_id = lookupOrAppendType("lang", locale.code() );
+  // don't bother with writing if the string is empty
+  if (text.empty()) return;
+
+  RecordId lang_id = lookupOrAppendType("lang",
+      locale.code().empty() ? "none" : locale.code() );
   RecordId type_id = lookupOrAppendType( klass, name );
   appendStringAttribute( resolvable_id, lang_id, type_id, text );
 }
@@ -813,6 +976,9 @@
                             const RecordId &type_id,
                             const string &value )
 {
+  // don't bother with writing if the string is empty
+  if (value.empty()) return;
+
   // weak resolvable_id
   _pimpl->append_text_attribute_cmd->bind(":rid", resolvable_id );
   _pimpl->append_text_attribute_cmd->bind(":lang_id", lang_id );

Modified: trunk/libzypp/zypp2/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.h?rev=5659&r1=5658&r2=5659&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.h Mon Jun  4 01:11:45 2007
@@ -77,7 +77,8 @@
        * \param repository_id ownership.
        * \param package Package data
       */
-      virtual void consumePackage( const data::RecordId &repository_id, data::Package_Ptr package);
+      virtual void consumePackage(const data::RecordId &repository_id,
+                                  const data::Package_Ptr & package);
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -86,7 +87,9 @@
        * \param catalog_id ownership.
        * \param srcpackage Source package data
       */
-      virtual void consumeSourcePackage( const data::RecordId &catalog_id, data::SrcPackage_Ptr srcpackage );
+      virtual void consumeSourcePackage(
+                                      const data::RecordId &catalog_id,
+                                      const data::SrcPackage_Ptr & srcpackage );
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -95,7 +98,8 @@
        * \param repository_id ownership.
        * \param patch Patch data
       */
-      virtual void consumePatch( const data::RecordId &repository_id, data::Patch_Ptr patch);
+      virtual void consumePatch( const data::RecordId &repository_id,
+                                 const data::Patch_Ptr & patch );
 
       /**
        * Implementation of the \ref ResolvableConsumer interface.
@@ -109,7 +113,8 @@
        * \note this is somewhat specific to current YUM patch metadata design
        *       and may change (to consumeAtom(data::RecordId,data::Atom)).
        */
-      virtual void consumePackageAtom( const data::RecordId &repository_id, const data::PackageAtom_Ptr & atom );
+      virtual void consumePackageAtom( const data::RecordId &repository_id,
+                                       const data::PackageAtom_Ptr & atom );
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -118,7 +123,8 @@
        * \param repository_id ownership.
        * \param message Message data
       */
-      virtual void consumeMessage( const data::RecordId &repository_id, data::Message_Ptr);
+      virtual void consumeMessage( const data::RecordId & repository_id,
+                                   const data::Message_Ptr & message);
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -127,7 +133,8 @@
        * \param repository_id ownership.
        * \param script Script data
       */
-      virtual void consumeScript( const data::RecordId &repository_id, data::Script_Ptr);
+      virtual void consumeScript( const data::RecordId & repository_id,
+                                  const data::Script_Ptr & script);
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -136,7 +143,8 @@
        * \param repository_id ownership.
        * \param pattern Pattern data
       */
-      virtual void consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr pattern );
+      virtual void consumePattern( const data::RecordId & repository_id,
+                                   const data::Pattern_Ptr & pattern );
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -145,7 +153,8 @@
        * \param repository_id ownership.
        * \param pattern Pattern data
       */
-      virtual void consumeProduct( const data::RecordId &repository_id, data::Product_Ptr product );
+      virtual void consumeProduct( const data::RecordId &repository_id,
+                                   const data::Product_Ptr & product );
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -154,8 +163,11 @@
        * \param repository_id ownership.
        * \param resolvable resolvable for which the changelog data are to be saved
        * \param changelog  the changelog
-      */
-      virtual void consumeChangelog( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const Changelog & changelog );
+       * \todo see implementation
+       */
+      virtual void consumeChangelog( const data::RecordId & repository_id,
+                                     const data::Resolvable_Ptr & resolvable,
+                                     const Changelog & changelog );
 
       /**
        * Implementation of the \ref ResolvableConsumer interface
@@ -164,8 +176,11 @@
        * \param repository_id ownership.
        * \param resolvable resolvable for which the filelist is to be saved
        * \param filenames  list of filenames the resolvable contains
-      */
-      virtual void consumeFilelist( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const data::Filenames & filenames );
+       * \todo see implementation
+       */
+      virtual void consumeFilelist( const data::RecordId &repository_id,
+                                    const data::Resolvable_Ptr & resolvable,
+                                    const data::Filenames & filenames );
 
       /**
        * Appends a resolvable to the store.
@@ -336,6 +351,24 @@
                                     capability::CapabilityImpl::Ptr cap );
 
       /**
+       * Insert patch RPM data into <tt>patch_packages</tt> table.
+       *
+       * \param prpm The patch RPM object to insert.
+       * \return Record ID of the newly inserted record.
+       */
+      data::RecordId appendPatchRpm( const data::PatchRpm_Ptr & prpm);
+
+
+      /**
+       * Insert delta RPM data into <tt>delta_packages</tt> table.
+       *
+       * \param drpm The delta RPM object to insert.
+       * \return Record ID of the newly inserted record.
+       */
+      data::RecordId appendDeltaRpm( const data::DeltaRpm_Ptr & drpm);
+
+
+      /**
        * Returns the record id of a type
        *
        * Types are mostly used internally. To give concepts
@@ -562,10 +595,31 @@
                                    const data::RecordId &type_id,
                                    int value );
 
+      /**
+       * Append a bool attribute to a resolvable. Will be stored as
+       * numeric 1 or 0.
+       * 
+       * \param resolvable_id Resovable Id, owner of the attribute
+       * \param type_id attribute id
+       * \param value bool value
+       */
+      void appendBooleanAttribute( const data::RecordId & resolvable_id,
+                                   const std::string & klass,
+                                   const std::string & name,
+                                   bool value);
+
+      /** \name Detail Attributes Inserters
+       * These functions are used by ResolvableConsumer interface functions
+       * to avoid some duplication across types.
+       */
+      //@{
+      void appendResObjectAttributes( const data::RecordId &rid,
+                                      const data::ResObject_Ptr & res );
+
+      void appendPackageBaseAttributes(const data::RecordId & pkgid,
+                                       const data::Packagebase_Ptr & package);
+      //@}
 
-      // this functions are used by ResolvableConsumer interface functions
-      // to avoid some duplication across types.
-      void consumeResObject( const data::RecordId &rid, data::ResObject_Ptr res );
 
     private:
       /** Implementation. */

Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.cc?rev=5659&r1=5658&r2=5659&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.cc (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.cc Mon Jun  4 01:11:45 2007
@@ -26,6 +26,7 @@
   {
   }
 
+
   data::ResObject_Ptr fromRow( sqlite3_reader &reader )
   {
     data::ResObject_Ptr ptr (new data::ResObject);
@@ -39,6 +40,7 @@
     return ptr;
   }
 
+  
   void query( const data::RecordId &id,
                   ProcessResolvable fnc )
   {
@@ -55,6 +57,7 @@
     con.executenonquery("COMMIT;");
   }
 
+
   void query( const std::string &s,
               ProcessResolvable fnc  )
   {  
@@ -72,6 +75,7 @@
     con.executenonquery("COMMIT;");
   }
 
+
   std::string queryStringAttribute( const data::RecordId &record_id,
                                     const std::string &klass,
                                     const std::string &name )
@@ -80,6 +84,7 @@
     return queryStringAttributeTranslationInternal( con, record_id, Locale(), klass, name);
   }
 
+
   std::string queryStringAttributeTranslation( const data::RecordId &record_id,
                                                const Locale &locale,
                                                const std::string &klass,
@@ -89,6 +94,7 @@
     return queryStringAttributeTranslationInternal( con, record_id, locale, klass, name );
   }
 
+
   TranslatedText queryTranslatedStringAttribute( const data::RecordId &record_id,
                                                  const std::string &klass,
                                                  const std::string &name )
@@ -97,6 +103,7 @@
     return queryTranslatedStringAttributeInternal( con, record_id, klass, name );
   }
 
+
   int queryNumericAttribute( const data::RecordId &record_id,
                                  const std::string &klass,
                                  const std::string &name )
@@ -211,6 +218,14 @@
   return _pimpl->queryNumericAttribute(record_id, klass, name);
 }
 
+bool ResolvableQuery::queryBooleanAttribute( const data::RecordId &record_id,
+                                             const std::string &klass,
+                                             const std::string &name )
+{
+  return _pimpl->queryNumericAttribute(record_id, klass, name);
+}
+
+
 std::string ResolvableQuery::queryStringAttribute( const data::RecordId &record_id,
                                                    const std::string &klass,
                                                    const std::string &name )

Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.h?rev=5659&r1=5658&r2=5659&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.h (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.h Mon Jun  4 01:11:45 2007
@@ -65,7 +65,23 @@
       int queryNumericAttribute( const data::RecordId &record_id,
                                  const std::string &klass,
                                  const std::string &name );
-      
+
+
+      /**
+       * Queries a specifc attribute for a resolvable
+       *
+       * \param record_id Resolvable cache id
+       * \param klass Attribute Class
+       * \param name Attribute Name
+       *
+       * \return The bool value of the attribute or <tt>false</tt>
+       *         if no record is found.
+       */
+      bool queryBooleanAttribute( const data::RecordId &record_id,
+                                  const std::string &klass,
+                                  const std::string &name );
+
+
       /**
        * Queries a specifc attribute for a resolvable
        *

Modified: trunk/libzypp/zypp2/repo/cached/PackageImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/cached/PackageImpl.cc?rev=5659&r1=5658&r2=5659&view=diff
==============================================================================
--- trunk/libzypp/zypp2/repo/cached/PackageImpl.cc (original)
+++ trunk/libzypp/zypp2/repo/cached/PackageImpl.cc Mon Jun  4 01:11:45 2007
@@ -82,7 +82,7 @@
 
 bool PackageImpl::installOnly() const
 {
-  return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "installOnly" );
+  return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" );
 }
 
 unsigned PackageImpl::repositoryMediaNr() const

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages