當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。