Skip to content

Commit

Permalink
test adding metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Weirich <matthias.weirich@selectcode.de>
  • Loading branch information
vavido committed Jan 8, 2021
1 parent 328fae4 commit b3c4cf9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions javascript/lib/api/src/model/things.model.ts
Expand Up @@ -26,6 +26,7 @@ export class Thing extends EntityWithId<Thing> {
private readonly _features?: Features,
private readonly __revision?: number,
private readonly __modified?: string,
private readonly __metadata?: Features,
private readonly _acl?: Acl) {
super();
}
Expand All @@ -43,11 +44,11 @@ export class Thing extends EntityWithId<Thing> {
// @ts-ignore
return new Thing(o['thingId'], o['policyId'], o['attributes'],
// @ts-ignore
Features.fromObject(o['features']), o['_revision'], o['_modified'], Acl.fromObject(o['acl']));
Features.fromObject(o['features']), o['_revision'], o['_modified'], Features.fromObject(o['_metadata']['features']), Acl.fromObject(o['acl']));
}

public static empty(): Thing {
return new Thing('', '', undefined, undefined, 0, '', undefined);
return new Thing('', '', undefined, undefined, 0, '', undefined, undefined);
}

public toObject(): object {
Expand All @@ -60,6 +61,7 @@ export class Thing extends EntityWithId<Thing> {
['features', featuresObj],
['_revision', this._revision],
['_modified', this._modified],
['_metadata', this._metadata],
['acl', aclObj]
]));
}
Expand Down Expand Up @@ -92,6 +94,10 @@ export class Thing extends EntityWithId<Thing> {
return this.__revision;
}

get _metadata(): Features | undefined {
return this.__metadata;
}

get namespace(): string {
return this.separateNamespaceAndThingId().namespace;
}
Expand Down Expand Up @@ -140,6 +146,7 @@ export class Features extends IndexedEntityModel<Features, Feature> {
}
return new Features(IndexedEntityModel.fromPlainObject(o, Feature.fromObject));
}

}

/**
Expand Down

0 comments on commit b3c4cf9

Please sign in to comment.