private function createImportFormContainer()
    {
        $sourceContainer = new tao_models_classes_import_CsvUploadForm();
        $sourceForm = $sourceContainer->getForm();
        /** @var tao_helpers_form_FormElement $element */
        foreach ($sourceForm->getElements() as $element) {
            $element->feed();
        }

        $sourceForm->getElement('source')->feed();
        $fileInfo = $sourceForm->getValue('source');

        if (isset($_POST['importFile'])) {
            $serial = $_POST['importFile'];
        } else {
            $serial = $fileInfo['uploaded_file'];
        }

        if (!is_string($serial)) {
            throw new InvalidArgumentException('Import file has to be a valid file serial.');
        }

        /** @var UploadService $uploadService */
        $uploadService = $this->getServiceManager()->get(UploadService::SERVICE_ID);
        $file = $uploadService->getUploadedFlyFile($serial);

        $properties = array(tao_helpers_Uri::encode(OntologyRdfs::RDFS_LABEL) => __('Label'));
		$rangedProperties = array();

		$classUri = \tao_helpers_Uri::decode($_POST['classUri']);
		$class = new core_kernel_classes_Class($classUri);
		$classProperties = $this->getClassProperties($class);

		foreach($classProperties as $property){
			if(!in_array($property->getUri(), $this->getExludedProperties())){
				//@todo manage the properties with range
				$range = $property->getRange();
				$properties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel();

				if($range instanceof core_kernel_classes_Resource && $range->getUri() != OntologyRdfs::RDFS_LITERAL){
					$rangedProperties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel();
				}
			}
		}

        //load the csv data from the file (uploaded in the upload form) to get the columns
        $csv_data = new tao_helpers_data_CsvFile($sourceForm->getValues());
        $csv_data->load($file);

        $values = $sourceForm->getValues();
        $values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES] = !empty($values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES]);
        $values['importFile'] = $serial;
        $myFormContainer = new tao_models_classes_import_CSVMappingForm($values, array(
            'class_properties' => $properties,
            'ranged_properties' => $rangedProperties,
            'csv_column' => $this->getColumnMapping($csv_data, $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES)),
            tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES => $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES),
        ));

        return $myFormContainer;
    }
private function createImportFormContainer()
    {
        $sourceContainer = new tao_models_classes_import_CsvUploadForm();
        $sourceForm = $sourceContainer->getForm();
        /** @var tao_helpers_form_FormElement $element */
        foreach ($sourceForm->getElements() as $element) {
            $element->feed();
        }

        $sourceForm->getElement('source')->feed();
        $fileInfo = $sourceForm->getValue('source');

        if (isset($_POST['importFile'])) {
            $serial = $_POST['importFile'];
        } else {
            $serial = $fileInfo['uploaded_file'];
        }

        if (!is_string($serial)) {
            throw new InvalidArgumentException('Import file has to be a valid file serial.');
        }

        /** @var UploadService $uploadService */
        $uploadService = $this->getServiceManager()->get(UploadService::SERVICE_ID);
        $file = $uploadService->getUploadedFlyFile($serial);

        $properties = array(tao_helpers_Uri::encode(OntologyRdfs::RDFS_LABEL) => __('Label'));
		$rangedProperties = array();

		$classUri = \tao_helpers_Uri::decode($_POST['classUri']);
		$class = new core_kernel_classes_Class($classUri);
		$classProperties = $this->getClassProperties($class);

		foreach($classProperties as $property){
			if(!in_array($property->getUri(), $this->getExludedProperties())){
				//@todo manage the properties with range
				$range = $property->getRange();
				$properties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel();

				if($range instanceof core_kernel_classes_Resource && $range->getUri() != OntologyRdfs::RDFS_LITERAL){
					$rangedProperties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel();
				}
			}
		}

        //load the csv data from the file (uploaded in the upload form) to get the columns
        $csv_data = new tao_helpers_data_CsvFile($sourceForm->getValues());
        $csv_data->load($file);

        $values = $sourceForm->getValues();
        $values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES] = !empty($values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES]);
        $values['importFile'] = $serial;
        $myFormContainer = new tao_models_classes_import_CSVMappingForm($values, array(
            'class_properties' => $properties,
            'ranged_properties' => $rangedProperties,
            'csv_column' => $this->getColumnMapping($csv_data, $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES)),
            tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES => $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES),
        ));

        return $myFormContainer;
    }
