コード例 #1
0
ファイル: drilldowns.py プロジェクト: mnjstwins/babbage
 def dimension(self, ast):
     refs = Parser.allrefs(self.cube.model.dimensions,
                           self.cube.model.attributes)
     if ast not in refs:
         raise QueryException('Invalid drilldown: %r' % ast)
     if ast not in self.results:
         self.results.append(ast)
コード例 #2
0
ファイル: fields.py プロジェクト: holgerd77/babbage
 def field(self, ast):
     refs = [m.ref for m in self.cube.model.measures] + \
            [d.ref for d in self.cube.model.dimensions] + \
            [a.ref for a in self.cube.model.attributes]
     if ast not in refs:
         raise QueryException('Invalid field: %r' % ast)
     self.results.append(ast)
コード例 #3
0
ファイル: parser.py プロジェクト: holgerd77/babbage
 def parse(self, text):
     if isinstance(text, six.string_types):
         try:
             model.parse(text, start=self.start, semantics=self)
             return self.results
         except GrakoException, ge:
             raise QueryException(ge.message)
コード例 #4
0
ファイル: ordering.py プロジェクト: mnjstwins/babbage
 def order(self, ast):
     if isinstance(ast, six.string_types):
         ref, direction = ast, 'asc'
     else:
         ref, direction = ast[0], ast[2]
     if ref not in self.cube.model:
         raise QueryException('Invalid sorting criterion: %r' % ast)
     self.results.append((ref, direction))
コード例 #5
0
ファイル: cuts.py プロジェクト: holgerd77/babbage
 def cut(self, ast):
     value = ast[2]
     if isinstance(value, six.string_types) and len(value.strip()) == 0:
         value = None
     # TODO: can you filter measures or aggregates?
     if ast[0] not in self.cube.model:
         raise QueryException('Invalid cut: %r' % ast[0])
     self.results.append((ast[0], ast[1], value))
コード例 #6
0
ファイル: fields.py プロジェクト: mnjstwins/babbage
    def field(self, ast):
        refs = Parser.allrefs(self.cube.model.measures,
                              self.cube.model.dimensions,
                              self.cube.model.attributes)

        if ast not in refs:
            raise QueryException('Invalid field: %r' % ast)
        self.results.append(ast)
コード例 #7
0
    def _check_type(self, ref, value):
        """
        Checks whether the type of the cut value matches the type of the
        concept being cut, and raises a QueryException if it doesn't match
        """
        if isinstance(value, list):
            return [self._check_type(ref, val) for val in value]

        model_type = self.cube.model[ref].datatype
        if model_type is None:
            return
        query_type = self._api_type(value)
        if query_type == model_type:
            return
        else:
            raise QueryException("Invalid value %r parsed as type '%s' "
                                 "for cut %s of type '%s'"
                                 % (value, query_type, ref, model_type))
コード例 #8
0
ファイル: aggregates.py プロジェクト: mnjstwins/babbage
 def aggregate(self, ast):
     refs = [a.ref for a in self.cube.model.aggregates]
     if ast not in refs:
         raise QueryException('Invalid aggregate: %r' % ast)
     self.results.append(ast)
コード例 #9
0
ファイル: drilldowns.py プロジェクト: holgerd77/babbage
 def dimension(self, ast):
     refs = [d.ref for d in self.cube.model.dimensions] + \
            [a.ref for a in self.cube.model.attributes]
     if ast not in refs:
         raise QueryException('Invalid drilldown: %r' % ast)
     self.results.append(ast)