]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/database/databases/class_LocalFileDatabase.php
Fake class names added, insertDataSet() stub added, dataset criteria added
[shipsimu.git] / inc / classes / main / database / databases / class_LocalFileDatabase.php
index 1960794377b30c5dd218a16a5f14dfe3470631ee..25cc4ba6d52887b51f600b1b5280796fc61f689a 100644 (file)
@@ -151,25 +151,10 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * Saves a given object to the local file system by serializing and
         * transparently compressing it
         *
-        * @param               $object                         The object we shall save to the local file system
+        * @param       $object                                 The object we shall save to the local file system
         * @return      void
-        * @throws      NullPointerException    If the object instance is null
-        * @throws      NoObjectException               If the parameter $object is not
-        *                                                              an object
         */
-       public final function saveObject ($object) {
-               // Some tests on the parameter...
-               if (is_null($object)) {
-                       // Is null, throw exception
-                       throw new NullPointerException($object, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($object)) {
-                       // Is not an object, throw exception
-                       throw new NoObjectException($object, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($object, '__toString')) {
-                       // A highly required method was not found... :-(
-                       throw new MissingMethodException(array($object, '__toString'), self::EXCEPTION_MISSING_METHOD);
-               }
-
+       public final function saveObject (FrameworkInterface $object) {
                // Get a string containing the serialized object. We cannot exchange
                // $this and $object here because $object does not need to worry
                // about it's limitations... ;-)
@@ -186,14 +171,14 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
        /**
         * Get a serialized string from the given object
         *
-        * @param               $object         The object we want to serialize and transparently
-        *                                              compress
-        * @return      $serialized     A string containing the serialzed/compressed object
+        * @param       $object                 The object we want to serialize and transparently
+        *                                                      compress
+        * @return      $serialized             A string containing the serialzed/compressed object
         * @see         ObjectLimits    An object holding limition information
         * @see         SerializationContainer  A special container class for e.g.
-        *                                                              attributes from limited objects
+        *                                                                      attributes from limited objects
         */
-       private function serializeObject ($object) {
+       private function serializeObject (FrameworkInterface $object) {
                // If there is no limiter instance we serialize the whole object
                // otherwise only in the limiter object (ObjectLimits) specified
                // attributes summarized in a special container class
@@ -218,13 +203,13 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * Analyses if a unique ID has already been used or not by search in the
         * local database folder.
         *
-        * @param               $uniqueID               A unique ID number which shall be checked
-        *                                              before it will be used
-        * @param               $inConstructor  If we got called in a de/con-structor or
-        *                                              from somewhere else
+        * @param       $uniqueID               A unique ID number which shall be checked
+        *                                                      before it will be used
+        * @param       $inConstructor  If we got called in a de/con-structor or
+        *                                                      from somewhere else
         * @return      $isUnused               true    = The unique ID was not found in the database,
-        *                                              false = It is already in use by an other object
-        * @throws      NoArrayCreatedException If explode() fails to create an array
+        *                                                      false = It is already in use by an other object
+        * @throws      NoArrayCreatedException         If explode() fails to create an array
         * @throws      InvalidArrayCountException      If the array contains less or
         *                                                                      more than two elements
         */
@@ -553,7 +538,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                $resultData = null;
 
                // Is this criteria supported?
-               if (!$criteriaInstance instanceof LocalCriteria) {
+               if (!$criteriaInstance instanceof LocalSearchCriteria) {
                        // Not supported by this database layer
                        throw new UnsupportedCriteriaException(array($this, $criteriaInstance), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
                }
@@ -600,6 +585,35 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                // Return the gathered result
                return $resultData;
        }
+
+       /**
+        * "Inserts" a data set instance into a local file database folder
+        *
+        * @param       $dataSetInstance        A storeable data set
+        * @return      void
+        */
+       public function insertDataSet (StoreableCriteria $dataSetInstance) {
+               // Create full path name
+               $fqfn = sprintf("%s%s/%s.%s",
+                       $this->getSavePath(),
+                       $dataSetInstance->getTableName(),
+                       $dataSetInstance->getCombinedUniqueKey(),
+                       $this->getFileExtension()
+               );
+               die($fqfn);
+
+               // Try to save the request away
+               try {
+                       // Get a file pointer instance
+
+                       // Reset last error message and exception
+                       $this->resetLastError();
+               } catch (FrameworkException $e) {
+                       // Catch all exceptions and store them in last error
+                       $this->lastException = $e;
+                       $this->lastError = $e->getMessage();
+               }
+       }
 }
 
 // [EOF]