/**
  * @see VirtualFolderInterface::create()
  * @param integer $folder_id
  * @param string $name
  * @return integer
  * @throws VirtualFolderCreateFailedException
  * @throws VirtualFolderCreateFolderNotFoundException
  * @throws VirtualFolderCreateIDMissingException
  */
 public final function create($folder_id, $name)
 {
     global $transaction;
     if (is_numeric($folder_id) and $name) {
         $transaction_id = $transaction->begin();
         try {
             $folder = Folder::get_instance($folder_id);
             if ($folder->exist_folder() == false) {
                 throw new VirtualFolderCreateFolderNotFoundException();
             }
             $data_entity_id = parent::create(1, null);
             parent::set_as_child_of($folder->get_data_entity_id());
             if (($vfolder_id = $this->virtual_folder->create($data_entity_id, $name)) == null) {
                 throw new VirtualFolderCreateFailedException();
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         self::__construct($vfolder_id);
         return $vfolder_id;
     } else {
         throw new VirtualFolderCreateIDMissingException();
     }
 }
Exemple #2
0
 /**
  * @see ParameterInterface::create()
  * @param integer $folder_id
  * @param integer $limit_id
  * @param array $parameter_array
  * @param integer $owner_id
  * @return integer
  * @throws ParameterCreateFailedException
  * @throws ParameterCreateVersionCreateFailedException
  * @throws ParameterCreateValueCreateFailedException
  * @throws ParameterCreateIDMissingException
  */
 protected function create($folder_id, $limit_id, $parameter_array, $owner_id = null)
 {
     global $user, $regional, $transaction;
     if (is_numeric($folder_id) and is_array($parameter_array)) {
         $transaction_id = $transaction->begin();
         try {
             if ($owner_id == null) {
                 $owner_id = $user->get_user_id();
             }
             $folder = Folder::get_instance($folder_id);
             $data_entity_id = parent::create($owner_id, null);
             parent::set_as_child_of($folder->get_data_entity_id());
             $parameter_access = new Parameter_Access(null);
             if (($parameter_id = $parameter_access->create($data_entity_id)) == null) {
                 throw new ParameterCreateFailedException();
             }
             $parameter_version_access = new ParameterVersion_Access(null);
             if (($parameter_version_id = $parameter_version_access->create($parameter_id, 1, 1, null, true, $owner_id, null, $limit_id)) == null) {
                 throw new ParameterCreateVersionCreateFailedException();
             }
             foreach ($parameter_array as $key => $value) {
                 $value['value'] = str_replace($regional->get_decimal_separator(), ".", $value['value']);
                 if (is_numeric($value['value'])) {
                     $parameter_field_value = new ParameterFieldValue_Access(null);
                     if ($parameter_field_value->create($parameter_version_id, $key, $value['method'], $value['value']) == null) {
                         throw new ParameterCreateValueCreateFailedException();
                     }
                 }
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         self::__construct($parameter_id);
         return $parameter_id;
     } else {
         throw new ParameterCreateIDMissingException();
     }
 }
Exemple #3
0
 /**
  * Creates a new folder
  * @param string $name
  * @param integer $toid
  * @param string $path
  * @param integer $owner_id
  * @param integer $owner_group_id
  * @return integer
  * @throws FolderCreateFailedException
  * @throws FolderCreateFolderAlreadyExistsException
  * @throws FolderCreatePhysicalCreationFailedException
  * @throws FolderCreateIDMissingException
  */
 public function create($name, $toid, $path, $owner_id, $owner_group_id)
 {
     global $transaction;
     if (is_numeric($toid)) {
         $transaction_id = $transaction->begin();
         try {
             $folder = new Folder($toid);
             $parent_data_entity_id = $folder->get_data_entity_id();
             if (!$path) {
                 $folder = new Folder($toid);
                 $folder_name = str_replace(" ", "_", trim($name));
                 $path = $folder->get_path() . "/" . $folder_name;
             }
             $data_entity_id = parent::create($owner_id, $owner_group_id);
             parent::set_as_child_of($parent_data_entity_id);
             if (($folder_id = $this->folder->create($data_entity_id, $name, $path)) == null) {
                 throw new FolderCreateFailedException();
             }
             self::__construct($folder_id);
             $system_path = constant("BASE_DIR") . "/" . $path;
             if (file_exists($system_path)) {
                 throw new FolderCreateFolderAlreadyExistsException();
             }
             if (mkdir($system_path) == false) {
                 throw new FolderCreatePhysicalCreationFailedException();
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         return $folder_id;
     } else {
         throw new FolderCreateIDMissingException();
     }
 }
Exemple #4
0
 /**
  * @see ValueInterface::create()
  * @param integer $folder_id
  * @param integer $owner_id
  * @param integer $type_id
  * @param array $value
  * @param bool $premature
  * @return integer
  */
 public function create($folder_id, $owner_id, $type_id, $value)
 {
     global $user, $transaction;
     if ($folder_id and $type_id) {
         $transaction_id = $transaction->begin();
         try {
             if ($owner_id == null) {
                 $owner_id = $user->get_user_id();
             }
             $checksum = md5(serialize($value));
             $folder = Folder::get_instance($folder_id);
             $data_entity_id = parent::create($owner_id, null);
             parent::set_as_child_of($folder->get_data_entity_id());
             $value_access = new Value_Access(null);
             if (($value_id = $value_access->create($data_entity_id, $type_id)) == null) {
                 throw new ValueCreateFailedException();
             }
             if ($type_id != 2 and is_array($value)) {
                 $full_text_index = false;
                 $full_text_key_array = array();
                 $full_text_content_string = "";
                 foreach ($value as $fe_key => $fe_value) {
                     if (strpos($fe_key, "-vartype") !== false) {
                         if ($fe_value == "string") {
                             $full_text_index = true;
                             $tmp_key = str_replace("-vartype", "", $fe_key);
                             array_push($full_text_key_array, $tmp_key);
                         }
                     }
                 }
                 if (is_array($full_text_key_array) and count($full_text_key_array) >= 1) {
                     foreach ($full_text_key_array as $fe_key => $fe_value) {
                         if ($full_text_content_string) {
                             $full_text_content_string = $full_text_content_string . " " . $value[$fe_value];
                         } else {
                             $full_text_content_string = $value[$fe_value];
                         }
                     }
                 }
             } else {
                 $full_text_index = true;
                 $full_text_content_string = $value;
             }
             $value_version_access = new ValueVersion_access(null);
             if ($value_version_access->create($value_id, 1, serialize($value), $checksum, null, 1, true, $owner_id) == null) {
                 throw new ValueCreateVersionCreateFailedException();
             }
             if ($full_text_index == true and $full_text_content_string) {
                 $value_version_access->set_text_search_vector($full_text_content_string, "english");
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         self::__construct($value_id);
         return $value_id;
     } else {
         throw new ValueCreateIDMissingException();
     }
 }
Exemple #5
0
 private function create_shape($folder_id, $owner_id)
 {
     global $user, $transaction;
     if (is_numeric($folder_id)) {
         $transaction_id = $transaction->begin();
         try {
             if ($owner_id == null) {
                 $owner_id = $user->get_user_id();
             }
             $folder = Folder::get_instance($folder_id);
             $data_entity_id = parent::create($owner_id, null);
             parent::set_as_child_of($folder->get_data_entity_id());
             $this->file = new File_Access(null);
             if (($file_id = $this->file->create($data_entity_id)) == null) {
                 throw new FileCreateFailedException();
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         return $file_id;
     } else {
         throw new FileCreateIDMissingException();
     }
 }