Skip to content

Commit

Permalink
Move logical metadata file when transforming SIP
Browse files Browse the repository at this point in the history
Refs #98.

Move the logical metadata file to the metadata directory when
transforming the SIP.
  • Loading branch information
djjuhasz committed Dec 17, 2024
1 parent 3b593cf commit 6c26b0c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
19 changes: 14 additions & 5 deletions internal/activities/transform_sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ func (a *TransformSIP) Execute(ctx context.Context, params *TransformSIPParams)
return nil, err
}

// Move the Prozess_Digitalisierung_PREMIS.xml file to the PIP metadata
// Move the Prozess_Digitalisierung_PREMIS.xml file to the metadata
// directory. Prozess_Digitalisierung_PREMIS.xml is only present in
// digitized SIPs/AIPs, and there can only be one dossier in a digitized SIP/AIP.
// digitized SIPs/AIPs, and there can only be one dossier in a digitized
// SIP/AIP.
if params.SIP.Type == enums.SIPTypeDigitizedSIP || params.SIP.Type == enums.SIPTypeDigitizedAIP {
entries, err := os.ReadDir(params.SIP.ContentPath)
if err != nil {
Expand All @@ -57,16 +58,24 @@ func (a *TransformSIP) Execute(ctx context.Context, params *TransformSIPParams)
}
}

// Move UpdatedAreldaMetatdata.xml to the metadata directory (Digitized AIP
// only)
if params.SIP.Type == enums.SIPTypeDigitizedAIP {
// Move the UpdatedAreldaMetatdata.xml and logical metadata files to the
// metadata directory (AIP only).
if params.SIP.IsAIP() {
err := fsutil.Move(
params.SIP.UpdatedAreldaMDPath,
filepath.Join(mdPath, filepath.Base(params.SIP.UpdatedAreldaMDPath)),
)
if err != nil {
return nil, err
}

err = fsutil.Move(
params.SIP.LogicalMDPath,
filepath.Join(mdPath, filepath.Base(params.SIP.LogicalMDPath)),
)
if err != nil {
return nil, err
}
}

// Create objects and [sip-name] sub-directories.
Expand Down
40 changes: 22 additions & 18 deletions internal/activities/transform_sip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,33 @@ func TestTransformSIP(t *testing.T) {
fmode = os.FileMode(0o600)
)

digitizedAIPPath := fs.NewDir(t, "Vecteur_Digitized_AIP",
fs.WithDir("additional",
fs.WithFile("UpdatedAreldaMetadata.xml", ""),
),
fs.WithDir("content",
fs.WithDir("content",
fs.WithDir("d_0000001",
fs.WithFile("00000001.jp2", ""),
fs.WithFile("00000001_PREMIS.xml", ""),
fs.WithFile("Prozess_Digitalisierung_PREMIS.xml", ""),
),
digitizedAIPPath := fs.NewDir(t, "",
fs.WithDir("Vecteur_Digitized_AIP",
fs.WithDir("additional",
fs.WithFile("UpdatedAreldaMetadata.xml", ""),
fs.WithFile("Vecteur_Digitized_AIP-premis.xml", ""),
),
fs.WithDir("header",
fs.WithDir("old",
fs.WithDir("SIP",
fs.WithFile("metadata.xml", ""),
fs.WithDir("content",
fs.WithDir("content",
fs.WithDir("d_0000001",
fs.WithFile("00000001.jp2", ""),
fs.WithFile("00000001_PREMIS.xml", ""),
fs.WithFile("Prozess_Digitalisierung_PREMIS.xml", ""),
),
),
fs.WithDir("xsd",
fs.WithFile("arelda.xsd", ""),
fs.WithDir("header",
fs.WithDir("old",
fs.WithDir("SIP",
fs.WithFile("metadata.xml", ""),
),
),
fs.WithDir("xsd",
fs.WithFile("arelda.xsd", ""),
),
),
),
),
).Path()
).Join("Vecteur_Digitized_AIP")

digitizedSIPPath := fs.NewDir(t, "Vecteur_Digitized_SIP",
fs.WithDir("content",
Expand Down Expand Up @@ -86,6 +89,7 @@ func TestTransformSIP(t *testing.T) {
fs.WithDir("metadata", fs.WithMode(dmode),
fs.WithFile("UpdatedAreldaMetadata.xml", "", fs.WithMode(fmode)),
fs.WithFile("Prozess_Digitalisierung_PREMIS.xml", "", fs.WithMode(fmode)),
fs.WithFile("Vecteur_Digitized_AIP-premis.xml", "", fs.WithMode(fmode)),
),
)

Expand Down

0 comments on commit 6c26b0c

Please sign in to comment.