OK = 'ok',
                    ERROR = 'error' )
    def __init__( self, state=None, plugin=None, params=None ):
        self.state = state
        self.plugin = plugin
        self.params = params

DeferredJob.table = Table( "deferred_job", metadata,
    Column( "id", Integer, primary_key=True ),
    Column( "create_time", DateTime, default=now ),
    Column( "update_time", DateTime, default=now, onupdate=now ),
    Column( "state", String( 64 ), index=True ),
    Column( "plugin", String( 128 ), index=True ),
    Column( "params", JSONType ) )

assign_mapper( context, DeferredJob, DeferredJob.table, properties = {} )

def upgrade():
    print __doc__
    liftoverjobs = dict()
    
    jobs = context.query( DeferredJob ).filter_by( plugin='LiftOverTransferPlugin' ).all()
    
    for job in jobs:
        if job.params[ 'parentjob' ] not in liftoverjobs:
            liftoverjobs[ job.params[ 'parentjob' ] ] = []
        liftoverjobs[ job.params[ 'parentjob'] ].append( job.id )
    
    for parent in liftoverjobs:
        lifts = liftoverjobs[ parent ]
        deferred = context.query( DeferredJob ).filter_by( id=parent ).first()
    Column( "info", TrimmedString( 255 ),  key="_info" ), #when not None/null this will supercede display in library (but not when imported into user's history?)
    Column( "deleted", Boolean, index=True, default=False ) )



##mappers


assign_mapper( context, Dataset, Dataset.table,
    properties=dict( 
        history_associations=relation( 
            HistoryDatasetAssociation, 
            primaryjoin=( Dataset.table.c.id == HistoryDatasetAssociation.table.c.dataset_id ) ),
        active_history_associations=relation( 
            HistoryDatasetAssociation, 
            primaryjoin=( ( Dataset.table.c.id == HistoryDatasetAssociation.table.c.dataset_id ) & ( HistoryDatasetAssociation.table.c.deleted == False ) ) ),
        library_associations=relation( 
            LibraryDatasetDatasetAssociation, 
            primaryjoin=( Dataset.table.c.id == LibraryDatasetDatasetAssociation.table.c.dataset_id ) ),
        active_library_associations=relation( 
            LibraryDatasetDatasetAssociation, 
            primaryjoin=( ( Dataset.table.c.id == LibraryDatasetDatasetAssociation.table.c.dataset_id ) & ( LibraryDatasetDatasetAssociation.table.c.deleted == False ) ) )
            ) )


assign_mapper( context, HistoryDatasetAssociation, HistoryDatasetAssociation.table,
    properties=dict( 
        dataset=relation( 
            Dataset, 
            primaryjoin=( Dataset.table.c.id == HistoryDatasetAssociation.table.c.dataset_id ), lazy=False ),
        # .history defined in History mapper
Пример #3
0
##mappers

assign_mapper(
    context,
    Dataset,
    Dataset.table,
    properties=dict(
        history_associations=relation(
            HistoryDatasetAssociation,
            primaryjoin=(Dataset.table.c.id ==
                         HistoryDatasetAssociation.table.c.dataset_id)),
        active_history_associations=relation(
            HistoryDatasetAssociation,
            primaryjoin=(
                (Dataset.table.c.id
                 == HistoryDatasetAssociation.table.c.dataset_id) &
                (HistoryDatasetAssociation.table.c.deleted == False))),
        library_associations=relation(
            LibraryDatasetDatasetAssociation,
            primaryjoin=(Dataset.table.c.id ==
                         LibraryDatasetDatasetAssociation.table.c.dataset_id)),
        active_library_associations=relation(
            LibraryDatasetDatasetAssociation,
            primaryjoin=(
                (Dataset.table.c.id
                 == LibraryDatasetDatasetAssociation.table.c.dataset_id) &
                (LibraryDatasetDatasetAssociation.table.c.deleted == False)))))

assign_mapper(
    context,