From 1fb772b38babda84853bdac1b48dec0f6fae49bd Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 16 Oct 2019 14:41:51 +0200 Subject: [PATCH] IS Model interfaces are now classes --- .../src/app/is-model/reference/ER.ts | 2 +- .../app/is-model/reference/ISManageable.ts | 2 +- .../is-model/reference/entities/Context.ts | 2 +- .../app/is-model/reference/entities/Entity.ts | 3 +- .../app/is-model/reference/entities/Facet.ts | 5 +-- .../is-model/reference/entities/Resource.ts | 2 +- .../reference/properties/Encrypted.ts | 2 +- .../is-model/reference/properties/Header.ts | 2 +- .../properties/PropagationConstraint.ts | 8 ++++- .../is-model/reference/properties/Property.ts | 2 +- .../reference/relations/ConsistsOf.ts | 8 ++++- .../reference/relations/IsIdentifiedBy.ts | 2 +- .../reference/relations/IsParentOf.ts | 2 +- .../reference/relations/IsRelatedTo.ts | 7 +++- .../is-model/reference/relations/Relation.ts | 13 +++++-- .../app/is-model/types/PropertyDefinition.ts | 35 +++++++++++++++++++ .../src/app/is-model/types/TypeDefinition.ts | 6 ++-- .../resource-list/resourceidentification.ts | 4 +++ 18 files changed, 87 insertions(+), 20 deletions(-) create mode 100644 is-monitor-frontend/src/app/is-model/types/PropertyDefinition.ts diff --git a/is-monitor-frontend/src/app/is-model/reference/ER.ts b/is-monitor-frontend/src/app/is-model/reference/ER.ts index 8b370c4..f68e11c 100644 --- a/is-monitor-frontend/src/app/is-model/reference/ER.ts +++ b/is-monitor-frontend/src/app/is-model/reference/ER.ts @@ -1,7 +1,7 @@ import { ISManageable } from './ISManageable'; import { Header } from './properties/Header'; -export interface ER extends ISManageable { +export class ER extends ISManageable { header: Header; diff --git a/is-monitor-frontend/src/app/is-model/reference/ISManageable.ts b/is-monitor-frontend/src/app/is-model/reference/ISManageable.ts index 028db6e..4bd42f4 100644 --- a/is-monitor-frontend/src/app/is-model/reference/ISManageable.ts +++ b/is-monitor-frontend/src/app/is-model/reference/ISManageable.ts @@ -1,3 +1,3 @@ -export interface ISManageable { +export class ISManageable { '@class': string; } diff --git a/is-monitor-frontend/src/app/is-model/reference/entities/Context.ts b/is-monitor-frontend/src/app/is-model/reference/entities/Context.ts index 58f7687..4c13146 100644 --- a/is-monitor-frontend/src/app/is-model/reference/entities/Context.ts +++ b/is-monitor-frontend/src/app/is-model/reference/entities/Context.ts @@ -1,7 +1,7 @@ import { Entity } from './Entity'; import { IsParentOf } from '../relations/IsParentOf'; -export interface Context extends Entity { +export class Context extends Entity { name: string; parent: IsParentOf; diff --git a/is-monitor-frontend/src/app/is-model/reference/entities/Entity.ts b/is-monitor-frontend/src/app/is-model/reference/entities/Entity.ts index 09e5d69..e30ac67 100644 --- a/is-monitor-frontend/src/app/is-model/reference/entities/Entity.ts +++ b/is-monitor-frontend/src/app/is-model/reference/entities/Entity.ts @@ -1,6 +1,5 @@ import { ER } from '../ER'; -// tslint:disable-next-line: no-empty-interface -export interface Entity extends ER { +export abstract class Entity extends ER { } diff --git a/is-monitor-frontend/src/app/is-model/reference/entities/Facet.ts b/is-monitor-frontend/src/app/is-model/reference/entities/Facet.ts index 0b5953a..2c50225 100644 --- a/is-monitor-frontend/src/app/is-model/reference/entities/Facet.ts +++ b/is-monitor-frontend/src/app/is-model/reference/entities/Facet.ts @@ -1,6 +1,7 @@ import { Entity } from './Entity'; -// tslint:disable-next-line: no-empty-interface -export interface Facet extends Entity { +export class Facet extends Entity { + + [x: string]: any; } diff --git a/is-monitor-frontend/src/app/is-model/reference/entities/Resource.ts b/is-monitor-frontend/src/app/is-model/reference/entities/Resource.ts index 050b291..730fec9 100644 --- a/is-monitor-frontend/src/app/is-model/reference/entities/Resource.ts +++ b/is-monitor-frontend/src/app/is-model/reference/entities/Resource.ts @@ -3,7 +3,7 @@ import { ConsistsOf } from '../relations/ConsistsOf'; import { IsRelatedTo } from '../relations/IsRelatedTo'; import { Facet } from './Facet'; -export interface Resource extends Entity { +export class Resource extends Entity { consistsOf: Array>; isRelatedTo: Array>; diff --git a/is-monitor-frontend/src/app/is-model/reference/properties/Encrypted.ts b/is-monitor-frontend/src/app/is-model/reference/properties/Encrypted.ts index 53f39e2..18995d6 100644 --- a/is-monitor-frontend/src/app/is-model/reference/properties/Encrypted.ts +++ b/is-monitor-frontend/src/app/is-model/reference/properties/Encrypted.ts @@ -1,5 +1,5 @@ import { Property } from './Property'; -export interface Encrypted extends Property { +export class Encrypted extends Property { value: string; } diff --git a/is-monitor-frontend/src/app/is-model/reference/properties/Header.ts b/is-monitor-frontend/src/app/is-model/reference/properties/Header.ts index ef48c31..856e3b6 100644 --- a/is-monitor-frontend/src/app/is-model/reference/properties/Header.ts +++ b/is-monitor-frontend/src/app/is-model/reference/properties/Header.ts @@ -1,6 +1,6 @@ import { Property } from './Property'; -export interface Header extends Property { +export class Header extends Property { 'uuid': string; 'creator': string; 'modifiedBy': string; diff --git a/is-monitor-frontend/src/app/is-model/reference/properties/PropagationConstraint.ts b/is-monitor-frontend/src/app/is-model/reference/properties/PropagationConstraint.ts index 94242cf..e31213b 100644 --- a/is-monitor-frontend/src/app/is-model/reference/properties/PropagationConstraint.ts +++ b/is-monitor-frontend/src/app/is-model/reference/properties/PropagationConstraint.ts @@ -31,9 +31,15 @@ export enum AddConstraint { } -export interface PropagationConstraint extends Property { +export class PropagationConstraint extends Property { remove: RemoveConstraint; add: AddConstraint; + constructor(remove: RemoveConstraint, add: AddConstraint){ + super(); + this.remove = remove; + this.add = add; + } + } diff --git a/is-monitor-frontend/src/app/is-model/reference/properties/Property.ts b/is-monitor-frontend/src/app/is-model/reference/properties/Property.ts index 4b47e47..a1c7c25 100644 --- a/is-monitor-frontend/src/app/is-model/reference/properties/Property.ts +++ b/is-monitor-frontend/src/app/is-model/reference/properties/Property.ts @@ -1,6 +1,6 @@ import { ISManageable } from '../ISManageable'; // tslint:disable-next-line: no-empty-interface -export interface Property extends ISManageable { +export class Property extends ISManageable { } diff --git a/is-monitor-frontend/src/app/is-model/reference/relations/ConsistsOf.ts b/is-monitor-frontend/src/app/is-model/reference/relations/ConsistsOf.ts index 0ba0650..2e1fd06 100644 --- a/is-monitor-frontend/src/app/is-model/reference/relations/ConsistsOf.ts +++ b/is-monitor-frontend/src/app/is-model/reference/relations/ConsistsOf.ts @@ -1,7 +1,13 @@ import { Resource } from '../entities/Resource'; import { Relation } from './Relation'; import { Facet } from '../entities/Facet'; +import { PropagationConstraint, RemoveConstraint, AddConstraint } from '../properties/PropagationConstraint'; -export interface ConsistsOf extends Relation { +export class ConsistsOf extends Relation { + + constructor(propagationConstraint: PropagationConstraint = + new PropagationConstraint(RemoveConstraint.cascade, AddConstraint.unpropagate)) { + super(propagationConstraint); + } } diff --git a/is-monitor-frontend/src/app/is-model/reference/relations/IsIdentifiedBy.ts b/is-monitor-frontend/src/app/is-model/reference/relations/IsIdentifiedBy.ts index 01b85bb..4e128b3 100644 --- a/is-monitor-frontend/src/app/is-model/reference/relations/IsIdentifiedBy.ts +++ b/is-monitor-frontend/src/app/is-model/reference/relations/IsIdentifiedBy.ts @@ -2,6 +2,6 @@ import { Resource } from '../entities/Resource'; import { ConsistsOf } from './ConsistsOf'; import { Facet } from '../entities/Facet'; -export interface IsIdentifiedBy extends ConsistsOf { +export class IsIdentifiedBy extends ConsistsOf { } diff --git a/is-monitor-frontend/src/app/is-model/reference/relations/IsParentOf.ts b/is-monitor-frontend/src/app/is-model/reference/relations/IsParentOf.ts index 161978b..5cd2148 100644 --- a/is-monitor-frontend/src/app/is-model/reference/relations/IsParentOf.ts +++ b/is-monitor-frontend/src/app/is-model/reference/relations/IsParentOf.ts @@ -1,7 +1,7 @@ import { Context } from '../entities/Context'; import { Relation } from './Relation'; -export interface IsParentOf +export class IsParentOf extends Relation { } diff --git a/is-monitor-frontend/src/app/is-model/reference/relations/IsRelatedTo.ts b/is-monitor-frontend/src/app/is-model/reference/relations/IsRelatedTo.ts index 7be3237..c10e453 100644 --- a/is-monitor-frontend/src/app/is-model/reference/relations/IsRelatedTo.ts +++ b/is-monitor-frontend/src/app/is-model/reference/relations/IsRelatedTo.ts @@ -1,6 +1,11 @@ import { Resource } from '../entities/Resource'; import { Relation } from './Relation'; +import { RemoveConstraint, AddConstraint, PropagationConstraint } from '../properties/PropagationConstraint'; -export interface IsRelatedTo extends Relation { +export class IsRelatedTo extends Relation { + constructor(propagationConstraint: PropagationConstraint = + new PropagationConstraint(RemoveConstraint.keep, AddConstraint.unpropagate)) { + super(propagationConstraint); + } } diff --git a/is-monitor-frontend/src/app/is-model/reference/relations/Relation.ts b/is-monitor-frontend/src/app/is-model/reference/relations/Relation.ts index 233eac1..e9a96aa 100644 --- a/is-monitor-frontend/src/app/is-model/reference/relations/Relation.ts +++ b/is-monitor-frontend/src/app/is-model/reference/relations/Relation.ts @@ -1,9 +1,18 @@ import { Entity } from '../entities/Entity'; import { ER } from '../ER'; +import { PropagationConstraint } from '../properties/PropagationConstraint'; -export interface Relation extends ER { +export abstract class Relation extends ER { - source: Out; + source?: Out; target: In; + propagationConstraint?: PropagationConstraint; + + [x: string]: any; + + constructor(propagationConstraint?: PropagationConstraint) { + super(); + this.propagationConstraint = propagationConstraint; + } } diff --git a/is-monitor-frontend/src/app/is-model/types/PropertyDefinition.ts b/is-monitor-frontend/src/app/is-model/types/PropertyDefinition.ts new file mode 100644 index 0000000..c6320ab --- /dev/null +++ b/is-monitor-frontend/src/app/is-model/types/PropertyDefinition.ts @@ -0,0 +1,35 @@ +enum OType { + + Boolean = 0, + Integer = 1, + Short = 2, + Long = 3, + Float = 4, + Double = 5, + Datetime = 6, + String = 7, + Bynary = 8, + Property = 9, + 'Property List' = 10, + 'Property Set' = 11, + 'Property Map' = 12, + Byte = 17, + Binary = 8 + +} + +export interface PropertyDefinition { + + name: string; + description: string; + mandatory: boolean; + readonly: boolean; + notnull: boolean; + max: number | null; + min: number | null; + regexp: string | null; + linkedType: OType | null; + linkedClass: string | null; + type: number | null; + +} diff --git a/is-monitor-frontend/src/app/is-model/types/TypeDefinition.ts b/is-monitor-frontend/src/app/is-model/types/TypeDefinition.ts index e0dcfea..579a724 100644 --- a/is-monitor-frontend/src/app/is-model/types/TypeDefinition.ts +++ b/is-monitor-frontend/src/app/is-model/types/TypeDefinition.ts @@ -1,7 +1,9 @@ +import { PropertyDefinition } from './PropertyDefinition'; + export interface TypeDefinition { name: string; description: string | null; abstract: boolean; - superClasses?: string[]; - properties?: any[]; + superClasses?: Set; + properties?: Array; } diff --git a/is-monitor-frontend/src/app/resource-list/resourceidentification.ts b/is-monitor-frontend/src/app/resource-list/resourceidentification.ts index 62dd334..8123e6b 100644 --- a/is-monitor-frontend/src/app/resource-list/resourceidentification.ts +++ b/is-monitor-frontend/src/app/resource-list/resourceidentification.ts @@ -1,4 +1,5 @@ export const TYPE_PROPERTY_KEY = '@class'; +export const HEADER_PROPERTY_KEY = 'header'; export class ResourceIdentification { @@ -20,6 +21,9 @@ export class ResourceIdentification { if (propertyKey.localeCompare(TYPE_PROPERTY_KEY) === 0) { continue; } + if (propertyKey.localeCompare(HEADER_PROPERTY_KEY) === 0) { + continue; + } this.mandatoryProperties.add(propertyKey); } this.first = false;