/**
  * Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollection; $x->cloneStructure($id))
  *
  * @param $original_id The original ID of the dataselection you want to clone it's structure
  */
 public function cloneStructure($original_id)
 {
     $original = new ilObjDataCollection($original_id);
     $this->setApproval($original->getApproval());
     $this->setNotification($original->getNotification());
     $this->setPublicNotes($original->getPublicNotes());
     $this->setRating($original->getRating());
     // delete old tables.
     foreach ($this->getTables() as $table) {
         $table->doDelete(true);
     }
     // add new tables.
     foreach ($original->getTables() as $table) {
         $new_table = new ilDataCollectionTable();
         $new_table->setObjId($this->getId());
         $new_table->cloneStructure($table);
         if ($table->getId() == $original->getMainTableId()) {
             $this->setMainTableId($new_table->getId());
         }
     }
     // update because maintable id is now set.
     $this->doUpdate();
     // Set new field-ID of referenced fields
     foreach ($original->getTables() as $origTable) {
         foreach ($origTable->getRecordFields() as $origField) {
             if ($origField->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
                 $newRefId = NULL;
                 $origFieldRefObj = ilDataCollectionCache::getFieldCache($origField->getFieldRef());
                 $origRefTable = ilDataCollectionCache::getTableCache($origFieldRefObj->getTableId());
                 // Lookup the new ID of the referenced field in the actual DC
                 $tableId = ilDataCollectionTable::_getTableIdByTitle($origRefTable->getTitle(), $this->getId());
                 $fieldId = ilDataCollectionField::_getFieldIdByTitle($origFieldRefObj->getTitle(), $tableId);
                 $field = ilDataCollectionCache::getFieldCache($fieldId);
                 $newRefId = $field->getId();
                 // Set the new refID in the actual DC
                 $tableId = ilDataCollectionTable::_getTableIdByTitle($origTable->getTitle(), $this->getId());
                 $fieldId = ilDataCollectionField::_getFieldIdByTitle($origField->getTitle(), $tableId);
                 $field = ilDataCollectionCache::getFieldCache($fieldId);
                 $field->setPropertyvalue($newRefId, ilDataCollectionField::PROPERTYID_REFERENCE);
                 $field->doUpdate();
             }
         }
     }
 }