Migrate datamodel

This commit is contained in:
Eric Espie
2022-06-01 11:19:46 +02:00
parent 9adb7f20ce
commit 812c1f6bb4
8 changed files with 160 additions and 66 deletions

View File

@@ -975,6 +975,18 @@
</state>
</states>
</lifecycle>
<event_listeners>
<listener id="OnInsertRequested">
<event>EVENT_SERVICE_DB_INSERT_REQUESTED</event>
<callback>OnInsertRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnUpdateRequested">
<event>EVENT_SERVICE_DB_UPDATE_REQUESTED</event>
<callback>OnUpdateRequested</callback>
<priority>0</priority>
</listener>
</event_listeners>
<methods>
<method id="GetTicketRefFormat">
<static>true</static>
@@ -1015,28 +1027,26 @@
return true;
}]]></code>
</method>
<method id="OnInsert">
<method id="OnInsertRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnInsert()
public function OnInsertRequested(Combodo\iTop\Service\EventData $oEventData)
{
parent::OnInsert();
$this->UpdateImpactedItems();
$this->SetIfNull('creation_date', time());
$this->SetIfNull('last_update', time());
}]]>
</code>
</method>
<method id="OnUpdate">
<method id="OnUpdateRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnUpdate()
public function OnUpdateRequested(Combodo\iTop\Service\EventData $oEventData)
{
parent::OnUpdate();
$aChanges = $this->ListChanges();
if (array_key_exists('functionalcis_list', $aChanges))
{

View File

@@ -512,6 +512,18 @@
</state>
</states>
</lifecycle>
<event_listeners>
<listener id="OnInsertRequested">
<event>EVENT_SERVICE_DB_INSERT_REQUESTED</event>
<callback>OnInsertRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnUpdateRequested">
<event>EVENT_SERVICE_DB_UPDATE_REQUESTED</event>
<callback>OnUpdateRequested</callback>
<priority>0</priority>
</listener>
</event_listeners>
<methods>
<method id="GetTicketRefFormat">
<static>true</static>
@@ -566,27 +578,25 @@
return true;
}]]></code>
</method>
<method id="OnInsert">
<method id="OnInsertRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnInsert()
public function OnInsertRequested(Combodo\iTop\Service\EventData $oEventData)
{
parent::OnInsert();
$this->UpdateImpactedItems();
$this->SetIfNull('creation_date', time());
$this->SetIfNull('last_update', time());
}]]></code>
</method>
<method id="OnUpdate">
<method id="OnUpdateRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnUpdate()
public function OnUpdateRequested(Combodo\iTop\Service\EventData $oEventData)
{
parent::OnUpdate();
$aChanges = $this->ListChanges();
if (array_key_exists('functionalcis_list', $aChanges))
{

View File

@@ -1052,6 +1052,28 @@
</state>
</states>
</lifecycle>
<event_listeners>
<listener id="OnInsertRequested">
<event>EVENT_SERVICE_DB_INSERT_REQUESTED</event>
<callback>OnInsertRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnUpdateRequested">
<event>EVENT_SERVICE_DB_UPDATE_REQUESTED</event>
<callback>OnUpdateRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnComputeValues">
<event>EVENT_SERVICE_DB_COMPUTE_VALUES</event>
<callback>OnComputeValues</callback>
<priority>0</priority>
</listener>
<listener id="OnCheckToWrite">
<event>EVENT_SERVICE_DB_CHECK_TO_WRITE</event>
<callback>OnCheckToWrite</callback>
<priority>0</priority>
</listener>
</event_listeners>
<methods>
<method id="GetTicketRefFormat">
<static>true</static>
@@ -1122,13 +1144,12 @@
return true;
}]]></code>
</method>
<method id="DoCheckToWrite">
<method id="OnCheckToWrite">
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[public function DoCheckToWrite()
<code><![CDATA[public function OnCheckToWrite(Combodo\iTop\Service\EventData $oEventData)
{
parent::DoCheckToWrite();
if (!$this->IsNew() && ($this->Get('parent_incident_id') == $this->GetKey()))
{
$this->m_aCheckIssues[] = Dict::Format('Class:Incident/Error:CannotAssignParentIncidentIdToSelf');
@@ -1177,17 +1198,15 @@
return $iPriority;
}]]></code>
</method>
<method id="ComputeValues">
<method id="OnComputeValues">
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public function ComputeValues()
<code><![CDATA[ public function OnComputeValues(Combodo\iTop\Service\EventData $oEventData)
{
// Compute the priority of the ticket
$this->Set('priority', $this->ComputePriority());
return parent::ComputeValues();
}]]></code>
</method>
<method id="DisplayBareRelations">
@@ -1465,26 +1484,24 @@
$this->UpdateImpactedItems();
}]]></code>
</method>
<method id="OnInsert">
<method id="OnInsertRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ protected function OnInsert()
<code><![CDATA[ public function OnInsertRequested(Combodo\iTop\Service\EventData $oEventData)
{
parent::OnInsert();
$this->ComputeImpactedItems();
$this->SetIfNull('last_update', time());
$this->SetIfNull('start_date', time());
}]]></code>
</method>
<method id="OnUpdate">
<method id="OnUpdateRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ protected function OnUpdate()
<code><![CDATA[ public function OnUpdateRequested(Combodo\iTop\Service\EventData $oEventData)
{
parent::OnUpdate();
$aChanges = $this->ListChanges();
if (array_key_exists('functionalcis_list', $aChanges))
{

View File

@@ -423,6 +423,23 @@
</state>
</states>
</lifecycle>
<event_listeners>
<listener id="OnInsertRequested">
<event>EVENT_SERVICE_DB_INSERT_REQUESTED</event>
<callback>OnInsertRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnUpdateRequested">
<event>EVENT_SERVICE_DB_UPDATE_REQUESTED</event>
<callback>OnUpdateRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnComputeValues">
<event>EVENT_SERVICE_DB_COMPUTE_VALUES</event>
<callback>OnComputeValues</callback>
<priority>0</priority>
</listener>
</event_listeners>
<methods>
<method id="GetTicketRefFormat">
<static>true</static>
@@ -520,31 +537,31 @@
return $iPriority;
}]]></code>
</method>
<method id="ComputeValues">
<method id="OnComputeValues">
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public function ComputeValues()
<code><![CDATA[ public function OnComputeValues(Combodo\iTop\Service\EventData $oEventData)
{
// Compute the priority of the ticket
$this->Set('priority', $this->ComputePriority());
}]]></code>
</method>
<method id="OnInsert">
<method id="OnInsertRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ protected function OnInsert()
<code><![CDATA[ public function OnInsertRequested(Combodo\iTop\Service\EventData $oEventData)
{
$this->SetIfNull('start_date', time());
$this->SetIfNull('last_update', time());
}]]></code>
</method>
<method id="OnUpdate">
<method id="OnUpdateRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ protected function OnUpdate()
<code><![CDATA[ public function OnUpdateRequested(Combodo\iTop\Service\EventData $oEventData)
{
$this->Set('last_update', time());
}]]></code>

View File

@@ -1209,6 +1209,16 @@
<callback>OnUpdateRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnComputeValues">
<event>EVENT_SERVICE_DB_COMPUTE_VALUES</event>
<callback>OnComputeValues</callback>
<priority>0</priority>
</listener>
<listener id="OnCheckToWrite">
<event>EVENT_SERVICE_DB_CHECK_TO_WRITE</event>
<callback>OnCheckToWrite</callback>
<priority>0</priority>
</listener>
</event_listeners>
<methods>
<method id="GetTicketRefFormat">
@@ -1294,13 +1304,12 @@
return true;
}]]></code>
</method>
<method id="DoCheckToWrite">
<method id="OnCheckToWrite">
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[public function DoCheckToWrite()
<code><![CDATA[public function OnCheckToWrite(Combodo\iTop\Service\EventData $oEventData)
{
parent::DoCheckToWrite();
if (!$this->IsNew() && ($this->Get('parent_request_id') == $this->GetKey()))
{
$this->m_aCheckIssues[] = Dict::Format('Class:UserRequest/Error:CannotAssignParentRequestIdToSelf');
@@ -1349,17 +1358,14 @@
return $iPriority;
}]]></code>
</method>
<method id="ComputeValues">
<method id="OnComputeValues">
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public function ComputeValues()
<code><![CDATA[ public function OnComputeValues(Combodo\iTop\Service\EventData $oEventData)
{
// Compute the priority of the ticket
$this->Set('priority', $this->ComputePriority());
return parent::ComputeValues();
}]]></code>
</method>
<method id="DisplayBareRelations">
@@ -1551,10 +1557,10 @@
</method>
<method id="OnInsertRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnInsertRequested(Combodo\iTop\Service\EventData $oEventData)
public function OnInsertRequested(Combodo\iTop\Service\EventData $oEventData)
{
$this->ComputeImpactedItems();
$this->SetIfNull('last_update', time());
@@ -1563,10 +1569,10 @@
</method>
<method id="OnUpdateRequested">
<static>false</static>
<access>protected</access>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnUpdateRequested(Combodo\iTop\Service\EventData $oEventData)
public function OnUpdateRequested(Combodo\iTop\Service\EventData $oEventData)
{
$aChanges = $this->ListChanges();
if (array_key_exists('functionalcis_list', $aChanges))

View File

@@ -1242,6 +1242,16 @@
<callback>OnUpdateRequested</callback>
<priority>0</priority>
</listener>
<listener id="OnComputeValues">
<event>EVENT_SERVICE_DB_COMPUTE_VALUES</event>
<callback>OnComputeValues</callback>
<priority>0</priority>
</listener>
<listener id="OnCheckToWrite">
<event>EVENT_SERVICE_DB_CHECK_TO_WRITE</event>
<callback>OnCheckToWrite</callback>
<priority>0</priority>
</listener>
</event_listeners>
<methods>
<method id="GetTicketRefFormat">
@@ -1327,13 +1337,12 @@
return true;
}]]></code>
</method>
<method id="DoCheckToWrite">
<method id="OnCheckToWrite">
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[public function DoCheckToWrite()
<code><![CDATA[public function OnCheckToWrite(Combodo\iTop\Service\EventData $oEventData)
{
parent::DoCheckToWrite();
if (!$this->IsNew() && ($this->Get('parent_request_id') == $this->GetKey()))
{
$this->m_aCheckIssues[] = Dict::Format('Class:UserRequest/Error:CannotAssignParentRequestIdToSelf');
@@ -1383,11 +1392,11 @@
return $iPriority;
}]]></code>
</method>
<method id="ComputeValues">
<method id="OnComputeValues">
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public function ComputeValues()
<code><![CDATA[ public function OnComputeValues(Combodo\iTop\Service\EventData $oEventData)
{
// Compute the priority of the ticket
$this->Set('priority', $this->ComputePriority());
@@ -1403,8 +1412,6 @@
$this->Set('request_type', $sType);
}
}
return parent::ComputeValues();
}]]></code>
</method>
<method id="DisplayBareRelations">

View File

@@ -1587,15 +1587,20 @@ public function PrefillSearchForm(&$aContextParam)
<duplicates>true</duplicates>
</field>
</fields>
<event_listeners>
<listener id="OnCheckToWrite">
<event>EVENT_SERVICE_DB_CHECK_TO_WRITE</event>
<callback>OnCheckToWrite</callback>
<priority>0</priority>
</listener>
</event_listeners>
<methods>
<method id="DoCheckToWrite">
<method id="OnCheckToWrite">
<static>false</static>
<access>public</access>
<code><![CDATA[
public function DoCheckToWrite()
public function OnCheckToWrite(Combodo\iTop\Service\EventData $oEventData)
{
parent::DoCheckToWrite();
$aCustomerContracts = $this->Get("customercontracts_list");
foreach ($aCustomerContracts as $sAttCode => $oCustomerContracts)
{

View File

@@ -283,15 +283,37 @@ function DisplayEvents(WebPage $oPage, $sClass)
$oTable = DataTableUIBlockFactory::MakeForStaticData(Dict::S('UI:Schema:Events:Defined'), $aColumns, $aRows);
$oPage->AddSubBlock($oTable);
$oObject = MetaModel::NewObject($sClass);
$aSources = [$oObject->GetObjectUniqId()];
foreach (MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL, false) as $sParentClass) {
$aSources[] = $sParentClass;
$aClasses = [];
foreach (MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sChildClass) {
if (MetaModel::IsAbstract($sChildClass)) {
continue;
}
$aClasses[] = $sChildClass;
}
$aSources = [];
foreach ($aClasses as $sChildClass) {
$oObject = MetaModel::NewObject($sChildClass);
$aSources[] = $oObject->GetObjectUniqId();
foreach (MetaModel::EnumParentClasses($sChildClass, ENUM_PARENT_CLASSES_ALL, false) as $sParentClass) {
if (!in_array($sParentClass, $aSources)) {
$aSources[] = $sParentClass;
}
}
}
$aListeners = [];
foreach (array_keys($aEvents) as $sEvent) {
$aListeners = array_merge($aListeners, EventService::GetListeners($sEvent, $aSources));
}
usort($aListeners, function ($a, $b) {
if ($a['event'] == $b['event']) {
if ($a['priority'] == $b['priority']) {
return 0;
}
return ($a['priority'] > $b['priority']) ? 1 : -1;
}
return ($a['event'] > $b['event']) ? 1 : -1;
});
$aColumns = [
'event' => ['label' => 'Event'],
'listener' => ['label' => 'Listener'],