Ejemplo n.º 1
0
def create_bundle_mop_sign_form(user_id,
                                session_key,
                                blank_form_serial,
                                signed_form_id,
                                form_data=None):
    bundle_id = 'b:%s/form/signing/%d' % (session_key, signed_form_id)
    b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
    b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())

    ag = b.agent('mopuser:%d/%s' % (user_id, session_key))
    bf = b.entity('form:blank/%s' % blank_form_serial,
                  [('prov:type', 'asset:BlankForm')])
    now = datetime.datetime.now()
    a = b.activity('ns:sign-form/%s' % blank_form_serial, now, now)
    b.wasAssociatedWith(a, ag)
    b.used(a, bf)
    data = {'prov:type': 'asset:SignedForm'}
    # Add relevant extra data of the form here
    if form_data is not None:
        data['mop:data'] = form_data
    sf = b.entity('form:signed/%s/%d' % (blank_form_serial, signed_form_id),
                  data)
    b.wasGeneratedBy(sf, a)
    b.wasAttributedTo(sf, ag)
    return bundle_id, b
Ejemplo n.º 2
0
def create_bundle_mop_logout(user_id, session_key):
    bundle_id = 'b:%s/logout' % session_key
    b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
    b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())

    ag = b.agent('mopuser:%d/%s' % (user_id, session_key))
    now = datetime.datetime.now()
    a = b.activity('log:%d/login/%s' % (user_id, session_key), now, now, other_attributes=[('prov:type', 'act:MopAccountLogout')])
    b.wasInvalidatedBy(ag, a)  # This user+session no longer exists after this
    return bundle_id, b
Ejemplo n.º 3
0
def create_bundle_mop_send_form(user_id, session_key, signed_form_id, blank_form_serial, email_id, unit_serial):
    bundle_id = 'b:%s/form/sending/%d' % (session_key, email_id)
    b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
    b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())

    ag = b.agent('mopuser:%d/%s' % (user_id, session_key))
    em = b.entity('email:%d' % email_id, [('prov:type', 'mop:Email'), ('mop:mailto', unit_serial)])
    sf = b.entity('form:signed/%s/%d' % (blank_form_serial, signed_form_id), [('prov:type', 'asset:SignedForm')])  # Add relevant extra data of the form here
    now = datetime.datetime.now()
    b.wasDerivedFrom(em, sf, time=now)
    b.wasAttributedTo(em, ag)
    return bundle_id, b
Ejemplo n.º 4
0
def create_bundle_mop_issue_form(user_id, session_key, signed_form_id, old_blank_form_serial, email_id, new_blank_form_serial, unit_serial):
#     t = long(time.time())
    bundle_id = 'b:%s/form/issue/%s' % (session_key, new_blank_form_serial)
    b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
    b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())

    ag = b.agent('dept:%s' % unit_serial)
    sf = b.entity('form:signed/%s/%d' % (old_blank_form_serial, signed_form_id))
    em = b.entity('email:%d' % email_id)
    now = datetime.datetime.now()
    a = b.activity('bs:issue-form/%s' % new_blank_form_serial, now, now)
    b.wasAssociatedWith(a, ag)
    b.used(a, em)
    nf = b.entity('form:blank/%s' % new_blank_form_serial)
    b.wasGeneratedBy(nf, a)
    b.wasDerivedFrom(nf, sf)
    return bundle_id, b
Ejemplo n.º 5
0
def create_bundle_mop_issue_document(user_id, session_key, email_id, blank_form_serial, signed_form_id, document_serial, document_instance_id, unit_serial):
    bundle_id = 'b:%s/document/issue/%s' % (session_key, document_instance_id)
    b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
    b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())

    ag = b.agent('dept:%s' % unit_serial)
    sf = b.entity('form:signed/%s/%d' % (blank_form_serial, signed_form_id))
    em = b.entity('email:%d' % email_id)
    now = datetime.datetime.now()
    a = b.activity('bs:issue-document/%d' % document_instance_id, now, now)
    b.wasAssociatedWith(a, ag)
    b.used(a, em)
    d = b.entity('document:%s' % document_serial, [('prov:type', 'asset:Document')])
    b.used(a, d)
    di = b.entity('document:%s/%d' % (document_serial, document_instance_id), [('prov:type', 'asset:MopDocumentInstance')])
    b.wasGeneratedBy(di, a)
    b.wasDerivedFrom(di, sf)
    b.wasDerivedFrom(di, d)
    return bundle_id, b