7.1.2.4. claimstore.models module

ClaimStore data model.

class claimstore.models.Claim(**kwargs)

Bases: flask_sqlalchemy.Model

Model representing a Claim.

Each claim is associated to a specific Claimant and references some already existing Identifier Types and predicate.

actor

Human that has performed the claim.

certainty

Certainty of the claim. It must be a float between 0 and 1.0.

claim_details

JSONB representation of the full claim as received.

claimant_id

Id of the associated Claimant.

created

Datetime in which the claim has been created by the claimant.

Get claims with the all the equivalent subjects or objects.

human

Whether the claims has been done by a human (1) or not (0).

id

Unique id of the claim.

object_eqid

Unique identifier for this object (type, value).

object_type_id

Id of the associated IdentifierType used as an object.

object_value

Value of the object.

predicate_id

Id of the associated Predicate.

received

Datetime in which the claim has been received and stored.

role

Role of the human who has performed the claim.

subject_eqid

Unique identifier for this subject (type, value).

subject_type_id

Id of the associated IdentifierType used as a subject.

subject_value

Value of the subject.

uuid

Universally Unique Identifier that represents a single claim.

class claimstore.models.Claimant(**kwargs)

Bases: flask_sqlalchemy.Model

Represents a Claimant.

Claimants are the main providers of claims. Each claimant may be associated to many different claims.

claim

Claim associated with this claimant.

id

Unique id of the claimant.

joined

Datetime when the claimant subscribed to ClaimStore.

name

Claimant name. It must be unique and preferably short.

url

URL of the claimant.

uuid

Universally unique id of the claimant.

class claimstore.models.EquivalentIdentifier(**kwargs)

Bases: flask_sqlalchemy.Model

Model that defines equivalent identifiers.

A given tuple (IdentifierType1, value1), e.g. (DOI, 1234) will have associated a unique id (eqid) that will be shared by the other tuple, e.g. (IdentifierType2, value2) in the relationship, in case the two IDs are equivalent (e.g. related via is_same_as predicate). If new equality claims are done in which existing identifiers are used, they will take the eqid from them.

For instance, if we have some claims like:

SubjectType SubjectValue Predicate ObjectType ObjectValue
Type1 Value1 is_same_as Type2 Value2
Type3 Value3 is_same_as Type4 Value4
Type1 Value1 is_same_as Type4 Value4
Type5 Value5 is_same_as Type6 Value6

Then, in the EquivalentIdentifier table there will be something like:

type value uuid
Type1 Value1 01
Type2 Value2 01
Type3 Value3 01
Type4 Value4 01
Type5 Value4 02
Type6 Value4 02

This table will enable and facilitate several use cases:

  1. We could very easily get a list of the different identifiers for the same data resource.
  2. It will simplify the recursive query by type/value in any subject/object claim.

Delete all the entries of the table equivalent_identifiers.

eqid

Universally Unique Identifier that represents a single data resource.

Return the identifiers of all the equivalent entities.

This method fetches the eqid for a given (type_name, value) and uses it to find all the equivalent identifiers. It returns a list with EquivalentIdentifier.id.

Return all the equivalent identifiers.

This method fetches the eqid for a given (type_name, value) and uses it to find all the equivalent identifiers.

id

Unique id of the data resource.

Rebuild index based on claims.

Store and return the equivalent identifiers as required.

type_id

The id of a given IdentifierType.

value

A given value for the IdentifierType.

class claimstore.models.IdentifierType(**kwargs)

Bases: flask_sqlalchemy.Model

Represents an identifier type.

An Identifier Type is a persistent identifier type that can be used in claims by claimants.

claimant_id

Id of the associated claimant that registered this identifier.

description

Description of the identifier type.

eqid

Backref in equivalent_identifier to reach this identifier_type.

example_url

Example of a full URL in which the identifier is being used.

example_value

Example of a possible value for an identifier.

id

Unique id of the Identifier.

name

Unique name of the identifier type. Preferably one word in caps.

object

Backref in claim to reach this identifier_type.

subject

Backref in claim to reach this identifier_type.

url

URL in which the identifier is used.

class claimstore.models.Predicate(**kwargs)

Bases: flask_sqlalchemy.Model

Represents a predicate.

The predicate defines the type of claim. An example of predicate could be: is_same_as.

claim

Backref in claim to reach this predicate.

description

Description of the predicate.

id

Unique id of the predicate.

name

Unique name of a predicate.