Skip to content

Commit

Permalink
Add PREMIS Object XML to files
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Sep 7, 2022
1 parent f6f00ef commit 75c77b2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 4 additions & 6 deletions AIPscan/Aggregator/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,12 @@ def _add_normalization_date(file_id):
db.session.commit()


def _add_characteristics_extension(fs_entry, file_id):
"""Add string representation of PREMIS Object characteristics_extension to File object."""
def _add_premis_object_with_characteristics_extension(fs_entry, file_id):
"""Add string representation of PREMIS Object to File object."""
file_ = File.query.get(file_id)
for premis_object in fs_entry.get_premis_objects():
if premis_object.characteristics_extension:
file_.characteristics_extension = str(
premis_object.characteristics_extension
)
file_.premis_object = premis_object.tostring()
db.session.commit()
return

Expand Down Expand Up @@ -364,7 +362,7 @@ def create_file_object(file_type, fs_entry, aip_id):
if file_type == FileType.preservation:
_add_normalization_date(new_file.id)

_add_characteristics_extension(fs_entry, new_file.id)
_add_premis_object_with_characteristics_extension(fs_entry, new_file.id)


def collect_mets_agents(mets):
Expand Down
6 changes: 4 additions & 2 deletions AIPscan/Reporter/templates/file.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ <h2 class="h3">File: {{ file_.name }}</h2>
{{ file_.checksum_value }}
</td>
</tr>
{% if file_.premis_object %}
<tr>
<td width=20%>
<strong>Characterization tool output</strong>
<strong>PREMIS Object XML</strong>
</td>
<td>
{{ file_.characteristics_extension }}
{{ file_.premis_object }}
</td>
</tr>
{% endif %}
{% if preservation_file %}
<tr>
<td width=20%>
Expand Down
6 changes: 3 additions & 3 deletions AIPscan/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class File(db.Model):
format_version = db.Column(db.String(255))
checksum_type = db.Column(db.String(255))
checksum_value = db.Column(db.String(255), index=True)
characteristics_extension = db.Column(db.Text())
premis_object = db.Column(db.Text())

original_file_id = db.Column(db.Integer(), db.ForeignKey("file.id"))
original_file = db.relationship(
Expand All @@ -406,7 +406,7 @@ def __init__(
checksum_value,
aip_id,
file_type=FileType.original,
characteristics_extension=None,
premis_object=None,
format_version=None,
puid=None,
original_file_id=None,
Expand All @@ -422,7 +422,7 @@ def __init__(
self.format_version = format_version
self.checksum_type = checksum_type
self.checksum_value = checksum_value
self.characteristics_extension = characteristics_extension
self.premis_object = premis_object
self.original_file_id = original_file_id
self.aip_id = aip_id

Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Jinja2==2.11.3
kombu==4.6.10
lxml==4.6.5
MarkupSafe==1.1.1
metsrw==0.3.15
metsrw==0.3.22
natsort==7.0.1
pandas==1.1.4
plotly==5.7.0
Expand Down

0 comments on commit 75c77b2

Please sign in to comment.