public function generateViews($resources,$context=null)
    {
        $contextAlias = $this->getContextAlias($context);

        // build a filter - will be used for impactIndex detection and finding direct views to re-gen
        $filter = [];
        foreach ($resources as $resource)
        {
            $resourceAlias = $this->labeller->uri_to_alias($resource);
            $this->getLogger()->warning(
                'Generating views',
                ['store' => $this->storeName, '_id' => $resourceAlias]
            );
            // delete any views this resource is involved in. It's type may have changed so it's not enough just to regen it with it's new type below.
            foreach ($this->getConfigInstance()->getViewSpecifications($this->storeName) as $type => $spec) {
                if ($spec['from'] == $this->podName) {
                    $this->config->getCollectionForView($this->storeName, $type, $this->readPreference)
                        ->deleteOne(array("_id" => array("r"=>$resourceAlias,"c"=>$contextAlias,"type"=>$type)));
                }
            }

            // build $filter for queries to impact index
            $filter[] = array("r"=>$resourceAlias,"c"=>$contextAlias);
        }

        // now generate view for $resources themselves... Maybe an optimisation down the line to cut out the query here
        $query = array("_id"=>array('$in'=>$filter));
        $resourceAndType = $this->collection->find($query, array('projection' => array("_id"=>1,"rdf:type"=>1)));

        foreach ($resourceAndType as $rt)
        {
            $id = $rt["_id"];
            if (array_key_exists("rdf:type",$rt))
            {
                if (array_key_exists('u',$rt["rdf:type"]))
                {
                    // single type, not an array of values
                    $this->generateViewsForResourcesOfType($rt["rdf:type"]['u'],$id[_ID_RESOURCE],$id[_ID_CONTEXT]);
                }
                else
                {
                    // an array of types
                    foreach ($rt["rdf:type"] as $type)
                    {
                        $this->generateViewsForResourcesOfType($type['u'],$id[_ID_RESOURCE],$id[_ID_CONTEXT]);
                    }
                }
            }
        }
    }
public function generateViews($resources,$context=null)
    {
        $contextAlias = $this->getContextAlias($context);

        // build a filter - will be used for impactIndex detection and finding direct views to re-gen
        $filter = [];
        foreach ($resources as $resource)
        {
            $resourceAlias = $this->labeller->uri_to_alias($resource);
            $this->getLogger()->warning(
                'Generating views',
                ['store' => $this->storeName, '_id' => $resourceAlias]
            );
            // delete any views this resource is involved in. It's type may have changed so it's not enough just to regen it with it's new type below.
            foreach ($this->getConfigInstance()->getViewSpecifications($this->storeName) as $type => $spec) {
                if ($spec['from'] == $this->podName) {
                    $this->config->getCollectionForView($this->storeName, $type, $this->readPreference)
                        ->deleteOne(array("_id" => array("r"=>$resourceAlias,"c"=>$contextAlias,"type"=>$type)));
                }
            }

            // build $filter for queries to impact index
            $filter[] = array("r"=>$resourceAlias,"c"=>$contextAlias);
        }

        // now generate view for $resources themselves... Maybe an optimisation down the line to cut out the query here
        $query = array("_id"=>array('$in'=>$filter));
        $resourceAndType = $this->collection->find($query, array('projection' => array("_id"=>1,"rdf:type"=>1)));

        foreach ($resourceAndType as $rt)
        {
            $id = $rt["_id"];
            if (array_key_exists("rdf:type",$rt))
            {
                if (array_key_exists('u',$rt["rdf:type"]))
                {
                    // single type, not an array of values
                    $this->generateViewsForResourcesOfType($rt["rdf:type"]['u'],$id[_ID_RESOURCE],$id[_ID_CONTEXT]);
                }
                else
                {
                    // an array of types
                    foreach ($rt["rdf:type"] as $type)
                    {
                        $this->generateViewsForResourcesOfType($type['u'],$id[_ID_RESOURCE],$id[_ID_CONTEXT]);
                    }
                }
            }
        }
    }
public function generateViews ( $ resources , $ context = null ) { $ contextAlias = $ this -> getContextAlias ( $ context ) ; // build a filter - will be used for impactIndex detection and finding direct views to re-gen $ filter = [ ] ; foreach ( $ resources as $ resource ) { $ resourceAlias = $ this -> labeller -> uri_to_alias ( $ resource ) ; $ this -> getLogger ( ) -> warning ( 'Generating views' , [ 'store' => $ this -> storeName , '_id' => $ resourceAlias ] ) ; // delete any views this resource is involved in. It's type may have changed so it's not enough just to regen it with it's new type below. foreach ( $ this -> getConfigInstance ( ) -> getViewSpecifications ( $ this -> storeName ) as $ type => $ spec ) { if ( $ spec [ 'from' ] == $ this -> podName ) { $ this -> config -> getCollectionForView ( $ this -> storeName , $ type , $ this -> readPreference ) -> deleteOne ( array ( "_id" => array ( "r" => $ resourceAlias , "c" => $ contextAlias , "type" => $ type ) ) ) ; } } // build $filter for queries to impact index $ filter [ ] = array ( "r" => $ resourceAlias , "c" => $ contextAlias ) ; } // now generate view for $resources themselves... Maybe an optimisation down the line to cut out the query here $ query = array ( "_id" => array ( '$in' => $ filter ) ) ; $ resourceAndType = $ this -> collection -> find ( $ query , array ( 'projection' => array ( "_id" => 1 , "rdf:type" => 1 ) ) ) ; foreach ( $ resourceAndType as $ rt ) { $ id = $ rt [ "_id" ] ; if ( array_key_exists ( "rdf:type" , $ rt ) ) { if ( array_key_exists ( 'u' , $ rt [ "rdf:type" ] ) ) { // single type, not an array of values $ this -> generateViewsForResourcesOfType ( $ rt [ "rdf:type" ] [ 'u' ] , $ id [ _ID_RESOURCE ] , $ id [ _ID_CONTEXT ] ) ; } else { // an array of types foreach ( $ rt [ "rdf:type" ] as $ type ) { $ this -> generateViewsForResourcesOfType ( $ type [ 'u' ] , $ id [ _ID_RESOURCE ] , $ id [ _ID_CONTEXT ] ) ; } } } } }
Autodiscovers the multiple view specification that may be applicable for a given resource, and submits each for generation
@param $resources
@param null $context
Autodiscovers the multiple view specification that may be applicable for a given resource and submits each for generation