2019-10-16 15:25:51 +02:00
|
|
|
import { Resource } from '../is-model/reference/entities/Resource';
|
|
|
|
|
2019-10-16 11:02:59 +02:00
|
|
|
export const TYPE_PROPERTY_KEY = '@class';
|
2019-10-16 14:41:51 +02:00
|
|
|
export const HEADER_PROPERTY_KEY = 'header';
|
2019-10-16 11:02:59 +02:00
|
|
|
|
|
|
|
export class ResourceIdentification {
|
|
|
|
|
|
|
|
public type: string;
|
|
|
|
public mandatoryProperties: Set<string>;
|
2019-10-16 15:25:51 +02:00
|
|
|
public resources: Array<Resource>;
|
2019-10-16 11:02:59 +02:00
|
|
|
|
|
|
|
private first = true;
|
|
|
|
|
|
|
|
constructor(type: string) {
|
|
|
|
this.type = type;
|
|
|
|
this.mandatoryProperties = new Set<string>();
|
2019-10-17 15:45:13 +02:00
|
|
|
this.resources = new Array<Resource>();
|
2019-10-16 11:02:59 +02:00
|
|
|
}
|
|
|
|
|
2019-10-16 15:25:51 +02:00
|
|
|
public addResource(resource: Resource) {
|
|
|
|
if (this.first) {
|
|
|
|
const facet = resource.consistsOf[0].target;
|
|
|
|
for (const propertyKey in facet) {
|
|
|
|
if (propertyKey.localeCompare(TYPE_PROPERTY_KEY) === 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (propertyKey.localeCompare(HEADER_PROPERTY_KEY) === 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
this.mandatoryProperties.add(propertyKey);
|
|
|
|
}
|
|
|
|
this.first = false;
|
|
|
|
}
|
|
|
|
this.resources.push(resource);
|
|
|
|
}
|
2019-10-16 11:02:59 +02:00
|
|
|
}
|