Skip to content

Model

QueryDOI

Bases: DomainObject

Object for holding query DOIs.

Source code in ckanext/query_dois/model.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class QueryDOI(DomainObject):
    """
    Object for holding query DOIs.
    """

    def get_resource_ids(self):
        return list(self.resources_and_versions.keys())

    def get_rounded_versions(self):
        return list(self.resources_and_versions.values())

    @staticmethod
    def on_resource(resource_id):
        """
        A convenience method to filter by a specific resource id.

        :param resource_id: the resource id
        :returns: an sqlalchemy boolean expression
        """
        return QueryDOI.resources_and_versions.has_key(resource_id)

on_resource(resource_id) staticmethod

A convenience method to filter by a specific resource id.

Parameters:

Name Type Description Default
resource_id

the resource id

required

Returns:

Type Description

an sqlalchemy boolean expression

Source code in ckanext/query_dois/model.py
67
68
69
70
71
72
73
74
75
@staticmethod
def on_resource(resource_id):
    """
    A convenience method to filter by a specific resource id.

    :param resource_id: the resource id
    :returns: an sqlalchemy boolean expression
    """
    return QueryDOI.resources_and_versions.has_key(resource_id)

QueryDOIStat

Bases: DomainObject

Object for holding query DOIs stats.

Source code in ckanext/query_dois/model.py
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
class QueryDOIStat(DomainObject):
    """
    Object for holding query DOIs stats.
    """

    def to_dict(self):
        """
        Returns the object as a dict for the stats API response.

        :returns: a dict
        """
        return {
            'id': self.id,
            'doi': self.doi,
            'action': self.action,
            'domain': self.domain,
            'identifier': self.identifier,
            'timestamp': str(self.timestamp),
        }

to_dict()

Returns the object as a dict for the stats API response.

Returns:

Type Description

a dict

Source code in ckanext/query_dois/model.py
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def to_dict(self):
    """
    Returns the object as a dict for the stats API response.

    :returns: a dict
    """
    return {
        'id': self.id,
        'doi': self.doi,
        'action': self.action,
        'domain': self.domain,
        'identifier': self.identifier,
        'timestamp': str(self.timestamp),
    }