From e9291a96c37ca248188bd698087c779eb333673c Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Thu, 16 Feb 2012 12:07:45 -0400 Subject: [PATCH 1/3] Added a new api --- newapi/Cache.php | 76 ++++++++++ newapi/Configuration.php | 58 ++++++++ newapi/IslandoraModule.php | 37 +++++ newapi/Repository.php | 264 ++++++++++++++++++++++++++++++++++ newapi/Search.php | 37 +++++ newapi/models/DataObject.php | 42 ++++++ newapi/models/ObjectModel.php | 119 +++++++++++++++ newapi/models/SPO.php | 75 ++++++++++ 8 files changed, 708 insertions(+) create mode 100644 newapi/Cache.php create mode 100644 newapi/Configuration.php create mode 100644 newapi/IslandoraModule.php create mode 100644 newapi/Repository.php create mode 100644 newapi/Search.php create mode 100644 newapi/models/DataObject.php create mode 100644 newapi/models/ObjectModel.php create mode 100644 newapi/models/SPO.php diff --git a/newapi/Cache.php b/newapi/Cache.php new file mode 100644 index 00000000..906fe804 --- /dev/null +++ b/newapi/Cache.php @@ -0,0 +1,76 @@ +objectList[$object->getId()])) + { + $this->objectList[$object->getId()] = array(); + } + + $this->objectList[$object->getId()]['checksum'] = sha1(serialize($object)); + $this->objectList[$object->getId()]['object'] = $object; + } + + /** + * Check to see if the object has been updated + * @param ObjectModel $object + */ + public function hasChanged(ObjectModel &$object) + { + // Is the object even cached + if ( !isset($this->objectList[$object->getId()])) + { + return false; + } + + // Does it have the same checksum + if ($this->objectList[$object->getId()]['checksum'] == sha1(serialize($object)) ) + { + return true; + } + + // If they were the same then it would have already exited + return false; + } + + /** + * Get object from the cache. Returns null if not found. + * @param type $id + */ + public function getObject($id) + { + // Is the object cached + if ( isset($this->objectList[$id]['object'] ) ) { + + // Return the object from the cache + return $this->objectList[$id]['object']; + } + + // Object wasn't found so return null + return null; + } + + /** + * Remove the object from the cache + * @param type $id + */ + public function deleteObject($id) + { + // Unset it from the array + unset( $this->objectList[$id]); + } +} + +?> diff --git a/newapi/Configuration.php b/newapi/Configuration.php new file mode 100644 index 00000000..5f939715 --- /dev/null +++ b/newapi/Configuration.php @@ -0,0 +1,58 @@ +$baseUrl = $base_url; + $this->$port = $port; + } + + /** + * Get the base url + * @return type + */ + public function getBaseURL() + { + return $this->$baseUrl; + } + + /** + * Set the base url + * @param type $url + */ + public function setBaseURL($url) + { + $this->$baseUrl = $url; + } + + /** + * Get the port + * @return type + */ + public function getPort() + { + return $this->$port; + } + + /** + * Set the port + * @param type $port + */ + public function setPort($port) + { + $this->$port = $port; + } +} + +?> diff --git a/newapi/IslandoraModule.php b/newapi/IslandoraModule.php new file mode 100644 index 00000000..8183415a --- /dev/null +++ b/newapi/IslandoraModule.php @@ -0,0 +1,37 @@ +repository = new Repository(new Configuration("127.0.0.1", 8080), new Search, new Cache()); + } + + /** + * Get the repository singleton + * @return type + */ + public static function instance() + { + if ( self::instance == null ) + { + $className = __CLASS__; + self::$instance = new $className; + // get_called_class only works in 5.3 + } + + // Return the link to the repository + return self::$instance->repository; + } +} + +?> diff --git a/newapi/Repository.php b/newapi/Repository.php new file mode 100644 index 00000000..cfc34e6c --- /dev/null +++ b/newapi/Repository.php @@ -0,0 +1,264 @@ +setConfig($config); + $this->setSearch($search); + $this->setCache($cache); + } + + /** + * Get the configuration implementation + * @return type + */ + public function getConfig() + { + return $this->config; + } + + /** + * Get the search implementation + * @return type + */ + public function getSearch() + { + return $this->search; + } + + /** + * Get the cache implementation + * @return type + */ + public function getCache() + { + return $this->cache; + } + + /** + * Set the configuration implementation + * @param Configuration $config + */ + public function setConfig(Configuration &$config) + { + if ( $config == null ) + { + throw new Exception("Config implementation can't be null"); + } + $this->config = $config; + } + + /** + * Set the search implementation + * @param Search $search + */ + public function setSearch(Search &$search) + { + if ( $search == null ) + { + throw new Exception("Search implementation can't be null"); + } + $this->search = $search; + } + + /** + * Set the cache implementation + * @param Cache $cache + */ + public function setCache(Cache &$cache) + { + if ( $cache == null ) + { + throw new Exception("Cache implementation can't be null"); + } + $this->cache = $cache; + } + + /** + * Get the object from the repo + * @param type $id + */ + public function loadObject($id, $cache=true) + { + // Check to see if its already cached + if ( $this->getCache()->getObject( $id ) && $cache = true) + { + // Return the cached object + return $this->getCache()->getObject( $id ); + } + + // Create the request + $results = $this->makeRequest( '/objects/' .$id ); + + // Return the object model + return unserialize($results); + } + + /** + * Save an object to the repository + * @param ObjectModel $model + * @param type $force + */ + public function saveObject(ObjectModel $model, $force=false) + { + // Has the object been created at all + if ( $model->getId() == null ) { + + // Get the next free persistent id + $id = $this->makeRequest( '/objects/nextPID' ); + + // Set the id on the model + $model->setId($id); + + } + + // If it hasn't changed then done't save unless it's forced + if ( ! $force && ! $this->getCache()->hasChanged($model) ) + { + return; + } + + // Add the object to the cache so everybody has the new copy + $this->getCache()->addObject($model); + + // Post the serialized model to the object endpoint + $this->makeRequest('/objects', $this->serialize($model)); + } + + /** + * Find an object using a search term + * @param type $term + * @return type + */ + public function findObjectByTerm($term) + { + // Create results + $results = $this->makeRequest('/objects?terms=' . $term); + + // Do something with results + return $results; + } + + /** + * Find an object with a query + * @param type $query + * @return type + */ + public function findObjectWithQuery($query) + { + // Create results + $results = $this->makeRequest('/objects?query=' . $term); + + // Do something with results + return $results; + } + + /** + * Search the repository using either a SPO or an array of SPOs + * @param type $query + */ + public function SearchSPO($SPO) + { + // Search + $results = $this->getSearch()->SearchSPO($SPO); + + // Do something with the results + return $results; + } + + /** + * Unserialize the object from foxml + * @param type $xml + * @return \ObjectModel + */ + protected function unserialize($xml) + { + // Create the object model + $model = new ObjectModel(); + + // Do something with the xml + $xml = $xml; + + // Return the model; + return $model; + } + + /** + * Serialize the object to foxml + * @param ObjectModel $model + * @return string + */ + protected function serialize(ObjectModel $model) + { + // Do something with the model + serialize($model); + + // return a string + return ""; + } + + /** + * Make a request + * @param type $request + * @return type + */ + private function makeRequest($request, array $postData = null, $responseCode=200, $format="xml") + { + // Check to see if we already have parameters + $pos = strpos($request, "?"); + if ($pos === false) { + $request.="?format=".$format; + } else { + $request.="&format=".$format; + } + + // Initialize Curl + $curl = curl_init(); + + // Set all the options + curl_setopt($curl, CURLOPT_URL, $this->getConfig()->getBaseURL() . $request); + curl_setopt($curl, CURLOPT_PORT , $this->getConfig()->getPort() ); + curl_setopt($curl, CURLOPT_VERBOSE, 1); + // If we have post data then append that + if ( $postData ) { + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } + + // Execute the curl call + $results = curl_exec($curl); + + // Check for an error + if( ! curl_errno($curl) ) { + + // Get information regarding the curl connection + $info = curl_getinfo($curl); + + // Check the response code + if ( $info['http_code'] != $responseCode ) + { + var_dump($results); + var_dump($info); + throw new Exception("Curl request failed"); + } else { + return $results; + } + } + + // Close connection + curl_close($curl); + + } // Close makeRequest + +} + + +?> diff --git a/newapi/Search.php b/newapi/Search.php new file mode 100644 index 00000000..406a68e5 --- /dev/null +++ b/newapi/Search.php @@ -0,0 +1,37 @@ +getSubject() . " " . $spo->getPredicate() . " " . $spo->getObject() . ", "; + } + // Strip off the extra comma + $queryString = substr($queryString, '', -2); + } + else { + $queryString .= $SPO->getSubject() . " " . $SPO->getPredicate() . " " . $SPO->getObject(); + } + + // Do a search + $results = ""; + + // Return results; + return $results; + } +} + +?> diff --git a/newapi/models/DataObject.php b/newapi/models/DataObject.php new file mode 100644 index 00000000..55af4062 --- /dev/null +++ b/newapi/models/DataObject.php @@ -0,0 +1,42 @@ +id; + } + + /** + * Set the idea if not already set + * @param type $id + * @throws Exception + */ + public function setId($id) + { + if ( $pid != null ) + { + throw new Exception("PID can't be changed"); + } + $this->id = $pid; + } + + /** + * Add the data from a file ( example ) + */ + public function addDataFromFile() + { + + } +} + +?> diff --git a/newapi/models/ObjectModel.php b/newapi/models/ObjectModel.php new file mode 100644 index 00000000..3ceb6da1 --- /dev/null +++ b/newapi/models/ObjectModel.php @@ -0,0 +1,119 @@ +id; + } + + /** + * Set the idea if not already set + * @param type $id + * @throws Exception + */ + public function setId($id) + { + if ( $id != null ) + { + throw new Exception("ID can't be changed"); + } + $this->id = $id; + } + + /** + * Get the object label + * @return type + */ + public function getLabel() + { + return $this->label; + } + + /** + * Set the label + * @param type $label + */ + public function setLabel($label) + { + $this->label = $label; + } + + /** + * Get the object status + * @return type + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set the status + * @param type $status + */ + public function setStatus($status) + { + $this->label = $status; + } + + /** + * Get a data using the id + * @param type $id + * @return null + */ + public function getData($id) + { + foreach($this->getAllDataObjects() as $data) + { + if ($data->getId() == $id) + { + return $data; + } + } + return null; + } + + /** + * Get all the data object + * @return type + */ + public function getAllDataObjects() + { + return $this->dataObjects; + } + + /** + * Add a data object + * @param type $data + */ + public function addData(DataObject &$data) + { + $this->dataObjects[$data->getId()] = $data; + } + + /** + * Delete a data object + * @param type $data + */ + public function deleteData(DataObject &$data) + { + unset( $this->datas[$data->getId()] ); + } +} + +?> diff --git a/newapi/models/SPO.php b/newapi/models/SPO.php new file mode 100644 index 00000000..6ccce543 --- /dev/null +++ b/newapi/models/SPO.php @@ -0,0 +1,75 @@ +subject = $subject; + $this->predicate = $predicate; + $this->object = $object; + } + + /** + * Get the subject + * @return type + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Get the predicate + * @return type + */ + public function getPredicate() + { + return $this->predicate; + } + + /** + * Get the object + * @return type + */ + public function getObject() + { + return $this->object; + } + + /** + * Set the subject + * @param type $value + */ + public function setSubject($value) + { + $this->subject = $value; + } + + /** + * Set the predicate + * @param type $value + */ + public function setPredicate($value) + { + $this->predicate = $value; + } + + /** + * Set the object + * @param type $value + */ + public function setObject($value) + { + $this->object = $value; + } +} + +?> From b60921adf42d6834b1a7b07249c683f8b975cb9b Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 27 Feb 2012 15:06:17 -0400 Subject: [PATCH 2/3] Switched queries from dc:title to fedora label --- CollectionClass.inc | 2 +- ContentModel.inc | 12 ++++++------ ObjectHelper.inc | 8 ++++---- api/fedora_collection.inc | 2 +- api/fedora_utils.inc | 4 ++-- fedora_repository.module | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index 71710d78..f561295c 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -81,7 +81,7 @@ class CollectionClass { $query_string = $objectHelper->getStream($pid, 'QUERY', 0); if ($query_string == NULL) { $query_string = 'select $object $title $content from <#ri> - where ($object $title + where ($object $title and $object $content and ($object or $object ) diff --git a/ContentModel.inc b/ContentModel.inc index cbacd422..444f485c 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -429,12 +429,12 @@ class ContentModel extends XMLDatastream { */ public function getServices() { $query = 'select $object $title from <#ri> - where ($object $title - and $object $deploymentOf - and $object - and $object pid . '> - and $object ) - order by $title'; + where ($object $title + and $object $deploymentOf + and $object + and $object pid . '> + and $object ) + order by $title'; module_load_include('inc', 'fedora_repository', 'CollectionClass'); diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 8f58a3ab..1a8db575 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -729,7 +729,7 @@ class ObjectHelper { */ function get_parent_objects($pid) { $query_string = 'select $object $title from <#ri> - where ($object $title + where ($object $title and $object and $object ) order by $title'; @@ -829,7 +829,7 @@ class ObjectHelper { // Get title and descriptions for $pid $query_string = 'select $title $desc from <#ri> - where $o $title + where $o $title and $o $desc and $o '; @@ -858,7 +858,7 @@ class ObjectHelper { $query_string = 'select $o $title from <#ri> ' . // $query_string = 'select $o $title $desc from <#ri> '. 'where $s $o ' . - 'and $o $title ' . + 'and $o $title ' . // 'and $o $desc '. 'and ( '; @@ -929,7 +929,7 @@ class ObjectHelper { } else { $query_string = 'select $parentObject $title $content from <#ri> - where ( $title + where ( $title and $parentObject $content and ( $parentObject or $parentObject diff --git a/api/fedora_collection.inc b/api/fedora_collection.inc index a82bf39b..200fb324 100644 --- a/api/fedora_collection.inc +++ b/api/fedora_collection.inc @@ -77,7 +77,7 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb } $query_string = 'select $object $title $content from <#ri> - where ($object $title + where ($object $title and $object $content and ('; diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index c2665fc7..eb56bdcc 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -239,7 +239,7 @@ function get_collections_as_option_array() { $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); $query = 'select $object $title from <#ri> - where ($object $title + where ($object $title and $object and $object ) order by $title'; @@ -288,7 +288,7 @@ function get_content_models_as_option_array() { } } $query = 'select $object $title from <#ri> - where ($object $title + where ($object $title and ($object or $object ) and $object ) diff --git a/fedora_repository.module b/fedora_repository.module index f3412b54..1646ce4f 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1596,7 +1596,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { $dc->set_element('dc:title', array('Installed Content Model')); $dc->save(); $cmodel_collection->add_datastream_from_string('select $object $title from <#ri> - where ($object $title + where ($object $title and ($object or $object ) and $object ) From 34fa8851274f939970994807df35e251ad66cecf Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 27 Feb 2012 15:14:38 -0400 Subject: [PATCH 3/3] removed the api stuff that shouldn't have been pushed --- newapi/Cache.php | 76 ---------- newapi/Configuration.php | 58 -------- newapi/IslandoraModule.php | 37 ----- newapi/Repository.php | 264 ---------------------------------- newapi/Search.php | 37 ----- newapi/models/DataObject.php | 42 ------ newapi/models/ObjectModel.php | 119 --------------- newapi/models/SPO.php | 75 ---------- 8 files changed, 708 deletions(-) delete mode 100644 newapi/Cache.php delete mode 100644 newapi/Configuration.php delete mode 100644 newapi/IslandoraModule.php delete mode 100644 newapi/Repository.php delete mode 100644 newapi/Search.php delete mode 100644 newapi/models/DataObject.php delete mode 100644 newapi/models/ObjectModel.php delete mode 100644 newapi/models/SPO.php diff --git a/newapi/Cache.php b/newapi/Cache.php deleted file mode 100644 index 906fe804..00000000 --- a/newapi/Cache.php +++ /dev/null @@ -1,76 +0,0 @@ -objectList[$object->getId()])) - { - $this->objectList[$object->getId()] = array(); - } - - $this->objectList[$object->getId()]['checksum'] = sha1(serialize($object)); - $this->objectList[$object->getId()]['object'] = $object; - } - - /** - * Check to see if the object has been updated - * @param ObjectModel $object - */ - public function hasChanged(ObjectModel &$object) - { - // Is the object even cached - if ( !isset($this->objectList[$object->getId()])) - { - return false; - } - - // Does it have the same checksum - if ($this->objectList[$object->getId()]['checksum'] == sha1(serialize($object)) ) - { - return true; - } - - // If they were the same then it would have already exited - return false; - } - - /** - * Get object from the cache. Returns null if not found. - * @param type $id - */ - public function getObject($id) - { - // Is the object cached - if ( isset($this->objectList[$id]['object'] ) ) { - - // Return the object from the cache - return $this->objectList[$id]['object']; - } - - // Object wasn't found so return null - return null; - } - - /** - * Remove the object from the cache - * @param type $id - */ - public function deleteObject($id) - { - // Unset it from the array - unset( $this->objectList[$id]); - } -} - -?> diff --git a/newapi/Configuration.php b/newapi/Configuration.php deleted file mode 100644 index 5f939715..00000000 --- a/newapi/Configuration.php +++ /dev/null @@ -1,58 +0,0 @@ -$baseUrl = $base_url; - $this->$port = $port; - } - - /** - * Get the base url - * @return type - */ - public function getBaseURL() - { - return $this->$baseUrl; - } - - /** - * Set the base url - * @param type $url - */ - public function setBaseURL($url) - { - $this->$baseUrl = $url; - } - - /** - * Get the port - * @return type - */ - public function getPort() - { - return $this->$port; - } - - /** - * Set the port - * @param type $port - */ - public function setPort($port) - { - $this->$port = $port; - } -} - -?> diff --git a/newapi/IslandoraModule.php b/newapi/IslandoraModule.php deleted file mode 100644 index 8183415a..00000000 --- a/newapi/IslandoraModule.php +++ /dev/null @@ -1,37 +0,0 @@ -repository = new Repository(new Configuration("127.0.0.1", 8080), new Search, new Cache()); - } - - /** - * Get the repository singleton - * @return type - */ - public static function instance() - { - if ( self::instance == null ) - { - $className = __CLASS__; - self::$instance = new $className; - // get_called_class only works in 5.3 - } - - // Return the link to the repository - return self::$instance->repository; - } -} - -?> diff --git a/newapi/Repository.php b/newapi/Repository.php deleted file mode 100644 index cfc34e6c..00000000 --- a/newapi/Repository.php +++ /dev/null @@ -1,264 +0,0 @@ -setConfig($config); - $this->setSearch($search); - $this->setCache($cache); - } - - /** - * Get the configuration implementation - * @return type - */ - public function getConfig() - { - return $this->config; - } - - /** - * Get the search implementation - * @return type - */ - public function getSearch() - { - return $this->search; - } - - /** - * Get the cache implementation - * @return type - */ - public function getCache() - { - return $this->cache; - } - - /** - * Set the configuration implementation - * @param Configuration $config - */ - public function setConfig(Configuration &$config) - { - if ( $config == null ) - { - throw new Exception("Config implementation can't be null"); - } - $this->config = $config; - } - - /** - * Set the search implementation - * @param Search $search - */ - public function setSearch(Search &$search) - { - if ( $search == null ) - { - throw new Exception("Search implementation can't be null"); - } - $this->search = $search; - } - - /** - * Set the cache implementation - * @param Cache $cache - */ - public function setCache(Cache &$cache) - { - if ( $cache == null ) - { - throw new Exception("Cache implementation can't be null"); - } - $this->cache = $cache; - } - - /** - * Get the object from the repo - * @param type $id - */ - public function loadObject($id, $cache=true) - { - // Check to see if its already cached - if ( $this->getCache()->getObject( $id ) && $cache = true) - { - // Return the cached object - return $this->getCache()->getObject( $id ); - } - - // Create the request - $results = $this->makeRequest( '/objects/' .$id ); - - // Return the object model - return unserialize($results); - } - - /** - * Save an object to the repository - * @param ObjectModel $model - * @param type $force - */ - public function saveObject(ObjectModel $model, $force=false) - { - // Has the object been created at all - if ( $model->getId() == null ) { - - // Get the next free persistent id - $id = $this->makeRequest( '/objects/nextPID' ); - - // Set the id on the model - $model->setId($id); - - } - - // If it hasn't changed then done't save unless it's forced - if ( ! $force && ! $this->getCache()->hasChanged($model) ) - { - return; - } - - // Add the object to the cache so everybody has the new copy - $this->getCache()->addObject($model); - - // Post the serialized model to the object endpoint - $this->makeRequest('/objects', $this->serialize($model)); - } - - /** - * Find an object using a search term - * @param type $term - * @return type - */ - public function findObjectByTerm($term) - { - // Create results - $results = $this->makeRequest('/objects?terms=' . $term); - - // Do something with results - return $results; - } - - /** - * Find an object with a query - * @param type $query - * @return type - */ - public function findObjectWithQuery($query) - { - // Create results - $results = $this->makeRequest('/objects?query=' . $term); - - // Do something with results - return $results; - } - - /** - * Search the repository using either a SPO or an array of SPOs - * @param type $query - */ - public function SearchSPO($SPO) - { - // Search - $results = $this->getSearch()->SearchSPO($SPO); - - // Do something with the results - return $results; - } - - /** - * Unserialize the object from foxml - * @param type $xml - * @return \ObjectModel - */ - protected function unserialize($xml) - { - // Create the object model - $model = new ObjectModel(); - - // Do something with the xml - $xml = $xml; - - // Return the model; - return $model; - } - - /** - * Serialize the object to foxml - * @param ObjectModel $model - * @return string - */ - protected function serialize(ObjectModel $model) - { - // Do something with the model - serialize($model); - - // return a string - return ""; - } - - /** - * Make a request - * @param type $request - * @return type - */ - private function makeRequest($request, array $postData = null, $responseCode=200, $format="xml") - { - // Check to see if we already have parameters - $pos = strpos($request, "?"); - if ($pos === false) { - $request.="?format=".$format; - } else { - $request.="&format=".$format; - } - - // Initialize Curl - $curl = curl_init(); - - // Set all the options - curl_setopt($curl, CURLOPT_URL, $this->getConfig()->getBaseURL() . $request); - curl_setopt($curl, CURLOPT_PORT , $this->getConfig()->getPort() ); - curl_setopt($curl, CURLOPT_VERBOSE, 1); - // If we have post data then append that - if ( $postData ) { - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } - - // Execute the curl call - $results = curl_exec($curl); - - // Check for an error - if( ! curl_errno($curl) ) { - - // Get information regarding the curl connection - $info = curl_getinfo($curl); - - // Check the response code - if ( $info['http_code'] != $responseCode ) - { - var_dump($results); - var_dump($info); - throw new Exception("Curl request failed"); - } else { - return $results; - } - } - - // Close connection - curl_close($curl); - - } // Close makeRequest - -} - - -?> diff --git a/newapi/Search.php b/newapi/Search.php deleted file mode 100644 index 406a68e5..00000000 --- a/newapi/Search.php +++ /dev/null @@ -1,37 +0,0 @@ -getSubject() . " " . $spo->getPredicate() . " " . $spo->getObject() . ", "; - } - // Strip off the extra comma - $queryString = substr($queryString, '', -2); - } - else { - $queryString .= $SPO->getSubject() . " " . $SPO->getPredicate() . " " . $SPO->getObject(); - } - - // Do a search - $results = ""; - - // Return results; - return $results; - } -} - -?> diff --git a/newapi/models/DataObject.php b/newapi/models/DataObject.php deleted file mode 100644 index 55af4062..00000000 --- a/newapi/models/DataObject.php +++ /dev/null @@ -1,42 +0,0 @@ -id; - } - - /** - * Set the idea if not already set - * @param type $id - * @throws Exception - */ - public function setId($id) - { - if ( $pid != null ) - { - throw new Exception("PID can't be changed"); - } - $this->id = $pid; - } - - /** - * Add the data from a file ( example ) - */ - public function addDataFromFile() - { - - } -} - -?> diff --git a/newapi/models/ObjectModel.php b/newapi/models/ObjectModel.php deleted file mode 100644 index 3ceb6da1..00000000 --- a/newapi/models/ObjectModel.php +++ /dev/null @@ -1,119 +0,0 @@ -id; - } - - /** - * Set the idea if not already set - * @param type $id - * @throws Exception - */ - public function setId($id) - { - if ( $id != null ) - { - throw new Exception("ID can't be changed"); - } - $this->id = $id; - } - - /** - * Get the object label - * @return type - */ - public function getLabel() - { - return $this->label; - } - - /** - * Set the label - * @param type $label - */ - public function setLabel($label) - { - $this->label = $label; - } - - /** - * Get the object status - * @return type - */ - public function getStatus() - { - return $this->status; - } - - /** - * Set the status - * @param type $status - */ - public function setStatus($status) - { - $this->label = $status; - } - - /** - * Get a data using the id - * @param type $id - * @return null - */ - public function getData($id) - { - foreach($this->getAllDataObjects() as $data) - { - if ($data->getId() == $id) - { - return $data; - } - } - return null; - } - - /** - * Get all the data object - * @return type - */ - public function getAllDataObjects() - { - return $this->dataObjects; - } - - /** - * Add a data object - * @param type $data - */ - public function addData(DataObject &$data) - { - $this->dataObjects[$data->getId()] = $data; - } - - /** - * Delete a data object - * @param type $data - */ - public function deleteData(DataObject &$data) - { - unset( $this->datas[$data->getId()] ); - } -} - -?> diff --git a/newapi/models/SPO.php b/newapi/models/SPO.php deleted file mode 100644 index 6ccce543..00000000 --- a/newapi/models/SPO.php +++ /dev/null @@ -1,75 +0,0 @@ -subject = $subject; - $this->predicate = $predicate; - $this->object = $object; - } - - /** - * Get the subject - * @return type - */ - public function getSubject() - { - return $this->subject; - } - - /** - * Get the predicate - * @return type - */ - public function getPredicate() - { - return $this->predicate; - } - - /** - * Get the object - * @return type - */ - public function getObject() - { - return $this->object; - } - - /** - * Set the subject - * @param type $value - */ - public function setSubject($value) - { - $this->subject = $value; - } - - /** - * Set the predicate - * @param type $value - */ - public function setPredicate($value) - { - $this->predicate = $value; - } - - /** - * Set the object - * @param type $value - */ - public function setObject($value) - { - $this->object = $value; - } -} - -?>