[Components] ezcPersistentSessionIdentityDecorator creating a sql query with createFindQuery() results in a wrong statement with missing attributes/columns

2010-04-28 Thread Christoph René Pardon
Hi lists reader :)

i've a problem with creating sql statements with persistent objects of ezc.

The following Code:
$ezcSession = ezcPersistentSessionInstance::get();
$query = $ezcSession-createFindQuery('Yela_Persistence_Core_Acl_Rules');
var_dump($query-getQuery());die();

results in this statement:
string(133) SELECT `yela_core_acl_rules`.`assert_id`,
`yela_core_acl_rules`.`privileges`, `yela_core_acl_rules`.`type` FROM
`yela_core_acl_rules`

But my table looks like this:
CREATE TABLE  `YelaCMS`.`yela_core_acl_rules` (
  `rule_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `group_id` int(10) unsigned NOT NULL,
  `resource_id` varchar(200) NOT NULL,
  `privileges` text NOT NULL,
  `assert_id` int(10) unsigned NOT NULL DEFAULT '0',
  `type` varchar(10) NOT NULL DEFAULT 'deny',
  PRIMARY KEY (`rule_id`) USING BTREE,
  KEY `fk1` (`resource_id`),
  KEY `fk2` (`group_id`),
  KEY `fk3` (`assert_id`),
  KEY `misc` (`type`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8

There are some attributes missing in my statement.
The definition file looks like this:

$def = new ezcPersistentObjectDefinition();
$def-table = 'yela_core_acl_rules';
$def-class = 'Yela_Persistence_Core_Acl_Rules';

$def-idProperty   = new ezcPersistentObjectIdProperty();
$def-idProperty-columnName   = 'rule_id';
$def-idProperty-propertyName = 'rule_id';
$def-idProperty-generator= new ezcPersistentGeneratorDefinition(
'ezcPersistentSequenceGenerator' );
$def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def-idProperty   = new ezcPersistentObjectIdProperty();
$def-idProperty-columnName   = 'group_id';
$def-idProperty-propertyName = 'group_id';
$def-idProperty-generator= new ezcPersistentGeneratorDefinition(
'ezcPersistentManualGenerator' );
$def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def-idProperty   = new ezcPersistentObjectIdProperty();
$def-idProperty-columnName   = 'resource_id';
$def-idProperty-propertyName = 'resource_id';
$def-idProperty-generator= new ezcPersistentGeneratorDefinition(
'ezcPersistentManualGenerator' );
$def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def-properties['privileges']   = new
ezcPersistentObjectProperty();
$def-properties['privileges']-columnName   = 'privileges';
$def-properties['privileges']-propertyName = 'privileges';
$def-properties['privileges']-propertyType =
ezcPersistentObjectProperty::PHP_TYPE_STRING;

$def-idProperty   = new ezcPersistentObjectIdProperty();
$def-idProperty-columnName   = 'assert_id';
$def-idProperty-propertyName = 'assert_id';
$def-idProperty-generator= new ezcPersistentGeneratorDefinition(
'ezcPersistentManualGenerator' );
$def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def-properties['type']   = new ezcPersistentObjectProperty();
$def-properties['type']-columnName   = 'type';
$def-properties['type']-propertyName = 'type';
$def-properties['type']-propertyType =
ezcPersistentObjectProperty::PHP_TYPE_STRING;

$def-relations['Yela_Persistence_Core_Resources'] = new
ezcPersistentOneToManyRelation('yela_core_resources',
'yela_core_acl_rules');
$def-relations['Yela_Persistence_Core_Resources']
-columnMap = array(new ezcPersistentSingleTableMap('resources_id',
'resource_id'));

$def-relations['Yela_Persistence_Core_Acl_Groups'] = new
ezcPersistentOneToManyRelation('yela_core_acl_groups',
'yela_core_acl_rules');
$def-relations['Yela_Persistence_Core_Acl_Groups']
-columnMap = array(new ezcPersistentSingleTableMap('id', 'group_id'));

$def-relations['Yela_Persistence_Core_Acl_Assertions'] = new
ezcPersistentOneToManyRelation('yela_core_acl_assertions',
'yela_core_acl_rules');
$def-relations['Yela_Persistence_Core_Acl_Assertions']
-columnMap = array(new ezcPersistentSingleTableMap('id', 'assert_id'));

return $def;


The following class represents the previous defined table:
class Yela_Persistence_Core_Acl_Rules extends Yela_Db_Table {
protected $_name = 'yela_core_acl_rules';
protected $_primary = 'rule_id';
public $rule_id = null;
public $assert_id = null;
public $group_id = null;
public $privileges = '*';
public $resource_id = null;
public $type = 'deny';
public function getState() {
$result = array();
$result['rule_id'] = $this-rule_id;
$result['group_id']= $this-group_id;
$result['resource_id'] = $this-resource_id;
$result['privileges']  = $this-privileges;
$result['assert_id']   = $this-assert_id;
$result['type']= $this-type;

return $result;
}
}


This may be a pebkac error but help will be useful :)
Thank you.
René
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


[Components] Node activates less conditional outgoing nodes than required

2010-04-28 Thread Margusja
Hi,

I have the workflow: http://ftp.margusja.pri.ee/demowf.png
I presume if I can create and execute the  workflow then I might  to 
resume it.
I have simple the code . almost copy paste from the documentation.

   1 ?php
   2 set_include_path( 
/var/www/arendus/mehis/big/library/ezcomponents/ . PATH_SEPARATOR .  
get_include_path());
   3 require_once Base/src/base.php; // dependent on installation 
method, see below
   4 function __autoload( $className ){
   5  ezcBase::autoload( $className );
   6 }
   7
   8 class age implements ezcWorkflowServiceObject{
   9  public $points;
  10  public $variableName;
  11  public $inNode;
  12  public $outNode;
  13  public $choice;
  14  public function  __construct($points) {
  15  $this-points = $points;
  16  $this-variableName = __CLASS__;
  17  $this-choice = array(
  18  array('start' = 0, 'end' = 17, 'score' = 1000),
  19  array('start' = 18, 'end' = 24, 'score' = 20),
  20  array('start' = 66, 'end' = 150, 'score' = 1000)
  21  );
  22  }
  23  public function execute( ezcWorkflowExecution $execution ){
  24  print $this-points;
  25  return true;
  26  }
  27  public function __toString() {
  28  return $this-variableName;
  29  }
  30  }
  31
  32
  33 // Set up database connection.
  34 $db = ezcDbFactory::create( 
'mysql://dbusert:dbpa...@localhost/mehis_ezwf' );
  35
  36 // Set up database-based workflow executer.
  37 $execution = new ezcWorkflowDatabaseExecution( $db, 34 );
  38
  39 // Resume workflow execution.
  40 $execution-resume(
  41   array( 'age' = 10 )
  42 );
  43 ?

If I try to resume my workflow I'll get:
1000
Fatal error: Uncaught exception 'ezcWorkflowExecutionException' with 
message 'Node activates less conditional outgoing nodes than required.' 
in 
/var/www/arendus/mehis/big/library/ezcomponents/Workflow/src/interfaces/node_conditional_branch.php:174
 
Stack trace: #0 
/var/www/arendus/mehis/big/library/ezcomponents/Workflow/src/interfaces/execution.php(494):
 
ezcWorkflowNodeConditionalBranch-execute(Object(ezcWorkflowDatabaseExecution)) 
#1 
/var/www/arendus/mehis/big/library/ezcomponents/Workflow/src/interfaces/execution.php(367):
 
ezcWorkflowExecution-execute() #2 
/var/www/arendus/mehis/big/exec.php(42): 
ezcWorkflowExecution-resume(Array) #3 {main} thrown in 
/var/www/arendus/mehis/big/library/ezcomponents/Workflow/src/interfaces/node_conditional_branch.php
 
on line 179

Any hint?
I see the main problem is: Node activates less conditional outgoing 
nodes than required
But how. I have a correct workflow and the relations between nodes.

digraph mtest { node1 [label=Start, color=#2e3436] node3 
[label=Input, color=#2e3436] node4 [label=Exclusive Choice, 
color=#2e3436] node5 [label=Class age not found., color=#2e3436] 
node6 [label=Simple Merge, color=#2e3436] node7 [label=Input, 
color=#2e3436] node8 [label=Exclusive Choice, color=#2e3436] node9 
[label=Class income not found., color=#2e3436] node10 
[label=Simple Merge, color=#2e3436] node2 [label=End, 
color=#2e3436] node11 [label=Class income not found., 
color=#2e3436] node12 [label=Class income not found., 
color=#2e3436] node13 [label=Class income not found., 
color=#2e3436] node14 [label=Class income not found., 
color=#2e3436] node15 [label=Class age not found., 
color=#2e3436] node16 [label=Class age not found., 
color=#2e3436] node1 - node3 node3 - node4 node4 - node5 
[label=age (  0  = 17 )] node4 - node15 [label=age (  18  = 
24 )] node4 - node16 [label=age (  66  = 150 )] node5 - node6 
node6 - node7 node7 - node8 node8 - node9 [label=income (  0  = 
3000 )] node8 - node11 [label=income (  3001  = 7000 )] node8 - 
node12 [label=income (  7001  = 11000 )] node8 - node13 
[label=income (  11001  = 25000 )] node8 - node14 [label=income 
(  25000  = 99 )] node9 - node10 node10 - node2 node11 - 
node10 node12 - node10 node13 - node10 node14 - node10 node15 - 
node6 node16 - node6 }


-- 
Regards Margusja
Phone: +372 51 48 780
MSN: margu...@kodila.ee
skype: margusja
web: http://margusja.pri.ee

-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


Re: [Components] ezcPersistentSessionIdentityDecorator creating a sql query with createFindQuery() results in a wrong statement with missing attributes/columns

2010-04-28 Thread Derick Rethans
On Wed, 28 Apr 2010, Christoph René Pardon wrote:

 There are some attributes missing in my statement.
 The definition file looks like this:
 
 $def = new ezcPersistentObjectDefinition();
 $def-table = 'yela_core_acl_rules';
 $def-class = 'Yela_Persistence_Core_Acl_Rules';
 
 $def-idProperty   = new ezcPersistentObjectIdProperty();
 $def-idProperty-columnName   = 'rule_id';
 $def-idProperty-propertyName = 'rule_id';
 $def-idProperty-generator= new ezcPersistentGeneratorDefinition( 
 'ezcPersistentSequenceGenerator' );
 $def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;
 
 $def-idProperty   = new ezcPersistentObjectIdProperty();
 $def-idProperty-columnName   = 'group_id';
 $def-idProperty-propertyName = 'group_id';
 $def-idProperty-generator= new ezcPersistentGeneratorDefinition( 
 'ezcPersistentManualGenerator' );
 $def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;
 
 $def-idProperty   = new ezcPersistentObjectIdProperty();
 $def-idProperty-columnName   = 'resource_id';
 $def-idProperty-propertyName = 'resource_id';
 $def-idProperty-generator= new ezcPersistentGeneratorDefinition( 
 'ezcPersistentManualGenerator' );
 $def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

You can only have one ID property, you're overwriting rule_id and 
group_id so hence they don't show up in the statement. 

Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


Re: [Components] ezcPersistentSessionIdentityDecorator ... missing attributes/columns [solved]

2010-04-28 Thread Christoph René Pardon
Hello Derick,

thank you very much :)

I've changed idProperty to normal properties.

The problem was, that i've used the ezc-Tools to create the definition
files.

// Creates a schema.xml from current database table.
// Needed for Persistent Object creation.
$schema = ezcDbSchema::createFromDb( $db );
$dest = APPLICATION_PATH . DS .
'sources' . DS .
'database' . DS .
'schema.xml';
$schema-writeToFile( 'xml', $dest );

// console code to create definition files from previous created schema.xml
php rungenerator.php -s ./application/sources/database/schema.xml -f xml
./application/sources/database/persistence/


(Maybe) ezcDbSchema doesn't recognize the correct types of attributes if
there are multiple primary keys on a table.

greetings
René

Derick Rethans schrieb:
 On Wed, 28 Apr 2010, Christoph René Pardon wrote:
 
 There are some attributes missing in my statement.
 The definition file looks like this:

 $def = new ezcPersistentObjectDefinition();
 $def-table = 'yela_core_acl_rules';
 $def-class = 'Yela_Persistence_Core_Acl_Rules';

 $def-idProperty   = new ezcPersistentObjectIdProperty();
 $def-idProperty-columnName   = 'rule_id';
 $def-idProperty-propertyName = 'rule_id';
 $def-idProperty-generator= new ezcPersistentGeneratorDefinition( 
 'ezcPersistentSequenceGenerator' );
 $def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

 $def-idProperty   = new ezcPersistentObjectIdProperty();
 $def-idProperty-columnName   = 'group_id';
 $def-idProperty-propertyName = 'group_id';
 $def-idProperty-generator= new ezcPersistentGeneratorDefinition( 
 'ezcPersistentManualGenerator' );
 $def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

 $def-idProperty   = new ezcPersistentObjectIdProperty();
 $def-idProperty-columnName   = 'resource_id';
 $def-idProperty-propertyName = 'resource_id';
 $def-idProperty-generator= new ezcPersistentGeneratorDefinition( 
 'ezcPersistentManualGenerator' );
 $def-idProperty-propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;
 
 You can only have one ID property, you're overwriting rule_id and 
 group_id so hence they don't show up in the statement. 
 
 Derick
 
 
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components