This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleave tracker_scalar param to tracker_param
- Loading branch information
mgrauer
committed
Oct 1, 2015
1 parent
b9c981c
commit be8693f
Showing
7 changed files
with
228 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/*========================================================================= | ||
Midas Server | ||
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. | ||
All rights reserved. | ||
For more information visit http://www.kitware.com/. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** | ||
* Upgrade the tracker module to version 1.2.2. | ||
*/ | ||
class Tracker_Upgrade_1_2_2 extends MIDASUpgrade | ||
{ | ||
/** Upgrade a MySQL database. */ | ||
public function mysql() | ||
{ | ||
$this->db->query( | ||
'CREATE TABLE IF NOT EXISTS `tracker_param` ('. | ||
' `param_id` bigint(20) NOT NULL AUTO_INCREMENT,'. | ||
' `scalar_id` bigint(20) NOT NULL,'. | ||
' `param_name` varchar(255) NOT NULL,'. | ||
' `param_type` enum(\'text\', \'numeric\') NOT NULL,'. | ||
' `text_value` text,'. | ||
' `numeric_value` double,'. | ||
' PRIMARY KEY (`param_id`),'. | ||
' KEY (`param_name`)'. | ||
') DEFAULT CHARSET=utf8;'); | ||
} | ||
|
||
/** Upgrade a PostgreSQL database. */ | ||
public function pgsql() | ||
{ | ||
$this->db->query( | ||
'CREATE TABLE IF NOT EXISTS "tracker_param" ('. | ||
' "param_id" serial PRIMARY KEY,'. | ||
' "scalar_id" bigint NOT NULL,'. | ||
' "param_name" character varying(255) NOT NULL,'. | ||
' "param_type" text CHECK (param_type in (\'text\', \'numeric\')),'. | ||
' "text_value" text,'. | ||
' "numeric_value" double precision);' | ||
); | ||
$this->db->query('CREATE INDEX "tracker_param_param_name_idx" on "tracker_param" ("param_name");'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/*========================================================================= | ||
Midas Server | ||
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. | ||
All rights reserved. | ||
For more information visit http://www.kitware.com/. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** Param base model class for the tracker module. */ | ||
abstract class Tracker_ParamModelBase extends Tracker_AppModel | ||
{ | ||
/** Constructor. */ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->_name = 'tracker_param'; | ||
$this->_key = 'param_id'; | ||
$this->_mainData = array( | ||
'param_id' => array('type' => MIDAS_DATA), | ||
'scalar_id' => array('type' => MIDAS_DATA), | ||
'param_name' => array('type' => MIDAS_DATA), | ||
'param_type' => array('type' => MIDAS_DATA), | ||
'text_value' => array('type' => MIDAS_DATA), | ||
'numeric_value' => array('type' => MIDAS_DATA), | ||
'scalar' => array( | ||
'type' => MIDAS_MANY_TO_ONE, | ||
'model' => 'Scalar', | ||
'module' => $this->moduleName, | ||
'parent_column' => 'scalar_id', | ||
'child_column' => 'scalar_id', | ||
), | ||
); | ||
|
||
$this->initialize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/*========================================================================= | ||
Midas Server | ||
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. | ||
All rights reserved. | ||
For more information visit http://www.kitware.com/. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** | ||
* Param DAO for the tracker module. | ||
* | ||
* @method int getParamId() | ||
* @method void setParamId(int $paramId) | ||
* @method int getScalarId() | ||
* @method void setScalarId(int $scalarId) | ||
* @method int getParamName() | ||
* @method void setParamName(int $paramName) | ||
* @method int getParamType() | ||
* @method void setParamType(int $paramType) | ||
* @method int getTextValue() | ||
* @method void setTextValue(int $textValue) | ||
* @method int getNumericValue() | ||
* @method void setNumericValue(int $numericValue) | ||
*/ | ||
class Tracker_ParamDao extends Tracker_AppDao | ||
{ | ||
/** @var string */ | ||
public $_model = 'Param'; | ||
|
||
/** @var string */ | ||
public $_module = 'tracker'; | ||
|
||
/** | ||
* Set the value of the param, which will be either stored as a numeric | ||
* value if the paramValue can be coerced to numeric or else a text value. | ||
* | ||
* @param string $paramValue value to be set for this param | ||
*/ | ||
public function setParamValue($paramValue) | ||
{ | ||
if (!empty($paramValue) && is_numeric($paramValue)) { | ||
$this->setParamType('numeric'); | ||
$this->setNumericValue(floatval($paramValue)); | ||
} else { | ||
$this->setParamType('text'); | ||
$this->setTextValue($paramValue); | ||
} | ||
} | ||
|
||
/** | ||
* Get the value of the param, regardless of its type, returning either a | ||
* numeric or a string. | ||
* | ||
* @return mixed value of the param | ||
*/ | ||
public function getParamValue() | ||
{ | ||
if ($this->getParamType() === 'numeric') { | ||
return $this->getNumericValue(); | ||
} else { | ||
return $this->getTextValue(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/*========================================================================= | ||
Midas Server | ||
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. | ||
All rights reserved. | ||
For more information visit http://www.kitware.com/. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
require_once BASE_PATH.'/modules/tracker/models/base/ParamModelBase.php'; | ||
|
||
/** Param model for the tracker module. */ | ||
class Tracker_ParamModel extends Tracker_ParamModelBase | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters