当前位置: 首页>>代码示例>>PHP>>正文


PHP ARC2::getMergedIndex方法代码示例

本文整理汇总了PHP中ARC2::getMergedIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP ARC2::getMergedIndex方法的具体用法?PHP ARC2::getMergedIndex怎么用?PHP ARC2::getMergedIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ARC2的用法示例。


在下文中一共展示了ARC2::getMergedIndex方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: toIndex

 /**
  * toIndex
  * @return array
  */
 public function toIndex()
 {
     $index = array();
     foreach ($this->resources as $res) {
         $index = ARC2::getMergedIndex($index, $res->index);
     }
     return $index;
 }
开发者ID:patrickmj,项目名称:Rubrick,代码行数:12,代码来源:PMJ_ResourceGraphPlugin.php

示例2: mergeResource

 /**
  * function  mergeResource
  * @param PMJ_ResourcePlus $res
  */
 public function mergeResource($res)
 {
     if ($res - uri != $this->uri) {
         $this->addError('Resource uris must match');
         return false;
     }
     $this->index = ARC2::getMergedIndex($res->index, $this->index);
 }
开发者ID:patrickmj,项目名称:Rubrick,代码行数:12,代码来源:PMJ_ResourcePlus.php

示例3: mergeResource

 /**
  * mergeResource
  * @param PMJ_ResourcePlus $res
  */
 public function mergeResource($res)
 {
     if ($res->uri != $this->uri) {
         $this->addError('Resource uris must match');
         return false;
     }
     $this->index = ARC2::getMergedIndex($res->index, $this->index);
     foreach ($res->ns as $prefix => $uri) {
         $this->addPrefix($prefix, $uri);
     }
 }
开发者ID:patrickmj,项目名称:Rubrick,代码行数:15,代码来源:PMJ_ResourcePlusPlugin.php

示例4: fetchData

 function fetchData($uri = '')
 {
     if (!$uri) {
         $uri = $this->uri;
     }
     if (!$uri) {
         return 0;
     }
     if (in_array($uri, $this->fetched)) {
         return 0;
     }
     $this->index[$uri] = array();
     if ($this->store) {
         $index = $this->store->query('DESCRIBE <' . $uri . '>', 'raw');
     } else {
         $index = $this->toIndex($uri);
     }
     $this->index = ARC2::getMergedIndex($this->index, $index);
     $this->fetched[] = $uri;
 }
开发者ID:joedevon,项目名称:arc2,代码行数:20,代码来源:ARC2_Resource.php

示例5: addIndex

 function addIndex($index)
 {
     $this->index = ARC2::getMergedIndex($this->index, $index);
     return $this;
 }
开发者ID:mk-smart,项目名称:datahub-rdf-catalogue,代码行数:5,代码来源:ARC2_Graph.php

示例6: insert

 function insert($doc, $g = 'http://localhost/')
 {
     $index = $this->v($g, array(), $this->data);
     $this->data[$g] = ARC2::getMergedIndex($index, $this->toIndex($doc));
 }
开发者ID:benblamey,项目名称:cmu-teaching-php,代码行数:5,代码来源:ARC2_MemStore.php

示例7: extractItem

 function extractItem($els)
 {
     list($props, $sub_index) = $this->extractProps($els, 'item');
     $uri = $props[$this->rss . 'link'][0]['value'];
     return ARC2::getMergedIndex(array($uri => $props), $sub_index);
 }
开发者ID:dmj,项目名称:uni-helmstedt.hab.de,代码行数:6,代码来源:ARC2_AtomParser.php

示例8: getUpdatedIndex

 function getUpdatedIndex($old_index, $q)
 {
     if (!preg_match('/^\\s*(INSERT|DELETE)\\s*(INTO|FROM)?\\s*(.*)$/is', $q, $m)) {
         return 0;
     }
     $qt = strtolower($m[1]);
     $g = $this->getTargetGraph();
     /* inject a target graph, if necessary */
     if (!$m[2]) {
         $q = strtoupper($qt) . ($qt == 'insert' ? ' INTO ' : ' FROM') . ' <' . $g . '> ' . $m[3];
     }
     /* parse the query */
     $this->writeLog($q);
     ARC2::inc('SPARQLPlusParser');
     $p =& new ARC2_SPARQLPlusParser($this->a, $this);
     $p->parse($q);
     $infos = $p->getQueryInfos();
     /* errors? */
     if ($errors = $this->getErrors()) {
         $this->setHeader('http', 'HTTP/1.1 400 Bad Request');
         $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
         $this->result = join("\n", $errors);
         return 0;
     }
     $q_index = ARC2::getSimpleIndex($infos['query']['construct_triples'], 0);
     if ($qt == 'insert') {
         return ARC2::getMergedIndex($old_index, $q_index);
     } elseif ($qt == 'delete') {
         return ARC2::getCleanedIndex($old_index, $q_index);
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:31,代码来源:ARC2_DataWikiPlugin.php

示例9: getLinkedData


//.........这里部分代码省略.........
                     $this->requests++;
                     if (is_object($dataParser)) {
                         $linkedData = $dataParser->getSimpleIndex(0);
                         // save cache
                         $this->addLogMessage('  --> save to cache: ' . $uriAbs);
                         $this->saveCache(array('data' => $linkedData, 'name' => $uriAbs, 'space' => $this->cache_space_prefix . 'DataAbs', 'time' => true));
                     }
                     unset($dataParser);
                 }
                 $this->addLogMessage('  --> read: ' . $uriAbs . ' (' . count($linkedData) . ' elements)');
             } else {
                 $this->addLogMessage('  --> read from cache: ' . $uriAbs . ' (' . count($linkedData) . ' elements)');
             }
             // check outdated cache as fallback
             // better old data than no data :)
             if (!$linkedData) {
                 if ($linkedData = $this->getCache(array('name' => $uriAbs, 'space' => $this->cache_space_prefix . 'DataAbs', 'time' => -1))) {
                     $this->addLogMessage('  --> read from OUTDATED cache: ' . $uriAbs . ' (' . count($linkedData) . ' elements)');
                 }
             }
             if (isset($testuri) && $uriAbs == $testuri) {
                 die('<pre>' . print_r($linkedData, true) . '</pre>');
             }
             if ($linkedData) {
                 // check linkedData, only keep uri and blanknodes which are referenced by resource
                 if (isset($linkedData[$uri])) {
                     //$indexedData[$uri] = $linkedData[$uri];
                     $indexedData = $linkedData;
                     if (isset($testuri) && $uri == $testuri) {
                         die('<pre>' . print_r($indexedData, true) . '</pre>');
                     }
                     /* TODO: reduceMemoryUsage()
                        $indexedData[$uri] = $linkedData[$uri];
                        if ($this->environment['FP_config']['LinkedData']['useBnodes'] === true)
                        {
                            // keep bnodes in results
                            $bnodes = $this->listBnodes($indexedData[$uri]);
                            foreach ($bnodes as $key)
                            {
                                $indexedData[$key] = $linkedData[$key];
                            }
                        }
                        else
                        {
                            // let bnodes out of result set
                            $indexedData[$uri] = $this->deleteBnodes($indexedData[$uri]);
                        }
                        // TODO: get all other relevant resources (referenced in any way over x steps)
                        unset($bnodes);
                        */
                     $this->addLogMessage('  --> use: ' . $uri . ' (' . count($indexedData[$uri]) . ' elements)');
                     if (isset($testuri) && $uri == $testuri) {
                         die('<pre>' . print_r($indexedData, true) . '</pre>');
                     }
                     unset($linkedData);
                     // save cache for indexed data of uri
                     $this->saveCache(array('data' => $indexedData, 'name' => $uri, 'space' => $this->cache_space_prefix . 'Data', 'time' => true));
                 }
             }
         } else {
             $this->addLogMessage('  --> read from cache: ' . $uri . ' (' . count($indexedData[$uri]) . ' elements)');
         }
     }
     // end of if (substr($uri, 0 , 1) != '_')
     if (isset($testuri) && $uri == $testuri) {
         die('<pre>' . print_r($indexedData, true) . '</pre>');
     }
     if ($indexedData) {
         // return Foafpress_resource
         $ARC2TO = clone $this;
         // check alias (e.g. for owl:sameAs)
         if ($alias) {
             $indexedData[$alias] = $indexedData[$uri];
             unset($indexedData[$uri]);
         }
         if (isset($testuri) && $uri == $testuri) {
             die('<pre>' . print_r($indexedData, true) . '</pre>');
         }
         // merge data
         $this->resource->index = ARC2::getMergedIndex($this->resource->index, $indexedData);
         if (isset($testuri) && $uri == $testuri) {
             die('<pre>' . print_r($this->resource->index, true) . '</pre>');
         }
         unset($indexedData);
         $ARC2TO->uri = $uri;
         $ARC2TO->updateNamespacePrefix();
         if ($alias) {
             //TODO: $ARC2TO->includeSameAs($alias);
             $ARC2TO->uri = $alias;
         } else {
             $ARC2TO->level++;
         }
         $this->addLogMessage('now: count ' . count($this->resource->index) . ' -- memory ' . intval(memory_get_usage(true) / 1024) . 'kb');
         return $ARC2TO;
     } else {
         $this->addLogMessage('now: count ' . count($this->resource->index) . ' -- memory ' . intval(memory_get_usage(true) / 1024) . 'kb');
         // no data or error, only return requested uri
         return $uri;
     }
 }
开发者ID:haschek,项目名称:RDF-Template-Object,代码行数:101,代码来源:rdfto.arc2.php

示例10: content_negociated_user_home

 /**
  * Outputs user's FOAF profile
  * @param unknown_type $params
  */
 function content_negociated_user_home(&$params)
 {
     $username = $params['username'];
     $accept = $params['accept'];
     if ($accept == 'application/rdf+xml') {
         $params['content_type'] = 'application/rdf+xml';
         $user_obj = user_get_object_by_name($username);
         $user_real_name = $user_obj->getRealName();
         $user_email = $user_obj->getEmail();
         $mbox = 'mailto:' . $user_email;
         $mbox_sha1sum = sha1($mbox);
         $projects = $user_obj->getGroups();
         sortProjectList($projects);
         $roles = RBACEngine::getInstance()->getAvailableRolesForUser($user_obj);
         sortRoleList($roles);
         // Construct an ARC2_Resource containing the project's RDF (DOAP) description
         $ns = array('rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'foaf' => 'http://xmlns.com/foaf/0.1/', 'sioc' => 'http://rdfs.org/sioc/ns#', 'doap' => 'http://usefulinc.com/ns/doap#', 'dcterms' => 'http://purl.org/dc/terms/', 'planetforge' => 'http://coclico-project.org/ontology/planetforge#');
         $conf = array('ns' => $ns);
         // First, let's deal with the account
         $account_res = ARC2::getResource($conf);
         $account_uri = util_make_url_u($username, $user_obj->getID());
         $account_uri = rtrim($account_uri, '/');
         $person_uri = $account_uri . '#person';
         $account_res->setURI($account_uri);
         // $account_res->setRel('rdf:type', 'foaf:OnlineAccount');
         rdfutils_setPropToUri($account_res, 'rdf:type', 'foaf:OnlineAccount');
         rdfutils_setPropToUri($account_res, 'foaf:accountServiceHomepage', $account_uri . '/');
         $account_res->setProp('foaf:accountName', $username);
         rdfutils_setPropToUri($account_res, 'sioc:account_of', $person_uri);
         rdfutils_setPropToUri($account_res, 'foaf:accountProfilePage', $account_uri);
         $groups_index = array();
         $projects_index = array();
         $roles_index = array();
         $usergroups_uris = array();
         // see if there were any groups
         if (count($projects) >= 1) {
             foreach ($projects as $p) {
                 // TODO : report also private projects if authenticated, for instance through OAuth
                 if ($p->isPublic()) {
                     $project_link = util_make_link_g($p->getUnixName(), $p->getID(), $p->getPublicName());
                     $project_uri = util_make_url_g($p->getUnixName(), $p->getID());
                     // sioc:UserGroups for all members of a project are named after /projects/A_PROJECT/members/
                     $usergroup_uri = $project_uri . 'members/';
                     $role_names = array();
                     $usergroups_uris[] = $usergroup_uri;
                     $usergroup_res = ARC2::getResource($conf);
                     $usergroup_res->setURI($usergroup_uri);
                     rdfutils_setPropToUri($usergroup_res, 'rdf:type', 'sioc:UserGroup');
                     rdfutils_setPropToUri($usergroup_res, 'sioc:usergroup_of', $project_uri);
                     $roles_uris = array();
                     foreach ($roles as $r) {
                         if ($r instanceof RoleExplicit && $r->getHomeProject() != NULL && $r->getHomeProject()->getID() == $p->getID()) {
                             $role_names[$r->getID()] = $r->getName();
                             $role_uri = $project_uri . 'roles/' . $r->getID();
                             $roles_uris[] = $role_uri;
                         }
                     }
                     rdfutils_setPropToUri($usergroup_res, 'planetforge:group_has_function', $roles_uris);
                     $project_res = ARC2::getResource($conf);
                     $project_res->setURI($project_uri);
                     rdfutils_setPropToUri($project_res, 'rdf:type', 'planetforge:ForgeProject');
                     $project_res->setProp('doap:name', $p->getUnixName());
                     $projects_index = ARC2::getMergedIndex($projects_index, $project_res->index);
                     foreach ($role_names as $id => $name) {
                         $role_res = ARC2::getResource($conf);
                         $role_res->setURI($project_uri . 'roles/' . $id);
                         rdfutils_setPropToUri($role_res, 'rdf:type', 'sioc:Role');
                         $role_res->setProp('sioc:name', $name);
                         $roles_index = ARC2::getMergedIndex($roles_index, $role_res->index);
                     }
                     $groups_index = ARC2::getMergedIndex($groups_index, $usergroup_res->index);
                 }
             }
         }
         // end if groups
         rdfutils_setPropToUri($account_res, 'sioc:member_of', $usergroups_uris);
         // next, deal with the person
         $person_res = ARC2::getResource($conf);
         $person_res->setURI($person_uri);
         rdfutils_setPropToUri($person_res, 'rdf:type', 'foaf:Person');
         $person_res->setProp('foaf:name', $user_real_name);
         rdfutils_setPropToUri($person_res, 'foaf:holdsAccount', $account_uri);
         $person_res->setProp('foaf:mbox_sha1sum', $mbox_sha1sum);
         // merge the two sets of triples
         $merged_index = ARC2::getMergedIndex($account_res->index, $person_res->index);
         $merged_index = ARC2::getMergedIndex($merged_index, $groups_index);
         $merged_index = ARC2::getMergedIndex($merged_index, $projects_index);
         $merged_index = ARC2::getMergedIndex($merged_index, $roles_index);
         $conf = array('ns' => $ns, 'serializer_type_nodes' => true);
         $ser = ARC2::getRDFXMLSerializer($conf);
         /* Serialize a resource index */
         $doc = $ser->getSerializedIndex($merged_index);
         $params['content'] = $doc . "\n";
     }
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:99,代码来源:foafprofilesPlugin.class.php

示例11: content_negociated_project_home

 /**
  * Outputs project's DOAP profile
  * @param unknown_type $params
  */
 function content_negociated_project_home(&$params)
 {
     $projectname = $params['groupname'];
     $accept = $params['accept'];
     $group_id = $params['group_id'];
     if ($accept == 'application/rdf+xml') {
         // connect to FusionForge internals
         $pm = ProjectManager::instance();
         $project = $pm->getProject($group_id);
         $project_shortdesc = $project->getPublicName();
         $project_description = $project->getDescription();
         $tags_list = NULL;
         if (forge_get_config('use_project_tags')) {
             $group = group_get_object($group_id);
             $tags_list = $group->getTags();
         }
         // We will return RDF+XML
         $params['content_type'] = 'application/rdf+xml';
         // Construct an ARC2_Resource containing the project's RDF (DOAP) description
         $ns = array('rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'doap' => 'http://usefulinc.com/ns/doap#', 'dcterms' => 'http://purl.org/dc/terms/', 'schema' => 'http://schema.org/');
         $conf = array('ns' => $ns);
         $res = ARC2::getResource($conf);
         $res->setURI(util_make_url_g($projectname, $group_id));
         // $res->setRel('rdf:type', 'doap:Project');
         rdfutils_setPropToUri($res, 'rdf:type', 'doap:Project');
         $res->setProp('doap:name', $projectname);
         $res->setProp('doap:shortdesc', $project_shortdesc);
         if ($project_description) {
             $res->setProp('doap:description', $project_description);
         }
         $res->setProp('doap:homepage', $project->getHomePage());
         $tags = array();
         if ($tags_list) {
             $tags = split(', ', $tags_list);
             $res->setProp('dcterms:subject', $tags);
         }
         // Now, we need to collect complementary RDF descriptiosn of the project via other plugins
         // invoke the 'project_rdf_metadata' hook so as to complement the RDF description
         $hook_params = array();
         $hook_params['prefixes'] = array();
         foreach ($ns as $prefix => $url) {
             $hook_params['prefixes'][$url] = $prefix;
         }
         $hook_params['group'] = $group_id;
         // pass the resource in case it could be useful (read-only in principle)
         $hook_params['in_Resource'] = $res;
         $hook_params['out_Resources'] = array();
         plugin_hook_by_reference('project_rdf_metadata', $hook_params);
         // add new prefixes to the list
         foreach ($hook_params['prefixes'] as $url => $prefix) {
             if (!isset($ns[$prefix])) {
                 $ns[$prefix] = $url;
             }
         }
         // merge the two sets of triples
         $merged_index = $res->index;
         foreach ($hook_params['out_Resources'] as $out_res) {
             $merged_index = ARC2::getMergedIndex($merged_index, $out_res->index);
         }
         $conf = array('ns' => $ns, 'serializer_type_nodes' => true);
         $ser = ARC2::getRDFXMLSerializer($conf);
         /* Serialize a resource index */
         $doc = $ser->getSerializedIndex($merged_index);
         $params['content'] = $doc . "\n";
     }
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:70,代码来源:doaprdfPlugin.class.php


注:本文中的ARC2::getMergedIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。