19 require_once(BASE.
"wcmf/lib/core/class.WCMFException.php");
 
   20 require_once(BASE.
"wcmf/lib/util/class.Message.php");
 
   21 require_once(BASE.
"wcmf/lib/util/class.Storable.php");
 
   22 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceMapper.php");
 
   23 require_once(BASE.
"wcmf/lib/persistence/class.LockManager.php");
 
   24 require_once(BASE.
"wcmf/lib/util/class.SearchUtil.php");
 
   29 define(
"STATE_CLEAN",   0);
 
   30 define(
"STATE_DIRTY",   1);
 
   31 define(
"STATE_NEW",     2);
 
   32 define(
"STATE_DELETED", 3);
 
   37 define(
"DATATYPE_DONTCARE",    0);
 
   38 define(
"DATATYPE_ATTRIBUTE",   1);
 
   39 define(
"DATATYPE_ELEMENT",     2);
 
   40 define(
"DATATYPE_IGNORE",      3); 
 
  118     $this->_type = $type;
 
  157       $pkValues = $mapper->getPkNames();
 
  158       $pkNames = array_keys($pkValues);
 
  159       for ($i=0; $i<
sizeof($pkNames); $i++) {
 
  160         $this->
setValue($pkNames[$i], $oidParts[
'id'][$i], $pkValues[$pkNames[$i]], 
true);
 
  196       $mapper = &$persistenceFacade->getMapper($this->_type);
 
  207     if ($mapper != null) {
 
  208       return $mapper->getDataConverter();
 
  217     if (!$this->_isImmutable)
 
  229       $persistenceFacade->save($this);
 
  250   function delete($recursive=
true)
 
  252     if (!$this->_isImmutable)
 
  259       $persistenceFacade->delete($this->
getOID(), $recursive);
 
  287     switch ($this->_state)
 
  298             $this->_state = $state;
 
  308         $this->_state = $state;
 
  310     if ($oldState != $this->_state) {
 
  327     $this->_isImmutable = 
true;
 
  338     $lock = $lockManager->getLock($this->
getOID());
 
  350     $class = get_class($this);
 
  369   function copyValues (&$object, $dataTypes=array(), $copyPkValues=
true)
 
  371     $valuesToIgnore = array();
 
  372     if (!$copyPkValues) {
 
  375         $valuesToIgnore = $mapper->getPkNames();
 
  378     $processor = 
new NodeProcessor(
'copyValueIntern', array(&$object, $dataTypes, $valuesToIgnore), $this);
 
  379     $processor->run($this, 
false);
 
  388   function copyValueIntern (&$node, $valueName, $dataType, &$targetNode, $dataTypes, $valuesToIgnore)
 
  390     if (
sizeof($dataTypes) == 0 || in_array($dataType, $dataTypes))
 
  392       if (!isset($valuesToIgnore[$valueName]) || $valuesToIgnore[$valueName] != $dataType) {
 
  393         $value = $node->getValue($valueName, $dataType);
 
  394         if (strlen($value) > 0) {
 
  395           $targetNode->setValue($valueName, $value, $dataType, 
true);
 
  407     $processor = 
new NodeProcessor(
'clearValueIntern', array($dataTypes), $this);
 
  408     $processor->run($this, 
false);
 
  416     if (
sizeof($dataTypes) == 0 || in_array($dataType, $dataTypes)) {
 
  417       $node->setValue($valueName, null, $dataType);
 
  428       $oidParts = array(
'type' => $this->
getType(), 
'id' => array());
 
  430       $pkValues = $mapper->getPkNames();
 
  431       foreach (array_keys($pkValues) as $pkName) {
 
  432         array_push($oidParts[
'id'], $this->
getValue($pkName, $pkValues[$pkName]));
 
  503       if (is_array($this->_data[$type]) && isset($this->_data[$type][$name])) {
 
  504         return $this->_data[$type][$name][
'value'];
 
  512       foreach($this->_data as $curDataArray) {
 
  513         if (isset($curDataArray[$name])) {
 
  514           return $curDataArray[$name][
'value'];
 
  530       if (is_array($this->_data[$type]) && array_key_exists($name, $this->_data[$type])) {
 
  531         unset($this->_data[$type][$name]);
 
  536       foreach(array_keys($this->_data) as $type) {
 
  537         if (is_array($this->_data[$type]) && array_key_exists($name, $this->_data[$type])) {
 
  538           unset($this->_data[$type][$name]);
 
  552     $value = $this->
getValue($name, $type);
 
  554     if (is_object($dataConverter) && $value != null) {
 
  555       $value = $dataConverter->convertApplicationToStorage($value, $this->
getValueProperty($name, 
'db_data_type', $type), $name);
 
  569     $value = $this->
getValue($name, $type);
 
  571     if (is_object($dataConverter) && $value != null) {
 
  572       $value = $dataConverter->convertStorageToApplication($value, $this->
getValueProperty($name, 
'db_data_type', $type), $name);
 
  584     foreach(array_keys($this->_data) as $type) {
 
  585       if (in_array($name, array_keys($this->_data[$type]))) {
 
  586         array_push($types, $type);
 
  599     $processor = 
new NodeProcessor(
'validateValueIntern', array(&$result), $this);
 
  600     $processor->run($this, 
false);
 
  610     $error = $node->validateValue($valueName, $value, $dataType);
 
  611     if (strlen($error) > 0) {
 
  612       $errorMsg .= $error.
"\n";
 
  642     $restrictionsMatch = $valueProperties[
'restrictions_match'];
 
  643     $restrictionsNotMatch = $valueProperties[
'restrictions_not_match'];
 
  644     if (($restrictionsMatch == 
'' || preg_match(
"/".$restrictionsMatch.
"/m", $value)) &&
 
  645         ($restrictionsNotMatch == 
'' || !preg_match(
"/".$restrictionsNotMatch.
"/m", $value))) {
 
  649     $errorMessage = 
Message::get(
"Wrong value for %1% (%2%). ", array($name, $value));
 
  652     if (strlen($valueProperties[
'restrictions_description']) > 0) {
 
  653       $errorMessage .= 
Message::get($valueProperties[
'restrictions_description']);
 
  658       if (strlen($restrictionsMatch) > 0) {
 
  659         $errorMessage .= 
Message::get(
"The value must match %1%.", array($restrictionsMatch));
 
  661       if (strlen($restrictionsNotMatch) > 0) {
 
  662         $errorMessage .= 
Message::get(
"The value must NOT match %1%.", array($restrictionsNotMatch));
 
  665     return $errorMessage;
 
  676   function setValue($name, $value, $type=null, $forceSet=
false)
 
  680       $validationResult = $this->
validateValue($name, $value, $type);
 
  681       if (strlen($validationResult) > 0) {
 
  682         WCMFException::throwEx(
"Invalid value (".$value.
") for ".$this->getOID().
".".$name.
": ".$validationResult, __FILE__, __LINE__);
 
  685     $oldValue = $this->
getValue($name, $type);
 
  686     if ($type != null && strlen($type) > 0)
 
  689       if (!isset($this->_data[$type]))
 
  691         $this->_data[$type] = array();
 
  694       if (!isset($this->_data[$type][$name]))
 
  696         $this->_data[$type][$name] = array();
 
  699       if ($this->_data[$type][$name][
'value'] !== $value || $forceSet)
 
  701         $this->_data[$type][$name][
'value'] = $value;
 
  704         if ($mapper != null && in_array($name, array_keys($mapper->getPKNames()))) {
 
  713       foreach(array_keys($this->_data) as $key)
 
  715         if (array_key_exists($name, $this->_data[$key]))
 
  717           if ($this->_data[$key][$name] != $value || $forceSet)
 
  719             $this->_data[$key][$name][
'value'] = $value;
 
  722             if ($mapper != null && in_array($name, array_keys($mapper->getPKNames()))) {
 
  744       if (isset($this->_data[$type][$name][
'properties'])) {
 
  745         return $this->_data[$type][$name][
'properties'];
 
  753       foreach($this->_data as $curDataArray)
 
  755         if (isset($curDataArray[$name])) {
 
  756           return $curDataArray[$name][
'properties'];
 
  775       if (!isset($type, $this->_data)) {
 
  779       if (isset($name, $this->_data[$type]))
 
  781         $this->_data[$type][$name][
'properties'] = $properties;
 
  788       foreach(array_keys($this->_data) as $key)
 
  790         if (isset($name, $this->_data[$key]))
 
  792           $this->_data[$key][$name][
'properties'] = $properties;
 
  811     if ($properties != null) {
 
  812       return $properties[$property];
 
  828     if ($properties != null)
 
  830       $properties[$property] = $value;
 
  846       foreach(array_keys($this->_data) as $key) {
 
  847         $names = array_merge($names, array_keys($this->_data[$key]));
 
  852       if (isset($this->_data[$type])) {
 
  853         $names = array_keys($this->_data[$type]);
 
  864     return array_keys($this->_data);
 
  873     if (isset($this->_properties[$name])) {
 
  874       return $this->_properties[$name];
 
  888     $this->_properties[$name] = $value;
 
  897     return array_keys($this->_properties);
 
  918     for ($i=0, $count=
sizeof($this->_changeListeners); $i<$count; $i++) {
 
  919       if ($this->_changeListeners[$i]->getId() == $listener->getId()) {
 
  920         unset($this->_changeListeners[$i]);
 
  933     for ($i=0, $count=
sizeof($this->_changeListeners); $i<$count; $i++) {
 
  934       if(method_exists($this->_changeListeners[$i], 
'valueChanged')) {
 
  935         $this->_changeListeners[$i]->valueChanged($this, $name, $type, $oldValue, $newValue);
 
  947     for ($i=0, $count=
sizeof($this->_changeListeners); $i<$count; $i++) {
 
  948       if(method_exists($this->_changeListeners[$i], 
'propertyChanged')) {
 
  949         $this->_changeListeners[$i]->propertyChanged($this, $name, $oldValue, $newValue);
 
  960     for ($i=0, $count=
sizeof($this->_changeListeners); $i<$count; $i++) {
 
  961       if(method_exists($this->_changeListeners[$i], 
'stateChanged')) {
 
  962         $this->_changeListeners[$i]->stateChanged($this, $oldValue, $newValue);
 
 1027     $str = 
'type:'.$this->getType().
', ';
 
 1029     if ($mapper != null)
 
 1030     $str .= 
'mapper:'.get_class($mapper).
', ';
 
 1031     $str .= 
'oid:'.$this->getOID().
' ';
 
 1032     $str .= 
'state:'.$this->getState().
' ';
 
 1033     $str .= 
'PROPERTIES ';
 
 1037       if (is_array($value)) {
 
 1038         $str .= $name.
':'.join(
',', $value).
' ';
 
 1041         $str .= $name.
':'.$value.
' ';
 
 1047     foreach($dataTypes as $type)
 
 1049       $str .= $type.
'->{';
 
 1051       foreach($valueNames as $name)
 
 1053         $str .= $name.
':'.$this->
getValue($name, $type).
' ';
 
 1057           if (sizeOf($valueProperties) > 0)
 
 1060             foreach($valueProperties as $key => $value) {
 
 1061               $str .= $key.
':'.$value.
' ';
 
 1063             $str = substr($str, 0, strlen($str)-1);
 
 1068       $str = substr($str, 0, -1).
'} ';
 
 1070     $str = substr($str, 0, -1);
 
getConvertedValue($name, $type=null)
get($message, $parameters=null, $domain='', $lang='')
static deleteFromSearch(&$obj)
removeChangeListener(&$listener)
getValueProperty($name, $property, $type=null)
addChangeListener(&$listener)
NodeProcessor is used to iterate over all values of a Node and apply a given callback function...
getValue($name, $type=null)
getValueNames($type=null)
throwEx($message, $file='', $line='')
setValueProperty($name, $property, $value, $type=null)
propagateStateChange($oldValue, $newValue)
validateValueIntern(&$node, $valueName, $dataType, &$errorMsg)
removeValue($name, $type=null)
clearValueIntern(&$node, $valueName, $dataType, $dataTypes)
decomposeOID($oid, $validate=true)
getValueProperties($name, $type=null)
getValueDescription($name, $type=null)
setValueProperties($name, $properties, $type=null)
setState($state, $recursive=true)
validateValue($name, $value, $type=null)
getBaseOID($oid, $validate=true)
This class defines the interface for classes that can be stored in the session. 
getValueDisplayName($name, $type=null)
propagateValueChange($name, $type, $oldValue, $newValue)
PersistentObject($type, $oid=null)
getOIDParameter($oid, $param, $validate=true)
setValue($name, $value, $type=null, $forceSet=false)
static indexInSearch(&$obj)
copyValueIntern(&$node, $valueName, $dataType, &$targetNode, $dataTypes, $valuesToIgnore)
validateValueAgainstRestrictions($name, $value, $type=null)
hasValue($name, $type=null)
getUnconvertedValue($name, $type=null)
propagatePropertyChange($name, $oldValue, $newValue)
PersistentObject is the base class of all persistent objects. It implements the basic persistence met...
copyValues(&$object, $dataTypes=array(), $copyPkValues=true)
clearValues($dataTypes=array())
setProperty($name, $value)