mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
Helper module to plug complex SLA computation schemes. This basic modules performs the simplest computation corresponding to a 24x7 (no holidays) model.
SVN:trunk[1345]
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// Copyright (C) 2010 Combodo SARL
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; version 3 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
/**
|
||||
* Localized data
|
||||
*
|
||||
* @author Erwan Taloc <erwan.taloc@combodo.com>
|
||||
* @author Romain Quetiez <romain.quetiez@combodo.com>
|
||||
* @author Denis Flaven <denis.flaven@combodo.com>
|
||||
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
|
||||
*/
|
||||
|
||||
Dict::Add('EN US', 'English', 'English', array(
|
||||
// Dictionary entries go here
|
||||
));
|
||||
?>
|
||||
117
modules/itop-sla-computation/model.itop-sla-computation.php
Normal file
117
modules/itop-sla-computation/model.itop-sla-computation.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
// Copyright (C) 2010 Combodo SARL
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; version 3 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
/**
|
||||
* Module itop-sla-computation: implements an extensible mechanism
|
||||
*
|
||||
* @author Erwan Taloc <erwan.taloc@combodo.com>
|
||||
* @author Romain Quetiez <romain.quetiez@combodo.com>
|
||||
* @author Denis Flaven <denis.flaven@combodo.com>
|
||||
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
|
||||
*/
|
||||
|
||||
/**
|
||||
* Static class that implements the public interface for utilities
|
||||
* related to the SLA computation
|
||||
*/
|
||||
class SLAComputation
|
||||
{
|
||||
protected static $m_oAddOn;
|
||||
|
||||
/**
|
||||
* Generic "extensibility" method: select which extension is actually used
|
||||
* @param $sClassName string The name of the class (derived from SLAComputationAddOnAPI) to use
|
||||
* @return void
|
||||
*/
|
||||
public static function SelectModule($sClassName)
|
||||
{
|
||||
if (!class_exists($sClassName))
|
||||
{
|
||||
throw new CoreException("Could not select this module, '$sModuleName' in not a valid class name");
|
||||
return;
|
||||
}
|
||||
if (!is_subclass_of($sClassName, 'SLAComputationAddOnAPI'))
|
||||
{
|
||||
throw new CoreException("Could not select this module, the class '$sClassName' is not derived from SLAComputationAddOnAPI (parent class:".get_parent_class($sClassName)." )");
|
||||
return;
|
||||
}
|
||||
self::$m_oAddOn = new $sClassName;
|
||||
self::$m_oAddOn->Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class of the extension actually used
|
||||
* @return string The name of the extension class used
|
||||
*/
|
||||
public static function GetModuleInstance()
|
||||
{
|
||||
return self::$m_oAddOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date/time correspnding to a given delay in the future from the present
|
||||
* considering only the valid (open) hours for a specified ticket
|
||||
* @param $oTicket Ticket The ticket for which to compute the deadline
|
||||
* @param $iDuration integer The duration (in seconds) in the future
|
||||
* @param $oStartDate DateTime The starting point for the computation (default = now)
|
||||
* @return DateTime The date/time for the deadline
|
||||
*/
|
||||
public static function GetDeadline($oTicket, $iDuration, $oStartDate = null)
|
||||
{
|
||||
if ($oStartDate == null)
|
||||
{
|
||||
$oStartDate = new DateTime();
|
||||
}
|
||||
return self::$m_oAddOn->GetDeadline($oTicket, $iDuration, $oStartDate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for extensions to the SLA computation mechanism
|
||||
* This class implements a default behavior, suitable for a simple
|
||||
* 24x7 (no holiday) computation. To override this behavior, implement
|
||||
* a derived class from this one, overloading the behavior, and call
|
||||
* SLAComputation::SetExtension()
|
||||
*/
|
||||
class SLAComputationAddOnAPI
|
||||
{
|
||||
/**
|
||||
* Called when the module is loaded, used for one time initialization (if needed)
|
||||
*/
|
||||
public function Init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date/time correspnding to a given delay in the future from the present
|
||||
* considering only the valid (open) hours for a specified ticket
|
||||
* @param $oTicket Ticket The ticket for which to compute the deadline
|
||||
* @param $iDuration integer The duration (in seconds) in the future
|
||||
* @param $oStartDate DateTime The starting point for the computation
|
||||
* @return DateTime The date/time for the deadline
|
||||
*/
|
||||
public static function GetDeadline($oTicket, $iDuration, DateTime $oStartDate)
|
||||
{
|
||||
// Default implementation: 24x7, no holidays: to compute the deadline, just add
|
||||
// the specified duration to the given date/time
|
||||
$oResult = clone $oStartDate;
|
||||
$oResult->modify('+'.$iDuration.' seconds');
|
||||
return $oResult;
|
||||
}
|
||||
}
|
||||
//SLAComputation::SelectModule('SLAComputationAddOnAPI');
|
||||
?>
|
||||
63
modules/itop-sla-computation/module.itop-sla-computation.php
Normal file
63
modules/itop-sla-computation/module.itop-sla-computation.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// Copyright (C) 2010 Combodo SARL
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; version 3 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
SetupWebPage::AddModule(
|
||||
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
|
||||
'itop-sla-computation/1.0.0',
|
||||
array(
|
||||
// Identification
|
||||
//
|
||||
'label' => 'SLA Computation',
|
||||
'category' => 'sla',
|
||||
|
||||
// Setup
|
||||
//
|
||||
'dependencies' => array(
|
||||
|
||||
),
|
||||
'mandatory' => true,
|
||||
'visible' => false,
|
||||
|
||||
// Components
|
||||
//
|
||||
'datamodel' => array(
|
||||
'model.itop-sla-computation.php'
|
||||
),
|
||||
'webservice' => array(
|
||||
|
||||
),
|
||||
'data.struct' => array(
|
||||
// add your 'structure' definition XML files here,
|
||||
),
|
||||
'data.sample' => array(
|
||||
// add your sample data XML files here,
|
||||
),
|
||||
|
||||
// Documentation
|
||||
//
|
||||
'doc.manual_setup' => '', // hyperlink to manual setup documentation, if any
|
||||
'doc.more_information' => '', // hyperlink to more information, if any
|
||||
|
||||
// Default settings
|
||||
//
|
||||
'settings' => array(
|
||||
// Module specific settings go here, if any
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user