本文整理汇总了Python中prov.model.ProvDocument.entity方法的典型用法代码示例。如果您正苦于以下问题:Python ProvDocument.entity方法的具体用法?Python ProvDocument.entity怎么用?Python ProvDocument.entity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prov.model.ProvDocument
的用法示例。
在下文中一共展示了ProvDocument.entity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deriveDependency
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def deriveDependency(self, aDO, aRO, derivedList):
d1 = ProvDocument() # d1 is now an empty provenance document
d1.add_namespace("dt", "http://cs.ncl.ac.uk/dtsim/")
e1 = d1.entity(DTns + aRO.id) # deriving
ag1 = d1.agent(DTns + str(aDO.id))
for der in derivedList:
# create provlet
e2 = d1.entity(DTns + der.id) # derived
d1.wasAttributedTo(e2, ag1)
d1.wasDerivedFrom(e2, e1)
# update upstream pointer
der.upstream = [(aRO, None)] # aRO is upstream from aRO with no activity
# update downstream
aRO.downstream.append((der, None)) # aR1 is downstream from aR1 with no activity
# update global graph
e1 = pGlobal.entity(DTns + aRO.id) # deriving
ag1 = pGlobal.agent(DTns + str(aDO.id))
pGlobal.wasAttributedTo(e2, ag1)
for der in derivedList:
e2 = pGlobal.entity(DTns + der.id) # derived
pGlobal.wasDerivedFrom(e2, e1)
# trigger credit recomputation
for der in derivedList:
# aRO needs its credit updated with aRO1.credit
aCreditManager.addDerivationCredit(aRO, der.currentTotalCredit)
# self.notify(d1)
return d1
示例2: test_xsd_qnames
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def test_xsd_qnames(self):
prov_doc = ProvDocument()
ex = Namespace('ex', 'http://www.example.org')
prov_doc.add_namespace(ex)
an_xsd_qname = XSDQName(ex['a_value'])
prov_doc.entity('ex:e1', {'prov:value': an_xsd_qname})
self.assertPROVJSONRoundTripEquivalence(prov_doc)
示例3: bundles2
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def bundles2():
# https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles2.provn
#===========================================================================
# document
g = ProvDocument()
# prefix ex <http://example.org/example/>
g.add_namespace("ex", "http://www.example.com/")
# prefix alice <http://example.org/alice/>
# prefix bob <http://example.org/bob/>
g.add_namespace('alice', 'http://example.org/alice/')
g.add_namespace('bob', 'http://example.org/bob/')
# entity(bob:bundle4, [prov:type='prov:Bundle'])
# wasGeneratedBy(bob:bundle4, -, 2012-05-24T10:30:00)
# agent(ex:Bob)
# wasAttributedTo(bob:bundle4, ex:Bob)
g.entity('bob:bundle4', {'prov:type': PROV['Bundle']})
g.wasGeneratedBy('bob:bundle4', time='2012-05-24T10:30:00')
g.agent('ex:Bob')
g.wasAttributedTo('bob:bundle4', 'ex:Bob')
# entity(alice:bundle5, [ prov:type='prov:Bundle' ])
# wasGeneratedBy(alice:bundle5, -, 2012-05-25T11:15:00)
# agent(ex:Alice)
# wasAttributedTo(alice:bundle5, ex:Alice)
g.entity('alice:bundle5', {'prov:type': PROV['Bundle']})
g.wasGeneratedBy('alice:bundle5', time='2012-05-25T11:15:00')
g.agent('ex:Alice')
g.wasAttributedTo('alice:bundle5', 'ex:Alice')
# bundle bob:bundle4
# entity(ex:report1, [ prov:type="report", ex:version=1 ])
# wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01)
# endBundle
b4 = g.bundle('bob:bundle4')
b4.entity('ex:report1', {'prov:type': "report", 'ex:version': 1})
b4.wasGeneratedBy('ex:report1', time='2012-05-24T10:00:01')
# bundle alice:bundle5
# entity(ex:report1bis)
# mentionOf(ex:report1bis, ex:report1, bob:bundle4)
# entity(ex:report2, [ prov:type="report", ex:version=2 ])
# wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01)
# wasDerivedFrom(ex:report2, ex:report1bis)
# endBundle
b5 = g.bundle('alice:bundle5')
b5.entity('ex:report1bis')
b5.mentionOf('ex:report1bis', 'ex:report1', 'bob:bundle4')
b5.entity('ex:report2', [('prov:type', "report"), ('ex:version', 2)])
b5.wasGeneratedBy('ex:report2', time='2012-05-25T11:00:01')
b5.wasDerivedFrom('ex:report2', 'ex:report1bis')
# endDocument
return g
示例4: long_literals
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def long_literals():
g = ProvDocument()
long_uri = "http://Lorem.ipsum/dolor/sit/amet/consectetur/adipiscing/elit/Quisque/vel/sollicitudin/felis/nec/venenatis/massa/Aenean/lectus/arcu/sagittis/sit/amet/nisl/nec/varius/eleifend/sem/In/hac/habitasse/platea/dictumst/Aliquam/eget/fermentum/enim/Curabitur/auctor/elit/non/ipsum/interdum/at/orci/aliquam/"
ex = Namespace('ex', long_uri)
g.add_namespace(ex)
g.entity('ex:e1', {'prov:label': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pellentesque luctus nulla vel ullamcorper. Donec sit amet ligula sit amet lorem pretium rhoncus vel vel lorem. Sed at consequat metus, eget eleifend massa. Fusce a facilisis turpis. Lorem volutpat.'})
return g
示例5: job2prov
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def job2prov(job):
"""
Create ProvDocument based on job description
:param job: UWS job
:return: ProvDocument
"""
# job.jdl.content = {
# 'description': description,
# 'parameters': parameters,
# 'results': results,
# 'executionduration': execdur,
# 'quote': quote
# }
# parameters[pname] = {
# 'type': p.get('type'),
# 'required': p.get('required'),
# 'default': p.get('default'),
# 'description': list(p)[0].text,
# }
# results[r.get('value')] = {
# 'mediaType': r.get('mediaType'),
# 'default': r.get('default'),
# 'description': list(r)[0].text,
# }
pdoc = ProvDocument()
# Declaring namespaces for various prefixes used in the example
pdoc.add_namespace('prov', 'http://www.w3.org/ns/prov#')
pdoc.add_namespace('voprov', 'http://www.ivoa.net/ns/voprov#')
pdoc.add_namespace('cta', 'http://www.cta-observatory.org#')
pdoc.add_namespace('uwsdata', 'https://voparis-uws-test.obspm.fr/rest/' + job.jobname + '/' + job.jobid + '/')
pdoc.add_namespace('ctajobs', 'http://www.cta-observatory.org#')
# Adding an activity
ctbin = pdoc.activity('ctajobs:' + job.jobname, job.start_time, job.end_time)
# TODO: add job description, version, url, ...
# Agent
pdoc.agent('cta:consortium', other_attributes={'prov:type': "Organization"})
pdoc.wasAssociatedWith(ctbin, 'cta:consortium')
# Entities, in and out with relations
e_in = []
for pname, pdict in job.jdl.content['parameters'].iteritems():
#if pname.startswith('in'):
if any(x in pdict['type'] for x in ['file', 'xs:anyURI']):
e_in.append(pdoc.entity('uwsdata:parameters/' + pname))
# TODO: use publisher_did? add prov attributes, add voprov attributes?
ctbin.used(e_in[-1])
e_out = []
for rname, rdict in job.jdl.content['results'].iteritems():
e_out.append(pdoc.entity('uwsdata:results/' + rname))
# TODO: use publisher_did? add prov attributes, add voprov attributes?
e_out[-1].wasGeneratedBy(ctbin)
for e in e_in:
e_out[-1].wasDerivedFrom(e)
return pdoc
示例6: bundles1
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def bundles1():
# https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles1.provn
#===============================================================================
# document
g = ProvDocument()
# prefix ex <http://example.org/example/>
EX = Namespace("ex", "http://www.example.com/")
g.add_namespace(EX)
# prefix alice <http://example.org/alice/>
# prefix bob <http://example.org/bob/>
g.add_namespace('alice', 'http://example.org/alice/')
g.add_namespace('bob', 'http://example.org/bob/')
# entity(bob:bundle1, [prov:type='prov:Bundle'])
g.entity('bob:bundle1', {'prov:type': PROV['Bundle']})
# wasGeneratedBy(bob:bundle1, -, 2012-05-24T10:30:00)
g.wasGeneratedBy('bob:bundle1', time='2012-05-24T10:30:00')
# agent(ex:Bob)
g.agent('ex:Bob')
# wasAttributedTo(bob:bundle1, ex:Bob)
g.wasAttributedTo('bob:bundle1', 'ex:Bob')
# entity(alice:bundle2, [ prov:type='prov:Bundle' ])
g.entity('alice:bundle2', {'prov:type': PROV['Bundle']})
# wasGeneratedBy(alice:bundle2, -, 2012-05-25T11:15:00)
g.wasGeneratedBy('alice:bundle2', time='2012-05-25T11:15:00')
# agent(ex:Alice)
g.agent('ex:Alice')
# wasAttributedTo(alice:bundle2, ex:Alice)
g.wasAttributedTo('alice:bundle2', 'ex:Alice')
# bundle bob:bundle1
b1 = g.bundle('bob:bundle1')
# entity(ex:report1, [ prov:type="report", ex:version=1 ])
b1.entity('ex:report1', {'prov:type': "report", 'ex:version': 1})
# wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01)
b1.wasGeneratedBy('ex:report1', time='2012-05-24T10:00:01')
# endBundle
# bundle alice:bundle2
b2 = g.bundle('alice:bundle2')
# entity(ex:report1)
b2.entity('ex:report1')
# entity(ex:report2, [ prov:type="report", ex:version=2 ])
b2.entity('ex:report2', {'prov:type': "report", 'ex:version': 2})
# wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01)
b2.wasGeneratedBy('ex:report2', time='2012-05-25T11:00:01')
# wasDerivedFrom(ex:report2, ex:report1)
b2.wasDerivedFrom('ex:report2', 'ex:report1')
# endBundle
# endDocument
return g
示例7: primer_example_alternate
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def primer_example_alternate():
g = ProvDocument(namespaces={
'ex': 'http://example/',
'dcterms': 'http://purl.org/dc/terms/',
'foaf': 'http://xmlns.com/foaf/0.1/'
})
article = g.entity('ex:article', {'dcterms:title': "Crime rises in cities"})
articleV1 = g.entity('ex:articleV1')
articleV2 = g.entity('ex:articleV2')
dataSet1 = g.entity('ex:dataSet1')
dataSet2 = g.entity('ex:dataSet2')
regionList = g.entity('ex:regionList')
composition = g.entity('ex:composition')
chart1 = g.entity('ex:chart1')
chart2 = g.entity('ex:chart2')
blogEntry = g.entity('ex:blogEntry')
compile = g.activity('ex:compile')
compile2 = g.activity('ex:compile2')
compose = g.activity('ex:compose')
correct = g.activity('ex:correct', '2012-03-31T09:21:00', '2012-04-01T15:21:00')
illustrate = g.activity('ex:illustrate')
compose.used(dataSet1, attributes={'prov:role': "ex:dataToCompose"})
compose.used(regionList, attributes={'prov:role': "ex:regionsToAggregateBy"})
composition.wasGeneratedBy(compose)
illustrate.used(composition)
chart1.wasGeneratedBy(illustrate)
chart1.wasGeneratedBy(compile, '2012-03-02T10:30:00')
derek = g.agent('ex:derek', {
'prov:type': PROV['Person'], 'foaf:givenName': "Derek", 'foaf:mbox': "<mailto:[email protected]>"
})
compose.wasAssociatedWith(derek)
illustrate.wasAssociatedWith(derek)
chartgen = g.agent('ex:chartgen', {
'prov:type': PROV["Organization"], 'foaf:name': "Chart Generators Inc"
})
derek.actedOnBehalfOf(chartgen, compose)
chart1.wasAttributedTo(derek)
dataSet2.wasGeneratedBy(correct)
correct.used(dataSet1)
dataSet2.wasDerivedFrom(dataSet1, attributes={'prov:type': PROV['Revision']})
chart2.wasDerivedFrom(dataSet2)
blogEntry.wasDerivedFrom(article, attributes={'prov:type': PROV['Quotation']})
articleV1.specializationOf(article)
articleV1.wasDerivedFrom(dataSet1)
articleV2.specializationOf(article)
articleV2.wasDerivedFrom(dataSet2)
articleV2.alternateOf(articleV1)
return g
示例8: collections
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def collections():
g = ProvDocument()
ex = Namespace('ex', 'http://example.org/')
c1 = g.collection(ex['c1'])
e1 = g.entity('ex:e1')
g.hadMember(c1, e1)
return g
示例9: datatypes
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def datatypes():
g = ProvDocument()
ex = Namespace('ex', 'http://example.org/')
g.add_namespace(ex)
attributes = {'ex:int': 100,
'ex:float': 100.123456,
'ex:long': 123456789000,
'ex:bool': True,
'ex:str': 'Some string',
'ex:unicode': u'Some unicode string with accents: Huỳnh Trung Đông',
'ex:timedate': datetime.datetime(2012, 12, 12, 14, 7, 48),
'ex:intstr': Literal("PROV Internationalized string", PROV["InternationalizedString"], "en"),
}
multiline = """Line1
Line2
Line3"""
attributes['ex:multi-line'] = multiline
g.entity('ex:e1', attributes)
return g
示例10: ctfToProv
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def ctfToProv():
d1 = ProvDocument()
dummy = ProvDocument()
ex = Namespace('ex', 'http://example/') # namespaces do not need to be explicitly added to a document
#data = event_field(os.path.join(trace_path,'../config.yaml'))
counter = 0
counter_1 = 0
relationships = []
entities = []
activities = []
producer_events = {}
for event in trace_collection.events:
dataset = {'ex:'+k:event[k] for k in event.field_list_with_scope(
babeltrace.CTFScope.EVENT_FIELDS)}
dataset.update({'ex:'+'timestamp':(event['timestamp']/1000000000)})
#dataset.update({'ex:'+'name':event.name})
e1 = d1.entity(ex['event'+str(counter)],dataset)
entities.append(e1)
producer_agent = d1.agent('ex:'+event['producer_id'])
if event['producer_id'] not in producer_events:
producer_events[event['producer_id']] = []
else:
pel = producer_events[events['producer_id']]
d1.wasAssociatedWith(pel[len(pel)-1], e1)
pel.append(e1)
controller_agent = d1.agent('ex:'+event['controller_id'])
activity = d1.activity('ex:'+event['activity']+str(counter_1))
activities.append(activity)
d1.wasGeneratedBy(e1, activity)
# strings used to detect if the relationship already exists in the d1 document
association_relationship = str(dummy.wasAssociatedWith(activity, producer_agent))
used_relationship = str(dummy.used(controller_agent, producer_agent))
# Add activity to producer agent if it has not been added before.
d1.wasAssociatedWith(activity, producer_agent)
# if association_relationship not in relationships:
# d1.wasAssociatedWith(activity, producer_agent)
# relationships.append(association_relationship)
# Add producer agent to controller agent if it has not been added yet.
if used_relationship not in relationships:
d1.used(controller_agent, producer_agent)
relationships.append(used_relationship)
# Add temporal relationship between this event and the previous one.
# if counter > 0:
# d1.wasAssociatedWith(entities[counter - 1], e1)
counter+=1
counter_1 +=1
return d1
示例11: test_document_update_simple
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def test_document_update_simple(self):
d1 = ProvDocument()
d1.set_default_namespace(EX_URI)
d1.entity('e')
b1 = d1.bundle('b1')
b1.entity('e')
d2 = ProvDocument()
d2.set_default_namespace(EX_URI)
d2.entity('e')
b1 = d2.bundle('b1')
b1.entity('e')
b2 = d2.bundle('b2')
b2.entity('e')
self.assertRaises(ProvException, lambda: d1.update(1))
d1.update(d2)
self.assertEqual(len(d1.get_records()), 2)
self.assertEqual(len(d1.bundles), 2)
示例12: test_xsd_qnames
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def test_xsd_qnames(self):
prov_doc = ProvDocument()
ex = Namespace('ex', 'http://www.example.org/')
prov_doc.add_namespace(ex)
ex1 = Namespace('ex1', 'http://www.example1.org/') # ex1 is not added to the document
an_xsd_qname = XSDQName(ex['a_value'])
another_xsd_qname = XSDQName(ex1['another_value'])
e1 = prov_doc.entity('ex:e1', {'prov:value': an_xsd_qname, 'prov:type': another_xsd_qname})
for _, attr_value in e1.attributes:
self.assertIsInstance(attr_value, XSDQName)
self.assertRoundTripEquivalence(prov_doc)
示例13: generateProvlet
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def generateProvlet(self, aDO, aRO):
# create provlet
d1 = ProvDocument() # d1 is now an empty provenance document
d1.add_namespace("dt", "http://cs.ncl.ac.uk/dtsim/")
e1 = d1.entity(DTns + aRO.id)
ag1 = d1.agent(DTns + str(aDO.id))
d1.wasAttributedTo(e1, ag1)
# update global graph
e1 = pGlobal.entity(DTns + aRO.id)
ag1 = pGlobal.agent(DTns + str(aDO.id))
pGlobal.wasAttributedTo(e1, ag1)
# self.notify(d1)
return d1
示例14: write_targets_prov
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def write_targets_prov(self, tlist, C, bundle_id):
#Initialisation
# cs = b.agent('CrowdScanner')
if self.document_id == -1:
d = ProvDocument()
d.add_namespace(AO)
d.set_default_namespace(self.defaultns % self.game_id)
if uploadprov:
provstore_document = self.api.document.create(d, name="Operation%s CrowdScanner" % self.game_id, public=True)
document_uri = provstore_document.url
logging.info("prov doc URI: " + str(document_uri))
self.provfilelist.append(provstore_document.id)
self.savelocalrecord()
self.document_id = provstore_document.id
b = ProvDocument() # Create a new document for this update
b.add_namespace(AO)
b.set_default_namespace(self.defaultns % self.game_id)
# cs to be used with all targets
cs = b.agent('agent/CrowdScanner', (('prov:type', AO['IBCCAlgo']), ('prov:type', PROV['SoftwareAgent'])))
timestamp = time.time() # Record the timestamp at each update to generate unique identifiers
startTime = datetime.datetime.fromtimestamp(timestamp)
endTime = startTime
activity = b.activity('activity/cs/update_report_%s' % timestamp, startTime, endTime)
activity.wasAssociatedWith(cs)
#Add target and report entities
for i, tdata in enumerate(tlist):
if self.changedtargets[i]==0:
continue
#Target entity for target i
tid = int(tdata[0])
x = tdata[1]
y = tdata[2]
# targettype = tdata[3] #don't record here, it will be revealed and recorded by UAVs
v = int(tdata[4])
agentids = tdata[7]
targetattributes = {'ao:longitude': x, 'ao:latitude': y, }
#'ao:asset_type':str(targettype)}
target_v0 = b.entity('cs/target/'+str(tid)+'.'+str(v), targetattributes)
#Post the root report if this is the first version
if v==0:
self.targets[tid] = b.entity('cs/target/'+str(tid))
else:
try:
target_v0.wasDerivedFrom(self.targetversions[tid])
except KeyError:
logging.error("Got a key error for key " + str(tid) + ', which is supposed to be version' + str(v))
self.targetversions[tid] = target_v0
target_v0.specializationOf(self.targets[tid])
target_v0.wasAttributedTo(cs)
#Report entities for origins of target i
for j, r in enumerate(self.target_rep_ids[i]):
if r not in self.postedreports:
Crow = C[r,:]
x = Crow[1]
y = Crow[2]
reptext = tdata[5][j].decode('utf8')
# Try to replace unusual characters
reptext = reptext.encode('ascii', 'replace')
agentid = agentids[j]
reporter_name = 'agent/crowdreporter%s' % agentid
b.agent(reporter_name, (('prov:type', AO['CrowdReporter']), ('prov:type', PROV['Person'])))
reportattributes = {'ao:longitude': x, 'ao:latitude': y, 'ao:report': reptext}
self.postedreports[r] = b.entity('cs/report/'+str(r), reportattributes)
self.postedreports[r].wasAttributedTo(reporter_name)
activity.used(self.postedreports[r])
target_v0.wasDerivedFrom(self.postedreports[r])
if uploadprov:
#Invalidate old targets no longer in use
for i,tid in enumerate(self.targets_to_invalidate):
target_v = self.targetversions[tid]
b.wasInvalidatedBy(target_v, activity)
#Post the document to the server
#bundle = b.bundle('crowd_scanner')
bundle_id = 'bundle/csupdate/%s' % timestamp
self.api.add_bundle(self.document_id, b.serialize(), bundle_id)
示例15: to_prov
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import entity [as 别名]
def to_prov(obj, namespace, service):
"""
:type obj: dict
:rtype: prov.model.ProvDocument
"""
g = ProvDocument()
ap = Namespace('aip', 'https://araport.org/provenance/')
g.add_namespace("dcterms", "http://purl.org/dc/terms/")
g.add_namespace("foaf", "http://xmlns.com/foaf/0.1/")
vaughn = g.agent(ap['matthew_vaughn'], {
'prov:type': PROV["Person"], 'foaf:givenName': "Matthew Vaughn",
'foaf:mbox': "<mailto:[email protected]>"
})
# Hard coded for now
walter = g.agent(ap['walter_moreira'], {
'prov:type': PROV["Person"], 'foaf:givenName': "Walter Moreira",
'foaf:mbox': "<mailto:[email protected]>"
})
utexas = g.agent(ap['university_of_texas'], {
'prov:type': PROV["Organization"],
'foaf:givenName': "University of Texas at Austin"
})
g.actedOnBehalfOf(walter, utexas)
g.actedOnBehalfOf(vaughn, utexas)
adama_platform = g.agent(
ap['adama_platform'],
{'dcterms:title': "ADAMA",
'dcterms:description': "Araport Data And Microservices API",
'dcterms:language': "en-US",
'dcterms:identifier': "https://api.araport.org/community/v0.3/",
'dcterms:updated': "2015-04-17T09:44:56"})
g.wasGeneratedBy(adama_platform, walter)
g.wasGeneratedBy(adama_platform, vaughn)
iden = service_iden(namespace, service)
srv = service_store[iden]['service']
adama_microservice = g.agent(
ap[iden],
{'dcterms:title': srv.name.title(),
'dcterms:description': srv.description,
'dcterms:language': "en-US",
'dcterms:identifier': api_url_for('service',
namespace=namespace,
service=service),
'dcterms:source': srv.git_repository
})
g.used(adama_microservice, adama_platform, datetime.datetime.now())
for author in getattr(srv, 'authors', []):
try:
author_name = author['name']
author_email = author['email']
except KeyError:
raise APIException(
'name and email are required in author field')
author_agent = g.agent(
ap[slugify(author_name)],
{'prov:type': PROV['Person'],
'foaf:givenName': author_name,
'foaf:mbox': '<mailto:{}>'.format(author_email)})
sponsor_name = author.get('sponsor_organization_name', None)
if sponsor_name:
sponsor_agent = g.agent(
ap[slugify(sponsor_name)],
{'prov:type': PROV['Organization'],
'foaf:givenName': sponsor_name,
'dcterms:identifier': author.get('sponsor_uri', '')})
g.actedOnBehalfOf(author_agent, sponsor_agent)
g.wasGeneratedBy(adama_microservice,
author_agent,
datetime.datetime.now())
sources_entities = process_sources(srv.sources, g, ap)
for src in sources_entities:
g.used(adama_microservice, src, datetime.datetime.now())
response = g.entity(ap['adama_response'])
g.wasGeneratedBy(response, ap[srv.type], datetime.datetime.now())
g.used(ap[srv.type], adama_microservice, datetime.datetime.now())
return g