onParentVersion attribute * in a property definition within a node type definition. *

* Level 2 only *

* This interface defines the following actions: *

*

* Every item (node or property) in the repository has a status indicator that * governs what happens to that item when its parent node is versioned. This * status is defined by the onParentVersion attribute in the PropertyDef or * NodeDef that applies to the item in question. This PropertyDef or NodeDef is * part of the NodeType of the parent node of the item in question. *

* For example, let N be a versionable node in workspace W of repository R. * Furthermore, let N be of node type T, where T is a sub-type of * nt:versionable and T allows N to have one property called P and one child * node called C. *

* What happens to P and C when N is versioned depends on their respective * OnParentVersion attribute as defined in the PropertyDef for P and the * NodeDef for C, found in the definition of node type T. *

* The possible values for the OnParentVersion attribute are: COPY, VERSION, * INITIALIZE, COMPUTE, NOTHING and FORBIDDEN. *

* The sections below describe, for each possible value of the OnParentVersion * attribute, what happens to C and P when, *

*

* COPY *

* Child Node *

* On checkin of N, C and all its descendent items, down to the leaves of the * subtree, will be copied to the version storage as a child subtree of VN. The * copy of C and its subtree will not have its own version history but will be * part of the state preserved in VN. C itself need not be versionable. *

* On restore of VN, the copy of C and its subtree stored will be restored as * well, replacing the current C and its subtree in the workspace. *

* Property *

* On checkin of N, P will be copied to the version storage as a child of VN. * This copy of P is part of the state preserved in VN. *

* On restore of VN, the copy of P stored as its child will be restored as * well, replacing the current P in the workspace. *

* VERSION *

* Child Node *

* On checkin of N, the node VN will get a child reference to the version * history of C (not to C or any actual version of C). In practice, this means * that the root version of C's version history becomes the child of VN * because, as mentioned before, the root version is used as the referent when * a reference to the version history as a whole is required. This also * requires that C itself be versionable (otherwise it would not have a version * history). If C is not versionable then behavior of IGNORE applies on checkin * (see below). *

* On restore of VN, if the workspace currently has an already existing node * corresponding to C's version history, then that instance of C becomes the * child of the restored N. If the workspace does not have an instance of C * then one is restored from C's version history. The workspace in which the * restore is being performed will determine which particular version of C will * be restored. This determination depends on the configuration of the * workspace and is outside the scope of this specification. *

* Property *

* In the case of properties, an OnParentVersion attribute of VERSION has the * same effect as COPY. *

* INITIALIZE *

* Child Node *

* On checkin of N, a new node C will be created and placed in version storage * as a child of VN. This new C will be initialized just as it would be if * created normally in a workspace. No state information of the current C in * the workspace is preserved. The new C will not have its own version history * but will be part of the state preserved in VN. C itself need not be * versionable. *

* On restore of VN, the C stored as its child will be restored as well, * replacing the current C in the workspace. *

* Property *

* On checkin of N, a new P will be created and placed in version storage as a * child of VN. The new P will be initialized just as it would be if created * normally in a workspace. The new P is part of the state preserved in VN. *

* On restore of VN, the P stored as its child will be restored as well, * replacing the current P in the workspace. *

* COMPUTE *

* Child Node *

* On checkin of N, a new node C will be created and placed in version storage * as a child of VN. This new C will be initialized according to some * configuration-specific procedure beyond the scope of this specification. The * new C will not have its own version history but will be part of the state * preserved in VN. C itself need not be versionable. *

* On restore of VN, the C stored as its child will be restored as well, * replacing the current C in the workspace. *

* Property *

* On checkin of N, a new P will be created and placed in version storage as a * child of VN. The new P will be initialized according to some * configuration-specific procedure beyond the scope of this specification. The * new P is part of the state preserved in VN. *

* On restore of VN, the P stored as its child will be restored as well, * replacing the current P in the workspace. *

* IGNORE *

* Child Node *

* On checkin of N, no state information about C will be stored in VN. *

* On restore of VN, the child node C of the current N will remain and not be * removed, despite not being included in the state recorded in VN, since its * IGNORE status tells the system to leave it alone. *

* Property *

* On checkin of N, no state information about P will be stored in VN. *

* On restore of VN, the property P of the current N will remain and not be * removed, despite not being included in the state of recorded in VN, since * its IGNORE status tells the system to leave it alone. *

* ABORT *

* Child Node or Property *

* On checkin of N an exception will be thrown. Having a child node or property * with an OnParentVersion attribute of ABORT prevents the parent node from * being checked-in. * * @author Markus Nix * @package phpcr * @subpackage version */ final class OnParentVersionAction { /** * The action constants. */ const COPY = 1; const VERSION = 2; const INITIALIZE = 3; const COMPUTE = 4; const IGNORE = 5; const ABORT = 6; /** * The names of the defined on-version actions, * as used in serialization. */ const ACTIONNAME_COPY = "COPY"; const ACTIONNAME_VERSION = "VERSION"; const ACTIONNAME_INITIALIZE = "INITIALIZE"; const ACTIONNAME_COMPUTE = "COMPUTE"; const ACTIONNAME_IGNORE = "IGNORE"; const ACTIONNAME_ABORT = "ABORT"; /** * Private constructor to prevent instantiation */ private function __construct() { } /** * Returns the name of the specified action, * as used in serialization. * @param int $action the on-version action * @return string the name of the specified action * @throws IllegalArgumentException if action * is not a valid on-version action. */ public static function nameFromValue( $action ) { switch ( $action ) { case self::COPY: return self::ACTIONNAME_COPY; case self::VERSION: return self::ACTIONNAME_VERSION; case self::INITIALIZE: return self::ACTIONNAME_INITIALIZE; case self::COMPUTE: return self::ACTIONNAME_COMPUTE; case self::IGNORE: return self::ACTIONNAME_IGNORE; case self::ABORT: return self::ACTIONNAME_ABORT; default: throw new IllegalArgumentException("unknown on-version action: " + $action); } } /** * Returns the numeric constant value of the on-version action with the * specified name. * @param string $name the name of the on-version action * @return int the numeric constant value * @throws IllegalArgumentException if name * is not a valid on-version action name. */ public static function valueFromName( $name ) { if ( $name == self::ACTIONNAME_COPY ) { return self::COPY; } else if ( $name == self::ACTIONNAME_VERSION ) { return self::VERSION; } else if ( $name == self::ACTIONNAME_INITIALIZE ) { return self::INITIALIZE; } else if ( $name == self::ACTIONNAME_COMPUTE ) { return self::COMPUTE; } else if ( $name == self::ACTIONNAME_IGNORE ) { return self::IGNORE; } else if ( $name == self::ACTIONNAME_ABORT ) { return self::ABORT; } else { throw new IllegalArgumentException( "unknown on-version action: " + $name ); } } } ?>