Commit 648e2ef0 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Rename PouchdbModel, PouchdbModelPart

parent cedb4e56
Pipeline #138008 failed with stages
in 10 minutes and 36 seconds
import { PouchdbModelPart } from '../database/pouchdb-model-part';
import { DatabaseModelPart } from '../database/database-model-part';
import { Equality } from '../shared/equality';
export class CanvasDefinitionCell
implements PouchdbModelPart, Equality<CanvasDefinitionCell>
implements DatabaseModelPart, Equality<CanvasDefinitionCell>
{
isSpacer: boolean;
id?: string;
......
import { Feature } from './feature';
import { PouchdbModel } from '../database/pouchdb-model';
import { DatabaseModel } from '../database/database-model';
import { CanvasDefinitionCell } from './canvas-definition-cell';
import { getId } from '../model/utils';
export class CanvasDefinition extends PouchdbModel {
export class CanvasDefinition extends DatabaseModel {
static readonly typeName = 'CanvasDefinition';
name: string;
......
import { PouchdbModel } from '../database/pouchdb-model';
import { DatabaseModel } from '../database/database-model';
import { Author } from '../model/author';
import { Feature } from './feature';
import { Instance } from './instance';
......@@ -6,7 +6,7 @@ import { RelationshipType } from './relationships';
import { getId } from '../model/utils';
import { CanvasDefinition } from './canvas-definition';
export class FeatureModel extends PouchdbModel {
export class FeatureModel extends DatabaseModel {
// JSON Schema (stored)
name: string;
description: string;
......
import { Relationships, RelationshipType } from './relationships';
import { PouchdbModelPart } from '../database/pouchdb-model-part';
import { DatabaseModelPart } from '../database/database-model-part';
export enum FeatureType {
OPTIONAL = 'optional',
......@@ -11,7 +11,7 @@ export enum SubfeatureConnectionsType {
XOR = 'xor',
}
export class Feature implements PouchdbModelPart {
export class Feature implements DatabaseModelPart {
// JSON Schema (stored)
name: string;
description: string;
......
import { PouchdbModelPart } from '../database/pouchdb-model-part';
import { DatabaseModelPart } from '../database/database-model-part';
export enum InstanceType {
PATTERN = 'pattern',
EXAMPLE = 'example',
}
export class Instance implements PouchdbModelPart {
export class Instance implements DatabaseModelPart {
// JSON Schema (stored)
name: string;
type: InstanceType;
......
import { PouchdbModelPart } from '../database/pouchdb-model-part';
import { DatabaseModelPart } from '../database/database-model-part';
export enum RelationshipType {
REQUIRES = 'requires',
......@@ -7,7 +7,7 @@ export enum RelationshipType {
HURTS = 'hurts',
}
export class Relationships implements PouchdbModelPart {
export class Relationships implements DatabaseModelPart {
// JSON Schema (stored)
requires: string[] = [];
excludes: string[] = [];
......
import { PouchdbModelPart } from '../database/pouchdb-model-part';
import { DatabaseModelPart } from '../database/database-model-part';
export class Trace implements PouchdbModelPart {
export class Trace implements DatabaseModelPart {
// stored
expertFeatureIdMap: { [expertModelFeatureId: string]: string } = {};
......
export interface PouchdbModelPart {
export interface DatabaseModelPart {
toDb(): any;
}
import { PouchdbModelPart } from './pouchdb-model-part';
import { DatabaseModelPart } from './database-model-part';
import { Equality } from '../shared/equality';
export class PouchdbModel implements PouchdbModelPart, Equality<PouchdbModel> {
export class DatabaseModel
implements DatabaseModelPart, Equality<DatabaseModel>
{
_id: string;
_rev: string;
......@@ -36,7 +38,7 @@ export class PouchdbModel implements PouchdbModelPart, Equality<PouchdbModel> {
* @param other the other pouchdb model
* @return true if the id and revision are equal
*/
equals(other: PouchdbModel): boolean {
equals(other: DatabaseModel): boolean {
if (other == null) {
return false;
}
......
......@@ -3,10 +3,10 @@ import { PouchdbService } from './pouchdb.service';
import { Observable } from 'rxjs';
import PouchDB from 'pouchdb-browser';
import { ElementService } from './element.service';
import { PouchdbModel } from './pouchdb-model';
import { DatabaseModel } from './database-model';
@Injectable()
export abstract class DefaultElementService<T extends PouchdbModel>
export abstract class DefaultElementService<T extends DatabaseModel>
implements ElementService<T>
{
protected abstract get typeName(): string;
......
import { PouchdbModel } from './pouchdb-model';
import { DatabaseModel } from './database-model';
import { Observable } from 'rxjs';
export interface ElementService<T extends PouchdbModel> {
export interface ElementService<T extends DatabaseModel> {
/**
* Get a list of all elements of this type in the database
*/
......
import { Injectable, NgZone } from '@angular/core';
import PouchDB from 'pouchdb-browser';
import PouchDBFind from 'pouchdb-find';
import { PouchdbModel } from './pouchdb-model';
import { DatabaseModel } from './database-model';
import examples from '../../examples';
import { from, Observable, Subject } from 'rxjs';
import { catchError, finalize } from 'rxjs/operators';
......@@ -14,7 +14,7 @@ export enum DatabaseErrors {
@Injectable()
export class PouchdbService {
private db: PouchDB.Database<PouchdbModel> = null;
private db: PouchDB.Database<DatabaseModel> = null;
private expired: () => Promise<void> = null;
private error: () => Promise<void> = null;
......@@ -45,7 +45,7 @@ export class PouchdbService {
*
* @param name the name of the database
*/
private getDatabase(name: string): PouchDB.Database<PouchdbModel> {
private getDatabase(name: string): PouchDB.Database<DatabaseModel> {
if (name == null) {
throw new Error(DatabaseErrors.MISSING_NAME);
}
......@@ -53,7 +53,7 @@ export class PouchdbService {
throw new Error(DatabaseErrors.INVALID_NAME);
}
if (environment.localDatabase) {
return new PouchDB<PouchdbModel>(name);
return new PouchDB<DatabaseModel>(name);
} else {
const options: PouchDB.Configuration.DatabaseConfiguration = {
fetch: (fetchUrl, fetchOptions) => {
......@@ -66,7 +66,7 @@ export class PouchdbService {
skip_setup: true,
};
const url = new URL('/database/' + name, location.origin).href;
return new PouchDB<PouchdbModel>(url, options);
return new PouchDB<DatabaseModel>(url, options);
}
}
......@@ -77,7 +77,7 @@ export class PouchdbService {
return this.db.info().catch((error) => this.handleError(error));
}
find<T extends PouchdbModel>(
find<T extends DatabaseModel>(
type: string,
request: PouchDB.Find.FindRequest<T>
): Promise<PouchDB.Find.FindResponse<T>> {
......@@ -108,19 +108,19 @@ export class PouchdbService {
}
}
get<T extends PouchdbModel>(id: string) {
get<T extends DatabaseModel>(id: string) {
return this.db.get<T>(id).catch((error) => this.handleError(error));
}
post<T extends PouchdbModel>(model: T) {
post<T extends DatabaseModel>(model: T) {
return this.db.post(model.toDb()).catch((error) => this.handleError(error));
}
put<T extends PouchdbModel>(model: T) {
put<T extends DatabaseModel>(model: T) {
return this.db.put(model.toDb()).catch((error) => this.handleError(error));
}
remove<T extends PouchdbModel>(model: T) {
remove<T extends DatabaseModel>(model: T) {
return this.db.remove(model).catch((error) => this.handleError(error));
}
......@@ -130,7 +130,7 @@ export class PouchdbService {
* @param id the id of the model
* @return the changes feed, needs to be canceled to stop receiving changes
*/
getChangesFeed<T extends PouchdbModel>(id: string): Observable<any> {
getChangesFeed<T extends DatabaseModel>(id: string): Observable<any> {
const subject = new Subject<any>();
const changes = this.db
.changes<T>({
......
import { PouchdbModel } from '../../database/pouchdb-model';
import { DatabaseModel } from '../../database/database-model';
import { SituationalFactor } from '../method-elements/situational-factor/situational-factor';
import { DevelopmentMethod } from '../development-method/development-method';
import { Decision, GroupSelection } from './decision';
......@@ -7,7 +7,7 @@ import { Artifact } from '../method-elements/artifact/artifact';
import { Domain } from '../knowledge/domain';
import { Selection } from '../development-method/selection';
export class BmProcess extends PouchdbModel {
export class BmProcess extends DatabaseModel {
static readonly typeName = 'BmProcess';
initial = true;
......
......@@ -6,7 +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';
import { DatabaseModelPart } from '../../database/database-model-part';
export class GroupSummary<T extends MethodElement> {
elements: {
......@@ -18,7 +18,7 @@ export class GroupSummary<T extends MethodElement> {
}
export class GroupSelection<T extends MethodElement>
implements Equality<GroupSelection<T>>, PouchdbModelPart
implements Equality<GroupSelection<T>>, DatabaseModelPart
{
selectedGroup: number = null;
elements: T[][] = null;
......@@ -121,7 +121,7 @@ export class GroupSelection<T extends MethodElement>
}
}
export class Decision implements PouchdbModelPart {
export class Decision implements DatabaseModelPart {
method: DevelopmentMethod;
inputArtifacts: GroupSelection<Artifact>;
outputArtifacts: GroupSelection<Artifact>;
......
import { Equality } from '../../shared/equality';
import { PouchdbModelPart } from '../../database/pouchdb-model-part';
import { DatabaseModelPart } from '../../database/database-model-part';
export class ArtifactMapping
implements Equality<ArtifactMapping>, PouchdbModelPart
implements Equality<ArtifactMapping>, DatabaseModelPart
{
output: boolean;
step?: number;
......
import { PouchdbModel } from '../../database/pouchdb-model';
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';
......@@ -10,7 +10,7 @@ import { ExecutionStep } from './execution-step';
import { MultipleMappingSelection } from './multiple-mapping-selection';
import { Selection } from './selection';
export class DevelopmentMethod extends PouchdbModel {
export class DevelopmentMethod extends DatabaseModel {
static readonly typeName = 'DevelopmentMethod';
name: string;
......
import { ArtifactMapping } from './artifact-mapping';
import { Equality } from '../../shared/equality';
import { equalsListOfLists } from '../../shared/utils';
import { PouchdbModelPart } from '../../database/pouchdb-model-part';
import { DatabaseModelPart } from '../../database/database-model-part';
export class ExecutionStep
implements Equality<ExecutionStep>, PouchdbModelPart
implements Equality<ExecutionStep>, DatabaseModelPart
{
module: string;
method: string;
......
import { MethodElement } from '../method-elements/method-element';
import { Equality } from '../../shared/equality';
import { PouchdbModelPart } from '../../database/pouchdb-model-part';
import { DatabaseModelPart } from '../../database/database-model-part';
export class MultipleSelection<T extends MethodElement>
implements Equality<MultipleSelection<T>>, PouchdbModelPart
implements Equality<MultipleSelection<T>>, DatabaseModelPart
{
list: string;
element: T;
......
import { Equality } from '../../shared/equality';
import { PouchdbModelPart } from '../../database/pouchdb-model-part';
import { DatabaseModelPart } from '../../database/database-model-part';
export class Selection<T extends PouchdbModelPart & Equality<T>>
implements Equality<Selection<T>>, PouchdbModelPart
export class Selection<T extends DatabaseModelPart & Equality<T>>
implements Equality<Selection<T>>, DatabaseModelPart
{
list: string;
element: T;
......
import { PouchdbModel } from '../../database/pouchdb-model';
import { DatabaseModel } from '../../database/database-model';
export class Domain extends PouchdbModel {
export class Domain extends DatabaseModel {
static readonly typeName = 'Domain';
name: string;
......
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