コード例 #1
0
class RetainerRule(ProvisionRule):
    def __init__(self, context, rule_id):
        super(RetainerRule, self).__init__(context, rule_id)
        self._fields['recipient'] = DatabaseObjectField(
            parent=self,
            aspect='*',
            field_locator='recipient_user_id',
            dtype=User)

        self._fields['amount'] = CurrencyValueField(
            database_object=self, aspect='*', field_locator='fixed_amount')

        self._fields['role'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='role',
                                           dtype=ProvisionRuleRole)

        self._fields['one_time'] = SimpleField(database_object=self,
                                               aspect='*',
                                               field_locator='one_time',
                                               dtype=str)

        self._fields['group'] = SimpleField(database_object=self,
                                            aspect='*',
                                            field_locator='group',
                                            dtype=str,
                                            nullable=True,
                                            serialized_null='')

    recipient = FieldDescriptor('recipient')
    amount = FieldDescriptor('amount')
    _role = FieldDescriptor('role')
    _one_time = FieldDescriptor('one_time')
    group = FieldDescriptor('group')
コード例 #2
0
class Institution(DatabaseObject):
    _object_class = 'institution'

    def __init__(self, context, institution_id):
        super(Institution, self).__init__(context, institution_id)

        self._fields['name'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='name',
                                           dtype=str,
                                           kind=FieldKind.readonly)

        self._fields['city'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='city',
                                           dtype=str,
                                           kind=FieldKind.readonly)

        self._fields['country'] = ExtendableEnumField(
            database_object=self,
            aspect='*',
            field_locator='country_id',
            dtype=Country,
            nullable=True,
            serialized_null=0,
            kind=FieldKind.readonly)

    name = FieldDescriptor('name')
    city = FieldDescriptor('city')
    country = FieldDescriptor('country')

    @property
    def institution_id(self):
        return self._object_id
コード例 #3
0
class NonAcademic(CatalogTypeBase):
    _catalog_type = CatalogType.non_academic

    def __init__(self, document=None):
        super(NonAcademic, self).__init__(document)
        self._fields['publication_year'] = NullableIntField(
            database_object=document,
            aspect='non_academic.*',
            field_locator='non_academic.publication_year')
        self._fields['copyright_year'] = NullableIntField(
            database_object=document,
            aspect='non_academic.*',
            field_locator='non_academic.copyright_year')

        self._fields['vlb_category'] = ExtendableEnumField(
            database_object=document,
            aspect='non_academic.*',
            field_locator='non_academic.vlb_kat_id',
            dtype=VLBCategory,
            nullable=True)

        self._fields['genres'] = GenresList(document)
        self._fields['bisac'] = BisacList(document=document)

    publication_year = FieldDescriptor('publication_year')
    copyright_year = FieldDescriptor('copyright_year')
    vlb_category = FieldDescriptor('vlb_category')
    bisac = FieldDescriptor('bisac')
    genres = FieldDescriptor('genres')
コード例 #4
0
class Academic(CatalogTypeBase):
    _catalog_type = CatalogType.academic

    def __init__(self, document):
        super(Academic, self).__init__(document)
        self._fields['subject'] = SubjectField(document=document)
        self._fields['category'] = SimpleField(
            database_object=document,
            aspect='academic.*',
            dtype=AcademicCategory,
            field_locator='academic.category_id',
            nullable=True,
            serialized_null=0)
        self._fields['publication_year'] = SimpleField(
            database_object=document,
            dtype=str,
            nullable=True,
            aspect='academic.*',
            field_locator='academic.year_of_text')

        self._fields['institution'] = InstitutionField(document=document)

    subject = FieldDescriptor('subject')
    category = FieldDescriptor('category')
    publication_year = FieldDescriptor('publication_year')
    institution = FieldDescriptor('institution')
コード例 #5
0
class TaxGroup(FieldGroup):
    def __init__(self, user):
        super(TaxGroup, self).__init__(user)

        self._fields['vat_id'] = SimpleField(database_object=user,
                                             aspect='masterdata.*',
                                             field_locator='masterdata.vat_id',
                                             dtype=str)

        self._fields['tax_id'] = SimpleField(database_object=user,
                                             aspect='masterdata.*',
                                             field_locator='masterdata.tax_id',
                                             dtype=str)

        self._fields['authority'] = SimpleField(
            database_object=user,
            aspect='masterdata.*',
            field_locator='masterdata.tax_authority',
            dtype=str)

        self._fields['tax'] = TaxField(user)

    authority = FieldDescriptor('authority')
    vat_id = FieldDescriptor('vat_id')
    tax_id = FieldDescriptor('tax_id')
    tax = FieldDescriptor('tax')
