Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 70cd448

Browse files
author
Charles Ma
committed
ENH: Added ezcomponent refs #163
1 parent 94b5ab8 commit 70cd448

File tree

2,274 files changed

+342208
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,274 files changed

+342208
-2
lines changed

modules/metadataextractor/controllers/ConfigController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ function indexAction()
1414
throw new Zend_Exception("You should be an administrator");
1515
}
1616

17-
if(file_exists(BASE_PATH."/core/configs/metadataextractor.local.ini"))
17+
if(file_exists(BASE_PATH."/core/configs/".$this->moduleName.".local.ini"))
1818
{
1919
$applicationConfig = parse_ini_file(BASE_PATH."/core/configs/".$this->moduleName.".local.ini", true);
2020
}
2121
else
2222
{
23-
$applicationConfig = parse_ini_file(BASE_PATH.'/modules/".$this->moduleName."/configs/module.ini', true);
23+
$applicationConfig = parse_ini_file(BASE_PATH.'/modules/'.$this->moduleName.'/configs/module.ini', true);
2424
}
2525
$configForm = $this->ModuleForm->Config->createConfigForm();
2626

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
class Scheduler_ConfigController extends Scheduler_AppController
4+
{
5+
public $_moduleForms=array('Config');
6+
public $_components=array('Utility', 'Date');
7+
8+
9+
/** index action*/
10+
function indexAction()
11+
{
12+
if(!$this->logged||!$this->userSession->Dao->getAdmin()==1)
13+
{
14+
throw new Zend_Exception("You should be an administrator");
15+
}
16+
17+
if(file_exists(BASE_PATH."/core/configs/".$this->moduleName.".local.ini"))
18+
{
19+
$applicationConfig = parse_ini_file(BASE_PATH."/core/configs/".$this->moduleName.".local.ini", true);
20+
}
21+
else
22+
{
23+
$applicationConfig = parse_ini_file(BASE_PATH.'/modules/'.$this->moduleName.'/configs/module.ini', true);
24+
}
25+
$configForm = $this->ModuleForm->Config->createConfigForm();
26+
27+
$formArray = $this->getFormAsArray($configForm);
28+
$formArray['dot']->setValue($applicationConfig['global']['dot']);
29+
30+
$this->view->configForm = $formArray;
31+
32+
if($this->_request->isPost())
33+
{
34+
$this->_helper->layout->disableLayout();
35+
$this->_helper->viewRenderer->setNoRender();
36+
$submitConfig = $this->_getParam('submitConfig');
37+
if(isset($submitConfig))
38+
{
39+
if(file_exists(BASE_PATH."/core/configs/".$this->moduleName.".local.ini.old"))
40+
{
41+
unlink(BASE_PATH."/core/configs/".$this->moduleName.".local.ini.old");
42+
}
43+
if(file_exists(BASE_PATH."/core/configs/".$this->moduleName.".local.ini"))
44+
{
45+
rename(BASE_PATH."/core/configs/".$this->moduleName.".local.ini",BASE_PATH."/core/configs/".$this->moduleName.".local.ini.old");
46+
}
47+
$applicationConfig['global']['dot'] = $this->_getParam('dot');
48+
$this->Component->Utility->createInitFile(BASE_PATH."/core/configs/".$this->moduleName.".local.ini", $applicationConfig);
49+
echo JsonComponent::encode(array(true, 'Changed saved'));
50+
}
51+
}
52+
}
53+
54+
}//end class
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
5+
69328 Lyon, FRANCE.
6+
7+
See Copyright.txt for details.
8+
This software is distributed WITHOUT ANY WARRANTY; without even
9+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10+
PURPOSE. See the above copyright notices for more information.
11+
=========================================================================*/
12+
13+
/**
14+
* TaskController
15+
*
16+
*/
17+
class Scheduler_WorkflowController extends Scheduler_AppController
18+
{
19+
public $_moduleModels=array();
20+
public $_moduleComponents=array('Ezc');
21+
22+
/**
23+
* @method initAction()
24+
* Index Action (first action when we access the application)
25+
*/
26+
function init()
27+
{
28+
29+
} // end method indexAction
30+
31+
/** create workflow */
32+
function createAction()
33+
{
34+
$definition = $this->ModuleComponent->Ezc->initWorkflowDefinitionStorage();
35+
// Load latest version of workflow named "Test".
36+
37+
$workflow = new ezcWorkflow( 'Test' );
38+
$input = new ezcWorkflowNodeInput(
39+
array( 'item1' => new ezcWorkflowConditionIsObject, 'item2' => new ezcWorkflowConditionIsObject )
40+
);
41+
$workflow->startNode->addOutNode( $input );
42+
43+
$split = new ezcWorkflowNodeParallelSplit();
44+
$input->addOutNode($split);
45+
$nodeExec1 = new ezcWorkflowNodeAction( 'Process A' );
46+
$nodeExec2 = new ezcWorkflowNodeAction( 'Process A' );
47+
$nodeExec1->addInNode($split);
48+
$nodeExec2->addInNode($split);
49+
50+
$disc = new ezcWorkflowNodeDiscriminator();
51+
$disc->addInNode( $nodeExec1 );
52+
$disc->addInNode( $nodeExec2 );
53+
54+
55+
$processB = new ezcWorkflowNodeAction( 'Process B' );
56+
$disc->addOutNode($processB );
57+
58+
$processB->addOutNode( $workflow->endNode);
59+
60+
61+
$this->_createGraph($workflow);
62+
63+
// Save workflow definition to database.
64+
// $definition->save( $workflow );
65+
}
66+
67+
/** create graph */
68+
private function _createGraph($workflow)
69+
{
70+
$visitor = new ezcWorkflowVisitorVisualization;
71+
$workflow->accept( $visitor );
72+
$modulesConfig=Zend_Registry::get('configsModules');
73+
$command = $modulesConfig['scheduler']->dot;
74+
$dotFile = BASE_PATH.'/tmp/misc/graphviz_workflow_'.$workflow->__get('id').'.dot';
75+
$image = BASE_PATH.'/tmp/misc/graphviz_workflow_'.$workflow->__get('id').'.png';
76+
if(file_exists($dotFile))
77+
{
78+
unlink($dotFile);
79+
}
80+
if(file_exists($image))
81+
{
82+
unlink($image);
83+
}
84+
file_put_contents($dotFile, (string) $visitor);
85+
86+
exec('"'.$command.'" -Tpng -o "'.$image.'" "'.$dotFile.'"');
87+
if(file_exists($dotFile))
88+
{
89+
unlink($dotFile);
90+
}
91+
if(!file_exists($image))
92+
{
93+
throw new Zend_Exception('Unable to create Graphviz');
94+
}
95+
return $image;
96+
}
97+
98+
}//end class
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
5+
69328 Lyon, FRANCE.
6+
7+
See Copyright.txt for details.
8+
This software is distributed WITHOUT ANY WARRANTY; without even
9+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10+
PURPOSE. See the above copyright notices for more information.
11+
=========================================================================*/
12+
13+
// load ezc autoloader
14+
set_include_path( BASE_PATH."/modules/scheduler/library/ezcomponents" . PATH_SEPARATOR . get_include_path());
15+
require_once "Base/src/base.php";
16+
function __autoload( $className )
17+
{
18+
ezcBase::autoload( $className );
19+
}
20+
21+
class Scheduler_EzcComponent extends AppComponent
22+
{
23+
public function initWorkflowDefinitionStorage()
24+
{
25+
$autoloader = Zend_Loader_Autoloader::getInstance();
26+
$autoloader->pushAutoloader(array('ezcBase', 'autoload'), 'ezc');
27+
// Set up database connection.
28+
$configDatabase = Zend_Registry::get('configDatabase');
29+
$db = ezcDbFactory::create( 'mysql://'.$configDatabase->database->params->username.':'.$configDatabase->database->params->password.'@'.$configDatabase->database->params->host.'/'.$configDatabase->database->params->dbname );
30+
31+
// Set up workflow definition storage (database).
32+
$definition = new ezcWorkflowDatabaseDefinitionStorage( $db );
33+
$options = $definition->__get('options');
34+
$options->__set('prefix', 'scheduler_');
35+
return $definition;
36+
}
37+
38+
} // end class
39+
?>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
class Scheduler_ConfigForm extends AppForm
3+
{
4+
5+
/** create form */
6+
public function createConfigForm()
7+
{
8+
$form = new Zend_Form;
9+
10+
$form->setAction($this->webroot.'/scheduler/config/index')
11+
->setMethod('post');
12+
13+
$dot = new Zend_Form_Element_Text('dot');
14+
15+
$submit = new Zend_Form_Element_Submit('submitConfig');
16+
$submit ->setLabel('Save configuration');
17+
18+
$form->addElements(array($dot, $submit));
19+
return $form;
20+
}
21+
22+
} // end class
23+
?>

