You are here

function ARC_sparql2sql_rewriter::parse_patterns in Taxonomy import/export via XML 6

Same name and namespace in other branches
  1. 5.2 arc/ARC_sparql2sql_rewriter.php \ARC_sparql2sql_rewriter::parse_patterns()
  2. 5 arc/ARC_sparql2sql_rewriter.php \ARC_sparql2sql_rewriter::parse_patterns()
  3. 6.2 arc/ARC_sparql2sql_rewriter.php \ARC_sparql2sql_rewriter::parse_patterns()
1 call to ARC_sparql2sql_rewriter::parse_patterns()
ARC_sparql2sql_rewriter::get_select_sql in arc/ARC_sparql2sql_rewriter.php

File

arc/ARC_sparql2sql_rewriter.php, line 874

Class

ARC_sparql2sql_rewriter

Code

function parse_patterns() {
  $infos = $this->infos;
  $where_code = "";
  $this->t_count = 0;
  $this->optional_count = 0;
  $this->union_count = 0;

  /* abs union count */
  $this->term2alias = array();
  $this->alias2term = array();
  $this->optional_term2alias = array();
  $this->optional_t_counts = array();
  $this->optional_patterns = array();
  $this->union_t_counts = array();

  /* individual t_counts for each union branch */
  $this->union_branches = array();
  $this->graphs = array();
  $this->graph_term2alias = array();
  $this->non_graph_aliases = array();
  $this->alias_alternatives = array();

  /* for peer optionals with common terms */
  $this->val_match_vars = array();

  /* for REGEX matching */
  $this->alias_prop_infos = array();
  $this->var_col_occurs = array();

  /* col positions (s,p,o) a var is used (needed to detect obj_props for table splitting) */
  $ind = " ";
  $cur_args = array(
    "ind" => $ind,
    "in_optional" => false,
    "optional_count" => 0,
    "parent_optional_count" => 0,
    "in_union" => false,
    "union_count" => 0,
    "union_branch_id" => "",
    "in_graph" => false,
    "graph" => array(),
    "pattern" => "",
  );
  $nl = "\n";
  $ind = $cur_args["ind"];
  $ni = $nl . $ind;
  foreach ($infos["patterns"] as $cur_pattern) {
    $cur_args["pattern"] = $cur_pattern;
    $sub_r = $this
      ->parse_pattern($cur_args);
    if (trim($sub_r)) {
      $where_code .= strlen($where_code) ? $ni . "AND" . $ni . "(" . $nl . " " . str_replace("\n", "\n ", $sub_r) . $ni . ")" : $sub_r;
    }
  }
  $this->where_code = $where_code;
}