コード例 #6
0
class Imprint(DatabaseObject):
    _object_class = 'realm_imprint'

    def __init__(self, context, imprint_id):
        super(Imprint, self).__init__(context, imprint_id)

        self._fields['imprint_name'] = SimpleField(
            database_object=self,
            aspect='imprint_name',
            field_locator='imprint_name',
            dtype=str,
            kind=FieldKind.readonly)

        self._fields['publisher_name'] = SimpleField(
            database_object=self,
            aspect='publisher_name',
            field_locator='publisher_name',
            dtype=str,
            kind=FieldKind.readonly)

        self._fields['publisher_id'] = SimpleField(
            database_object=self,
            aspect='isbn_publisher_identifier',
            field_locator='isbn_publisher_identifier',
            dtype=str,
            kind=FieldKind.readonly)

        self._fields['publisher_city'] = SimpleField(
            database_object=self,
            aspect='*',
            field_locator='publisher_city',
            dtype=str,
            kind=FieldKind.readonly)

        self._fields['publisher_country'] = ExtendableEnumField(
            database_object=self,
            aspect='*',
            field_locator='publisher_country_id',
            dtype=Country,
            nullable=True,
            serialized_null=0,
            kind=FieldKind.readonly)

    imprint_name = FieldDescriptor('imprint_name')
    publisher_name = FieldDescriptor('publisher_name')
    publisher_id = FieldDescriptor('publisher_id')
    publisher_city = FieldDescriptor('publisher_city')
    publisher_country = FieldDescriptor('publisher_country')

    @property
    def imprint_id(self):
        return self._object_id

    def __repr__(self):
        return '<Imprint {0}>'.format(self.imprint_name)

    def __str__(self):
        return '{0}'.format(self.imprint_name)
コード例 #7
0
class CatalogTypeBase(FieldGroup):
    _catalog_type = None

    def __init__(self, document):
        super(CatalogTypeBase, self).__init__(document)
        self._fields['series'] = SeriesList(document)
        self._fields['thema'] = ThemaList(document=document)

    series = FieldDescriptor('series')
    thema = FieldDescriptor('thema')

    @property
    def catalog_type(self):
        return self._catalog_type
コード例 #8
0
class MediaFileLink(DatabaseObject):
    """Class for GJP abstraction of media file links."""
    _object_class = 'document_mediafile_link'

    def __init__(self, context, mediafile_link_id):
        """Initalize a media file link."""
        super(MediaFileLink, self).__init__(context, mediafile_link_id)

        self._fields['url'] = SimpleField(database_object=self,
                                          aspect='*',
                                          field_locator='media_file_link',
                                          dtype=str)

        self._fields['type_code'] = SimpleField(
            database_object=self,
            aspect='*',
            field_locator='media_file_type_code',
            dtype=MediaFileTypeCode)

        self._fields['format_code'] = SimpleField(
            database_object=self,
            aspect='*',
            field_locator='media_file_format_code',
            dtype=MediaFileFormatCode,
            nullable=True)

        self._fields['link_type_code'] = SimpleField(
            database_object=self,
            aspect='*',
            field_locator='link_type_code',
            dtype=MediaFileLinkTypeCode)

        self._fields['publication_type'] = SimpleField(
            database_object=self,
            aspect='*',
            field_locator='publication_type',
            dtype=str)

    url = FieldDescriptor('url')
    type_code = FieldDescriptor('type_code')
    format_code = FieldDescriptor('format_code')
    link_type_code = FieldDescriptor('link_type_code')
    publication_type = FieldDescriptor('publication_type')

    @property
    def mediafile_link_id(self):
        """Property for media file link id."""
        return self._object_id
コード例 #9
0
class Manual(PriceTypeBase):
    _price_type = PriceType.manual

    def __init__(self, document, price_locator):
        super(Manual, self).__init__(document, price_locator)
        self._fields["territories"] = TerritoryList(
            document=document, price_locator=price_locator)

    territories = FieldDescriptor("territories")
