NAME

perfSONAR_PS::DataModels::APIBuilder - builder utils to build binding perl objects collection

DESCRIPTION

   single call is here with several private ones
   the public call is:
   buildAPI(<top object name>, <top object>, <path>,<API root name>);

SYNOPSIS

###
use   perfSONAR_PS::DataModels::DataModel  qw($message); 
use  perfSONAR_PS::DataModels::APIBuilderqw(&buildAPI  $API_ROOT $TOP_DIR $DATATYPES_ROOT) ;
 
$API_ROOT = 'perfSONAR_PS';
$TOP_DIR = "/tmp/API/" .$API_ROOT;   
$DATATYPES_ROOT = 'Datatypes';
 
buildAPI('message', $message, '','' );
####
 

API

Exported variables

 $API_ROOT  - name of the  API  ( empty string by default)
 $TOP_DIR  - top dirname of the API location( /tmp/API by default)
 $DATATYPES_ROOT - dirname for schema datamodel files

buildAPI

  builds the whole API recursively
  
  accepts  four parameters
  - name of the root element - message by default
  - top hashref ( object to be built) 
  -   path ( empty by default )
  -   root API name ( empty by default )  

   

buildClass

builds  single class on the filesystem and corresponded test file

accepts  four parameters
  -   full  path to the class ( except for .pm extension)
  -   full  package  name  
  -   name of the   element 
  -   hashref with the element definition  
  -   hashref with parent definition if its not the root element

NAME

$className  - A base class, implements  '$name'  element from the perfSONAR_PS RelaxNG schema
 

DESCRIPTION

 Object representation of the $name element.
 Object fields are:
EOA
#------------------------------------------------------------------------------
map { print $fh   "    Scalar:     $_, \n"  }   @attributes ;
map { print $fh   "    Object reference:   " . $_->[0]  . " => type " . ref($_->[1]) . ",\n" }  @elements ;
 

 print $fh <<EOB;
 
 The constructor accepts only single parameter, it could be a hashref to parameters hash  or DOM with  '$name' element 
  
  

SYNOPSIS

             use $className;
         
         my \$el =  $className->new(\$DOM_Obj);

METHODS

new( )

     creates   object, accepts DOM with  element tree or hashref to the list of
     keyd parameters
EOD
map { print $fh   "         $_   => undef, \n"  }  @attributes ;
map { print $fh   "         " . $_->[0]  . " => " . ref($_->[1]) . ",\n"   }  @elementnodes;
print $fh "text => 'text'\n" if $element->{text};              

print $fh <<EOF;

getDOM (\$)

     accept parent DOM
     return $name object DOM, generated from object contents 

add$subname()

if any of subelements can be an arrray then this method will provide
facility to add another element to the  array and will return ref to such array
or just set the element to a new one

remove\u${subname}ById()

remove specific element from the array of ${subname} elements by id ( if id is supported by this element )
accepts single param - id - which is id attribute of the element
if there is no array then it will return undef and warninig
if it removed some id then \$id will be returned

get\u${subname}ByMetadataIdRef()

get specific object from the array of ${subname} elements by  MetadataIdRef( if  MetadataIdRef is supported by this element )
accepts single param -  MetadataIdRef
if there is no array then it will return just an object

get\u${subname}ById()

get specific element from the array of ${subname} elements by id ( if id is supported by this element )
accepts single param - id
if there is no array then it will return just an object

querySQL ()

  depending on config  it will return some hash ref  to the initialized fields
for example querySQL ()
accepts one optional prameter - query hashref
will return:
{ ip_name_src =>  'hepnrc1.hep.net' },}

merge

merge with another $name ( append + overwrite if exists )
we can do it differently
method #1:
   convert to dom both objects and then get resulted object from combined dom 
method #2 default:
   through the introspection of the object

buildIdMap()

if any of subelements has id then get a map of it in form of
hashref to { element}{id} = index in array and store in the idmap field

buildrefIdMap ()

if any of subelements has  metadataIdRef  then get a map of it in form of
hashref to { element}{ metadataIdRef } = index in array and store in the idmap field

asString()

shortcut to get DOM and convert into the XML string
returns XML string  representation of the  $name object

registerNamespaces ()

will parse all subelements and register all namepspaces within the $name namespace

fromDOM (\$)

accepts parent XML DOM   element   tree as parameter 
returns $name  object

AUTHORS

Maxim Grigoriev (FNAL)  2007-2008, maxim\@fnal.gov