Commit 1161b209 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add entry for development method

parent 41775b80
......@@ -56,7 +56,7 @@ export class AppComponent {
(method) => new DevelopmentMethod(method)
);
const out = methods.map((method) => method.toDb());
out.forEach((method) => delete method._rev);
out.forEach((method) => delete (method as DatabaseMeta)._rev);
console.log(out);
}
......
import { Equality } from '../../shared/equality';
import { DatabaseModelPart } from '../../database/database-model-part';
import { DatabaseEntry } from '../../database/database-entry';
export interface ArtifactMappingEntry extends DatabaseEntry {
output: boolean;
step?: number;
group?: number;
artifact: number;
}
export class ArtifactMapping
implements Equality<ArtifactMapping>, DatabaseModelPart
......@@ -13,8 +21,9 @@ export class ArtifactMapping
Object.assign(this, artifactMapping);
}
toDb(): any {
const pouchDb: any = {
toDb(): ArtifactMappingEntry {
const pouchDb: ArtifactMappingEntry = {
artifact: this.artifact,
output: this.output,
};
if (!this.output) {
......@@ -22,7 +31,6 @@ export class ArtifactMapping
} else {
pouchDb.group = this.group;
}
pouchDb.artifact = this.artifact;
return pouchDb;
}
......
import { DatabaseModel } from '../../database/database-model';
import { Author } from '../../model/author';
import { SituationalFactor } from '../method-elements/situational-factor/situational-factor';
import { Artifact } from '../method-elements/artifact/artifact';
import { Type } from '../method-elements/type/type';
import { Stakeholder } from '../method-elements/stakeholder/stakeholder';
import { Tool } from '../method-elements/tool/tool';
import { MultipleSelection } from './multiple-selection';
import { ExecutionStep } from './execution-step';
import { MultipleMappingSelection } from './multiple-mapping-selection';
import { Selection } from './selection';
import { Author, AuthorEntry } from '../../model/author';
import {
SituationalFactor,
SituationalFactorEntry,
} from '../method-elements/situational-factor/situational-factor';
import { Artifact, ArtifactEntry } from '../method-elements/artifact/artifact';
import { Type, TypeEntry } from '../method-elements/type/type';
import {
Stakeholder,
StakeholderEntry,
} from '../method-elements/stakeholder/stakeholder';
import { Tool, ToolEntry } from '../method-elements/tool/tool';
import {
MultipleSelection,
MultipleSelectionEntry,
} from './multiple-selection';
import { ExecutionStep, ExecutionStepEntry } from './execution-step';
import {
MultipleMappingSelection,
MultipleMappingSelectionEntry,
} from './multiple-mapping-selection';
import { Selection, SelectionEntry } from './selection';
import { DatabaseRootEntry } from '../../database/database-entry';
export interface DevelopmentMethodEntry extends DatabaseRootEntry {
name: string;
description: string;
examples: string[];
author: AuthorEntry;
types: SelectionEntry<TypeEntry>[];
situationalFactors: SelectionEntry<SituationalFactorEntry>[];
inputArtifacts: MultipleMappingSelectionEntry<ArtifactEntry>[][];
outputArtifacts: MultipleSelectionEntry<ArtifactEntry>[][];
stakeholders: MultipleSelectionEntry<StakeholderEntry>[][];
tools: MultipleSelectionEntry<ToolEntry>[][];
executionSteps: ExecutionStepEntry[];
}
export class DevelopmentMethod extends DatabaseModel {
static readonly typeName = 'DevelopmentMethod';
......@@ -38,7 +68,7 @@ export class DevelopmentMethod extends DatabaseModel {
*
* @param developmentMethod the new values of this development method (values will be copied to the current object)
*/
update(developmentMethod: Partial<DevelopmentMethod>) {
update(developmentMethod: Partial<DevelopmentMethod>): void {
Object.assign(this, developmentMethod);
this.author = new Author(this.author);
this.types = this.types.map(
......@@ -154,7 +184,7 @@ export class DevelopmentMethod extends DatabaseModel {
return tools;
}
toDb(): any {
toDb(): DevelopmentMethodEntry {
return {
...super.toDb(),
name: this.name,
......
import { ArtifactMapping } from './artifact-mapping';
import { ArtifactMapping, ArtifactMappingEntry } from './artifact-mapping';
import { Equality } from '../../shared/equality';
import { equalsListOfLists } from '../../shared/utils';
import { DatabaseModelPart } from '../../database/database-model-part';
import { DatabaseEntry } from '../../database/database-entry';
export interface ExecutionStepEntry extends DatabaseEntry {
module: string;
method: string;
predefinedInput: any;
outputMappings: ArtifactMappingEntry[][];
}
export class ExecutionStep
implements Equality<ExecutionStep>, DatabaseModelPart
......@@ -18,7 +26,7 @@ export class ExecutionStep
);
}
toDb(): any {
toDb(): ExecutionStepEntry {
return {
module: this.module,
method: this.method,
......
import { MultipleSelection } from './multiple-selection';
import { MethodElement } from '../method-elements/method-element';
import { ArtifactMapping } from './artifact-mapping';
import {
MultipleSelection,
MultipleSelectionEntry,
} from './multiple-selection';
import {
MethodElement,
MethodElementEntry,
} from '../method-elements/method-element';
import { ArtifactMapping, ArtifactMappingEntry } from './artifact-mapping';
import { equalsList } from '../../shared/utils';
export interface MultipleMappingSelectionEntry<T extends MethodElementEntry>
extends MultipleSelectionEntry<T> {
mapping: ArtifactMappingEntry[];
}
export class MultipleMappingSelection<
T extends MethodElement
> extends MultipleSelection<T> {
......@@ -18,14 +29,14 @@ export class MultipleMappingSelection<
update(
selection: MultipleMappingSelection<T>,
createElement: (element: Partial<T>) => T
) {
): void {
this.mapping = [];
super.update(selection, createElement);
this.element = this.element ? createElement(this.element) : null;
this.mapping = this.mapping.map((mapping) => new ArtifactMapping(mapping));
}
toDb(): any {
toDb(): MultipleMappingSelectionEntry<ReturnType<T['toDb']>> {
return {
...super.toDb(),
mapping: this.mapping.map((mapping) => mapping.toDb()),
......
import { MethodElement } from '../method-elements/method-element';
import {
MethodElement,
MethodElementEntry,
} from '../method-elements/method-element';
import { Equality } from '../../shared/equality';
import { DatabaseModelPart } from '../../database/database-model-part';
import { DatabaseEntry } from '../../database/database-entry';
export interface MultipleSelectionEntry<T extends MethodElementEntry>
extends DatabaseEntry {
list: string;
element: T;
multiple: boolean;
multipleElements: boolean;
}
export class MultipleSelection<T extends MethodElement>
implements Equality<MultipleSelection<T>>, DatabaseModelPart
......@@ -20,15 +32,17 @@ export class MultipleSelection<T extends MethodElement>
update(
selection: MultipleSelection<T>,
createElement: (element: Partial<T>) => T
) {
): void {
Object.assign(this, selection);
this.element = this.element ? createElement(this.element) : null;
}
toDb(): any {
toDb(): MultipleSelectionEntry<ReturnType<T['toDb']>> {
return {
list: this.list,
element: this.element ? this.element.toDb() : null,
element: this.element
? (this.element.toDb() as ReturnType<T['toDb']>)
: null,
multiple: this.multiple,
multipleElements: this.multipleElements,
};
......
import { Equality } from '../../shared/equality';
import { DatabaseModelPart } from '../../database/database-model-part';
import { DatabaseEntry } from '../../database/database-entry';
export interface SelectionEntry<T extends DatabaseEntry> extends DatabaseEntry {
list: string;
element: T;
}
export class Selection<T extends DatabaseModelPart & Equality<T>>
implements Equality<Selection<T>>, DatabaseModelPart
......@@ -14,15 +20,20 @@ export class Selection<T extends DatabaseModelPart & Equality<T>>
this.update(selection, createElement);
}
update(selection: Selection<T>, createElement: (element: Partial<T>) => T) {
update(
selection: Selection<T>,
createElement: (element: Partial<T>) => T
): void {
Object.assign(this, selection);
this.element = this.element ? createElement(this.element) : null;
}
toDb(): any {
toDb(): SelectionEntry<ReturnType<T['toDb']>> {
return {
list: this.list,
element: this.element ? this.element.toDb() : null,
element: this.element
? (this.element.toDb() as ReturnType<T['toDb']>)
: null,
};
}
......
Supports Markdown
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