Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
maarchRM
Commits
59060842
Verified
Commit
59060842
authored
Dec 07, 2021
by
Cyril Vazquez
Browse files
Add transformation engine WIP
parent
19052a6b
Pipeline
#14813
failed with stages
in 33 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bundle/medona/Controller/ArchiveTransfer.php
View file @
59060842
...
...
@@ -1015,6 +1015,15 @@ class ArchiveTransfer extends abstractMessage
$archive
->
originatorOwnerOrgId
=
$originatorOrg
->
ownerOrgId
;
$mapping
=
$this
->
getInputTranformationRules
(
$archive
,
$namespace
);
if
(
$mapping
)
{
$this
->
applyTransformationRules
(
$archive
->
descriptionObject
,
$mapping
,
$archive
);
}
var_dump
(
$mapping
);
var_dump
(
$archive
);
exit
;
if
(
!
empty
(
$archive
->
archiveUnitProfile
))
{
$this
->
archiveController
->
completeArchivalProfileCodes
(
$archive
);
}
...
...
@@ -1097,6 +1106,54 @@ class ArchiveTransfer extends abstractMessage
return
(
string
)
$replyMessage
->
messageId
;
}
protected
function
getInputTranformationRules
(
$archive
,
$namespace
)
{
if
(
empty
(
$archive
->
archivalProfileReference
))
{
return
;
}
$mappingFile
=
$this
->
profilesDirectory
.
DIRECTORY_SEPARATOR
.
$archive
->
archivalProfileReference
.
'.json'
;
if
(
!
is_file
(
$mappingFile
))
{
return
;
}
$mapping
=
json_decode
(
file_get_contents
(
$mappingFile
));
if
(
!
isset
(
$mapping
->
inputs
->
{
$namespace
}))
{
return
;
}
return
$mapping
->
inputs
->
{
$namespace
};
}
protected
function
applyTransformationRules
(
$source
,
$rules
,
$target
=
null
)
{
$jsonPath
=
\
laabs
::
newService
(
'dependency/json/Jsonpath'
,
$source
);
if
(
!
$target
)
{
$target
=
(
object
)
[];
}
foreach
(
$rules
as
$name
=>
$rule
)
{
if
(
is_object
(
$rule
))
{
$target
->
{
$name
}
=
$this
->
applyTransformationRules
(
$source
,
$rule
);
}
elseif
(
is_array
(
$rule
))
{
$results
=
[];
foreach
(
$rule
as
$subrule
)
{
$subpath
=
'$.'
.
$subrule
;
$results
=
array_merge
(
$results
,
$jsonPath
->
query
(
$subpath
));
}
$target
->
{
$name
}
=
array_values
(
$results
);
}
else
{
$path
=
'$.'
.
$rule
;
$results
=
$jsonPath
->
query
(
$path
);
if
(
count
(
$results
))
{
$target
->
{
$name
}
=
reset
(
$results
);
}
}
}
return
$target
;
}
protected
function
generateId
(
$archive
)
{
if
(
!
isset
(
\
laabs
::
configuration
(
'recordsManagement'
)[
'archiveIdGenerator'
])
||
empty
(
\
laabs
::
configuration
(
'recordsManagement'
)[
'archiveIdGenerator'
]))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment