public function import(array $data, $dryrun = false)
    {
        try {
            /** @var Injector[] $injectors */
            $injectors = $this->getInjectors();
        } catch (InconsistencyConfigException $e) {
            return \common_report_Report::createFailure('Config problem: ' . $e->getMessage());
        }

        // Global report
        $report = \common_report_Report::createInfo('Report of metadata import.');

        // Foreach line of dateSource
        foreach ($data as $uri => $dataSource) {
            try {

                // Check if resource exists
                $resource = $this->getResource($uri);
                if (! $resource->exists()) {
                    throw new MetadataImportException('Unable to find resource associated to uri : "' . $uri . '"');
                }

                $lineReport = \common_report_Report::createInfo('Report by line.');
                $dataSource = array_change_key_case($dataSource);

                // Foreach injector to map a target source
                /** @var Injector $injector */
                foreach ($injectors as $name => $injector) {
                    $injectorReport = null;

                    try {
                        $dataRead = $injector->read($dataSource);
                        $injector->write($resource, $dataRead, $dryrun);
                        $injectorReport = \common_report_Report::createSuccess('Injector "' . $name . '" successfully ran.');
                    } catch (MetadataInjectorReadException $e) {
                        $injectorReport = \common_report_Report::createFailure(
                            'Injector "' . $name . '" failed to run at read: ' . $e->getMessage()
                        );
                    } catch (MetadataInjectorWriteException $e) {
                        $injectorReport = \common_report_Report::createFailure(
                            'Injector "' . $name . '" failed to run at write: ' . $e->getMessage()
                        );
                    }

                    // Skip if there are no report (no data to read for this injector)
                    if (! is_null($injectorReport)) {
                        $lineReport->add($injectorReport);
                    }

                }

            } catch (MetadataImportException $e) {
                $lineReport = \common_report_Report::createFailure($e->getMessage());
            }
            $report->add($lineReport);
        }

        return $report;
    }
public function import(array $data, $dryrun = false)
    {
        try {
            /** @var Injector[] $injectors */
            $injectors = $this->getInjectors();
        } catch (InconsistencyConfigException $e) {
            return \common_report_Report::createFailure('Config problem: ' . $e->getMessage());
        }

        // Global report
        $report = \common_report_Report::createInfo('Report of metadata import.');

        // Foreach line of dateSource
        foreach ($data as $uri => $dataSource) {
            try {

                // Check if resource exists
                $resource = $this->getResource($uri);
                if (! $resource->exists()) {
                    throw new MetadataImportException('Unable to find resource associated to uri : "' . $uri . '"');
                }

                $lineReport = \common_report_Report::createInfo('Report by line.');
                $dataSource = array_change_key_case($dataSource);

                // Foreach injector to map a target source
                /** @var Injector $injector */
                foreach ($injectors as $name => $injector) {
                    $injectorReport = null;

                    try {
                        $dataRead = $injector->read($dataSource);
                        $injector->write($resource, $dataRead, $dryrun);
                        $injectorReport = \common_report_Report::createSuccess('Injector "' . $name . '" successfully ran.');
                    } catch (MetadataInjectorReadException $e) {
                        $injectorReport = \common_report_Report::createFailure(
                            'Injector "' . $name . '" failed to run at read: ' . $e->getMessage()
                        );
                    } catch (MetadataInjectorWriteException $e) {
                        $injectorReport = \common_report_Report::createFailure(
                            'Injector "' . $name . '" failed to run at write: ' . $e->getMessage()
                        );
                    }

                    // Skip if there are no report (no data to read for this injector)
                    if (! is_null($injectorReport)) {
                        $lineReport->add($injectorReport);
                    }

                }

            } catch (MetadataImportException $e) {
                $lineReport = \common_report_Report::createFailure($e->getMessage());
            }
            $report->add($lineReport);
        }

        return $report;
    }
public function import ( array $ data , $ dryrun = false ) { try { /** @var Injector[] $injectors */ $ injectors = $ this -> getInjectors ( ) ; } catch ( InconsistencyConfigException $ e ) { return \ common_report_Report :: createFailure ( 'Config problem: ' . $ e -> getMessage ( ) ) ; } // Global report $ report = \ common_report_Report :: createInfo ( 'Report of metadata import.' ) ; // Foreach line of dateSource foreach ( $ data as $ uri => $ dataSource ) { try { // Check if resource exists $ resource = $ this -> getResource ( $ uri ) ; if ( ! $ resource -> exists ( ) ) { throw new MetadataImportException ( 'Unable to find resource associated to uri : "' . $ uri . '"' ) ; } $ lineReport = \ common_report_Report :: createInfo ( 'Report by line.' ) ; $ dataSource = array_change_key_case ( $ dataSource ) ; // Foreach injector to map a target source /** @var Injector $injector */ foreach ( $ injectors as $ name => $ injector ) { $ injectorReport = null ; try { $ dataRead = $ injector -> read ( $ dataSource ) ; $ injector -> write ( $ resource , $ dataRead , $ dryrun ) ; $ injectorReport = \ common_report_Report :: createSuccess ( 'Injector "' . $ name . '" successfully ran.' ) ; } catch ( MetadataInjectorReadException $ e ) { $ injectorReport = \ common_report_Report :: createFailure ( 'Injector "' . $ name . '" failed to run at read: ' . $ e -> getMessage ( ) ) ; } catch ( MetadataInjectorWriteException $ e ) { $ injectorReport = \ common_report_Report :: createFailure ( 'Injector "' . $ name . '" failed to run at write: ' . $ e -> getMessage ( ) ) ; } // Skip if there are no report (no data to read for this injector) if ( ! is_null ( $ injectorReport ) ) { $ lineReport -> add ( $ injectorReport ) ; } } } catch ( MetadataImportException $ e ) { $ lineReport = \ common_report_Report :: createFailure ( $ e -> getMessage ( ) ) ; } $ report -> add ( $ lineReport ) ; } return $ report ; }
Main method to import Iterator data to Ontology object

@param array $data
@param boolean $dryrun If set to true no data will be written
@return \common_report_Report
Main method to import Iterator data to Ontology object