private function createImportFormContainer ( ) { $ sourceContainer = new tao_models_classes_import_CsvUploadForm ( ) ; $ sourceForm = $ sourceContainer -> getForm ( ) ; /** @var tao_helpers_form_FormElement $element */ foreach ( $ sourceForm -> getElements ( ) as $ element ) { $ element -> feed ( ) ; } $ sourceForm -> getElement ( 'source' ) -> feed ( ) ; $ fileInfo = $ sourceForm -> getValue ( 'source' ) ; if ( isset ( $ _POST [ 'importFile' ] ) ) { $ serial = $ _POST [ 'importFile' ] ; } else { $ serial = $ fileInfo [ 'uploaded_file' ] ; } if ( ! is_string ( $ serial ) ) { throw new InvalidArgumentException ( 'Import file has to be a valid file serial.' ) ; } /** @var UploadService $uploadService */ $ uploadService = $ this -> getServiceManager ( ) -> get ( UploadService :: SERVICE_ID ) ; $ file = $ uploadService -> getUploadedFlyFile ( $ serial ) ; $ properties = array ( tao_helpers_Uri :: encode ( OntologyRdfs :: RDFS_LABEL ) => __ ( 'Label' ) ) ; $ rangedProperties = array ( ) ; $ classUri = \ tao_helpers_Uri :: decode ( $ _POST [ 'classUri' ] ) ; $ class = new core_kernel_classes_Class ( $ classUri ) ; $ classProperties = $ this -> getClassProperties ( $ class ) ; foreach ( $ classProperties as $ property ) { if ( ! in_array ( $ property -> getUri ( ) , $ this -> getExludedProperties ( ) ) ) { //@todo manage the properties with range $ range = $ property -> getRange ( ) ; $ properties [ tao_helpers_Uri :: encode ( $ property -> getUri ( ) ) ] = $ property -> getLabel ( ) ; if ( $ range instanceof core_kernel_classes_Resource && $ range -> getUri ( ) != OntologyRdfs :: RDFS_LITERAL ) { $ rangedProperties [ tao_helpers_Uri :: encode ( $ property -> getUri ( ) ) ] = $ property -> getLabel ( ) ; } } } //load the csv data from the file (uploaded in the upload form) to get the columns $ csv_data = new tao_helpers_data_CsvFile ( $ sourceForm -> getValues ( ) ) ; $ csv_data -> load ( $ file ) ; $ values = $ sourceForm -> getValues ( ) ; $ values [ tao_helpers_data_CsvFile :: FIRST_ROW_COLUMN_NAMES ] = ! empty ( $ values [ tao_helpers_data_CsvFile :: FIRST_ROW_COLUMN_NAMES ] ) ; $ values [ 'importFile' ] = $ serial ; $ myFormContainer = new tao_models_classes_import_CSVMappingForm ( $ values , array ( 'class_properties' => $ properties , 'ranged_properties' => $ rangedProperties , 'csv_column' => $ this -> getColumnMapping ( $ csv_data , $ sourceForm -> getValue ( tao_helpers_data_CsvFile :: FIRST_ROW_COLUMN_NAMES ) ) , tao_helpers_data_CsvFile :: FIRST_ROW_COLUMN_NAMES => $ sourceForm -> getValue ( tao_helpers_data_CsvFile :: FIRST_ROW_COLUMN_NAMES ) , ) ) ; return $ myFormContainer ; }
Constructs the Import form container
In need of a major refactoring, which will
probably involve refactoring the Form engine as well

@return tao_models_classes_import_CSVMappingForm
@throws \oat\generis\model\fileReference\FileSerializerException
@throws common_exception_NotAcceptable
Constructs the Import form container In need of a major refactoring which will probably involve refactoring the Form engine as well