src/acdhOeaw/util/MetadataCollection.php
public function import(string $namespace, int $singleOutNmsp): array {
        $dict = array(self::SKIP, self::CREATE);
        if (!in_array($singleOutNmsp, $dict)) {
            throw new InvalidArgumentException('singleOutNmsp parameters must be one of MetadataCollection::SKIP, MetadataCollection::CREATE');
        }
        $this->autoCommitCounter = 0;

        $this->removeLiteralIds();
        $this->promoteUrisToIds();
        $toBeImported    = $this->filterResources($namespace, $singleOutNmsp);
        $fedoraResources = $this->assureUuids($toBeImported);

        foreach ($toBeImported as $n => $res) {
            $uri       = $res->getUri();
            $fedoraRes = $fedoraResources[$uri];

            echo self::$debug ? "Importing " . $uri . " (" . ($n + 1) . "/" . count($toBeImported) . ")\n" : "";
            $this->sanitizeResource($res, $namespace);

            echo self::$debug ? "\tupdating " . $fedoraRes->getUri(true) . "\n" : "";
            $meta = $fedoraRes->getMetadata();
            $meta->merge($res, array(RC::idProp()));
            $fedoraRes->setMetadata($meta, false);
            $fedoraRes->updateMetadata();
            $this->handleAutoCommit();
        }
        return array_values($fedoraResources);
    }
public function import(string $namespace, int $singleOutNmsp): array {
        $dict = array(self::SKIP, self::CREATE);
        if (!in_array($singleOutNmsp, $dict)) {
            throw new InvalidArgumentException('singleOutNmsp parameters must be one of MetadataCollection::SKIP, MetadataCollection::CREATE');
        }
        $this->autoCommitCounter = 0;

        $this->removeLiteralIds();
        $this->promoteUrisToIds();
        $toBeImported    = $this->filterResources($namespace, $singleOutNmsp);
        $fedoraResources = $this->assureUuids($toBeImported);

        foreach ($toBeImported as $n => $res) {
            $uri       = $res->getUri();
            $fedoraRes = $fedoraResources[$uri];

            echo self::$debug ? "Importing " . $uri . " (" . ($n + 1) . "/" . count($toBeImported) . ")\n" : "";
            $this->sanitizeResource($res, $namespace);

            echo self::$debug ? "\tupdating " . $fedoraRes->getUri(true) . "\n" : "";
            $meta = $fedoraRes->getMetadata();
            $meta->merge($res, array(RC::idProp()));
            $fedoraRes->setMetadata($meta, false);
            $fedoraRes->updateMetadata();
            $this->handleAutoCommit();
        }
        return array_values($fedoraResources);
    }
public function import ( string $ namespace , int $ singleOutNmsp ) : array { $ dict = array ( self :: SKIP , self :: CREATE ) ; if ( ! in_array ( $ singleOutNmsp , $ dict ) ) { throw new InvalidArgumentException ( 'singleOutNmsp parameters must be one of MetadataCollection::SKIP, MetadataCollection::CREATE' ) ; } $ this -> autoCommitCounter = 0 ; $ this -> removeLiteralIds ( ) ; $ this -> promoteUrisToIds ( ) ; $ toBeImported = $ this -> filterResources ( $ namespace , $ singleOutNmsp ) ; $ fedoraResources = $ this -> assureUuids ( $ toBeImported ) ; foreach ( $ toBeImported as $ n => $ res ) { $ uri = $ res -> getUri ( ) ; $ fedoraRes = $ fedoraResources [ $ uri ] ; echo self :: $ debug ? "Importing " . $ uri . " (" . ( $ n + 1 ) . "/" . count ( $ toBeImported ) . ")\n" : "" ; $ this -> sanitizeResource ( $ res , $ namespace ) ; echo self :: $ debug ? "\tupdating " . $ fedoraRes -> getUri ( true ) . "\n" : "" ; $ meta = $ fedoraRes -> getMetadata ( ) ; $ meta -> merge ( $ res , array ( RC :: idProp ( ) ) ) ; $ fedoraRes -> setMetadata ( $ meta , false ) ; $ fedoraRes -> updateMetadata ( ) ; $ this -> handleAutoCommit ( ) ; } return array_values ( $ fedoraResources ) ; }
Imports the whole graph by looping over all resources.

A repository resource is created for every node containing at least one
cfg:fedoraIdProp property and:
- containg at least one other property
- or being within $namespace
- or when $singleOutNmsp equals to MetadataCollection::CREATE

Resources without cfg:fedoraIdProp property are skipped as we are unable
to identify them on the next import (which would lead to duplication).

Resource with a fully qualified URI is considered as having
cfg:fedoraIdProp (its URI is taken as cfg:fedoraIdProp property value).

Resources in the graph can denote relationships in any way but all
object URIs already existing in the repository and all object URIs in the
$namespace will be turned into ACDH ids.
This means graph can not contain circular dependencies between resources
which do not already exist in the repository, like:
```
_:a some:Prop _:b .
_:b some:Prop _:a .
```
The $errorOnCycle parameter determines behaviour of the method when such
a cycle exists in the graph.

@param string $namespace repository resources will be created for all
resources in this namespace
@param int $singleOutNmsp should repository resources be created
representing URIs outside $namespace (MetadataCollection::SKIP or
MetadataCollection::CREATE)
@return array
@throws InvalidArgumentException
Imports the whole graph by looping over all resources .