Commit cedb4e56 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Rename toPouchDb to toDb

parent 131bcced
Pipeline #138007 failed with stages
in 10 minutes and 35 seconds
......@@ -51,7 +51,7 @@ export class AppComponent {
const methods = (await this.developmentMethodService.getList()).docs.map(
(method) => new DevelopmentMethod(method)
);
const out = methods.map((method) => method.toPouchDb());
const out = methods.map((method) => method.toDb());
out.forEach((method) => delete method._rev);
console.log(out);
}
......@@ -60,7 +60,7 @@ export class AppComponent {
const processes = (await this.bmProcessService.getList()).docs.map(
(process) => new BmProcess(process)
);
const out = processes.map((process) => process.toPouchDb());
const out = processes.map((process) => process.toDb());
out.forEach((process) => delete process._rev);
console.log(out);
}
......@@ -69,7 +69,7 @@ export class AppComponent {
const processes = (await this.runningProcessService.getList()).docs.map(
(process) => new RunningProcess(process)
);
const out = processes.map((process) => process.toPouchDb());
const out = processes.map((process) => process.toDb());
out.forEach((process) => delete process._rev);
console.log(out);
}
......@@ -78,7 +78,7 @@ export class AppComponent {
const models = (await this.expertModelService.getList()).docs.map(
(model) => new ExpertModel(model)
);
const out = models.map((model) => model.toPouchDb());
const out = models.map((model) => model.toDb());
out.forEach((model) => delete model._rev);
console.log(out);
}
......@@ -87,7 +87,7 @@ export class AppComponent {
const models = (await this.companyModelService.getAll()).docs.map(
(model) => new CompanyModel(model)
);
const out = models.map((model) => model.toPouchDb());
const out = models.map((model) => model.toDb());
out.forEach((model) => delete model._rev);
console.log(out);
}
......@@ -96,7 +96,7 @@ export class AppComponent {
const models = (await this.domainService.getList()).docs.map(
(domain) => new Domain(domain)
);
const out = models.map((domain) => domain.toPouchDb());
const out = models.map((domain) => domain.toDb());
out.forEach((domain) => delete domain._rev);
console.log(out);
}
......
......@@ -14,7 +14,7 @@ export class CanvasDefinitionCell
Object.assign(this, canvasDefinitionCell);
}
toPouchDb(): any {
toDb(): any {
return {
isSpacer: this.isSpacer,
id: this.id,
......
......@@ -56,9 +56,9 @@ export class CanvasDefinition extends PouchdbModel {
return rootFeatures;
}
toPouchDb(): any {
toDb(): any {
return {
...super.toPouchDb(),
...super.toDb(),
name: this.name,
rows: this.rows,
};
......@@ -67,7 +67,7 @@ export class CanvasDefinition extends PouchdbModel {
toJSON() {
return {
name: this.name,
rows: this.rows.map((row) => row.map((cell) => cell.toPouchDb())),
rows: this.rows.map((row) => row.map((cell) => cell.toDb())),
};
}
}
......@@ -229,13 +229,13 @@ export class CompanyModel extends FeatureModel {
return Object.keys(this.expertModelTraces);
}
toPouchDb(): any {
toDb(): any {
const expertModelTraces = {};
Object.entries(this.expertModelTraces).forEach(
([id, trace]) => (expertModelTraces[id] = trace.toPouchDb())
([id, trace]) => (expertModelTraces[id] = trace.toDb())
);
return {
...super.toPouchDb(),
...super.toDb(),
expertModelTraces,
createdByMethod: this.createdByMethod,
};
......
......@@ -41,10 +41,10 @@ export class ExpertModel extends FeatureModel {
);
}
toPouchDb(): any {
toDb(): any {
return {
...super.toPouchDb(),
domains: this.domains.map((domain) => domain.toPouchDb()),
...super.toDb(),
domains: this.domains.map((domain) => domain.toDb()),
version: this.version,
};
}
......
......@@ -336,21 +336,21 @@ export class FeatureModel extends PouchdbModel {
// Export
toPouchDb(): any {
toDb(): any {
const features = {};
Object.entries(this.features).forEach(
([id, feature]) => (features[id] = feature.toPouchDb())
([id, feature]) => (features[id] = feature.toDb())
);
return {
...super.toPouchDb(),
...super.toDb(),
name: this.name,
description: this.description,
copyright: this.copyright,
author: this.author.toPouchDb(),
author: this.author.toDb(),
features,
instances: this.instances.map((instance) => instance.toPouchDb()),
instances: this.instances.map((instance) => instance.toDb()),
nextInstanceId: this.nextInstanceId,
$definition: this.$definition ? this.$definition.toPouchDb() : null,
$definition: this.$definition ? this.$definition.toDb() : null,
};
}
......
import { Relationships, RelationshipType } from './relationships';
import { PouchdbModelPart } from '../database/pouchdb-model-part';
export enum FeatureType {
OPTIONAL = 'optional',
......@@ -10,7 +11,7 @@ export enum SubfeatureConnectionsType {
XOR = 'xor',
}
export class Feature {
export class Feature implements PouchdbModelPart {
// JSON Schema (stored)
name: string;
description: string;
......@@ -170,10 +171,10 @@ export class Feature {
// Export
toPouchDb(): any {
toDb(): any {
const subfeatures = {};
Object.entries(this.subfeatures).forEach(
([id, feature]) => (subfeatures[id] = feature.toPouchDb())
([id, feature]) => (subfeatures[id] = feature.toDb())
);
return {
name: this.name,
......@@ -181,7 +182,7 @@ export class Feature {
type: this.type,
subfeatures,
subfeatureConnections: this.subfeatureConnections,
relationships: this.relationships.toPouchDb(),
relationships: this.relationships.toDb(),
expertModelTrace: this.expertModelTrace,
};
}
......
import { PouchdbModelPart } from '../database/pouchdb-model-part';
export enum InstanceType {
PATTERN = 'pattern',
EXAMPLE = 'example',
}
export class Instance {
export class Instance implements PouchdbModelPart {
// JSON Schema (stored)
name: string;
type: InstanceType;
......@@ -71,7 +73,7 @@ export class Instance {
// Export
toPouchDb(): any {
toDb(): any {
return {
id: this.id,
name: this.name,
......
import { PouchdbModelPart } from '../database/pouchdb-model-part';
export enum RelationshipType {
REQUIRES = 'requires',
EXCLUDES = 'excludes',
......@@ -5,7 +7,7 @@ export enum RelationshipType {
HURTS = 'hurts',
}
export class Relationships {
export class Relationships implements PouchdbModelPart {
// JSON Schema (stored)
requires: string[] = [];
excludes: string[] = [];
......@@ -110,7 +112,7 @@ export class Relationships {
// Export
toPouchDb(): any {
toDb(): any {
return {
requires: this.requires,
excludes: this.excludes,
......
export class Trace {
import { PouchdbModelPart } from '../database/pouchdb-model-part';
export class Trace implements PouchdbModelPart {
// stored
expertFeatureIdMap: { [expertModelFeatureId: string]: string } = {};
......@@ -14,7 +16,7 @@ export class Trace {
delete this.expertFeatureIdMap[expertFeatureId];
}
toPouchDb(): any {
toDb(): any {
return {
expertFeatureIdMap: this.expertFeatureIdMap,
};
......
......@@ -66,7 +66,7 @@ export class CreateCanvasConfigurationComponent
model,
canvasDefinition
);
await this.companyModelService.add(companyModel.toPouchDb());
await this.companyModelService.add(companyModel.toDb());
this.forceUpdate.emit({
companyModelId: companyModel._id,
automaticCreation: true,
......
......@@ -41,7 +41,7 @@ export class ExpertModelsComponent {
{ name, description },
definition
);
await this.listService.add(expertModel.toPouchDb());
await this.listService.add(expertModel.toDb());
this.modelList.resetAddForm();
}
......
export interface PouchdbModelPart {
toPouchDb(): any;
toDb(): any;
}
......@@ -11,7 +11,7 @@ export class PouchdbModel implements PouchdbModelPart, Equality<PouchdbModel> {
this.type = type;
}
toPouchDb(): any {
toDb(): any {
if (!this._id) {
this._id = String(Date.now());
}
......
......@@ -113,15 +113,11 @@ export class PouchdbService {
}
post<T extends PouchdbModel>(model: T) {
return this.db
.post(model.toPouchDb())
.catch((error) => this.handleError(error));
return this.db.post(model.toDb()).catch((error) => this.handleError(error));
}
put<T extends PouchdbModel>(model: T) {
return this.db
.put(model.toPouchDb())
.catch((error) => this.handleError(error));
return this.db.put(model.toDb()).catch((error) => this.handleError(error));
}
remove<T extends PouchdbModel>(model: T) {
......
......@@ -120,19 +120,19 @@ export class BmProcess extends PouchdbModel {
delete this.decisions[id];
}
toPouchDb(): any {
toDb(): any {
const decisions: { [elementId: string]: Decision } = {};
Object.entries(this.decisions).forEach(([id, decision]) => {
decisions[id] = decision.toPouchDb();
decisions[id] = decision.toDb();
});
return {
...super.toPouchDb(),
...super.toDb(),
initial: this.initial,
name: this.name,
processDiagram: this.processDiagram,
domains: this.domains.map((domain) => domain.toPouchDb()),
domains: this.domains.map((domain) => domain.toDb()),
situationalFactors: this.situationalFactors.map((selection) =>
selection.toPouchDb()
selection.toDb()
),
decisions,
};
......
......@@ -6,6 +6,7 @@ import { MethodElement } from '../method-elements/method-element';
import { MultipleSelection } from '../development-method/multiple-selection';
import { Equality } from '../../shared/equality';
import { equalsList } from '../../shared/utils';
import { PouchdbModelPart } from '../../database/pouchdb-model-part';
export class GroupSummary<T extends MethodElement> {
elements: {
......@@ -17,7 +18,7 @@ export class GroupSummary<T extends MethodElement> {
}
export class GroupSelection<T extends MethodElement>
implements Equality<GroupSelection<T>>
implements Equality<GroupSelection<T>>, PouchdbModelPart
{
selectedGroup: number = null;
elements: T[][] = null;
......@@ -82,12 +83,12 @@ export class GroupSelection<T extends MethodElement>
return summary;
}
toPouchDb(): any {
toDb(): any {
return {
selectedGroup: this.selectedGroup,
elements: this.elements
? this.elements.map((element) =>
element ? element.map((e) => (e ? e.toPouchDb() : null)) : null
element ? element.map((e) => (e ? e.toDb() : null)) : null
)
: null,
};
......@@ -120,7 +121,7 @@ export class GroupSelection<T extends MethodElement>
}
}
export class Decision {
export class Decision implements PouchdbModelPart {
method: DevelopmentMethod;
inputArtifacts: GroupSelection<Artifact>;
outputArtifacts: GroupSelection<Artifact>;
......@@ -176,13 +177,13 @@ export class Decision {
};
}
toPouchDb(): any {
toDb(): any {
return {
method: this.method.toPouchDb(),
inputArtifacts: this.inputArtifacts.toPouchDb(),
outputArtifacts: this.outputArtifacts.toPouchDb(),
stakeholders: this.stakeholders.toPouchDb(),
tools: this.tools.toPouchDb(),
method: this.method.toDb(),
inputArtifacts: this.inputArtifacts.toDb(),
outputArtifacts: this.outputArtifacts.toDb(),
stakeholders: this.stakeholders.toDb(),
tools: this.tools.toDb(),
stepDecisions: this.stepDecisions,
};
}
......
import { Equality } from '../../shared/equality';
import { PouchdbModelPart } from '../../database/pouchdb-model-part';
export class ArtifactMapping implements Equality<ArtifactMapping> {
export class ArtifactMapping
implements Equality<ArtifactMapping>, PouchdbModelPart
{
output: boolean;
step?: number;
group?: number;
......@@ -10,7 +13,7 @@ export class ArtifactMapping implements Equality<ArtifactMapping> {
Object.assign(this, artifactMapping);
}
toPouchDb(): any {
toDb(): any {
const pouchDb: any = {
output: this.output,
};
......
......@@ -154,28 +154,28 @@ export class DevelopmentMethod extends PouchdbModel {
return tools;
}
toPouchDb(): any {
toDb(): any {
return {
...super.toPouchDb(),
...super.toDb(),
name: this.name,
description: this.description,
examples: this.examples,
author: this.author.toPouchDb(),
types: this.types.map((type) => type.toPouchDb()),
author: this.author.toDb(),
types: this.types.map((type) => type.toDb()),
situationalFactors: this.situationalFactors.map((factor) =>
factor.toPouchDb()
factor.toDb()
),
inputArtifacts: this.inputArtifacts.map((group) =>
group.map((artifact) => artifact.toPouchDb())
group.map((artifact) => artifact.toDb())
),
outputArtifacts: this.outputArtifacts.map((group) =>
group.map((artifact) => artifact.toPouchDb())
group.map((artifact) => artifact.toDb())
),
stakeholders: this.stakeholders.map((group) =>
group.map((element) => element.toPouchDb())
group.map((element) => element.toDb())
),
tools: this.tools.map((group) => group.map((tool) => tool.toPouchDb())),
executionSteps: this.executionSteps.map((step) => step.toPouchDb()),
tools: this.tools.map((group) => group.map((tool) => tool.toDb())),
executionSteps: this.executionSteps.map((step) => step.toDb()),
};
}
}
import { ArtifactMapping } from './artifact-mapping';
import { Equality } from '../../shared/equality';
import { equalsListOfLists } from '../../shared/utils';
import { PouchdbModelPart } from '../../database/pouchdb-model-part';
export class ExecutionStep implements Equality<ExecutionStep> {
export class ExecutionStep
implements Equality<ExecutionStep>, PouchdbModelPart
{
module: string;
method: string;
predefinedInput: any;
......@@ -15,13 +18,13 @@ export class ExecutionStep implements Equality<ExecutionStep> {
);
}
toPouchDb(): any {
toDb(): any {
return {
module: this.module,
method: this.method,
predefinedInput: this.predefinedInput,
outputMappings: this.outputMappings.map((mappings) =>
mappings.map((mapping) => mapping.toPouchDb())
mappings.map((mapping) => mapping.toDb())
),
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment