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


TypeScript plywood.Expression类代码示例

本文整理汇总了TypeScript中plywood.Expression的典型用法代码示例。如果您正苦于以下问题:TypeScript Expression类的具体用法?TypeScript Expression怎么用?TypeScript Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: constructor

  constructor(parameters: DimensionValue) {
    var name = parameters.name;
    verifyUrlSafeName(name);
    this.name = name;
    this.title = parameters.title || makeTitle(name);

    var formula = parameters.formula || $(name).toString();
    this.formula = formula;
    this.expression = Expression.parse(formula);

    var kind = parameters.kind || typeToKind(this.expression.type) || 'string';
    this.kind = kind;

    if (kind === 'string' && isGeo(name)) {
      this.className = 'string-geo';
    } else {
      this.className = kind;
    }
    if (parameters.url) {
      if (typeof parameters.url !== 'string') {
        throw new Error(`unsupported url: ${parameters.url}: only strings are supported`);
      }
      this.url = parameters.url;
    }

    if (parameters.granularities) {
      if (parameters.granularities.length !== 5) throw new Error('there must be exactly 5 granularities');
      this.granularities = parameters.granularities;
    }
    if (parameters.bucketedBy) this.bucketedBy = parameters.bucketedBy;
    if (parameters.bucketingStrategy) this.bucketingStrategy = parameters.bucketingStrategy;
    if (parameters.sortStrategy) this.sortStrategy = parameters.sortStrategy;
  }
开发者ID:djfwan,项目名称:pivot,代码行数:33,代码来源:dimension.ts

示例2: return

 return (ex: Expression, env: Environment = {}) => {
   return Qajax({
     method: "POST",
     url: url + '?by=' + getSplitsDescription(ex),
     data: {
       version: version,
       dataCube: name,
       expression: ex.toJS(),
       timezone: env ? env.timezone : null
     }
   })
     .then(Qajax.filterSuccess)
     .then(Qajax.toJSON)
     .then(
       (res) => {
         return Dataset.fromJS(res.result);
       },
       (xhr: XMLHttpRequest): Dataset => {
         if (!xhr) return null; // This is only here to stop TS complaining
         var jsonError = JSON.parse(xhr.responseText);
         if (jsonError.action === 'reload') reload();
         throw new Error(jsonError.message || jsonError.error);
       }
     );
 };
开发者ID:djfwan,项目名称:pivot,代码行数:25,代码来源:ajax.ts

示例3: fromJS

  static fromJS(parameters: SplitCombineJS, context?: SplitCombineContext): SplitCombine {
    if (typeof parameters === 'string') {
      if (!context) throw new Error('must have context for string split');
      var dimension = context.dimensions.find(d => d.name === parameters);
      if (!dimension) throw new Error(`can not find dimension ${parameters}`);
      return new SplitCombine({
        expression: dimension.expression,
        bucketAction: null,
        sortAction: null,
        limitAction: null
      });
    } else {
      var value: SplitCombineValue = {
        expression: Expression.fromJSLoose(parameters.expression),
        bucketAction: null,
        sortAction: null,
        limitAction: null
      };

      if (parameters.bucketAction) value.bucketAction = Action.fromJS(parameters.bucketAction);
      if (parameters.sortAction) value.sortAction = SortAction.fromJS(parameters.sortAction);
      if (parameters.limitAction) value.limitAction = LimitAction.fromJS(parameters.limitAction);
      return new SplitCombine(value);
    }
  }
开发者ID:RaviNK,项目名称:pivot,代码行数:25,代码来源:split-combine.ts

示例4: fromJS

  static fromJS(parameters: DimensionJS): Dimension {
    var value: DimensionValue = {
      name: parameters.name,
      title: parameters.title,
      expression: parameters.expression ? Expression.fromJSLoose(parameters.expression) : null,
      kind: parameters.kind || typeToKind((parameters as any).type),
      url: parameters.url
    };
    var granularities = parameters.granularities;
    if (granularities) {
      if (!Array.isArray(granularities) || granularities.length !== 5) {
        throw new Error(`must have list of 5 granularities in dimension '${parameters.name}'`);
      }

      var runningActionType: string = null;
      value.granularities = granularities.map((g) => {
        var granularity = granularityFromJS(g);
        if (runningActionType === null) runningActionType = granularity.action;
        if (granularity.action !== runningActionType) throw new Error("granularities must have the same type of actions");
        return granularity;
      });
    }

    return new Dimension(value);
  }
开发者ID:gerencio,项目名称:pivot,代码行数:25,代码来源:dimension.ts

示例5: createJSONServer

  createJSONServer(port, (parameters: JSONParameters, res: any) => {
    var { sql } = parameters;

    try {
      var sqlParse = Expression.parseSQL(sql);
    } catch (e) {
      res.status(400).send({ error: e.message });
      return;
    }

    if (sqlParse.verb && sqlParse.verb !== 'SELECT') { // DESCRIBE + SHOW get re-written
      res.status(400).send({ error: `Unsupported SQL verb ${sqlParse.verb} must be SELECT, DESCRIBE, SHOW, or a raw expression` });
    }

    executeSQLParse(sqlParse, context, timezone)
      .then((value: PlywoodValue) => {
        if (Dataset.isDataset(value)) {
          res.json({
            result: value.toJS()
          });
        } else {
          res.json({
            result: value
          });
        }
      })
      .fail((e) => {
        res.status(400).send({ error: e.message });
      })
      .done();
  });
开发者ID:waltonseymour,项目名称:plyql,代码行数:31,代码来源:plyql-json-server.ts

示例6: fromJS

 static fromJS(parameters: DimensionJS): Dimension {
   return new Dimension({
     name: parameters.name,
     title: parameters.title,
     expression: parameters.expression ? Expression.fromJSLoose(parameters.expression) : null,
     kind: parameters.kind || typeToKind((parameters as any).type)
   });
 }
开发者ID:coconutpalm,项目名称:pivot,代码行数:8,代码来源:dimension.ts

示例7: fromJS

 static fromJS(parameters: DimensionJS): Dimension {
   return new Dimension({
     name: parameters.name,
     title: parameters.title,
     expression: parameters.expression ? Expression.fromJSLoose(parameters.expression) : null,
     type: parameters.type || 'STRING',
     sortOn: parameters.sortOn || null
   });
 }
开发者ID:Ghostubborn,项目名称:pivot,代码行数:9,代码来源:dimension.ts

示例8: getReferences

function getReferences(ex: Expression): string[] {
  var references: string[] = [];
  ex.forEach((ex: Expression) => {
    if (ex instanceof RefExpression) {
      references.push(ex.name);
    }
  });
  return references;
}
开发者ID:coconutpalm,项目名称:pivot,代码行数:9,代码来源:executor.ts

示例9: upperCaseRefs

function upperCaseRefs(expression: Expression): Expression {
  return expression.substitute((ex) => {
    if (ex instanceof RefExpression) {
      var v = ex.valueOf();
      v.name = v.name.toUpperCase();
      return new RefExpression(v);
    }
    return null;
  })
}
开发者ID:baeeq,项目名称:plyql,代码行数:10,代码来源:plyql-executor.ts

示例10: getSplitsDescription

function getSplitsDescription(ex: Expression): string {
  var splits: string[] = [];
  ex.forEach((ex) => {
    if (ex instanceof ChainExpression) {
      ex.actions.forEach((action) => {
        if (action.action === 'split') splits.push(action.expression.toString());
      });
    }
  });
  return splits.join(';');
}
开发者ID:Ghostubborn,项目名称:pivot,代码行数:11,代码来源:executors.ts

示例11: equals

 public equals(other: Dimension): boolean {
   return Dimension.isDimension(other) &&
     this.name === other.name &&
     this.title === other.title &&
     this.expression.equals(other.expression) &&
     this.kind === other.kind;
 }
开发者ID:coconutpalm,项目名称:pivot,代码行数:7,代码来源:dimension.ts

示例12: toJS

 public toJS(): DimensionJS {
   return {
     name: this.name,
     title: this.title,
     expression: this.expression.toJS(),
     kind: this.kind
   };
 }
开发者ID:coconutpalm,项目名称:pivot,代码行数:8,代码来源:dimension.ts

示例13: equals

 public equals(other: Dimension): boolean {
   return Dimension.isDimension(other) &&
     this.name === other.name &&
     this.title === other.title &&
     this.expression.equals(other.expression) &&
     this.type === other.type &&
     this.sortOn === other.sortOn;
 }
开发者ID:Ghostubborn,项目名称:pivot,代码行数:8,代码来源:dimension.ts

示例14: toJS

 public toJS(): SplitCombineJS {
   var js: SplitCombineJSFull = {
     expression: this.expression.toJS()
   };
   if (this.bucketAction) js.bucketAction = this.bucketAction.toJS();
   if (this.sortAction) js.sortAction = this.sortAction.toJS();
   if (this.limitAction) js.limitAction = this.limitAction.toJS();
   return js;
 }
开发者ID:RaviNK,项目名称:pivot,代码行数:9,代码来源:split-combine.ts

示例15: equals

 public equals(other: Dimension): boolean {
   return Dimension.isDimension(other) &&
     this.name === other.name &&
     this.title === other.title &&
     this.expression.equals(other.expression) &&
     this.kind === other.kind &&
     this.url === other.url &&
     immutableArraysEqual(this.granularities, other.granularities);
 }
开发者ID:gerencio,项目名称:pivot,代码行数:9,代码来源:dimension.ts


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