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


TypeScript Expression.fromJSLoose方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: createJSONServer

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

    var resultPromise: Q.Promise<PlywoodValue>;

    if (expression) {
      try {
        var ex = Expression.fromJSLoose(expression);
      } catch (e) {
        res.status(400).send({ error: e.message });
        return;
      }

      resultPromise = executePlywood(ex, context, timezone);
    } else {
      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` });
        return;
      }

      resultPromise = executeSQLParse(sqlParse, context, timezone);
    }

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


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