Skip to content

Commit

Permalink
Fix issue #27
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm104 committed May 4, 2021
1 parent a14064d commit 0772dc9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rda-to-bf-conversion-for-sinopia/transform_rda_to_bf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def transform_works(workList, currentDate):
# create variables for new triples
snapshot_bnode = BNode()
currentTime = time.strftime("%Y-%m-%dT%H:%M:%S+00:00")
currentDate_hyphen = time.strftime("%Y-%m-%d")
snapshot_literal = Literal(f"rml.py SNAPSHOT: {currentTime}")

# create new triples
Expand All @@ -157,6 +158,11 @@ def transform_works(workList, currentDate):
Graph_localWork.add((snapshot_bnode, RDF.type, bf.GenerationProcess))
Graph_localWork.add((snapshot_bnode, RDFS.label, snapshot_literal))

# edit bf:creationDate
for s, p, o in Graph_localWork.triples((None, bf.adminMetadata, None)):
Graph_localWork.remove((o, bf.creationDate, None))
Graph_localWork.add((o, bf.creationDate, Literal(currentDate_hyphen)))

# serialize graph as XML
Graph_localWork.serialize(destination=f'../output/{currentDate}/work_1_xml/{BF_ID}.xml', format="xml")

Expand Down Expand Up @@ -223,6 +229,7 @@ def transform_expressions(expressionList, currentDate):
# create variables for new triples
snapshot_bnode = BNode()
currentTime = time.strftime("%Y-%m-%dT%H:%M:%S+00:00")
currentDate_hyphen = time.strftime("%Y-%m-%d")
snapshot_literal = Literal(f"rml.py SNAPSHOT: {currentTime}")

# create new triples
Expand All @@ -231,6 +238,11 @@ def transform_expressions(expressionList, currentDate):
Graph_localExpression.add((snapshot_bnode, RDF.type, bf.GenerationProcess))
Graph_localExpression.add((snapshot_bnode, RDFS.label, snapshot_literal))

# edit bf:creationDate
for s, p, o in Graph_localExpression.triples((None, bf.adminMetadata, None)):
Graph_localExpression.remove((o, bf.creationDate, None))
Graph_localExpression.add((o, bf.creationDate, Literal(currentDate_hyphen)))

# serialize graph as XML
Graph_localExpression.serialize(destination=f'../output/{currentDate}/work_2_xml/{BF_ID}.xml', format="xml")

Expand Down Expand Up @@ -298,6 +310,7 @@ def transform_manifestations(manifestationList, currentDate):
# create variables for new triples
snapshot_bnode = BNode()
currentTime = time.strftime("%Y-%m-%dT%H:%M:%S+00:00")
currentDate_hyphen = time.strftime("%Y-%m-%d")
snapshot_literal = Literal(f"rml.py SNAPSHOT: {currentTime}")

# create new triples
Expand All @@ -306,6 +319,11 @@ def transform_manifestations(manifestationList, currentDate):
Graph_localManifestation.add((snapshot_bnode, RDF.type, bf.GenerationProcess))
Graph_localManifestation.add((snapshot_bnode, RDFS.label, snapshot_literal))

# edit bf:creationDate
for s, p, o in Graph_localManifestation.triples((None, bf.adminMetadata, None)):
Graph_localManifestation.remove((o, bf.creationDate, None))
Graph_localManifestation.add((o, bf.creationDate, Literal(currentDate_hyphen)))

# serialize graph as XML
Graph_localManifestation.serialize(destination=f'../output/{currentDate}/instance_xml/{BF_ID}.xml', format="xml")

Expand Down Expand Up @@ -373,6 +391,7 @@ def transform_items(itemList, currentDate):
# create variables for new triples
snapshot_bnode = BNode()
currentTime = time.strftime("%Y-%m-%dT%H:%M:%S+00:00")
currentDate_hyphen = time.strftime("%Y-%m-%d")
snapshot_literal = Literal(f"rml.py SNAPSHOT: {currentTime}")

# create new triples
Expand All @@ -381,6 +400,11 @@ def transform_items(itemList, currentDate):
Graph_localItem.add((snapshot_bnode, RDF.type, bf.GenerationProcess))
Graph_localItem.add((snapshot_bnode, RDFS.label, snapshot_literal))

# edit bf:creationDate
for s, p, o in Graph_localItem.triples((None, bf.adminMetadata, None)):
Graph_localItem.remove((o, bf.creationDate, None))
Graph_localItem.add((o, bf.creationDate, Literal(currentDate_hyphen)))

# serialize file in XML
Graph_localItem.serialize(destination=f'../output/{currentDate}/item_xml/{BF_ID}.xml', format="xml")

Expand Down

0 comments on commit 0772dc9

Please sign in to comment.