コード例 #10
0
class Auto(PriceTypeBase):
    _price_type = PriceType.auto

    def __init__(self, document, price_locator):
        super(Auto, self).__init__(document, price_locator)
        self._fields["price"] = AutoPrice(document=document,
                                          price_locator=price_locator)

    price = FieldDescriptor("price")
コード例 #11
0
class ThemaSubject(DatabaseObject):
    _object_class = 'thema_subject'

    def __init__(self, context, thema_subject_id):
        super(ThemaSubject, self).__init__(context, thema_subject_id)

        self._fields['code'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='code',
                                           dtype=ThemaCode,
                                           kind=FieldKind.readonly)

        self._fields['name'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='screenname',
                                           dtype=str,
                                           kind=FieldKind.readonly)

    code = FieldDescriptor('code')
    name = FieldDescriptor('name')
コード例 #12
0
class BisacSubject(DatabaseObject):
    _object_class = 'bisac_subject'

    def __init__(self, context, bisac_subject_id):
        super(BisacSubject, self).__init__(context, bisac_subject_id)

        self._fields['code'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='subject_code',
                                           dtype=BisacCode,
                                           kind=FieldKind.readonly)

        self._fields['name'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='subject_name',
                                           dtype=str,
                                           kind=FieldKind.readonly)

    code = FieldDescriptor('code')
    name = FieldDescriptor('name')
コード例 #13
0
class PriceGroup(FieldGroup):
    def __init__(self, document):
        super(PriceGroup, self).__init__(document)
        self._fields["pod"] = PriceField(
            document=document,
            valid_price_types=(price_types.Auto, price_types.Manual,
                               price_types.NoPrice),
            price_locator="prices.pod")

        self._fields["ebook"] = PriceField(
            document=document,
            valid_price_types=(price_types.Auto, price_types.Manual,
                               price_types.OpenAccess, price_types.NoPrice),
            price_locator="prices.ebook")

        self._fields["audiobook"] = PriceField(
            document=document,
            valid_price_types=(price_types.Manual, price_types.NoPrice),
            price_locator="prices.audiobook")

        self._fields["software"] = PriceField(
            document=document,
            valid_price_types=(price_types.Manual, price_types.NoPrice),
            price_locator="prices.software")

    pod = FieldDescriptor("pod")
    ebook = FieldDescriptor("ebook")
    audiobook = FieldDescriptor("audiobook")
    software = FieldDescriptor("software")

    def recalculate(self):
        self.database_object.context.gjp.recalculate_prices(
            self.database_object.document_id)

    def current(self, product, country_code, currency_code=None):
        price_json = self.database_object.context.gjp.current_price(
            self.database_object.document_id,
            product=product,
            country_code=country_code,
            currency_code=currency_code)
        return CurrentPrice(price_json)
コード例 #14
0
class ProgressionRule(ProvisionRule):
    
    def __init__(self,
                 context,
                 rule_id):
        super(ProgressionRule, self).__init__(context,
                                             rule_id)
        self._fields['recipient'] = DatabaseObjectField(parent=self,
                                                        aspect='*',
                                                        field_locator='recipient_user_id',
                                                        dtype=User)

        self._fields['role'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='role',
                                           dtype=ProvisionRuleRole)
                                                
        self._fields['channels'] = ProgressionChannelsList(rule=self)

    recipient = FieldDescriptor('recipient')
    role = FieldDescriptor('role')
    channels = FieldDescriptor('channels')
コード例 #15
0
class ProvisionRule(DatabaseObject):
    _object_class = 'provision_rule'

    def __init__(self, context, rule_id):
        super(ProvisionRule, self).__init__(context, rule_id)
        self._fields['algorithm'] = SimpleField(database_object=self,
                                                aspect='*',
                                                field_locator='algorithm',
                                                dtype=ProvisionRuleAlgorithm)

        self._fields['source_type'] = SimpleField(database_object=self,
                                                  aspect='*',
                                                  field_locator='source_type',
                                                  dtype=str)

        self._fields['reference_id'] = SimpleField(
            database_object=self,
            aspect='*',
            field_locator='reference_id',
            dtype=int)

        self._fields['scope'] = SimpleField(database_object=self,
                                            aspect='*',
                                            field_locator='scope',
                                            dtype=str)

    _algorithm = FieldDescriptor('algorithm')
    _source_type = FieldDescriptor('source_type')
    _reference_id = FieldDescriptor('reference_id')
    _scope = FieldDescriptor('scope')

    @property
    def algorithm(self):
        return self._algorithm

    @property
    def rule_id(self):
        return self._object_id
