Skip to content

Commit

Permalink
Adjusted export-xml --xml to output draft endringslogg.xml
Browse files Browse the repository at this point in the history
The log is based on each entities relation to hendelseslogg, present in
Nikita.  The current Nikita implementation is not implementing the same
inheritance as is described in N5TG.

Because it is based on entity relations, entries for deleted entities
will not be included.  A different approach would be to fetch all
endringslogg/hendelseslogg entries

See also arkivverket/noark5-tjenestegrensesnitt-standard#319 .
  • Loading branch information
petterreinholdtsen committed Jun 13, 2024
1 parent 8452c9c commit 0ff0f98
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions export-all
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ class ContentDumper(n5core.endpoint.Endpoint):
self.files = {}
self.schemas = {}

self.hendelserel = '%sloggingogsporing/hendelseslogg/' % self.relbaseurl


def stats_add(self, entity):
if entity not in self.stats:
Expand Down Expand Up @@ -437,6 +439,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
konvrel = '%sarkivstruktur/konvertering/' % self.relbaseurl
sequence = [
'systemID',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -556,6 +559,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
'systemID',
'oppdatertAv>[null]',
'oppdatertDato>[null]',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -774,6 +778,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
'opprettetAv',
'oppdatertAv>[null]',
'oppdatertDato>[null]',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -897,6 +902,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
'systemID',
'oppdatertAv>[null]',
'oppdatertDato>[null]',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -980,6 +986,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
'klasseID',
'oppdatertAv>[null]',
'oppdatertDato>[null]',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -1013,6 +1020,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
'systemID',
'oppdatertAv>[null]',
'oppdatertDato>[null]',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -1061,6 +1069,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
'systemID',
'oppdatertAv>[null]',
'oppdatertDato>[null]',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -1112,6 +1121,7 @@ class ContentDumper(n5core.endpoint.Endpoint):
'systemID',
'oppdatertAv>[null]',
'oppdatertDato>[null]',
(self.hendelserel, self.recurse_xml_endring),
]
if self.xml_extended:
sequence.extend((
Expand Down Expand Up @@ -1299,6 +1309,34 @@ class ContentDumper(n5core.endpoint.Endpoint):
# skjermingMetadata
pass

def recurse_xml_endring(self, output, content, parents):
sequence = (
'referanseArkivenhet',
'referanseMetadata',
'endretDato',
'endretAv',
'tidligereVerdi',
'nyVerdi',
)
entityrel = self.entity_rel(content)
#print("recurse_xml_endring", entityrel)
#print(content)
if 'https://rel.arkivverket.no/noark5/v5/api/loggingogsporing/endringslogg/' == entityrel:
self.recurse_xml_out_ordered(self.eloutput, 'endring', content, sequence, parents=parents)


def recurse_xml_save_endringslogg(self, callback):
with codecs.open('%s/endringslogg.xml' % self.savepath,
'w', encoding='UTF-8') as fh:
eloutput = XMLFile(fh)
attr = {
'xmlns': 'http://www.arkivverket.no/standarder/noark5/endringslogg',
}
with eloutput.tag('endringslogg', attr=attr):
self.eloutput = eloutput
callback()
del self.eloutput

def recurse_xml_save_journal(self, callback):
ljfilename = '%s/loependeJournal.xml' % self.savepath
ojfilename = '%s/offentligJournal.xml' % self.savepath
Expand Down Expand Up @@ -1381,8 +1419,10 @@ class ContentDumper(n5core.endpoint.Endpoint):
encoding='UTF-8') as fh:
output = XMLFile(fh)
self.recurse_xml_save_journal(
lambda : self.recurse_xml_arkiv(output,
arkiv, first=True)
lambda : self.recurse_xml_save_endringslogg(
lambda : self.recurse_xml_arkiv(output, arkiv,
first=True)
)
)
self.files['arkivstruktur.xml'] = sha256_of_file(filename)
self.save_xml_vsm_xsd(self.savepath)
Expand Down

0 comments on commit 0ff0f98

Please sign in to comment.