/dev/adei/adei-blob

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei/adei-blob

« back to all changes in this revision

Viewing changes to classes/readers/dbreader.php

  • Committer: Nicholas Tan Jerome
  • Date: 2015-01-30 10:47:32 UTC
  • Revision ID: nicholas.jerome@kit.edu-20150130104732-e37pofkoamnvqkf6
added identifier and logic to handle blob array data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
 function __construct(array &$info, DBReader &$rdr, $flags = 0) {
8
8
    parent::__construct($info);
9
 
 
10
9
    if (preg_match("/^(.*)__BLOB__(.*)$/", $this->gid, $m)) {
11
10
        $gid = $m[1];
12
11
        $blob_group = $m[2];
13
 
        /*
14
 
        $this->options = array(
15
 
        );
16
 
        */
 
12
        $blob_opts = $rdr->GetGroupOption($this, "blob_groups");
 
13
        #print_r($blob_opts);
 
14
        $this->options = $blob_opts[$gid];
17
15
    } else {
18
16
        $gid = $this->gid;
19
17
        $blob_group = false;
20
18
    }
 
19
    $this->blob_group = $blob_group;
21
20
 
22
21
    if (is_array($rdr->groups)) {
23
22
        foreach($rdr->groups as $re => &$table) {
520
519
    if ($flags&REQUEST::ONLY_AXISINFO) {
521
520
        if ((!$this->item_info)&&(!$this->req->GetGroupOptions($grp, "axis"))) return array();
522
521
    }
 
522
    $grp = $this->CheckGroup($grp, $flags);
523
523
 
524
 
    $grp = $this->CheckGroup($grp, $flags);
525
524
    if (!$mask) $mask = $this->CreateMask($grp, $info = NULL, $flags);
526
 
 
527
525
    if (!$mask->IsFull()) $flags |= REQUEST::LIST_CUSTOM;
528
526
 
529
 
    $uid = $this->opts->Get('channel_uids', false);
530
 
    
531
 
    $data_columns = $this->req->GetGroupOption('columns', $grp);
532
 
 
533
527
    $items = array();
534
528
 
535
 
    $resp = $this->db->ShowColumns($grp->table);
536
 
 
537
 
    $pos = 0; $rpos = 0; $cpos = 0;
538
 
    foreach ($resp as $row) {
539
 
        $name = $row[0];
540
 
        
541
 
//      if (!preg_match($this->columns['data'], $name)) continue;
542
 
        if ((!$data_columns['data'])||(!preg_match($data_columns['data'], $name))) {
543
 
            if (($flags&REQUEST::LIST_CUSTOM)&&(isset($data_columns['custom']))&&(preg_match($data_columns['custom'], $name))) $custom = 1;
544
 
            else continue;
545
 
        } else $custom = 0;
546
 
 
547
 
        if ($custom) $id = "c" . ($cpos++);
548
 
        else $id = $pos++;
549
 
 
550
 
        if (!$mask->Check($id)) continue;
551
 
 
552
 
        $items[$rpos] = array(
553
 
            "id" => $id,
554
 
            "name" =>  $this->db->RecodeMessage($name),
555
 
            "column" => $name
556
 
        );
557
 
        
558
 
        if ($custom) $items[$rpos]['custom'] = $custom;
559
 
 
560
 
        if ($this->item_info) {
561
 
            if ($this->item_info['__group_mode__']) {
562
 
                $info = $this->item_info[$grp->gid][$name];
563
 
            } else {
564
 
                $info = $this->item_info[$name];
565
 
            }
566
 
            if (is_array($info)) {
567
 
                unset($info['id']);
568
 
                unset($info['column']);
569
 
                
570
 
                $items[$rpos] = array_merge($items[$rpos], $info);
571
 
            }
572
 
        }
573
 
        
574
 
        if (($uid)&&(!isset($items[$rpos]["uid"]))) {
575
 
            if (($uid === true)||(preg_match($uid, $name))) {
576
 
                $items[$rpos]["uid"] = $name;
577
 
            }
578
 
        }
579
 
 
580
 
 
581
 
        $rpos++;
 
529
 
 
530
    if(!empty($grp->options)) {
 
531
        // Handles BLOB decoding
 
532
        $end = $grp->options["item_count"];
 
533
        for($i = 0; $i < $end; $i++) {
 
534
            $items[] = array(
 
535
                "id" => $i+1,
 
536
                "name" => $i+1
 
537
            );
 
538
        }
 
539
    } else {
 
540
        $uid = $this->opts->get('channel_uids', false);
 
541
        $data_columns = $this->req->getgroupoption('columns', $grp);
 
542
        $resp = $this->db->showcolumns($grp->table);
 
543
        $pos = 0; $rpos = 0; $cpos = 0;
 
544
        foreach ($resp as $row) {
 
545
            $name = $row[0];
 
546
            //  if (!preg_match($this->columns['data'], $name)) continue;
 
547
            if ((!$data_columns['data'])||(!preg_match($data_columns['data'], $name))) {
 
548
                if (($flags&request::list_custom)&&(isset($data_columns['custom']))&&(preg_match($data_columns['custom'], $name))) $custom = 1;
 
549
                else continue;
 
550
            } else $custom = 0;
 
551
 
 
552
            if ($custom) $id = "c" . ($cpos++);
 
553
            else $id = $pos++;
 
554
 
 
555
            if (!$mask->check($id)) continue;
 
556
 
 
557
            $items[$rpos] = array(
 
558
                "id" => $id,
 
559
                "name" =>  $this->db->recodemessage($name),
 
560
                "column" => $name
 
561
            );
 
562
                
 
563
            if ($custom) $items[$rpos]['custom'] = $custom;
 
564
 
 
565
            if ($this->item_info) {
 
566
                if ($this->item_info['__group_mode__']) {
 
567
                    $info = $this->item_info[$grp->gid][$name];
 
568
                } else {
 
569
                    $info = $this->item_info[$name];
 
570
                }
 
571
                if (is_array($info)) {
 
572
                    unset($info['id']);
 
573
                    unset($info['column']);
 
574
                        
 
575
                    $items[$rpos] = array_merge($items[$rpos], $info);
 
576
                }
 
577
            }
 
578
                
 
579
            if (($uid)&&(!isset($items[$rpos]["uid"]))) {
 
580
                if (($uid === true)||(preg_match($uid, $name))) {
 
581
                    $items[$rpos]["uid"] = $name;
 
582
                }
 
583
            }
 
584
            $rpos++;
 
585
        }
582
586
    }
583
587
 
584
 
    $this->AppendExtractedItems($grp, $mask, $items, $flags);
 
588
    $this->appendextracteditems($grp, $mask, $items, $flags);
585
589
 
586
590
    if (!$items) {    
587
591
        if (!$name)
588
 
            throw new ADEIException(translate("DBReader can't find any column in table (%s)", $grp->table));
 
592
            throw new adeiexception(translate("dbreader can't find any column in table (%s)", $grp->table));
589
593
 
590
594
        if (!$pos)
591
595
            throw new ADEIException(translate("DBReader is not able to find any column matching filter (%s) in table (%s)", $this->columns['data'], $grp->table));
594
598
    if ($flags&REQUEST::NEED_AXISINFO) {
595
599
        $this->AddAxisInfo($grp, $items);
596
600
    }
597
 
    
 
601
 
598
602
    return $items;
599
603
 }
600
604
 
703
707
 }    
704
708
 
705
709
 function GetRawData(LOGGROUP $grp = NULL, $from = 0, $to = 0, DATAFilter $filter = NULL, &$filter_data = NULL) {
 
710
    echo "Inside GetRawData".PHP_EOL;
706
711
    $grp = $this->CheckGroup($grp);
 
712
    print_r($grp);
707
713
 
708
714
    if ((!$from)||(!$to)) {
709
715
        $ivl = $this->CreateInterval($grp);
730
736
        $limit = 0;
731
737
    }
732
738
 
733
 
    $data_columns = $this->FindColumns($grp, $mask);
 
739
    if(!empty($grp->options)) {
 
740
    } else {
 
741
        $data_columns = $this->FindColumns($grp, $mask);
 
742
    }
734
743
 
735
744
    if ($this->emit_delays) {
736
745
        log_message("Sleeping");
765
774
    } else {
766
775
        $selopts['order'] = $this->time_sort;
767
776
    }
 
777
    print_r($grp->table); echo PHP_EOL;
 
778
    print_r($data_columns);echo PHP_EOL;
 
779
    print_r($selopts);echo PHP_EOL;
768
780
    
769
781
    $query = $this->db->SelectRequest($grp->table, $data_columns, $selopts);
770
 
#    echo $query . "\n";
 
782
    echo $query . "\n";
771
783
 
772
784
    $stmt = $this->db->Prepare($query);
773
785
    return new DATABASEData($this, $stmt);
790
802
 
791
803
}
792
804
 
793
 
?>
 
 
b'\\ No newline at end of file'
 
805
?>