repo/cached/PatchImpl.cc
repo/cached/PatternImpl.cc
repo/cached/ProductImpl.cc
+ repo/cached/MessageImpl.cc
)
SET( zypp_repository_cached_HEADERS
repo/cached/PatchImpl.h
repo/cached/PatternImpl.h
repo/cached/ProductImpl.h
+ repo/cached/MessageImpl.h
)
SET( zypp_repository_data_SRCS
std::string queryStringAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ const std::string &default_value )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryStringAttributeTranslationInternal( con, record_id, Locale(), klass, name);
+
+ string value;
+ try {
+ value = queryStringAttributeTranslationInternal( con, record_id, Locale(), klass, name);
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_CAUGHT(e);
+ return default_value;
+ }
+
+ return value;
}
std::string queryStringAttributeTranslation( const data::RecordId &record_id,
const Locale &locale,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ const std::string &default_value )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryStringAttributeTranslationInternal( con, record_id, locale, klass, name );
+ string value;
+ try {
+ value = queryStringAttributeTranslationInternal( con, record_id, locale, klass, name );
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_CAUGHT(e);
+ return default_value;
+ }
+ return value;
}
TranslatedText queryTranslatedStringAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ const TranslatedText &default_value )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryTranslatedStringAttributeInternal( con, record_id, klass, name );
+ TranslatedText value;
+ try {
+ value = queryTranslatedStringAttributeInternal( con, record_id, klass, name );
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_CAUGHT(e);
+ return default_value;
+ }
+ return value;
}
bool queryBooleanAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
+ const std::string &klass,
+ const std::string &name,
+ bool default_value )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return ( queryNumericAttributeInternal( con, record_id, klass, name) != 0 );
+ bool value;
+ try {
+ value = queryNumericAttributeInternal( con, record_id, klass, name);
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_CAUGHT(e);
+ return default_value;
+ }
+ return value;
}
int queryNumericAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
+ const std::string &klass,
+ const std::string &name,
+ int default_value )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryNumericAttributeInternal( con, record_id, klass, name);
+ int n;
+ try {
+ n = queryNumericAttributeInternal( con, record_id, klass, name);
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_CAUGHT(e);
+ return default_value;
+ }
+ return n;
}
private:
int ResolvableQuery::queryNumericAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ int default_value )
{
- return _pimpl->queryNumericAttribute(record_id, klass, name);
+ return _pimpl->queryNumericAttribute(record_id, klass, name, default_value);
}
bool ResolvableQuery::queryBooleanAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ bool default_value )
{
- return _pimpl->queryNumericAttribute(record_id, klass, name);
+ return _pimpl->queryNumericAttribute(record_id, klass, name, default_value);
}
std::string ResolvableQuery::queryStringAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ const std::string &default_value )
{
- return _pimpl->queryStringAttribute(record_id, klass, name);
+ return _pimpl->queryStringAttribute(record_id, klass, name, default_value);
}
//////////////////////////////////////////////////////////////////////////////
std::string ResolvableQuery::queryStringAttributeTranslation( const data::RecordId &record_id,
const Locale &locale,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ const std::string &default_value )
{
- return _pimpl->queryStringAttributeTranslation(record_id, locale, klass, name);
+ return _pimpl->queryStringAttributeTranslation(record_id, locale, klass, name, default_value );
}
//////////////////////////////////////////////////////////////////////////////
TranslatedText ResolvableQuery::queryTranslatedStringAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name )
+ const std::string &name,
+ const TranslatedText &default_value )
{
- return _pimpl->queryTranslatedStringAttribute(record_id, klass, name);
+ return _pimpl->queryTranslatedStringAttribute(record_id, klass, name, default_value );
}
//////////////////////////////////////////////////////////////////////////////
* \param klass Attribute Class
* \param name Attribute Name
*
- * \return The attribute or 0 if
+ * \return The attribute or -1 if
* no record is found.
*/
int queryNumericAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name );
+ const std::string &name,
+ int default_value = -1 );
/**
*/
bool queryBooleanAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name );
+ const std::string &name,
+ bool default_value = false );
/**
*/
std::string queryStringAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name );
+ const std::string &name,
+ const std::string &default_value = std::string() );
/**
* Queries a specifc attribute translation
std::string queryStringAttributeTranslation( const data::RecordId &record_id,
const Locale &locale,
const std::string &klass,
- const std::string &name );
+ const std::string &name,
+ const std::string &default_value = std::string() );
/**
* Queries all translations for a specific attribute
*/
TranslatedText queryTranslatedStringAttribute( const data::RecordId &record_id,
const std::string &klass,
- const std::string &name );
+ const std::string &name,
+ const TranslatedText &default_vaue = TranslatedText() );
/**
* Queries for a specific container attribute
* \param klass Attribute Class
* \param name Attribute Name
*
- * \return the attribute or a empty
- * \ref _Container if no record is found.
+ * The results are filled to the provided
+ * \ref _OutputIterator
*/
template<class _OutputIterator>
void queryStringContainerAttribute( const data::RecordId &record_id,
TranslatedText MessageImplIf::text() const
{ return TranslatedText(); }
- ByteCount MessageImplIf::size() const
- { return ResObjectImplIf::size(); }
-
/** Patch the message belongs to - if any */
Patch::constPtr MessageImplIf::patch() const
{ return Patch::constPtr(); }
public:
/** Get the text of the message */
virtual TranslatedText text() const PURE_VIRTUAL;
- /** */
- virtual ByteCount size() const;
/** Patch the message belongs to - if any */
virtual Patch::constPtr patch() const; // TODO make it abstract = 0;
};
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include "zypp/TranslatedText.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Logger.h"
+#include "zypp/repo/RepositoryImpl.h"
+#include "MessageImpl.h"
+
+
+using namespace std;
+using namespace zypp::detail;
+using namespace::zypp::repo;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp { namespace repo { namespace cached {
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : MessageImpl
+//
+///////////////////////////////////////////////////////////////////
+
+/** Default ctor
+*/
+MessageImpl::MessageImpl (const data::RecordId &id, cached::RepoImpl::Ptr repository_r)
+ : _repository (repository_r),
+ _id(id)
+{}
+
+Repository
+MessageImpl::repository() const
+{
+ return _repository->selfRepository();
+}
+
+///////////////////////////////////////////////////
+// ResObject Attributes
+///////////////////////////////////////////////////
+
+TranslatedText MessageImpl::summary() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "summary" );
+}
+
+TranslatedText MessageImpl::description() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "description" );
+}
+
+TranslatedText MessageImpl::insnotify() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "insnotify" );
+}
+
+TranslatedText MessageImpl::delnotify() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "delnotify" );
+}
+
+TranslatedText MessageImpl::licenseToConfirm() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "licenseToConfirm" );
+}
+
+Vendor MessageImpl::vendor() const
+{
+ return _repository->resolvableQuery().queryStringAttribute( _id, "ResObject", "vendor" );
+}
+
+
+ByteCount MessageImpl::size() const
+{
+ return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "size" );
+}
+
+ByteCount MessageImpl::archivesize() const
+{
+ return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "archivesize" );
+}
+
+bool MessageImpl::installOnly() const
+{
+ return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" );
+}
+
+Date MessageImpl::buildtime() const
+{
+ return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "buildtime" );
+}
+
+Date MessageImpl::installtime() const
+{
+ return Date();
+}
+
+//////////////////////////////////////////
+// DEPRECATED
+//////////////////////////////////////////
+
+Source_Ref MessageImpl::source() const
+{
+ return Source_Ref::noSource;
+}
+
+unsigned MessageImpl::sourceMediaNr() const
+{
+ return 1;
+}
+
+//////////////////////////////////////////
+// MESSAGE
+/////////////////////////////////////////
+
+TranslatedText MessageImpl::text() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "Message", "text" );
+}
+
+Patch::constPtr MessageImpl::patch() const
+{
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////
+} } } // namespace zypp::repo::cached
+///////////////////////////////////////////////////////////////////
+
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef zypp_repo_cached_MessageImpl_H
+#define zypp_repo_cached_MessageImpl_H
+
+#include "zypp/detail/MessageImpl.h"
+#include "zypp/repo/cached/RepoImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace repo
+{ /////////////////////////////////////////////////////////////////
+namespace cached
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : MessageImpl
+ //
+ class MessageImpl : public detail::MessageImplIf
+ {
+ public:
+
+ MessageImpl( 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;
+
+ // MESSAGE
+ virtual TranslatedText text() const;
+ virtual Patch::constPtr patch() 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
+