modules/scheduler/database/mysql/1.0.0.sql

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,71 @@ CREATE TABLE IF NOT EXISTS `scheduler_job` (
1111
`params` text,
1212
PRIMARY KEY (`job_id`)
1313
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
14+
15+
16+
DROP TABLE IF EXISTS scheduler_workflow;
17+
CREATE TABLE scheduler_workflow (
18+
workflow_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
19+
workflow_name VARCHAR(255) NOT NULL,
20+
workflow_version INTEGER UNSIGNED NOT NULL DEFAULT 1,
21+
workflow_created INTEGER NOT NULL,
22+
23+
PRIMARY KEY (workflow_id),
24+
UNIQUE KEY name_version (workflow_name, workflow_version)
25+
) ENGINE=InnoDB;
26+
27+
DROP TABLE IF EXISTS scheduler_node;
28+
CREATE TABLE scheduler_node (
29+
workflow_id INTEGER UNSIGNED NOT NULL REFERENCES workflow.workflow_id,
30+
node_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
31+
node_class VARCHAR(255) NOT NULL,
32+
node_configuration BLOB NULL,
33+
34+
PRIMARY KEY (node_id),
35+
KEY workflow_id (workflow_id)
36+
) ENGINE=InnoDB;
37+
38+
DROP TABLE IF EXISTS scheduler_node_connection;
39+
CREATE TABLE scheduler_node_connection (
40+
node_connection_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
41+
incoming_node_id INTEGER UNSIGNED NOT NULL,
42+
outgoing_node_id INTEGER UNSIGNED NOT NULL,
43+
44+
PRIMARY KEY (node_connection_id)
45+
) ENGINE=InnoDB;
46+
47+
DROP TABLE IF EXISTS scheduler_variable_handler;
48+
CREATE TABLE scheduler_variable_handler (
49+
workflow_id INTEGER UNSIGNED NOT NULL REFERENCES workflow.workflow_id,
50+
variable VARCHAR(255) NOT NULL,
51+
class VARCHAR(255) NOT NULL,
52+
53+
PRIMARY KEY (workflow_id, class)
54+
) ENGINE=InnoDB;
55+
56+
DROP TABLE IF EXISTS scheduler_execution;
57+
CREATE TABLE scheduler_execution (
58+
workflow_id INTEGER UNSIGNED NOT NULL REFERENCES workflow.workflow_id,
59+
execution_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
60+
execution_parent INTEGER UNSIGNED NULL REFERENCES execution.execution_id,
61+
execution_started INTEGER NOT NULL,
62+
execution_suspended INTEGER NULL,
63+
execution_variables BLOB NULL,
64+
execution_waiting_for BLOB NULL,
65+
execution_threads BLOB NULL,
66+
execution_next_thread_id INTEGER UNSIGNED NOT NULL,
67+
68+
PRIMARY KEY (execution_id, workflow_id),
69+
KEY execution_parent (execution_parent)
70+
) ENGINE=InnoDB;
71+
72+
DROP TABLE IF EXISTS scheduler_execution_state;
73+
CREATE TABLE scheduler_execution_state (
74+
execution_id INTEGER UNSIGNED NOT NULL REFERENCES execution.execution_id,
75+
node_id INTEGER UNSIGNED NOT NULL REFERENCES node.node_id,
76+
node_state BLOB NULL,
77+
node_activated_from BLOB NULL,
78+
node_thread_id INTEGER UNSIGNED NOT NULL,
79+
80+
PRIMARY KEY (execution_id, node_id)
81+
) ENGINE=InnoDB;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CREDITS
2+
=======
3+
4+
eZ Components team
5+
------------------
6+
7+
- Sergey Alexeev
8+
- Sebastian Bergmann
9+
- Jan Borsodi
10+
- Raymond Bosman
11+
- Frederik Holljen
12+
- Kore Nordmann
13+
- Derick Rethans
14+
- Vadym Savchuk
15+
- Tobias Schlitt
16+
- Alexandru Stanoi

0 commit comments

Comments
 (0)