mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°5563 AttributeLinkedSet & LinkedSetIndirect conversions between 3.0 and 3.1 formats
This commit is contained in:
@@ -1520,7 +1520,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
|||||||
*/
|
*/
|
||||||
public function GetEditMode()
|
public function GetEditMode()
|
||||||
{
|
{
|
||||||
return $this->GetOptional('edit_mode', LINKSET_EDITMODE_ACTIONS);
|
return $this->GetOptional('legacy_edit_mode', LINKSET_EDITMODE_ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1002,12 +1002,64 @@ class iTopDesignFormat
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Upgrade the format from version 3.0 to 3.1
|
* Upgrade the format from version 3.0 to 3.1
|
||||||
|
*
|
||||||
* @param \ModelFactory $oFactory
|
* @param \ModelFactory $oFactory
|
||||||
|
*
|
||||||
* @return void (Errors are logged)
|
* @return void (Errors are logged)
|
||||||
*/
|
*/
|
||||||
protected function From30To31($oFactory)
|
protected function From30To31($oFactory)
|
||||||
{
|
{
|
||||||
//nothing
|
$oXPath = new DOMXPath($this->oDocument);
|
||||||
|
|
||||||
|
// N°5563 AttributeLinkedSet
|
||||||
|
// - move edit_mode attribute to legacy_edit_mode attribute
|
||||||
|
// - fill relation_type & read_only
|
||||||
|
$oLinkedSetNodes = $oXPath->query("/itop_design/classes/class/fields/field[@xsi:type='AttributeLinkedSet']");
|
||||||
|
/** @var \DOMElement $oNode */
|
||||||
|
foreach ($oLinkedSetNodes as $oNode) {
|
||||||
|
$sEditMode = 'actions';
|
||||||
|
if ($oNode->hasChildNodes()) {
|
||||||
|
$oLinkedSetEditModeNodes = $oNode->getElementsByTagName('edit_mode');
|
||||||
|
if (count($oLinkedSetEditModeNodes)) {
|
||||||
|
$oEditModeNode = $oLinkedSetEditModeNodes->item(0);
|
||||||
|
/** @noinspection NullPointerExceptionInspection already checked */
|
||||||
|
$sEditMode = $oEditModeNode->nodeValue;
|
||||||
|
$oLegacyEditModeNode = $oNode->ownerDocument->createElement('legacy_edit_mode', $sEditMode);
|
||||||
|
/** @noinspection NullPointerExceptionInspection already checked */
|
||||||
|
$oNode->replaceChild($oLegacyEditModeNode, $oEditModeNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($sEditMode) {
|
||||||
|
case 'none':
|
||||||
|
$sRelationType = 'link';
|
||||||
|
$sReadOnly = 'true';
|
||||||
|
break;
|
||||||
|
case 'add_only':
|
||||||
|
case 'add_remove':
|
||||||
|
case 'actions':
|
||||||
|
$sRelationType = 'link';
|
||||||
|
$sReadOnly = 'false';
|
||||||
|
break;
|
||||||
|
case 'in_place':
|
||||||
|
$sRelationType = 'property';
|
||||||
|
$sReadOnly = 'false';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$oRelationTypeNode = $oNode->ownerDocument->createElement('relation_type', $sRelationType);
|
||||||
|
$oNode->appendChild($oRelationTypeNode);
|
||||||
|
$oReadOnlyNode = $oNode->ownerDocument->createElement('read_only', $sReadOnly);
|
||||||
|
$oNode->appendChild($oReadOnlyNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// N°5563 AttributeLinkedSetIndirect
|
||||||
|
// - fill read_only attribute
|
||||||
|
$oLinkedSetIndirectNodes = $oXPath->query("/itop_design/classes/class/fields/field[@xsi:type='AttributeLinkedSetIndirect']");
|
||||||
|
foreach ($oLinkedSetIndirectNodes as $oNode) {
|
||||||
|
$oReadOnlyNode = $oNode->ownerDocument->createElement('read_only', 'false');
|
||||||
|
$oNode->appendChild($oReadOnlyNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Downgrade the format from version 3.1 to 3.0
|
* Downgrade the format from version 3.1 to 3.0
|
||||||
@@ -1016,7 +1068,26 @@ class iTopDesignFormat
|
|||||||
*/
|
*/
|
||||||
protected function From31To30($oFactory)
|
protected function From31To30($oFactory)
|
||||||
{
|
{
|
||||||
//nothing
|
$oXPath = new DOMXPath($this->oDocument);
|
||||||
|
|
||||||
|
// N°5563 AttributeLinkedSet
|
||||||
|
// - remove relation_type & read_only (added in 3.1)
|
||||||
|
// - restore edit_mode attribute from legacy_edit_mode attribute
|
||||||
|
$this->RemoveNodeFromXPath("/itop_design/classes/class/fields/field[@xsi:type='AttributeLinkedSet']/read_only");
|
||||||
|
$this->RemoveNodeFromXPath("/itop_design/classes/class/fields/field[@xsi:type='AttributeLinkedSet']/relation_type");
|
||||||
|
$oLegacyEditModeNodesList = $oXPath->query("/itop_design/classes/class/fields/field[@xsi:type='AttributeLinkedSet']/legacy_edit_mode");
|
||||||
|
/** @var \DOMElement $oLegacyEditModeNode */
|
||||||
|
foreach ($oLegacyEditModeNodesList as $oLegacyEditModeNode) {
|
||||||
|
$sEditMode = $oLegacyEditModeNode->nodeValue;
|
||||||
|
$oEditModeNode = $oLegacyEditModeNode->ownerDocument->createElement('edit_mode', $sEditMode);
|
||||||
|
$oLinkedSetNode = $oLegacyEditModeNode->parentNode;
|
||||||
|
/** @noinspection NullPointerExceptionInspection already checked */
|
||||||
|
$oLinkedSetNode->replaceChild($oEditModeNode, $oLegacyEditModeNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// N°5563 AttributeLinkedSetIndirect
|
||||||
|
// - remove read_only attribute (added in 3.1)
|
||||||
|
$this->RemoveNodeFromXPath("/itop_design/classes/class/fields/field[@xsi:type='AttributeLinkedSetIndirect']/read_only");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1">
|
||||||
|
<classes>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeNone">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>none</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>true</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>add_only</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>add_remove</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeActions">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>actions</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>in_place</legacy_edit_mode>
|
||||||
|
<relation_type>property</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetNoEditMode">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<linked_class>Ticket</linked_class>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetIndirect">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSetIndirect">
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</itop_design>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
|
||||||
|
<classes>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeNone">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>none</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>add_only</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>add_remove</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeActions">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>actions</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>in_place</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetNoEditMode">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<linked_class>Ticket</linked_class>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetIndirect">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSetIndirect"/>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</itop_design>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
|
||||||
|
<classes>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeNone">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>none</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>add_only</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>add_remove</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeActions">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>actions</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<edit_mode>in_place</edit_mode>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetNoEditMode">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<linked_class>Ticket</linked_class>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetIndirect">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSetIndirect"/>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</itop_design>
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1">
|
||||||
|
<classes>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeNone">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>none</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>true</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>add_only</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>add_remove</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeActions">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>actions</legacy_edit_mode>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<legacy_edit_mode>in_place</legacy_edit_mode>
|
||||||
|
<relation_type>property</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetNoEditMode">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSet">
|
||||||
|
<linked_class>Ticket</linked_class>
|
||||||
|
<relation_type>link</relation_type>
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithAttributeLinkedSetIndirect">
|
||||||
|
<fields>
|
||||||
|
<field id="status" xsi:type="AttributeLinkedSetIndirect">
|
||||||
|
<read_only>false</read_only>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</itop_design>
|
||||||
@@ -79,6 +79,8 @@ class iTopDesignFormatTest extends ItopTestCase
|
|||||||
'1.7 to 1.6 2' => ['sXmlFileName' => '1.7_to_1.6_2'],
|
'1.7 to 1.6 2' => ['sXmlFileName' => '1.7_to_1.6_2'],
|
||||||
'1.7 to 3.0' => ['sXmlFileName' => '1.7_to_3.0'],
|
'1.7 to 3.0' => ['sXmlFileName' => '1.7_to_3.0'],
|
||||||
'3.0 to 1.7' => ['sXmlFileName' => '3.0_to_1.7'],
|
'3.0 to 1.7' => ['sXmlFileName' => '3.0_to_1.7'],
|
||||||
|
'3.0 to 3.1' => ['sXmlFileName' => '3.0_to_3.1'],
|
||||||
|
'3.1 to 3.0' => ['sXmlFileName' => '3.1_to_3.0'],
|
||||||
'Bug_4569' => ['sXmlFileName' => 'Bug_4569'],
|
'Bug_4569' => ['sXmlFileName' => 'Bug_4569'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user