3 require_once( dirname(__FILE__
).'/base/baseobjectpool.php' );
6 * The univese of a objects of a given type in livestatus
8 abstract class ObjectPool_Model
extends BaseObjectPool_Model
{
11 * List which places this object is available for.
13 * It is (for now) always available within ninja. Other places are: api
15 protected static $available_for = array(
20 * Check if a table is available to read and export from a given interface.
22 * This can be used to hide tables from the HTTP-API that isn't API-stable
26 public function available_for($where) {
27 if(isset(static::$available_for[$where])) {
28 return static::$available_for[$where];
31 * Everything has traditionally been available everywhere. This is to limit
32 * access if we can't guarantee integrety of the API in upcoming releases
39 * Parse a query and return the related set
41 public static function get_by_query( $query, $disabled_saved_queries = array() ) {
42 $preprocessor = new LSFilterPP();
44 $parser = new LSFilter($preprocessor, new LSFilterMetadataVisitor());
45 $metadata = $parser->parse( $query );
47 $parser = new LSFilter($preprocessor, new LSFilterSetBuilderVisitor($metadata, $disabled_saved_queries));
48 return $parser->parse( $query );
52 * Get a set of object, given a named query. Can be overridden to handle groups (in HostPool/ServicePool)
54 public function get_by_name( $name, $disabled_saved_queries = array() ) {
55 if( in_array($name, $disabled_saved_queries) ) {
56 throw new ORMException( 'Circular depencencies of saved filters detected');
58 $query = LSFilter_Saved_Queries_Model
::get_query($name,$this->table
);
59 if( $query === false ) return false;
61 $disabled_saved_queries[] = $name;
62 return self
::get_by_query($query, $disabled_saved_queries);
66 * Get classes for tables in the system
68 static public function load_table_classes() {
69 return Module_Manifest_Model
::get('orm_table_classes');
73 * Get JS-files to render the orm...
75 * @todo move from this class... should be somewhere else, but not here...
77 static public function get_js_files() {
79 foreach( scandir(MODPATH
) as $module ) {
80 $path = MODPATH
. $module . '/js/orm_structure.js';
81 if( is_file($path) ) {
82 $js_files[] = 'modules/'.$module.'/js/orm_structure.js';