aboutsummaryrefslogtreecommitdiff
path: root/src/client/northstar/core/attribute
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2020-04-07 23:01:46 -0400
committerBob Zeleznik <zzzman@gmail.com>2020-04-07 23:01:46 -0400
commite262d9ac73af5b2cef384468c47d69917e205d44 (patch)
tree4b563896d93febb233e7bffc2a292af4097136b3 /src/client/northstar/core/attribute
parent52ad8b3874419a76e6953c3bd698d9e68a3158a6 (diff)
lots of code cleanup - removed all northstar db stuff. added scriptingBox. renamed things. made collectiontypes strings not numbers.
Diffstat (limited to 'src/client/northstar/core/attribute')
-rw-r--r--src/client/northstar/core/attribute/AttributeModel.ts111
-rw-r--r--src/client/northstar/core/attribute/AttributeTransformationModel.ts52
-rw-r--r--src/client/northstar/core/attribute/CalculatedAttributeModel.ts42
3 files changed, 0 insertions, 205 deletions
diff --git a/src/client/northstar/core/attribute/AttributeModel.ts b/src/client/northstar/core/attribute/AttributeModel.ts
deleted file mode 100644
index c89b1617c..000000000
--- a/src/client/northstar/core/attribute/AttributeModel.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import { Attribute, DataType, VisualizationHint } from '../../model/idea/idea';
-import { BaseObject } from '../BaseObject';
-import { observable } from "mobx";
-
-export abstract class AttributeModel extends BaseObject {
- public abstract get DisplayName(): string;
- public abstract get CodeName(): string;
- public abstract get DataType(): DataType;
- public abstract get VisualizationHints(): VisualizationHint[];
-}
-
-export class ColumnAttributeModel extends AttributeModel {
- public Attribute: Attribute;
-
- constructor(attribute: Attribute) {
- super();
- this.Attribute = attribute;
- }
-
- public get DataType(): DataType {
- return this.Attribute.dataType ? this.Attribute.dataType : DataType.Undefined;
- }
-
- public get DisplayName(): string {
- return this.Attribute.displayName ? this.Attribute.displayName.ReplaceAll("_", " ") : "";
- }
-
- public get CodeName(): string {
- return this.Attribute.rawName ? this.Attribute.rawName : "";
- }
-
- public get VisualizationHints(): VisualizationHint[] {
- return this.Attribute.visualizationHints ? this.Attribute.visualizationHints : [];
- }
-
- public Equals(other: ColumnAttributeModel): boolean {
- return this.Attribute.rawName === other.Attribute.rawName;
- }
-}
-
-export class CodeAttributeModel extends AttributeModel {
- private _visualizationHints: VisualizationHint[];
-
- public CodeName: string;
-
- @observable
- public Code: string;
-
- constructor(code: string, codeName: string, displayName: string, visualizationHints: VisualizationHint[]) {
- super();
- this.Code = code;
- this.CodeName = codeName;
- this.DisplayName = displayName;
- this._visualizationHints = visualizationHints;
- }
-
- public get DataType(): DataType {
- return DataType.Undefined;
- }
-
- @observable
- public DisplayName: string;
-
- public get VisualizationHints(): VisualizationHint[] {
- return this._visualizationHints;
- }
-
- public Equals(other: CodeAttributeModel): boolean {
- return this.CodeName === other.CodeName;
- }
-
-}
-
-export class BackendAttributeModel extends AttributeModel {
- private _dataType: DataType;
- private _displayName: string;
- private _codeName: string;
- private _visualizationHints: VisualizationHint[];
-
- public Id: string;
-
- constructor(id: string, dataType: DataType, displayName: string, codeName: string, visualizationHints: VisualizationHint[]) {
- super();
- this.Id = id;
- this._dataType = dataType;
- this._displayName = displayName;
- this._codeName = codeName;
- this._visualizationHints = visualizationHints;
- }
-
- public get DataType(): DataType {
- return this._dataType;
- }
-
- public get DisplayName(): string {
- return this._displayName.ReplaceAll("_", " ");
- }
-
- public get CodeName(): string {
- return this._codeName;
- }
-
- public get VisualizationHints(): VisualizationHint[] {
- return this._visualizationHints;
- }
-
- public Equals(other: BackendAttributeModel): boolean {
- return this.Id === other.Id;
- }
-
-} \ No newline at end of file
diff --git a/src/client/northstar/core/attribute/AttributeTransformationModel.ts b/src/client/northstar/core/attribute/AttributeTransformationModel.ts
deleted file mode 100644
index 66485183b..000000000
--- a/src/client/northstar/core/attribute/AttributeTransformationModel.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-
-import { computed, observable } from "mobx";
-import { AggregateFunction } from "../../model/idea/idea";
-import { AttributeModel } from "./AttributeModel";
-import { IEquatable } from "../../utils/IEquatable";
-
-export class AttributeTransformationModel implements IEquatable {
-
- @observable public AggregateFunction: AggregateFunction;
- @observable public AttributeModel: AttributeModel;
-
- constructor(attributeModel: AttributeModel, aggregateFunction: AggregateFunction = AggregateFunction.None) {
- this.AttributeModel = attributeModel;
- this.AggregateFunction = aggregateFunction;
- }
-
- @computed
- public get PresentedName(): string {
- var displayName = this.AttributeModel.DisplayName;
- if (this.AggregateFunction === AggregateFunction.Count) {
- return "count";
- }
- if (this.AggregateFunction === AggregateFunction.Avg) {
- displayName = "avg(" + displayName + ")";
- }
- else if (this.AggregateFunction === AggregateFunction.Max) {
- displayName = "max(" + displayName + ")";
- }
- else if (this.AggregateFunction === AggregateFunction.Min) {
- displayName = "min(" + displayName + ")";
- }
- else if (this.AggregateFunction === AggregateFunction.Sum) {
- displayName = "sum(" + displayName + ")";
- }
- else if (this.AggregateFunction === AggregateFunction.SumE) {
- displayName = "sumE(" + displayName + ")";
- }
-
- return displayName;
- }
-
- public clone(): AttributeTransformationModel {
- var clone = new AttributeTransformationModel(this.AttributeModel);
- clone.AggregateFunction = this.AggregateFunction;
- return clone;
- }
-
- public Equals(other: AttributeTransformationModel): boolean {
- return this.AggregateFunction === other.AggregateFunction &&
- this.AttributeModel.Equals(other.AttributeModel);
- }
-} \ No newline at end of file
diff --git a/src/client/northstar/core/attribute/CalculatedAttributeModel.ts b/src/client/northstar/core/attribute/CalculatedAttributeModel.ts
deleted file mode 100644
index a197c1305..000000000
--- a/src/client/northstar/core/attribute/CalculatedAttributeModel.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { BackendAttributeModel, AttributeModel, CodeAttributeModel } from "./AttributeModel";
-import { DataType, VisualizationHint } from '../../model/idea/idea';
-
-export class CalculatedAttributeManager {
- public static AllCalculatedAttributes: Array<AttributeModel> = new Array<AttributeModel>();
-
- public static Clear() {
- this.AllCalculatedAttributes = new Array<AttributeModel>();
- }
-
- public static CreateBackendAttributeModel(id: string, dataType: DataType, displayName: string, codeName: string, visualizationHints: VisualizationHint[]): BackendAttributeModel {
- var filtered = this.AllCalculatedAttributes.filter(am => {
- if (am instanceof BackendAttributeModel &&
- am.Id === id) {
- return true;
- }
- return false;
- });
- if (filtered.length > 0) {
- return filtered[0] as BackendAttributeModel;
- }
- var newAttr = new BackendAttributeModel(id, dataType, displayName, codeName, visualizationHints);
- this.AllCalculatedAttributes.push(newAttr);
- return newAttr;
- }
-
- public static CreateCodeAttributeModel(code: string, codeName: string, visualizationHints: VisualizationHint[]): CodeAttributeModel {
- var filtered = this.AllCalculatedAttributes.filter(am => {
- if (am instanceof CodeAttributeModel &&
- am.CodeName === codeName) {
- return true;
- }
- return false;
- });
- if (filtered.length > 0) {
- return filtered[0] as CodeAttributeModel;
- }
- var newAttr = new CodeAttributeModel(code, codeName, codeName.ReplaceAll("_", " "), visualizationHints);
- this.AllCalculatedAttributes.push(newAttr);
- return newAttr;
- }
-} \ No newline at end of file