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.
Migrate dicomextractor module settings to database
- Loading branch information
Jamie Snape
committed
Dec 5, 2014
1 parent
0077c8e
commit 411438a
Showing
11 changed files
with
302 additions
and
231 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
[global] | ||
; version of the module | ||
version = 1.0.0 | ||
; full name | ||
fullname = DICOM Extractor | ||
; description | ||
description = Extract metadata from DICOM files | ||
; category | ||
category = DICOM | ||
; dependencies | ||
dependencies = scheduler,api,thumbnailcreator | ||
; MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0. | ||
|
||
; hachoir-metadata command | ||
dcm2xml = "dcm2xml" | ||
dcmj2pnm = "dcmj2pnm --write-jpeg --min-max-window" | ||
dcmftest = "dcmftest" | ||
dcmdictpath = "" | ||
[global] | ||
fullname = "DICOM Extractor" | ||
description = "Extract metadata from DICOM files" | ||
category = "DICOM" | ||
dependencies = api,scheduler,thumbnailcreator | ||
uuid = "53ef7737-29d8-4873-97f5-d35ffb2c2200" | ||
version = "1.1.0" |
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,68 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information 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. | ||
=========================================================================*/ | ||
|
||
/** Admin controller for the dicomextractor module. */ | ||
class Dicomextractor_AdminController extends Dicomextractor_AppController | ||
{ | ||
/** @var array */ | ||
public $_models = array('Setting'); | ||
|
||
/** Index action */ | ||
public function indexAction() | ||
{ | ||
$this->requireAdminPrivileges(); | ||
|
||
$this->view->pageTitle = 'DICOM Extractor Module Configuration'; | ||
$form = new Dicomextractor_Form_Admin(); | ||
|
||
if ($this->getRequest()->isPost()) { | ||
$data = $this->getRequest()->getPost(); | ||
|
||
if ($form->isValid($data)) { | ||
$values = $form->getValues(); | ||
|
||
foreach ($values as $key => $value) { | ||
if ($value !== null) { | ||
$this->Setting->setConfig($key, $value, $this->moduleName); | ||
} | ||
} | ||
} | ||
|
||
$form->populate($data); | ||
} else { | ||
$elements = $form->getElements(); | ||
|
||
foreach ($elements as $element) { | ||
$name = $element->getName(); | ||
|
||
if ($name !== 'csrf' && $name !== 'submit') { | ||
$value = $this->Setting->getValueByName($name, $this->moduleName); | ||
|
||
if (!is_null($value)) { | ||
$form->setDefault($name, $value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$this->view->form = $form; | ||
session_start(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,39 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information 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/dicomextractor/constant/module.php'; | ||
|
||
/** Install the dicomextractor module. */ | ||
class Dicomextractor_InstallScript extends MIDASModuleInstallScript | ||
{ | ||
/** @var string */ | ||
public $moduleName = 'dicomextractor'; | ||
|
||
/** Post database install. */ | ||
public function postInstall() | ||
{ | ||
/** @var SettingModel $settingModel */ | ||
$settingModel = MidasLoader::loadModel('Setting'); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE, $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE, $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE, $this->moduleName); | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information 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 dicomextractor module to version 1.1.0. */ | ||
class Dicomextractor_Upgrade_1_1_0 extends MIDASUpgrade | ||
{ | ||
/** @var string */ | ||
public $moduleName = 'dicomextractor'; | ||
|
||
/** Post database upgrade. */ | ||
public function postUpgrade() | ||
{ | ||
/** @var SettingModel $settingModel */ | ||
$settingModel = MidasLoader::loadModel('Setting'); | ||
$configPath = LOCAL_CONFIGS_PATH.DIRECTORY_SEPARATOR.$this->moduleName.'.local.ini'; | ||
|
||
if (file_exists($configPath)) { | ||
$config = new Zend_Config_Ini($configPath, 'global'); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, $config->get('dcm2xml', DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE), $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, $config->get('dcmj2pnm', DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE), $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, $config->get('dcmftest', DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE), $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, $config->get('dcmdictpath', DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE), $this->moduleName); | ||
|
||
$config = new Zend_Config_Ini($configPath, null, true); | ||
unset($config->global->dcm2xml); | ||
unset($config->global->dcmj2pnm); | ||
unset($config->global->dcmftest); | ||
unset($config->global->dcmdictpath); | ||
|
||
$writer = new Zend_Config_Writer_Ini(); | ||
$writer->setConfig($config); | ||
$writer->setFilename($configPath); | ||
$writer->write(); | ||
} else { | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE, $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE, $this->moduleName); | ||
$settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE, $this->moduleName); | ||
} | ||
} | ||
} |
Oops, something went wrong.