コード例 #16
0
class DocumentAuthor(DatabaseObject):
    _object_class = 'document_author'

    def __init__(self, context, document_author_id):
        super(DocumentAuthor, self).__init__(context, document_author_id)

        self._fields['first_name'] = SimpleField(database_object=self,
                                                 aspect=':basic',
                                                 field_locator='first_name',
                                                 dtype=str)

        self._fields['last_name'] = SimpleField(database_object=self,
                                                aspect=':basic',
                                                field_locator='last_name',
                                                dtype=str)

        self._fields['user_id'] = SimpleField(database_object=self,
                                              aspect=':basic',
                                              field_locator='user_id',
                                              dtype=int,
                                              nullable=True)

        self._fields['role'] = ExtendableEnumField(
            database_object=self,
            aspect=':basic',
            field_locator='contributor_role_id',
            dtype=ContributorRole,
            nullable=True,
            serialized_null=0)

    first_name = FieldDescriptor('first_name')
    last_name = FieldDescriptor('last_name')
    user_id = FieldDescriptor('user_id')
    role = FieldDescriptor('role')

    @property
    def document_author_id(self):
        return self._object_id
コード例 #17
0
class TaxTypeBase(FieldGroup):
    _catalog_type = None

    def __init__(self, user):
        super(TaxTypeBase, self).__init__(user)
        self._fields['vat_percentage'] = SimpleField(
            database_object=user,
            aspect='masterdata.*',
            field_locator='masterdata.vat_percentage',
            dtype=int)

        self._fields['eu_reverse_charge'] = SimpleField(
            database_object=user,
            aspect='masterdata.*',
            field_locator='masterdata.vat_eu_reverse_charge',
            dtype=bool)

    _vat_percentage = FieldDescriptor('vat_percentage')
    _eu_reverse_charge = FieldDescriptor('eu_reverse_charge')

    @property
    def tax_type(self):
        return self._tax_type
コード例 #18
0
class DocumentSeries(DatabaseObject):
    _object_class = 'document_series'

    def __init__(self, context, document_series_id):
        super(DocumentSeries, self).__init__(context, document_series_id)

        self._fields['title'] = SimpleField(database_object=self,
                                            aspect='*',
                                            field_locator='title',
                                            dtype=str)

        self._fields['number'] = SimpleField(database_object=self,
                                             aspect='*',
                                             field_locator='number',
                                             dtype=str,
                                             nullable=True)

    title = FieldDescriptor('title')
    number = FieldDescriptor('number')

    @property
    def document_series_id(self):
        return self._object_id
コード例 #19
0
class CountryInfo(DatabaseObject):
    _object_class = 'country'
    
    def __init__(self,
                 context,
                 country_id):
        super(CountryInfo, self).__init__(context,
                                          country_id)

        self._fields['name'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='country',
                                           dtype=str,
                                           kind=FieldKind.readonly)


        self._fields['code'] = SimpleField(database_object=self,
                                           aspect='*',
                                           field_locator='code_iso',
                                           dtype=str,
                                           kind=FieldKind.readonly)                                           

        self._fields['code_2'] = SimpleField(database_object=self,
                                             aspect='*',
                                             field_locator='code_iso_2',
                                             dtype=str,
                                             kind=FieldKind.readonly)                                           
        

    name = FieldDescriptor('name')
    code = FieldDescriptor('code')
    code_2 = FieldDescriptor('code_2')

    @property
    def country_id(self):
        return self._object_id
コード例 #20
0
class Subject(DatabaseObject):
    _object_class = 'subject'

    def __init__(self, context, subject_id):
        super(Subject, self).__init__(context, subject_id)

        self._fields['bisac'] = BisacSubjectField(subject=self)

    bisac = FieldDescriptor('bisac')

    @property
    def subject_id(self):
        return self._object_id

    def __repr__(self):
        return '<Subject {0}>'.format(self.name)

    def __str__(self):
        return '{0}'.format(self.name)