Added resource tree generation

This commit is contained in:
Luca Frosini 2019-10-02 17:58:41 +02:00
parent decb61c419
commit b8743a4cf7
4 changed files with 310 additions and 62 deletions

View File

@ -1,65 +1,11 @@
<ul id="resource-tree" class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">Actor</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">LegalBody</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Person</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Configuration</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">Configuration Template</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Dataset</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">ConcreteDataset</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Service</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">EService</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">RunningPlugin</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">HostingNode</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">VirtualMachine</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">VirtualService</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Schema</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Site</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Software</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">Plugin</a>
</li>
</ul>
<ng-template #recursiveList let-resources>
<li *ngFor="let type of resources" class="list-group-item">
<a class="nav-link" href="#" [title]="type.description">{{ type.name }}</a>
<ul *ngIf="type.children.length > 0">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: type.children }"></ng-container>
</ul>
</li>
</ng-template>
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: resources }"></ng-container>
</ul>

View File

@ -0,0 +1,65 @@
<ul id="resource-tree" class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">Actor</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">LegalBody</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Person</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Configuration</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">Configuration Template</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Dataset</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">ConcreteDataset</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Service</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">EService</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">RunningPlugin</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">HostingNode</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">VirtualMachine</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">VirtualService</a>
</li>
</ul>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Schema</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Site</a>
</li>
<li class="list-group-item">
<a class="nav-link" href="#">Software</a>
<ul class="list-group">
<li class="list-group-item">
<a class="nav-link" href="#">Plugin</a>
</li>
</ul>
</li>
</ul>

View File

@ -1,4 +1,28 @@
import { Component, OnInit } from '@angular/core';
import { types } from './types';
export class Type {
name: string;
description: string;
abstract: boolean;
parent: Type;
children: Type[];
constructor(type: { name: string; description: string; superClasses?: string[]; properties?: any; abstract: boolean; }) {
this.name = type.name;
this.description = type.description;
this.abstract = type.abstract;
this.children = new Array();
}
addChild(type: Type) {
type.parent = this;
this.children.push(type);
}
}
@Component({
selector: 'app-resource-types-tree',
@ -7,9 +31,58 @@ import { Component, OnInit } from '@angular/core';
})
export class ResourceTypesTreeComponent implements OnInit {
resources: Type[];
map = new Map<string, Type>();
unassociated = new Map<string, {
name: string; description: string; superClasses?: string[];
properties?: any[]; abstract: boolean;
}>();
constructor() { }
analyseUnassociated(type: Type) {
const associated: string[] = new Array();
for (const name of this.unassociated.keys()) {
const t = this.unassociated.get(name);
const parent = t.superClasses[0];
if (parent === type.name) {
type.addChild(this.map.get(t.name));
associated.push(t.name);
}
}
for (const a of associated) {
this.unassociated.delete(a);
}
}
ngOnInit() {
for (const t of types) {
const type: Type = new Type(t);
this.map.set(type.name, type);
if (type.name !== 'Resource') {
const parent = t.superClasses[0];
if (this.map.has(parent)) {
this.map.get(parent).addChild(type);
} else {
this.analyseUnassociated(type);
this.unassociated.set(type.name, t);
}
}
}
this.resources = this.map.get('Resource').children;
}
}

View File

@ -0,0 +1,164 @@
export const types = [
{
name: 'Resource',
description: '',
superClasses: [
'Entity'
],
properties: null,
abstract: true
},
{
name: 'Service',
description: 'Collect Service information through the list of its facets',
superClasses: [
'Resource'
],
properties: null,
abstract: true
},
{
name: 'HostingNode',
description: 'Collect Hosting Node information through the list of its facets',
superClasses: [
'Service'
],
properties: null,
abstract: false
},
{
name: 'Software',
description: 'Collect Software information through the list of its facets',
superClasses: [
'Resource'
],
properties: null,
abstract: false
},
{
name: 'Plugin',
description: 'Collect Plugin information through the list of its facets',
superClasses: [
'Software'
],
properties: null,
abstract: false
},
{
name: 'Actor',
description: 'Any entity (human or machine) playing an active role.',
superClasses: [
'Resource'
],
properties: null,
abstract: true
},
{
name: 'LegalBody',
description: 'Actor',
superClasses: [
'Actor'
],
properties: null,
abstract: false
},
{
name: 'Dataset',
description: 'Collect Dataset information through the list of its facets',
superClasses: [
'Resource'
],
properties: null,
abstract: false
},
{
name: 'Person',
description: 'Person',
superClasses: [
'Actor'
],
properties: null,
abstract: false
},
{
name: 'Schema',
description: 'Collect Schema information through the list of its facets',
superClasses: [
'Resource'
],
properties: null,
abstract: false
},
{
name: 'Site',
description: 'Collect Site information through the list of its facets',
superClasses: [
'Resource'
],
properties: null,
abstract: false
},
{
name: 'ConcreteDataset',
description: 'Collect Dataset information through the list of its facets',
superClasses: [
'Dataset'
],
properties: null,
abstract: false
},
{
name: 'VirtualMachine',
description: 'Collect Hosting Node information through the list of its facets',
superClasses: [
'Service'
],
properties: null,
abstract: false
},
{
name: 'ConfigurationTemplate',
description: 'It represents a template for a configuration. It describe how a configuration has to be realized. E.g. Used to define the accounting configuration parameters template.',
superClasses: [
'Resource'
],
properties: null,
abstract: false
},
{
name: 'Configuration',
description: 'Collect Configuration information through the list of its facets',
superClasses: [
'ConfigurationTemplate'
],
properties: null,
abstract: false
},
{
name: 'EService',
description: 'Collect Electronic Service (aka Running Service) information through the list of its facets',
superClasses: [
'Service'
],
properties: null,
abstract: false
},
{
name: 'VirtualService',
description: 'Collect Virtual Service information through the list of its facets',
superClasses: [
'Service'
],
properties: null,
abstract: false
},
{
name: 'RunningPlugin',
description: 'Collect Running Plugin information through the list of its facets',
superClasses: [
'EService'
],
properties: null,
abstract: false
}
];