NAME

Rit::Base::Node

DESCRIPTION

Base class for Rit::Base::Resource and Rit::Base::Literal.

Inherits from Rit::Base::Object.

Object creation

1. Call Class->get($identity)

If you know the correct class, call get for that class. Resource handles the get(). Get handles node chaching.

2. get() calls Class->new($id), blesses the object to the right class and then calls $obj->init()

3. new($id) calls $obj->initiate_cache, that handles the Resource cahce part. Caching specific for a subclass must be handled outside this, in init()

4. init() will store node in cache if not yet existing

The create() method creates a new object and then creates the object and calls init()

A get_by_rec($rec) will get the node from the cache or create an object and call init($rec)

is_node

Returns true.

parse

  $n->parse( $value, \%args )

Compatible with Rit::Base::Literal/parse. This just calls Rit::Base::Resource/get_by_anything with the same args.

Supported args:

  valtype
  arc

Returns: the value as a literal or resource node

new_from_db

  $n->parse( $value )

Compatible with Rit::Base::Literal/new_from_db. This just calls Rit::Base::Resource/get the given $value

Returns: the value as a resource node

find_remove

  $n->find_remove(\%props, \%args )

Remove matching nodes if existing.

Calls /find with the given props.

Calls /remove for each found node.

For arcs, the argument implicit, if given, is passed on to /remove. This will only remove arc if it no longer can be infered and it's not explicitly declared

If the node is an arc and force is not true, it will not remove an arc that is a removal or that has been deactivated.

Supported args:

  arclim
  res
  implicit
  force

Returns: ---

id_alphanum

  $n->id_alphanum

The unique node id expressed with [0-9A-Z] as a plain string, with a one char checksum at the end.

parse_prop

  $n->parse_prop( $criterion, \%args )

Parses $criterion...

Returns the values of the property matching the criterion. See /list for explanation of the params.

See also Rit::Base::List/parse_prop

prop

  $n->prop( $predname, undef, \%args )

  $n->prop( $predname, $proplim, \%args )

  $n->prop( $predname, $value, \%args )

Returns the values of the property with predicate $predname. See /list for explanation of the params.

For special predname id, returns the id.

Use /first_prop or /list instead if that's what you want!

If given a value instead of a proplim, returns true/false based on if the node has a property with the specified $predname and $value.

Returns:

If more then one node found, returns a Rit::Base::List.

If one node found, returns the node.

In no nodes found, returns is_undef.

For $value, returns the given $value, or is_undef

revprop

  $n->revprop( $predname )

  $n->revprop( $predname, $proplim )

  $n->revprop( $predname, $proplim, \%args )

Returns the values of the reverse property with predicate $predname. See /list for explanation of the params.

Returns:

If more then one node found, returns a Rit::Base::List.

If one node found, returns the node.

In no nodes found, returns undef.

has_pred

  $n->has_pred( $pred )

  $n->has_pred( $pred, $proplim, $arclim )

Return true if the node has at least one property with this predicate. The return values makes this method usable as a filter.

Example:

  m.revlist('our_reference').has_pred('contact_next').sorted('contact_next')

Returns:

True: The node

False: is_undef

has_revpred

  $n->has_revpred( $pred )

  $n->has_revpred( $pred, $proplim, $arclim )

The reverse of has_pred. Return true if the node has at least one ACTIVE reverse property with this predicate.

Returns:

True: The node

False: is_undef

meets_proplim

  $n->meets_proplim( $proplim, \%args )

  $n->meets_proplim( $object, \%args )

See Rit::Base::List/find for docs.

Also implements predor

This also implements meets_proplim for arcs!!!

Also implements the form mypred1{is this}.that

Returns: boolean

add_arc

  $n->add_arc({ $pred => $value }, \%args )

Supported args are: res read_access write_access weight

Returns:

  The arc object

See also Rit::Base::Resource/add

replace

  $n->replace( \@arclist, \%props, \%args )

See /update for description of what is done.

But here we explicitly check against the given list of arcs.

Adds arcs with Rit::Base::Arc/create and removes arcs with Rit::Base::Arc/remove.

The %props are processed by /construct_proplist and @arclist are processed by /find_arcs.

We use valclean of the value syskey for a key for what strings to replace.

Supported args are:

  res

Debug:

  3 = detailed info
  4 = more details

Returns:

The number of arcs created or removed.

remove

  $n->remove( $args )

Removes the node with all arcs pointing to and from the node.

It does not do a recursive remove. You will have to traverse the tree by yourself.

Supported args are: arclim res force force_recursive

TODO: Count the changes correctly

Returns: The number of arcs removed

has_node_record

  $n->has_node_record

Implemented i Rit::Base::Resource/has_node_record

For other nodes, like literals..:

Returns: false

copy_props

 $n->copy_props( $from_obj, \@preds, \%args )

Copies all properties with listed @preds from $from_obj.

Returns:

copy_revprops

 $n->copy_revprops( $from_obj, \@preds, \%args )

Copies all rev-properties with listed @preds from $from_obj.

Returns:

find_arcs

  $n->find_arcs( [ @crits ], \%args )

  $n->find_arcs( $query, \%args )

NB! Use Rit::Base::Resource/arc_list instead!

Used by Rit::Base::Node/replace

@crits can be a mixture of arcs, hashrefs or arc numbers. Hashrefs holds pred/value pairs that is added as arcs. Mostly only usable if called via Rit::Base::Node/replace.

Returns the union of all results from each criterion

Returns: A Rit::Base::List of found Rit::Base::Arcs

construct_proplist

  $n->construct_proplist(\%props, \%args)

Checks that the values has the right format. If a value is a hashref; looks up an object with those properties using /find_set.

TODO: REMOVE THE NEED FOR THIS!

Used by /replace.

Returns:

the normalized hashref of props.

Exceptions:

confesses if a value is an object of an unknown class.

update_by_query

  $n->update_by_query( \%args )

Setts query param id to node id.

Calls Rit::Base::Widget::Handler/update_by_query for the main work.

Returns: -

add_note

  $n->add_note( $text, \%args )

Adds a note

Supported args are:

  res

set_arc

Called for literal resources. Ignored here but active for literal nodes

wu_jump

  $n->wu_jump( \%attrs, \%args )

Attrs are the Para::Frame::Widget/jump attributes

Returns: a HTML link to a form form updating the node

wun_jump

  $n->wun_jump( \%attrs, \%args )

Attrs are the Para::Frame::Widget/jump attributes

Returns: a HTML link to node-updating page

code_class

  $node->code_class()

List the class of the node

code_class_desig

  $node->code_class_desig()

Return a string naming the class of the node suitable for Rit::Base.

AUTOLOAD

  $n->$method()

  $n->$method( $proplim )

  $n->$method( $proplim, $args )

If $method ends in _$arclim there $arclim is one of Rit::Base::Arc::Lim/limflag, the param $arclim is set to that value and the suffix removed from $method. Args arclim is stored as arclim2 and will be used for proplims. The given arclim will be used in the arclim for the given $method.

If $proplim or $arclim are given, we return the result of $n->list( $proplim, $arclim ). In the other case, we return the result of $n->prop( $proplim, $args ).

But if $method begins with rev_ we instead call the corresponding /revlist or /revprop correspondingly, with the prefix removed.

Note that the Rit::Base::List/AUTOLOAD will distribute the method calls so that $list->$method will via this AUTOLOAD call each elements $method and return the new list.

SEE ALSO

Rit::Base, Rit::Base::Arc, Rit::Base::Pred, Rit::Base::List, Rit::Base::Search, Rit::Base::Literal::Time