IS Model interfaces are now classes
This commit is contained in:
parent
21a2ff9195
commit
1fb772b38b
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export interface ISManageable {
|
||||
export class ISManageable {
|
||||
'@class': string;
|
||||
}
|
||||
|
|
|
@ -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<Context, Context>;
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ConsistsOf<Resource, Facet>>;
|
||||
isRelatedTo: Array<IsRelatedTo<Resource, Resource>>;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Property } from './Property';
|
||||
|
||||
export interface Encrypted extends Property {
|
||||
export class Encrypted extends Property {
|
||||
value: string;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Property } from './Property';
|
||||
|
||||
export interface Header extends Property {
|
||||
export class Header extends Property {
|
||||
'uuid': string;
|
||||
'creator': string;
|
||||
'modifiedBy': string;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Out extends Resource, In extends Facet> extends Relation<Out, In> {
|
||||
export class ConsistsOf<Out extends Resource, In extends Facet> extends Relation<Out, In> {
|
||||
|
||||
constructor(propagationConstraint: PropagationConstraint =
|
||||
new PropagationConstraint(RemoveConstraint.cascade, AddConstraint.unpropagate)) {
|
||||
super(propagationConstraint);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@ import { Resource } from '../entities/Resource';
|
|||
import { ConsistsOf } from './ConsistsOf';
|
||||
import { Facet } from '../entities/Facet';
|
||||
|
||||
export interface IsIdentifiedBy<Out extends Resource, In extends Facet> extends ConsistsOf<Out, In> {
|
||||
export class IsIdentifiedBy<Out extends Resource, In extends Facet> extends ConsistsOf<Out, In> {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Context } from '../entities/Context';
|
||||
import { Relation } from './Relation';
|
||||
|
||||
export interface IsParentOf<Out extends Context, In extends Context>
|
||||
export class IsParentOf<Out extends Context, In extends Context>
|
||||
extends Relation<Out, In> {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import { Resource } from '../entities/Resource';
|
||||
import { Relation } from './Relation';
|
||||
import { RemoveConstraint, AddConstraint, PropagationConstraint } from '../properties/PropagationConstraint';
|
||||
|
||||
export interface IsRelatedTo<Out extends Resource, In extends Resource> extends Relation<Out, In> {
|
||||
export class IsRelatedTo<Out extends Resource, In extends Resource> extends Relation<Out, In> {
|
||||
|
||||
constructor(propagationConstraint: PropagationConstraint =
|
||||
new PropagationConstraint(RemoveConstraint.keep, AddConstraint.unpropagate)) {
|
||||
super(propagationConstraint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
import { Entity } from '../entities/Entity';
|
||||
import { ER } from '../ER';
|
||||
import { PropagationConstraint } from '../properties/PropagationConstraint';
|
||||
|
||||
export interface Relation<Out extends Entity, In extends Entity> extends ER {
|
||||
export abstract class Relation<Out extends Entity, In extends Entity> extends ER {
|
||||
|
||||
source: Out;
|
||||
source?: Out;
|
||||
target: In;
|
||||
|
||||
propagationConstraint?: PropagationConstraint;
|
||||
|
||||
[x: string]: any;
|
||||
|
||||
constructor(propagationConstraint?: PropagationConstraint) {
|
||||
super();
|
||||
this.propagationConstraint = propagationConstraint;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
import { PropertyDefinition } from './PropertyDefinition';
|
||||
|
||||
export interface TypeDefinition {
|
||||
name: string;
|
||||
description: string | null;
|
||||
abstract: boolean;
|
||||
superClasses?: string[];
|
||||
properties?: any[];
|
||||
superClasses?: Set<string>;
|
||||
properties?: Array<PropertyDefinition>;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue