/**
  * Hardify a class.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return void
  */
 public function actionHardify()
 {
     // Retrieve parameter values.
     $class = $this->options['class'];
     $topClass = $this->options['topClass'];
     $createForeigns = $this->options['createForeigns'];
     $recursive = $this->options['recursive'];
     $classUri = $class->getUri();
     $additionalProperties = array();
     $blackList = array('http://www.tao.lu/middleware/wfEngine.rdf#ClassProcessVariables');
     if (!empty($this->options['additionalProperties'])) {
         $additionalProperties = $this->options['additionalProperties'];
     }
     $optionsHardify = array('recursive' => $recursive, 'append' => true, 'createForeigns' => $createForeigns, 'referencesAllTypes' => true, 'rmSources' => true, 'topClass' => $topClass, 'additionalProperties' => $additionalProperties);
     try {
         $this->outVerbose("Hardifying class '{$classUri}'...");
         $switcher = new core_kernel_persistence_Switcher($blackList);
         $switcher->hardify($class, $optionsHardify);
         $hardenedClasses = $switcher->getHardenedClasses();
         if (array_key_exists($classUri, $hardenedClasses)) {
             $count = $hardenedClasses[$classUri];
             $this->outVerbose("Class '{$classUri}' successfully hardified: {$count} instance(s) compiled.");
             if (true == $optionsHardify['createForeigns']) {
                 unset($hardenedClasses[$classUri]);
                 if (true == empty($hardenedClasses)) {
                     $this->outVerbose("No foreign classes were compiled.");
                 } else {
                     foreach ($hardenedClasses as $uri => $count) {
                         $this->outVerbose("Foreign class '{$uri} successfully hardified: {$count} instance(s) compiled.'");
                     }
                 }
             }
         }
     } catch (Exception $e) {
         $msg = "A fatal error occured while hardifying class '{$classUri}': " . $e->getMessage();
         $this->error($msg, true);
     }
 }
 /**
  * Short description of method run
  *
  * @access protected
  * @author Bertrand Chevrier, <*****@*****.**>
  * @return mixed
  */
 protected function run()
 {
     if (!defined('DEBUG_PERSISTENCE')) {
         define('DEBUG_PERSISTENCE', false);
     }
     switch ($this->mode) {
         case self::MODE_SMOOTH2HARD:
             $this->out("Compiling triples to relational database...", array('color' => 'light_blue'));
             $options = array('recursive' => true, 'append' => true, 'createForeigns' => false, 'referencesAllTypes' => true, 'rmSources' => true);
             $switcher = new core_kernel_persistence_Switcher(array('http://www.tao.lu/middleware/wfEngine.rdf#ClassProcessVariables', 'http://www.tao.lu/Ontologies/TAOResult.rdf#GradeVariable'));
             $api = core_kernel_impl_ApiModelOO::singleton();
             $toCompile = $api->getAllClasses()->toArray();
             foreach ($toCompile as $tC) {
                 $classLabel = $tC->getLabel();
                 $this->out("\nCompiling '{$classLabel}' class...", array('color' => 'light_blue'));
                 $switcher->hardify($tC, $options);
             }
             unset($switcher);
             $this->out("Compilation process complete.");
             break;
         case self::MODE_HARD2SMOOTH:
             $this->out("Uncompiling relational database to triples...", array('color' => 'light_blue'));
             $options = array('recursive' => true, 'removeForeigns' => true);
             $switcher = new core_kernel_persistence_Switcher(array('http://www.tao.lu/middleware/wfEngine.rdf#ClassProcessVariables', 'http://www.tao.lu/Ontologies/TAOResult.rdf#GradeVariable'));
             $api = core_kernel_impl_ApiModelOO::singleton();
             $toDecompile = $api->getAllClasses()->toArray();
             foreach ($toDecompile as $tD) {
                 $classLabel = $tD->getLabel();
                 $this->out("\nDecompiling '{$classLabel}' class...", array('color' => 'light_blue'));
                 $switcher->unhardify($tD, $options);
             }
             $this->out("Decompilation process complete.");
             unset($switcher);
             break;
         default:
             $this->err('Unknow mode', true);
     }
 }