NAME

RDF::Base::Node

DESCRIPTION

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

Inherits from RDF::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.

is_resource

Returns false.

parse

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

Compatible with RDF::Base::Literal/parse. This just calls RDF::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 RDF::Base::Literal/new_from_db. This just calls RDF::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 RDF::Base::Resource/list for explanation of the params.

See also RDF::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 RDF::Base::Resource/list for explanation of the params.

For special predname id, returns the id.

Use /first_prop or RDF::Base::Resource/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 RDF::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 RDF::Base::Resource/list for explanation of the params.

Returns:

If more then one node found, returns a RDF::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 RDF::Base::List/find for docs.

Also implements predor

This also implements meets_proplim for arcs!!!

Also implements the form mypred1{is this}.that

... implements not => { ... }

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 RDF::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 RDF::Base::Arc/create and removes arcs with RDF::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 RDF::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 RDF::Base::Resource/arc_list instead!

Used by RDF::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 RDF::Base::Node/replace.

Returns the union of all results from each criterion

Returns: A RDF::Base::List of found RDF::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 RDF::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

wp_jump

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

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

Returns: a HTML link to page presenting the node

code_class

  $node->code_class()

List the class of the node

wuirc_input_type

code_class_desig

  $node->code_class_desig()

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

AUTOLOAD

  $n->$method()

  $n->$method( $proplim )

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

If $method ends in _$arclim there $arclim is one of RDF::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 RDF::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

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