Ejemplo n.º 1
0
 def run(self):
     """Explain every Overdrive collection and, for each one, all of its
     Advantage collections.
     """
     collections = Collection.by_protocol(self._db,
                                          ExternalIntegration.OVERDRIVE)
     for collection in collections:
         self.explain_main_collection(collection)
         print
Ejemplo n.º 2
0
 def run(self):
     """Explain every Overdrive collection and, for each one, all of its
     Advantage collections.
     """
     collections = Collection.by_protocol(
         self._db, ExternalIntegration.OVERDRIVE
     )
     for collection in collections:
         self.explain_main_collection(collection)
         print
Ejemplo n.º 3
0
 def all(cls, _db, **kwargs):
     if cls.PROTOCOL and cls.DATA_SOURCE_NAME:
         qu = Collection.by_protocol(_db, cls.PROTOCOL)
         qu = qu.join(ExternalIntegration.settings).filter(
             ConfigurationSetting.key ==
             Collection.DATA_SOURCE_NAME_SETTING,
             ConfigurationSetting.value == cls.DATA_SOURCE_NAME).order_by(
                 func.random())
         for collection in qu:
             yield cls(collection, **kwargs)
     else:
         for collection in super(OPDSImportCoverageProvider,
                                 cls).all(_db, **kwargs):
             yield collection
from core.model import (
    Collection,
    ConfigurationSetting,
    DataSource,
    ExternalIntegration,
    production_session,
)

log = logging.getLogger(name="Metadata Wrangler configuration import")

try:
    _db = production_session()

    # Get all of the OPDS_IMPORT collections.
    collections = Collection.by_protocol(_db, ExternalIntegration.OPDS_IMPORT)

    for collection in collections:
        opds_url = collection.external_account_id
        if not opds_url:
            decoded_collection, ignore = Collection.from_metadata_identifier(
                _db, collection.name
            )

            opds_url = decoded_collection.external_account_id
            if not opds_url:
                # This shouldn't happen.
                log.warn(
                    'Could not find external_account_id for %r' % collection
                )
                continue
from sqlalchemy.orm import aliased
from sqlalchemy import and_

from core.model import (
    Collection,
    Hyperlink,
    LicensePool,
    Representation,
    Resource,
    production_session,
)
from api.odl import SharedODLAPI

try:
    _db = production_session()
    for collection in Collection.by_protocol(_db, SharedODLAPI.NAME):
        borrow_link = aliased(Hyperlink)
        open_link = aliased(Hyperlink)

        pools = _db.query(
            LicensePool
        ).join(
            borrow_link,
            LicensePool.identifier_id==borrow_link.identifier_id,
        ).join(
            open_link,
            LicensePool.identifier_id==open_link.identifier_id,
        ).join(
            Resource,
            borrow_link.resource_id==Resource.id,
        ).join(
from sqlalchemy.orm import aliased
from sqlalchemy import and_

from core.model import (
    Collection,
    Hyperlink,
    LicensePool,
    Representation,
    Resource,
    production_session,
)
from api.odl import SharedODLAPI

try:
    _db = production_session()
    for collection in Collection.by_protocol(_db, SharedODLAPI.NAME):
        borrow_link = aliased(Hyperlink)
        open_link = aliased(Hyperlink)

        pools = _db.query(LicensePool).join(
            borrow_link,
            LicensePool.identifier_id == borrow_link.identifier_id,
        ).join(
            open_link,
            LicensePool.identifier_id == open_link.identifier_id,
        ).join(
            Resource,
            borrow_link.resource_id == Resource.id,
        ).join(
            Representation,
            Resource.representation_id == Representation.id,
Ejemplo n.º 7
0
from core.model import (
    Collection,
    ConfigurationSetting,
    DataSource,
    ExternalIntegration,
    production_session,
)

log = logging.getLogger(name="Metadata Wrangler configuration import")

try:
    _db = production_session()

    # Get all of the OPDS_IMPORT collections.
    collections = Collection.by_protocol(_db, ExternalIntegration.OPDS_IMPORT)

    for collection in collections:
        opds_url = collection.external_account_id
        if not opds_url:
            decoded_collection, ignore = Collection.from_metadata_identifier(
                _db, collection.name)

            opds_url = decoded_collection.external_account_id
            if not opds_url:
                # This shouldn't happen.
                log.warn('Could not find external_account_id for %r' %
                         collection)
                continue
            if opds_url and collection == decoded_collection:
                log.info('Added URL "%s" to collection %r',