You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { Resource } from '../is-model/reference/entities/Resource';
|
|
|
|
export const TYPE_PROPERTY_KEY = '@class';
|
|
export const HEADER_PROPERTY_KEY = 'header';
|
|
|
|
export class ResourceIdentification {
|
|
|
|
public type: string;
|
|
public mandatoryProperties: Set<string>;
|
|
public resources: Array<Resource>;
|
|
|
|
private first = true;
|
|
|
|
constructor(type: string) {
|
|
this.type = type;
|
|
this.mandatoryProperties = new Set<string>();
|
|
this.resources = new Array<Resource>();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|