/**
  * save
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function save()
 {
     $this->core->logger->debug('massiveart->generic->data->GenericDataTypeFolder->save()');
     try {
         $this->getModelFolders()->setLanguageId($this->setup->getLanguageId());
         $intUserId = Zend_Auth::getInstance()->getIdentity()->id;
         /**
          * add|edit|newVersion core and instance data
          */
         switch ($this->setup->getActionType()) {
             case $this->core->sysConfig->generic->actions->add:
                 $strFolderId = uniqid();
                 $intFolderVersion = 1;
                 $intSortPosition = GenericSetup::DEFAULT_SORT_POSITION;
                 if ($this->setup->getParentId() != '' && $this->setup->getParentId() > 0) {
                     $objNaviData = $this->getModelFolders()->loadChildNavigation($this->setup->getParentId());
                 } else {
                     $objNaviData = $this->getModelFolders()->loadRootNavigation($this->setup->getRootLevelId());
                 }
                 $intSortPosition = count($objNaviData);
                 $arrMainData = array('idGenericForms' => $this->setup->getGenFormId(), 'idFolderTypes' => $this->core->sysConfig->folder_types->folder, 'folderId' => $strFolderId, 'version' => $intFolderVersion, 'sortPosition' => $intSortPosition, 'sortTimestamp' => date('Y-m-d H:i:s'), 'idUsers' => $intUserId, 'creator' => $this->setup->getCreatorId(), 'created' => date('Y-m-d H:i:s'), 'idStatus' => $this->setup->getStatusId(), 'isUrlFolder' => $this->setup->getUrlFolder(), 'showInNavigation' => $this->setup->getShowInNavigation());
                 /**
                  * add folder node to the "Nested Set Model"
                  */
                 $this->setup->setElementId($this->objModelFolders->addFolderNode($this->setup->getRootLevelId(), $this->setup->getParentId(), $arrMainData));
                 $this->insertCoreData('folder', $strFolderId, $intFolderVersion);
                 $this->insertInstanceData('folder', array('Id' => $strFolderId, 'Version' => $intFolderVersion));
                 break;
             case $this->core->sysConfig->generic->actions->edit:
                 $objSelect = $this->objModelFolders->getFolderTable()->select();
                 $objSelect->from('folders', array('folderId', 'version'));
                 $objSelect->where('id = ?', $this->setup->getElementId());
                 $objRowSet = $this->objModelFolders->getFolderTable()->fetchAll($objSelect);
                 if (count($objRowSet) == 1) {
                     $objFolder = $objRowSet->current();
                     $strWhere = $this->objModelFolders->getFolderTable()->getAdapter()->quoteInto('folderId = ?', $objFolder->folderId);
                     $strWhere .= $this->objModelFolders->getFolderTable()->getAdapter()->quoteInto(' AND version = ?', $objFolder->version);
                     $this->core->logger->debug('save(): creator: ' . $this->setup->getCreatorId() . ' - idStatus: ' . $this->setup->getStatusId() . ' - isUrlFolder: ' . $this->setup->getUrlFolder());
                     $this->objModelFolders->getFolderTable()->update(array('idUsers' => $intUserId, 'creator' => $this->setup->getCreatorId(), 'idStatus' => $this->setup->getStatusId(), 'isUrlFolder' => $this->setup->getUrlFolder(), 'showInNavigation' => $this->setup->getShowInNavigation(), 'changed' => date('Y-m-d H:i:s')), $strWhere);
                     $this->updateCoreData('folder', $objFolder->folderId, $objFolder->version);
                     $this->updateInstanceData('folder', $objFolder->folderId, $objFolder->version);
                 }
                 break;
         }
         return $this->setup->getElementId();
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }