# Path: demetsiiify/extensions.py



from datetime import datetime
from flask import current_app, url_for
from sqlalchemy.dialects import postgresql as pg
from sqlalchemy.orm import load_only
from .extensions import db
import shortuuid
        if not identifiers:
            return
        base_query = pg.insert(cls).returning(Identifier.id)
        return db.session.execute(
            base_query.on_conflict_do_nothing(),
            [dict(id=i.id, type=i.type, manifest_id=i.manifest_id)
             for i in identifiers])

    @classmethod
    def resolve(cls, identifier):
        result = cls.query.filter_by(id=identifier).first()
        if result:
            return result.manifest_id


class Manifest(db.Model):
    surrogate_id = db.Column(db.Integer, primary_key=True)
    id = db.Column(db.String, unique=True, nullable=False)
    identifiers = db.relationship('Identifier', backref='manifest',
                                  lazy='dynamic')
    origin = db.Column(db.String, unique=True, nullable=False)
    manifest = db.Column(pg.JSONB, nullable=False)
    label = db.Column(db.String, nullable=False)

    def __init__(self, origin, manifest, label=None, id=None):
        self.id = id or shortuuid.uuid()
        self.origin = origin
        self.manifest = manifest
        self.label = label


# Path: demetsiiify/extensions.py



# Path: demetsiiify/models.py
from datetime import datetime
from flask import current_app, url_for
from sqlalchemy.dialects import postgresql as pg
from sqlalchemy.orm import load_only
from .extensions import db
import shortuuid

        if not identifiers:
            return
        base_query = pg.insert(cls).returning(Identifier.id)
        return db.session.execute(
            base_query.on_conflict_do_nothing(),
            [dict(id=i.id, type=i.type, manifest_id=i.manifest_id)
             for i in identifiers])

    @classmethod
    def resolve(cls, identifier):
        result = cls.query.filter_by(id=identifier).first()
        if result:
            return result.manifest_id


class Manifest(db.Model):
    surrogate_id = db.Column(db.Integer, primary_key=True)
    id = db.Column(db.String, unique=True, nullable=False)
    identifiers = db.relationship('Identifier', backref='manifest',
                                  lazy='dynamic')
    origin = db.Column(db.String, unique=True, nullable=False)
    manifest = db.Column(pg.JSONB, nullable=False)
    label = db.Column(db.String, nullable=False)

    def __init__(self, origin, manifest, label=None, id=None):
        self.id = id or shortuuid.uuid()
        self.origin = origin
        self.manifest = manifest
        self.label = label


    @classmethod