Verified Commit 3b61f39c authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(sinaps) Allow XPath for XML fields mapping

issue #5956
Showing with 16 additions and 12 deletions
+16 -12
......@@ -106,7 +106,7 @@ class sinapsConfig extends simplePlugin
'fdSinapsUserDiffusionMap',
array(
new StringAttribute(
'', _('Name of the Sinaps attribute'),
'', _('XPath for the XML value to fetch'),
'fdSinapsUserDiffusionMap_sinaps', TRUE
),
new StringAttribute(
......@@ -137,7 +137,7 @@ class sinapsConfig extends simplePlugin
'fdSinapsStructureDiffusionMap',
array(
new StringAttribute(
'', _('Name of the Sinaps attribute'),
'', _('XPath for the XML value to fetch'),
'fdSinapsStructureDiffusionMap_sinaps', TRUE
),
new StringAttribute(
......@@ -225,7 +225,7 @@ class sinapsConfig extends simplePlugin
parent::__construct($dn, $object, $parent, $mainTab, $attributesInfo);
$this->attributesAccess['fdSinapsAcquisitionContactMethodMap']->setHeaders(array(_('LDAP'), _('Sinaps')));
$this->attributesAccess['fdSinapsUserDiffusionMap']->setHeaders(array(_('Sinaps'), _('Tab'), _('Field')));
$this->attributesAccess['fdSinapsStructureDiffusionMap']->setHeaders(array(_('Sinaps'), _('Tab'), _('Field')));
$this->attributesAccess['fdSinapsUserDiffusionMap']->setHeaders(array(_('XPath'), _('Tab'), _('Field')));
$this->attributesAccess['fdSinapsStructureDiffusionMap']->setHeaders(array(_('XPath'), _('Tab'), _('Field')));
}
}
......@@ -145,11 +145,13 @@ class sinapsRequest
array_unshift($values['entite']['supannRefId'], '{'.$uuidPrefix.'}'.$uuid);
foreach ($mapping as $sinapsAttr => list($fdTab,$fdAttr)) {
if (isset($structure->$sinapsAttr)) {
$values[$fdTab][$fdAttr] = (string)$structure->$sinapsAttr;
} else {
foreach ($mapping as $xpath => list($fdTab, $fdAttr)) {
$nodes = $structure->xpath($xpath);
if (empty($nodes)) {
$values[$fdTab][$fdAttr] = '';
} else {
/* Note: We only support monovalued attributes through custom mapping for now */
$values[$fdTab][$fdAttr] = (string)$nodes[0];
}
}
......@@ -294,11 +296,13 @@ class sinapsRequest
return $values;
}
foreach ($mapping as $sinapsAttr => list($fdTab,$fdAttr)) {
if (isset($personne->$sinapsAttr)) {
$values[$fdTab][$fdAttr] = (string)$personne->$sinapsAttr;
} else {
foreach ($mapping as $xpath => list($fdTab, $fdAttr)) {
$nodes = $personne->xpath($xpath);
if (empty($nodes)) {
$values[$fdTab][$fdAttr] = '';
} else {
/* Note: We only support monovalued attributes through custom mapping for now */
$values[$fdTab][$fdAttr] = (string)$nodes[0];
}
}
......
  • SonarQube analysis reported 3 issues

    • :warning: 3 major

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. :warning: This function "getAttributesInfo" has 175 lines, which is greater than the 150 lines authorized. Split it into smaller functions. :blue_book:
    2. :warning: This function "getUserValues" has 206 lines, which is greater than the 150 lines authorized. Split it into smaller functions. :blue_book:
    3. :warning: Remove this unused "$class" local variable. :blue_book:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment