/**
  * Constructor
  * 
  * @param string $name
  * @return object
  * @access public
  * @since 3/1/06
  */
 function HarmoniReadableLog($name, $dbIndex)
 {
     ArgumentValidator::validate($name, StringValidatorRule::getRule());
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule());
     $this->_name = $name;
     $this->_dbIndex = $dbIndex;
 }
 /**
  * Constructor.
  * @param object Id $setId The Id of this set.
  * @param integer $dbIndex The index of the database connection which has
  * 		tables in which to store the set.
  */
 function PersistentOrderedSet($setId, $dbIndex)
 {
     parent::OrderedSet($setId);
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     // Create our internal array
     $this->_dbIndex = $dbIndex;
     // populate our array with any previously stored items.
     $query = new SelectQuery();
     $query->addColumn("item_order", "item_order");
     $query->addColumn("item_id", "item_id");
     $query->addTable("sets");
     $query->addWhere("id = '" . addslashes($this->_setId->getIdString()) . "'");
     $query->addOrderBy("item_order");
     $dbHandler = Services::getService("DatabaseManager");
     $result = $dbHandler->query($query, $this->_dbIndex);
     $i = 0;
     $oldItems = array();
     while ($result->hasMoreRows()) {
         // Add the items to our array
         $this->_items[$i] = $result->field("item_id");
         // Store an array of the order-key/value relationships to reference
         // when updating any inconsistancies in order numbering.
         $oldItems[$result->field("item_order")] = $result->field("item_id");
         $i++;
         $result->advanceRow();
     }
     $result->free();
     // Make sure that we have our set is filled from 0 to count()
     reset($oldItems);
     $this->_updateOrders($oldItems);
 }
示例#3
0
 /**
  * The constructor.
  *
  * @param integer $numberOfColumns
  * @access public
  **/
 function TableLayout($numberOfColumns, $tdStyles = null)
 {
     ArgumentValidator::validate($numberOfColumns, IntegerValidatorRule::getRule());
     $this->_numColumns = $numberOfColumns;
     $this->_tdStyles = $tdStyles;
     $this->_renderDirection = 'Left-Right/Top-Bottom';
     $this->printEmptyCells = true;
 }
 /**
  * Assigns the configuration of databases etc.
  * 
  * @param object $configuration
  * 
  * @access public
  *
  * @return void
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_dbIndex = $dbIndex;
 }
示例#5
0
 /**
  * Constructor
  * 
  * @param string $path
  * @return null
  * @access public
  * @since 5/6/08
  */
 public function __construct($databaseIndex, $id)
 {
     ArgumentValidator::validate($databaseIndex, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($id, NonzeroLengthStringValidatorRule::getRule());
     $this->databaseIndex = $databaseIndex;
     $this->id = $id;
     $this->preHtml = array();
     $this->postHtml = array();
 }
 /**
  * Constructor.
  *
  * @param object ID	  $id	The Id of this Node.
  * @param string $displayName The displayName of the Node.
  * @param integer $depth The depth of the Node.
  * @access public
  */
 function __construct(Id $id, $displayName, $depth)
 {
     // Check the arguments
     ArgumentValidator::validate($displayName, StringValidatorRule::getRule());
     ArgumentValidator::validate($depth, IntegerValidatorRule::getRule());
     // set the private variables
     $this->_id = $id;
     $this->_displayName = $displayName;
     $this->_depth = $depth;
 }
示例#7
0
 /**
  * Constructor. Creates a HarmoniId with id = $id or a new unique id if $id is NULL.
  * @param string $id The desired id. If NULL, a new unique id is used.
  *
  */
 function __construct($id)
 {
     // ** parameter validation
     ArgumentValidator::validate($id, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), IntegerValidatorRule::getRule()), true);
     // ** end of parameter validation
     // 		if (preg_match('/^#.+$/', $id))
     $this->_id = strval($id);
     // 		else
     // 			$this->_id = '#'.md5($id);
 }
 /**
  * Constructor
  * 
  * @param object SeguePluginsAPI $pluginInstance
  * @param string $versionId
  * @param object DateAndTime $timestamp
  * @param object Id $agentId
  * @param int $number
  * @param string $comment
  * @return void
  * @access public
  * @since 1/7/08
  */
 public function __construct(SeguePluginsAPI $pluginInstance, $versionId, DateAndTime $timestamp, Id $agentId, $number, $comment)
 {
     ArgumentValidator::validate($versionId, NonZeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($number, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($comment, StringValidatorRule::getRule());
     $this->pluginInstance = $pluginInstance;
     $this->versionId = $versionId;
     $this->timestamp = $timestamp;
     $this->agentId = $agentId;
     $this->number = $number;
     $this->comment = $comment;
 }
 /**
  * Creates a new OracleINSERTQueryResult object.
  * @access public
  * @param integer $resourceId The resource id for this query.
  * @param integer $lastId The last id that was inserted
  * @return object A new OracleINSERTQueryResult object.
  */
 function OracleInsertQueryResult($resourceId, $lastId)
 {
     // ** parameter validation
     $resourceRule = ResourceValidatorRule::getRule();
     $integerRule = OptionalRule::getRule(IntegerValidatorRule::getRule());
     ArgumentValidator::validate($resourceId, $resourceRule, true);
     ArgumentValidator::validate($lastId, $integerRule, true);
     // ** end of parameter validation
     $this->_resourceId = $resourceId;
     $this->_numberOfRows = ocirowcount($this->_resourceId);
     $this->_lastAutoIncrementValue = $lastId;
 }
 /**
  * Stores the configuration. Calls the parent configuration first,
  * then does additional operations.
  * 
  * @param object Properties $configuration
  * @return object
  * @access public
  * @since 3/24/05
  */
 function assignConfiguration(Properties $configuration)
 {
     parent::assignConfiguration($configuration);
     // Validate the configuration options we use:
     ArgumentValidator::validate($this->_configuration->getProperty('properties_fields'), ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('database_id'), IntegerValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('authentication_table'), StringValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('username_field'), StringValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('password_field'), StringValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('allow_token_addition'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('allow_token_deletion'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('allow_token_updates'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('allow_property_updates'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
 }
 /**
  * The constructor.
  * @param ref object id - is externally defined functionId - is externally 
  *		defined.
  * @param string referenceName - is externally defined referenceName - the 
  *		name to display for this Function
  * @param string  description - is externally defined description - the 
  *		description of this Function
  * @param ref object functionType - is externally defined functionType - the 
  *		Type of this Function
  * @param ref object qualifierHierarchyId - is externally defined 
  *		qualifierHierarchyId - the Id of the Qualifier Hierarchy associated 
  *		with this Function	 
  * @param  integer dbIndex The index of the database connection as returned 
  *		by the DBHandler.
  * @param  string authzDB The name of the Authorization database.
  * @access public
  */
 function __construct(Id $id, $referenceName, $description, Type $functionType, Id $qualifierHierarchyId, $dbIndex)
 {
     // ** parameter validation
     $stringRule = StringValidatorRule::getRule();
     ArgumentValidator::validate($referenceName, $stringRule, true);
     ArgumentValidator::validate($description, $stringRule, true);
     $integerRule = IntegerValidatorRule::getRule();
     ArgumentValidator::validate($dbIndex, $integerRule, true);
     // ** end of parameter validation
     $this->_id = $id;
     $this->_referenceName = $referenceName;
     $this->_description = $description;
     $this->_functionType = $functionType;
     $this->_qualifierHierarchyId = $qualifierHierarchyId;
     $this->_dbIndex = $dbIndex;
 }
示例#12
0
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	database_index			integer
  *	database_name			string
  *	default_theme			object Theme
  *
  * @param object Properties $configuration (original type: java.util.Properties)
  *
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  *
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     $dbName = $configuration->getProperty('database_name');
     $theme = $configuration->getProperty('default_theme');
     $id = $configuration->getProperty('default_state_id');
     $arrayOfDefaultThemes = $configuration->getProperty('array_of_default_themes');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     ArgumentValidator::validate($theme, ExtendsValidatorRule::getRule("ThemeInterface"), true);
     ArgumentValidator::validate($arrayOfDefaultThemes, ArrayValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_dbName = $dbName;
     $this->_dbIndex = $dbIndex;
     $this->_themeList = $arrayOfDefaultThemes;
     $this->setTheme($theme);
 }
 /**
  * Constructor
  * 
  * @param object $iterator The iterator to print.
  * @param integer $numColumns The number of result columns to print on each page.
  * @param integer $numResultsPerPage The number of iterator items to print on a page.
  * @param string $callbackFunction The name of the function that will be called to
  *			to print each result.
  * @param optional mixed $callbackArgs Any additional arguements will be stored
  *			and passed on to the callback function.
  * @access public
  * @date 8/5/04
  */
 function EmbeddedArrayResultPrinter($array, $numColumns, $numResultsPerPage, $callbackFunction)
 {
     ArgumentValidator::validate($array, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($numColumns, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($numResultsPerPage, IntegerValidatorRule::getRule());
     // 		if (is_array($callbackFunction))
     // 			ArgumentValidator::validate($callbackFunction[1], new StringValidatorRule);
     // 		else
     // 			ArgumentValidator::validate($callbackFunction, new StringValidatorRule);
     $this->_array = $array;
     $this->_numColumns = $numColumns;
     $this->_pageSize = $numResultsPerPage;
     $this->_callbackFunction = $callbackFunction;
     $this->_callbackParams = array();
     $args = func_get_args();
     for ($i = 4; $i < count($args); $i++) {
         $this->_callbackParams[] = $args[$i];
     }
 }
 /**
  *    Tests different types of validations.
  */
 function test_All_Sorts_Of_Values()
 {
     // test a plain string
     $this->assertTrue(ArgumentValidator::validate("Hello!", StringValidatorRule::getRule(), true));
     // test numeric values
     $this->assertTrue(ArgumentValidator::validate("23.21E10", NumericValidatorRule::getRule(), true));
     $this->assertTrue(ArgumentValidator::validate(23, NumericValidatorRule::getRule(), true));
     $this->assertTrue(ArgumentValidator::validate(23.21, NumericValidatorRule::getRule(), true));
     // test integer values
     $this->assertTrue(ArgumentValidator::validate(23, IntegerValidatorRule::getRule(), true));
     // test string values
     $this->assertTrue(ArgumentValidator::validate("23", StringValidatorRule::getRule(), true));
     // test email values
     $this->assertTrue(ArgumentValidator::validate("*****@*****.**", EmailValidatorRule::getRule(), true));
     $this->assertFalse(ArgumentValidator::validate("dradichk@middlebury", EmailValidatorRule::getRule(), false), "Gabe, fix this! Your EmailValidatorRule is faulty!");
     // test boolean values
     $this->assertTrue(ArgumentValidator::validate(true, BooleanValidatorRule::getRule(), true));
     $this->assertFalse(ArgumentValidator::validate("HOHO", BooleanValidatorRule::getRule(), false), "Gabe, fix this! Your BooleanValidatorRule is faulty!\nIn fact, I think you should just use is_bool() in your check() function.");
 }
 /**
  * Constructor
  * 
  * @param object $iterator The iterator to print.
  * @param integer $numColumns The number of result columns to print on each page.
  * @param integer $numResultsPerPage The number of iterator items to print on a page.
  * @param mixed $callbackFunction The name of the function that will be called to
  *			to print each result. If null, the first parameter is assumed to be an
  *			array of gui components that can be rendered without further processing.
  * @param optional mixed $callbackArgs Any additional arguements will be stored
  *			and passed on to the callback function.
  * @access public
  * @date 8/5/04
  */
 function ArrayResultPrinter($array, $numColumns, $numResultsPerPage, $callbackFunction = NULL)
 {
     ArgumentValidator::validate($array, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($numColumns, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($numResultsPerPage, IntegerValidatorRule::getRule());
     //		ArgumentValidator::validate($callbackFunction, StringValidatorRule::getRule());
     if (is_null($callbackFunction)) {
         ArgumentValidator::validate($array, ArrayValidatorRuleWithRule::getRule(ExtendsValidatorRule::getRule("ComponentInterface")));
     }
     $this->_array = $array;
     $this->_numColumns = $numColumns;
     $this->_pageSize = $numResultsPerPage;
     $this->_callbackFunction = $callbackFunction;
     $this->_callbackParams = array();
     $args = func_get_args();
     for ($i = 4; $i < count($args); $i++) {
         $this->_callbackParams[] = $args[$i];
     }
     $this->_resultLayout = new TableLayout($this->_numColumns);
     $this->_resultLayout->printEmptyCells = false;
     $this->_linksStyleCollection = new StyleCollection("*.result_page_links", "result_page_links", "Result Page Links", "Links to other pages of results.");
     // 		$this->_linksStyleCollection->addSP(new MarginTopSP("10px"));
 }
示例#16
0
 /**
  * The constructor.
  * @access public
  * @param string content This is an arbitrary string that will be printed,
  * whenever the user calls the <code>render()</code> method. If <code>null</code>,
  * then the component will have no content.
  * @param integer type The type of this component. One of BLANK, HEADING, HEADER, FOOTER,
  * BLOCK, MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER.
  * @param integer index The index of this component. The index has no semantic meaning: 
  * you can think of the index as 'level' of the component. Alternatively, 
  * the index could serve as means of distinguishing between components with 
  * the same type. Most often one would use the index in conjunction with
  * the <code>getStylesForComponentType()</code> and 
  * <code>addStyleForComponentType()</code> methods.
  * @param optional object StyleCollections styles,... Zero, one, or more StyleCollection 
  * objects that will be added to the newly created Component. Warning, this will
  * result in copying the objects instead of referencing them as using
  * <code>addStyle()</code> would do.
  **/
 function Component($content, $type, $index)
 {
     // ** parameter validation
     $rule = OptionalRule::getRule(StringValidatorRule::getRule());
     ArgumentValidator::validate($content, $rule, true);
     $rule = ChoiceValidatorRule::getRule(BLANK, HEADING, HEADER, FOOTER, BLOCK, MENU, SUB_MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER);
     ArgumentValidator::validate($type, $rule, true);
     ArgumentValidator::validate($index, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_content = $content;
     $this->_styleCollections = array();
     $this->_type = $type;
     $this->_index = $index;
     // if there are style collections to add
     if (func_num_args() > 3) {
         for ($i = 3; $i < func_num_args(); $i++) {
             $this->addStyle(func_get_arg($i));
         }
     }
 }
 /**
  * Assign the configuration of this OsidManager.
  * 
  * @param object Properties $configuration (original type: java.util.Properties)
  * 
  * @throws object OsidException An exception with one of the following
  *         messages defined in org.osid.OsidException:  {@link
  *         org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *         {@link org.osid.OsidException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.OsidException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *         org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  * 
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     ArgumentValidator::validate($this->_configuration->getProperty('database_id'), IntegerValidatorRule::getRule());
     // Store the Harmoni_Db adapter if it is configured.
     $harmoni_db_name = $this->_configuration->getProperty('harmoni_db_name');
     if (!is_null($harmoni_db_name)) {
         try {
             $this->harmoni_db = Harmoni_Db::getDatabase($harmoni_db_name);
         } catch (UnknownIdException $e) {
         }
     }
     $this->_dbId = $this->_configuration->getProperty('database_id');
     $this->_isInitialized = TRUE;
 }
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	database_index			integer
  *	database_name			string
  * 
  * @param object Properties $configuration (original type: java.util.Properties)
  * 
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  * 
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     $authzDB = $configuration->getProperty('database_name');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     ArgumentValidator::validate($authzDB, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     // Store the Harmoni_Db adapter if it is configured.
     $harmoni_db_name = $this->_configuration->getProperty('harmoni_db_name');
     if (!is_null($harmoni_db_name)) {
         try {
             $this->harmoni_db = Harmoni_Db::getDatabase($harmoni_db_name);
         } catch (UnknownIdException $e) {
         }
     }
     if (isset($this->harmoni_db)) {
         $this->_cache = new AuthZ2_AuthorizationCache($this, $dbIndex, $this->harmoni_db);
     } else {
         $this->_cache = new AuthZ2_AuthorizationCache($this, $dbIndex);
     }
     // do a test to see if our configuration worked.
     try {
         $this->getFunctionTypes();
     } catch (QueryDatabaseException $e) {
         throw new ConfigurationErrorException("Database is not properly set up for AuthZ2.");
     }
 }
示例#19
0
 /**
  * Sets the number of visible columns in this textarea.
  * @param integer $cols
  * @access public
  * @return void
  */
 function setColumns($cols)
 {
     ArgumentValidator::validate($cols, IntegerValidatorRule::getRule());
     $this->_cols = $cols;
 }
示例#20
0
 /**
  * Optional: Add an enclosure. As of this writing the RSS 2.0 spec does not
  * allow multiple enclosures. Some aggregators however, support them anyway
  * and the one's I've (Adam) tested in simply ignore the extra enclosures.
  * Add multiple enclosures at your own risk.
  * 
  * @param string $url
  * @param integer $length
  * @param string $mimeType
  * @return void
  * @access public
  * @since 8/7/06
  */
 function addEnclosure($url, $length, $mimeType)
 {
     ArgumentValidator::validate($url, StringValidatorRule::getRule());
     ArgumentValidator::validate($length, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($mimeType, RegexValidatorRule::getRule('/^(text|image|audio|video|application)\\/.+$/'));
     $this->_enclosures[] = array('url' => $url, 'length' => $length, 'mimeType' => $mimeType);
 }
示例#21
0
 /**
  *  Fetches and returns an array of DMRecord IDs from the database in one Query.
  * @return ref array Indexed by DMRecord ID, values are {@link DMRecord}s.
  * @param array $IDs
  * @param optional int $mode Specifies the mode the record should be fetched.
  * @param optional object $limitResults NOT YET IMPLEMENTED
  * criteria. If not specified, will fetch all IDs.
  */
 function fetchRecords($IDs, $mode = RECORD_CURRENT, $limitResults = null)
 {
     ArgumentValidator::validate($IDs, ArrayValidatorRuleWithRule::getRule(OrValidatorRule::getRule(StringValidatorRule::getRule(), IntegerValidatorRule::getRule())));
     ArgumentValidator::validate($mode, IntegerValidatorRule::getRule());
     $IDs = array_unique($IDs);
     // let's weed out those IDs that we can take from cache
     $fromCacheIDs = array();
     $fromDBIDs = array();
     if (count($this->_recordCache)) {
         foreach ($IDs as $id) {
             // only take from the cache if we have it cached, AND
             // what is cached is fetched at a higher/equal data-mode than what's requested
             if (isset($this->_recordCache[$id]) && $this->_recordCache[$id]->getFetchMode() >= $mode) {
                 $fromCacheIDs[] = $id;
             } else {
                 $fromDBIDs[] = $id;
             }
         }
     } else {
         $fromDBIDs = $IDs;
     }
     $records = array();
     // put all the records from the cache into the array
     foreach ($IDs as $id) {
         if (isset($this->_recordCache[$id])) {
             $records[$id] = $this->_recordCache[$id];
         }
     }
     if (count($fromDBIDs)) {
         // first, make the new query
         $query = new SelectQuery();
         $this->_setupSelectQuery($query, $mode);
         // and now, go through the records we already have cached but are fetching more information for,
         // and make sure that we don't fetch information for fields that are already fetched.
         $alreadyFetchedFields = array();
         // and, build the WHERE clause while we're at it.
         $t = array();
         foreach ($fromDBIDs as $id) {
             $t[] = "dm_record.id='" . addslashes($id) . "'";
             if (isset($this->_recordCache[$id])) {
                 $alreadyFetchedFields = array_unique(array_merge($alreadyFetchedFields, $this->_recordCache[$id]->getFetchedFieldIDs()));
             }
         }
         $query->addWhere("(" . implode(" OR ", $t) . ")");
         if (count($alreadyFetchedFields)) {
             $temp = array();
             foreach ($alreadyFetchedFields as $id) {
                 $temp[] = "dm_record_field.id != '" . addslashes($id) . "'";
             }
             $query->addWhere('(' . implode(" AND ", $temp) . ')');
         }
         $dbHandler = Services::getService("DatabaseManager");
         //			print "<PRE>" . MySQL_SQLGenerator::generateSQLQuery($query)."</PRE>";
         $result = $dbHandler->query($query, DATAMANAGER_DBID);
         if (!$result) {
             throwError(new UnknownDBError("RecordManager"));
         }
         // now, we need to parse things out and distribute the lines accordingly
         while ($result->hasMoreRows()) {
             $a = $result->getCurrentRow();
             $result->advanceRow();
             $id = $a['record_id'];
             $type = $a['fk_schema'];
             $vcontrol = $a['record_ver_control'];
             if (!isset($records[$id])) {
                 $schemaManager = Services::getService("SchemaManager");
                 $schema = $schemaManager->getSchemaByID($type);
                 $schema->load();
                 $records[$id] = new DMRecord($schema, $vcontrol ? true : false, $mode);
                 if ($this->_cacheMode) {
                     $this->_recordCache[$id] = $records[$id];
                 }
             }
             $records[$id]->takeRow($a);
             unset($a);
         }
         $result->free();
     }
     // make sure we found the data sets
     $rule = ExtendsValidatorRule::getRule("DMRecord");
     foreach ($IDs as $id) {
         if (!isset($records[$id]) || !$rule->check($records[$id])) {
             throw new UnknownIdException("DMRecord {$id} was requested, but not found.");
         }
         // and set the fetch mode.
         $records[$id]->setFetchMode($mode);
         //			print "<pre>";print_r($records[$id]);print "</pre>";
     }
     return $records;
 }
示例#22
0
 /**
  * Private method for validating the dbIndex passed.
  * 
  * @param integer $dbIndex
  * @return void
  * @access private
  * @since 3/9/05
  */
 function _validateDBIndex($dbIndex)
 {
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     // check that the index is valid
     if (!is_object($this->_databases[$dbIndex])) {
         throw new DatabaseException("Invalid database index.");
         return false;
     }
 }
示例#23
0
 /**
  * Selects the <code>MenuItem</code> with the given id, and deselects the one
  * that was previoiusly selected. Ids reflect the order in which menu items 
  * are added. That is, the very first menu item has an id of 1, the second 
  * menu item has an id of 2, and so forth.
  * @access public
  * @param integer id The id of the menu item to select.
  **/
 function select($id)
 {
     // ** parameter validation
     ArgumentValidator::validate($id, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     // make sure the id is valid
     $newSelected = $this->getComponent($id);
     if (!isset($newSelected)) {
         return;
     }
     // deselect the old one
     $oldSelected = $this->getSelected();
     if (isset($oldSelected)) {
         $oldSelected->setSelected(false);
     }
     // select the new component
     $newSelected->setSelected(true);
     $this->_selectedId = $id;
 }
示例#24
0
 /**
  * Removes the component with the specified id from this container. Ids
  * reflect the order in which components are added. That is, the very first 
  * component has an id of 1, the second component has an id of 2, and so forth.
  * @access public
  * @param integer id The id of the component which should be removed from
  * this container..
  * @return ref object The component that was just removed.
  **/
 function remove($id)
 {
     // ** parameter validation
     ArgumentValidator::validate($id, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     $component = $this->_components[$id - 1];
     unset($this->_components[$id - 1]);
     unset($this->_constraints[$id - 1]);
     return $component;
 }
示例#25
0
 /**
  * Adds a new condition in the WHERE clause.
  * 
  * The query will execute only on rows that fulfil the condition. If this method
  * is never called, then the WHERE clause will not be included.
  * @param string condition The WHERE clause condition to add.
  * @param integer logicalOperation The logical operation to use to connect
  * this WHERE condition with the previous WHERE conditions. Allowed values:
  * <code>_AND</code> and <code>_OR</code>. 
  * @access public
  * @return void 
  */
 function addWhere($condition, $logicalOperation = _AND)
 {
     // ** parameter validation
     $stringRule = StringValidatorRule::getRule();
     $integerRule = IntegerValidatorRule::getRule();
     $optionalRule = OptionalRule::getRule($integerRule);
     ArgumentValidator::validate($condition, $stringRule, true);
     ArgumentValidator::validate($logicalOperation, $optionalRule, true);
     // ** end of parameter validation
     $arr = array();
     $arr[] = $condition;
     $arr[] = $logicalOperation;
     $this->_condition[] = $arr;
 }
示例#26
0
 /**
  * Attempts to delete the specified node in the database. Only leaf nodes can
  * be deleted.
  * @access public
  * @param mixed idValue The string id of the node to delete.
  * @return void
  **/
 function deleteNode($idValue)
 {
     // ** parameter validation
     ArgumentValidator::validate($idValue, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), IntegerValidatorRule::getRule()), true);
     // ** end of parameter validation
     // get the node
     $node = $this->getNode($idValue);
     // if not a leaf, cannot delete
     if (!$node->isLeaf()) {
         // "Can not delete non-leaf nodes.";
         throw new OperationFailedException("Cannont delete non-leaf nodes.");
     }
     // clear the cache and update the _tree structure
     // detach the node from each of its parents and update the join table
     $parents = $node->getParents();
     while ($parents->hasNext()) {
         $parent = $parents->next();
         $node->removeParent($parent->getId());
     }
     // now delete the tree node
     $treeNode = $this->_tree->getNode($idValue);
     $this->_tree->deleteNode($treeNode);
     // -----------------
     // remove from cache
     unset($this->_cache[$idValue]);
     $node = null;
     // now remove from database
     $dbHandler = Services::getService("DatabaseManager");
     // 1. Get the id of the type associated with the node
     $query = new SelectQuery();
     $query->addTable("az2_node");
     $query->addColumn("fk_type", "type_id", "az2_node");
     $query->addWhereEqual("id", $idValue);
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     if (!$queryResult->hasNext()) {
         $queryResult->free();
         throw new OperationFailedException("No type found for node, '{$idValue}'.");
     }
     $typeIdValue = $queryResult->field("type_id");
     $queryResult->free();
     // 2. Now delete the node
     $query = new DeleteQuery();
     $query->setTable("az2_node");
     $query->addWhereEqual("id", $idValue);
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     // 3. Now see if any other nodes have the same type
     $query = new SelectQuery();
     $query->addTable("az2_node");
     // count the number of nodes using the same type
     $query->addColumn("COUNT(fk_type)", "num");
     $query->addWhereEqual("fk_type", $typeIdValue);
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     $num = $queryResult->field("num");
     $queryResult->free();
     if ($num == 0) {
         // if no other nodes use this type, then delete the type
         $query = new DeleteQuery();
         $query->setTable("az2_node_type");
         $query->addWhereEqual("id", $typeIdValue);
         $queryResult = $dbHandler->query($query, $this->_dbIndex);
     }
     // Delete the node's ancestory from the Ancestory table
     $this->clearNodeAncestory($idValue);
 }
示例#27
0
 /**
  * Starts the results from the specified row.
  * 
  * Starts the results of the SELECT query from the specified row.
  * @param integer $startingRow The number of the starting row. Numbers
  * start with 1 for the first row, 2 for the second row, and so forth.
  * @access public
  */
 function startFromRow($startFromRow)
 {
     // ** parameter validation
     $integerRule = IntegerValidatorRule::getRule();
     ArgumentValidator::validate($startFromRow, $integerRule, true);
     // ** end of parameter validation
     $this->limit($this->_parts[self::LIMIT_COUNT], $startFromRow);
 }
 /**
  * Moves the internal row pointer to the specified position. The range of
  * possible values is <code>0 - (getNumberOfRows()-1)</code>.
  * @param integer rowNumber The number of the row to move to.
  * @access public
  * @return boolean <code>true</code>, if operation was successful; <code>false</code>, otherwise.
  */
 function moveToRow($rowNumber)
 {
     // ** parameter validation
     $integerRule = IntegerValidatorRule::getRule();
     ArgumentValidator::validate($rowNumber, $integerRule, true);
     // ** end of parameter validation
     if ($rowNumber < 0 || $rowNumber > $this->getNumberOfRows() - 1) {
         $str = "\$rowNumber must be in the range 0..(getNumberOfRows()-1)";
         throw new DatabaseException($str);
     }
     $ok = true;
     while ($this->_currentRowIndex < $rowNumer) {
         if (!$this->advanceRow()) {
             $ok = false;
             break;
         }
     }
     //$result = pg_result_seek($this->_resourceId, $rowNumber);
     return $ok;
 }
示例#29
0
 /**
  * Traverse a Hierarchy returning information about each Node encountered.
  * 
  * @param object Id $startId
  * @param int $mode
  * @param int $direction
  * @param int $levels
  *	
  * @return object TraversalInfoIterator
  * 
  * @throws object HierarchyException An exception with one of
  *		   the following messages defined in
  *		   org.osid.hierarchy.HierarchyException may be thrown:	 {@link
  *		   org.osid.hierarchy.HierarchyException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.hierarchy.HierarchyException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.hierarchy.HierarchyException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.hierarchy.HierarchyException#NODE_TYPE_NOT_FOUND
  *		   NODE_TYPE_NOT_FOUND}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNKNOWN_TRAVERSAL_MODE
  *		   UNKNOWN_TRAVERSAL_MODE}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNKNOWN_TRAVERSAL_DIRECTION
  *		   UNKNOWN_TRAVERSAL_DIRECTION}
  * 
  * @access public
  */
 function traverse(Id $startId, $mode, $direction, $levels)
 {
     // Check the arguments
     ArgumentValidator::validate($mode, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($direction, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($levels, IntegerValidatorRule::getRule());
     if ($mode != Hierarchy::TRAVERSE_MODE_DEPTH_FIRST) {
         // Only depth-first traversal is supported in the current implementation.
         throw new OperationFailedException("Unknown Traversal Direction");
     }
     $down = $direction == Hierarchy::TRAVERSE_DIRECTION_DOWN;
     $result = $this->_cache->traverse($startId, $down, $levels);
     return $result;
 }
 /**
  * Moves the internal row pointer to the specified position. The range of
  * possible values is <code>0 - (getNumberOfRows()-1)</code>.
  * @param integer rowNumber The number of the row to move to.
  * @access public
  * @return boolean <code>true</code>, if operation was successful; <code>false</code>, otherwise.
  */
 function moveToRow($rowNumber)
 {
     // ** parameter validation
     $integerRule = IntegerValidatorRule::getRule();
     ArgumentValidator::validate($rowNumber, $integerRule, true);
     // ** end of parameter validation
     if ($rowNumber < 0 || $rowNumber > $this->getNumberOfRows() - 1) {
         $str = "\$rowNumber must be in the range 0..(getNumberOfRows()-1)";
         throw new DatabaseException($str);
     }
     $result = pg_result_seek($this->_resourceId, $rowNumber);
     if ($result === true) {
         $this->_currentRowIndex = $rowNumber;
     }
     return $result;
 }