Getting resources
This commit is contained in:
parent
7e58e23727
commit
e58d3c34a7
|
@ -11,6 +11,14 @@
|
||||||
"port": 9225,
|
"port": 9225,
|
||||||
"webRoot": "${workspaceFolder}",
|
"webRoot": "${workspaceFolder}",
|
||||||
"url": "http://localhost:4200/#"
|
"url": "http://localhost:4200/#"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Launch Chrome localhost",
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"port": 9227,
|
||||||
|
"webRoot": "${workspaceFolder}",
|
||||||
|
"url": "http://localhost:4200/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -10,10 +10,6 @@
|
||||||
|
|
||||||
<div id="content" class="content" role="main">
|
<div id="content" class="content" role="main">
|
||||||
<app-resource-types-tree></app-resource-types-tree>
|
<app-resource-types-tree></app-resource-types-tree>
|
||||||
<div id="list-and-details">
|
|
||||||
<app-resource-list></app-resource-list>
|
|
||||||
<app-resource-details></app-resource-details>
|
|
||||||
</div>
|
|
||||||
<app-basket></app-basket>
|
<app-basket></app-basket>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
export class ISManageable {
|
export class ISManageable {
|
||||||
'@class': string;
|
'@class': string;
|
||||||
|
'@superClasses'?: Array<string>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Facet } from './Facet';
|
||||||
|
|
||||||
export class Resource extends Entity {
|
export class Resource extends Entity {
|
||||||
|
|
||||||
consistsOf: Array<ConsistsOf<Resource, Facet>>;
|
consistsOf?: Array<ConsistsOf<Resource, Facet>>;
|
||||||
isRelatedTo: Array<IsRelatedTo<Resource, Resource>>;
|
isRelatedTo?: Array<IsRelatedTo<Resource, Resource>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,45 @@
|
||||||
import { Property } from './Property';
|
import { Property } from './Property';
|
||||||
|
|
||||||
export enum RemoveConstraint {
|
type RemoveConstraint = 'cascadeWhenOrphan' | 'cascade' | 'keep';
|
||||||
|
export const RemoveConstraint = {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When the source Entity is removed also the target
|
* When the source Entity is removed also the target
|
||||||
* Entity is removed but if and only if the latter has no other
|
* Entity is removed but if and only if the latter has no other
|
||||||
* incoming Relation.
|
* incoming Relation.
|
||||||
*/
|
*/
|
||||||
cascadeWhenOrphan,
|
cascadeWhenOrphan: 'cascadeWhenOrphan' as RemoveConstraint,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When the source Entity is removed also the target
|
* When the source Entity is removed also the target
|
||||||
* Entity is removed.
|
* Entity is removed. */
|
||||||
*/
|
cascade: 'cascade' as RemoveConstraint,
|
||||||
cascade,
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When the source Entity is removed the target Entity
|
* When the source Entity is removed the target Entity
|
||||||
* is keep.
|
* is keep.
|
||||||
*/
|
*/
|
||||||
keep
|
keep: 'keep' as RemoveConstraint
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
export enum AddConstraint {
|
type AddConstraint = 'propagate' | 'unpropagate';
|
||||||
|
export const AddConstraint = {
|
||||||
|
|
||||||
propagate,
|
propagate: 'propagate' as AddConstraint,
|
||||||
|
|
||||||
unpropagate
|
unpropagate: 'unpropagate' as AddConstraint
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
export class PropagationConstraint extends Property {
|
export class PropagationConstraint extends Property {
|
||||||
|
|
||||||
remove: RemoveConstraint;
|
remove: RemoveConstraint;
|
||||||
add: AddConstraint;
|
add: AddConstraint;
|
||||||
|
|
||||||
constructor(remove: RemoveConstraint, add: AddConstraint){
|
|
||||||
|
|
||||||
|
constructor(remove: RemoveConstraint, add: AddConstraint) {
|
||||||
super();
|
super();
|
||||||
this.remove = remove;
|
this.remove = remove;
|
||||||
this.add = add;
|
this.add = add;
|
||||||
|
|
|
@ -17,11 +17,11 @@ export class IsService {
|
||||||
private baseURL = 'http://pc-frosini.isti.cnr.it:8080/resource-registry';
|
private baseURL = 'http://pc-frosini.isti.cnr.it:8080/resource-registry';
|
||||||
private typesURL = this.baseURL + '/types';
|
private typesURL = this.baseURL + '/types';
|
||||||
private instancesURL = this.baseURL + '/instances';
|
private instancesURL = this.baseURL + '/instances';
|
||||||
private queryURL = this.baseURL + '/query';
|
// private queryURL = this.baseURL + '/query';
|
||||||
|
|
||||||
|
|
||||||
/* NextNext Token */
|
/* NextNext Token */
|
||||||
private token = '';
|
private token = '7c66c94c-7f6e-49cd-9a34-909cd3832f3e-98187548';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle Http operation that failed.
|
* Handle Http operation that failed.
|
||||||
|
@ -39,8 +39,8 @@ export class IsService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public getResourceTypes(callback: (isTypes: TypeDefinition[]) => void): void {
|
public getTypeDefinition(typeName: string, polymorphic: boolean = true, callback: (isTypes: TypeDefinition[]) => void): void {
|
||||||
const url = this.typesURL + '/Resource?polymorphic=true&gcube-token=' + this.token;
|
const url = this.typesURL + '/' + typeName + '?polymorphic=' + polymorphic + '&gcube-token=' + this.token;
|
||||||
// const observable: Observable<ISType[]> = of(types);
|
// const observable: Observable<ISType[]> = of(types);
|
||||||
const observable: Observable<TypeDefinition[]> = this.httpClient.get<TypeDefinition[]>(url);
|
const observable: Observable<TypeDefinition[]> = this.httpClient.get<TypeDefinition[]>(url);
|
||||||
observable.pipe(
|
observable.pipe(
|
||||||
|
@ -49,7 +49,7 @@ export class IsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getResourceInstances(resourceType: string, callback: (instances: Resource[]) => void): void {
|
public getResourceInstances(resourceType: string, callback: (instances: Resource[]) => void): void {
|
||||||
const url = this.queryURL + resourceType + '?polymorphic=true&gcube-token=' + this.token;
|
const url = this.instancesURL + '/' + resourceType + '?polymorphic=true&gcube-token=' + this.token;
|
||||||
// const observable: Observable<ISType[]> = of(types);
|
// const observable: Observable<ISType[]> = of(types);
|
||||||
const observable: Observable<any[]> = this.httpClient.get<any[]>(url);
|
const observable: Observable<any[]> = this.httpClient.get<any[]>(url);
|
||||||
observable.pipe(
|
observable.pipe(
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { TypeDefinition } from '../is-model/types/TypeDefinition';
|
||||||
|
|
||||||
|
export const CLASS_PROPERTY_KEY = '@class';
|
||||||
|
export const SUPERCLASSES_PROPERTY_KEY = '@superClasses';
|
||||||
|
export const HEADER_PROPERTY_KEY = 'header';
|
||||||
|
|
||||||
|
export class FacetDefinition {
|
||||||
|
|
||||||
|
public typeName: string;
|
||||||
|
public mandatoryProperties: Set<string>;
|
||||||
|
public typeDefinition: TypeDefinition;
|
||||||
|
|
||||||
|
// private first = true;
|
||||||
|
|
||||||
|
constructor(typeName: string, typeDefinition: TypeDefinition) {
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.typeDefinition = typeDefinition;
|
||||||
|
this.analyseType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public analyseType() {
|
||||||
|
this.mandatoryProperties = new Set<string>();
|
||||||
|
|
||||||
|
for (const p of this.typeDefinition.properties) {
|
||||||
|
switch (p.name) {
|
||||||
|
|
||||||
|
case (CLASS_PROPERTY_KEY || SUPERCLASSES_PROPERTY_KEY || HEADER_PROPERTY_KEY) : {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (p.mandatory) {
|
||||||
|
this.mandatoryProperties.add(p.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (this.first) {
|
||||||
|
const facet = resource.consistsOf[0].target;
|
||||||
|
for (const propertyKey in facet) {
|
||||||
|
if (propertyKey.localeCompare(CLASS_PROPERTY_KEY) === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (propertyKey.localeCompare(SUPERCLASSES_PROPERTY_KEY) === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (propertyKey.localeCompare(HEADER_PROPERTY_KEY) === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.mandatoryProperties.add(propertyKey);
|
||||||
|
}
|
||||||
|
this.first = false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
<table class="table table-striped table-bordered" *ngFor="let key of resources.keys()">
|
<table class="table table-striped table-bordered" *ngFor="let key of resources.keys()">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th [attr.colspan]="resources.get(key).mandatoryProperties.size+2" class="header">Resources identified by {{resources.get(key).type}}</th>
|
<th [attr.colspan]="resources.get(key).mandatoryProperties.size+2" class="header">{{ resourceType }}s identified by {{resources.get(key).type}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Resource Type</th>
|
<th>Resource Type</th>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { IsService } from '../is.service';
|
import { IsService } from '../is.service';
|
||||||
import { ResourceIdentification, TYPE_PROPERTY_KEY } from './resourceidentification';
|
import { FacetDefinition, CLASS_PROPERTY_KEY } from './resourceidentification';
|
||||||
import { Resource } from '../is-model/reference/entities/Resource';
|
import { Resource } from '../is-model/reference/entities/Resource';
|
||||||
|
import { TypeDefinition } from '../is-model/types/TypeDefinition';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-resource-list',
|
selector: 'app-resource-list',
|
||||||
|
@ -10,30 +11,52 @@ import { Resource } from '../is-model/reference/entities/Resource';
|
||||||
})
|
})
|
||||||
export class ResourceListComponent implements OnInit {
|
export class ResourceListComponent implements OnInit {
|
||||||
|
|
||||||
public resources: Map<string, ResourceIdentification>;
|
|
||||||
|
|
||||||
constructor(private isService: IsService) { }
|
constructor(private isService: IsService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
set resourceType(resourceType: string) {
|
||||||
this.isService.getResourceInstances('Service', res => { this.resources = this.analyseResources(res); });
|
// tslint:disable-next-line: no-console
|
||||||
|
console.debug('Going to retrieve ' + resourceType + ' instances');
|
||||||
|
this._resourceType = resourceType;
|
||||||
|
this.isService.getResourceInstances(this._resourceType, res => { this.resources = this.analyseResources(res); });
|
||||||
}
|
}
|
||||||
|
|
||||||
analyseResources(resources: Resource[]): Map<string, ResourceIdentification> {
|
get resourceType(): string {
|
||||||
|
return this._resourceType;
|
||||||
|
}
|
||||||
|
|
||||||
const map = new Map<string, ResourceIdentification>();
|
public static facetTypes: Map<string, TypeDefinition> = new Map<string, TypeDefinition>();
|
||||||
|
|
||||||
|
// <FacetType, Array<Resource>>
|
||||||
|
public resources: Map<string, Array<Resource>>;
|
||||||
|
|
||||||
|
// tslint:disable-next-line: variable-name
|
||||||
|
private _resourceType: string;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.resourceType = 'Service';
|
||||||
|
}
|
||||||
|
|
||||||
|
analyseResources(resources: Resource[]): Map<string, Array<Resource>> {
|
||||||
|
|
||||||
|
const map = new Map<string, Array<Resource>>();
|
||||||
|
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
|
|
||||||
const facetType: string = resource.consistsOf[0].target[TYPE_PROPERTY_KEY];
|
const facetType: string = resource.consistsOf[0].target[CLASS_PROPERTY_KEY];
|
||||||
let resourceIdentification: ResourceIdentification;
|
let res: Array<Resource>;
|
||||||
|
|
||||||
if (map.has(facetType)) {
|
if (map.has(facetType)) {
|
||||||
resourceIdentification = map.get(facetType);
|
if (!ResourceListComponent.facetTypes.has(facetType)) {
|
||||||
|
let typeDefinition: TypeDefinition;
|
||||||
|
this.isService.getTypeDefinition(facetType, false, types => { typeDefinition = types[0]; } );
|
||||||
|
ResourceListComponent.facetTypes.set(facetType, typeDefinition);
|
||||||
|
}
|
||||||
|
res = map.get(facetType);
|
||||||
} else {
|
} else {
|
||||||
resourceIdentification = new ResourceIdentification(facetType);
|
res = new Array<Resource>();
|
||||||
map.set(facetType, resourceIdentification);
|
map.set(facetType, res);
|
||||||
}
|
}
|
||||||
resourceIdentification.addResource(resource);
|
res.push(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,15 @@
|
||||||
<ul id="resource-tree" class="list-group">
|
<ul id="resource-tree" class="list-group">
|
||||||
<ng-template #recursiveList let-resources>
|
<ng-template #recursiveList let-resources>
|
||||||
<li *ngFor="let type of resources" class="list-group-item">
|
<li *ngFor="let type of resources" class="list-group-item">
|
||||||
<a class="nav-link" href="#" [title]="type.description" (click)="loadResources(type.name)">{{ type.name }}</a>
|
<a class="nav-link" href="#" [title]="type.description" (click)="list.resourceType = type.name">{{ type.name }}</a>
|
||||||
<ul *ngIf="type.children.length > 0">
|
<ul *ngIf="type.children.length > 0">
|
||||||
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: type.children }"></ng-container>
|
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: type.children }"></ng-container>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: resources }"></ng-container>
|
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: resources }"></ng-container>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div id="list-and-details">
|
||||||
|
<app-resource-list #list></app-resource-list>
|
||||||
|
<app-resource-details></app-resource-details>
|
||||||
|
</div>
|
|
@ -17,7 +17,7 @@ export class ResourceTypesTreeComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isService.getResourceTypes(isTypes => { this.resources = this.analyseTypes(isTypes); });
|
this.isService.getTypeDefinition('Resource', true, isTypes => { this.resources = this.analyseTypes(isTypes); });
|
||||||
}
|
}
|
||||||
|
|
||||||
analyseUnassociated(type: Type, map: Map<string, Type>, unassociated: Map<string, TypeDefinition>) {
|
analyseUnassociated(type: Type, map: Map<string, Type>, unassociated: Map<string, TypeDefinition>) {
|
||||||
|
@ -67,10 +67,6 @@ export class ResourceTypesTreeComponent implements OnInit {
|
||||||
return map.get('Resource').children;
|
return map.get('Resource').children;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadResources(typeName: string) {
|
|
||||||
window.alert('Loading ' + typeName + ' resources');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
import { Resource } from './is-model/reference/entities/Resource';
|
||||||
|
|
||||||
|
export const resources: Array<Resource> = [
|
||||||
|
{
|
||||||
|
'@class': 'HostingNode',
|
||||||
|
header: {
|
||||||
|
'@class': 'Header',
|
||||||
|
uuid: 'f0460614-9ffb-4ecd-bf52-d91e8d81d604',
|
||||||
|
creator: 'luca.frosini',
|
||||||
|
modifiedBy: 'luca.frosini',
|
||||||
|
creationTime: '2109-06-29 12:00:00.000 CEST',
|
||||||
|
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
|
||||||
|
},
|
||||||
|
consistsOf: [
|
||||||
|
{
|
||||||
|
'@class': 'IsIdentifiedBy',
|
||||||
|
header: {
|
||||||
|
'@class': 'Header',
|
||||||
|
uuid: '84d5756a-693e-4b4d-99dd-a150cf843c3e',
|
||||||
|
creator: 'luca.frosini',
|
||||||
|
modifiedBy: 'luca.frosini',
|
||||||
|
creationTime: '2109-06-29 12:00:00.000 CEST',
|
||||||
|
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
'@class': 'NetworkingFacet',
|
||||||
|
header: {
|
||||||
|
'@class': 'Header',
|
||||||
|
uuid: 'aff4173c-ef7d-4f4f-9195-6b33d852e033',
|
||||||
|
creator: 'luca.frosini',
|
||||||
|
modifiedBy: 'luca.frosini',
|
||||||
|
creationTime: '2109-06-29 12:00:00.000 CEST',
|
||||||
|
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
|
||||||
|
},
|
||||||
|
hostName: 'pc-frosini.isti.cnr.it',
|
||||||
|
domainName: 'isti.cnr.it',
|
||||||
|
mask: null,
|
||||||
|
broadcastAddress: null,
|
||||||
|
ipaddress: '127.0.1.1',
|
||||||
|
Port: 8080
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
isRelatedTo: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'@class': 'EService',
|
||||||
|
header: {
|
||||||
|
'@class': 'Header',
|
||||||
|
uuid: '23b6145f-b5f0-42d1-9630-17590d9831d6',
|
||||||
|
creator: 'luca.frosini',
|
||||||
|
modifiedBy: 'luca.frosini',
|
||||||
|
creationTime: '2109-06-29 12:00:00.000 CEST',
|
||||||
|
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
|
||||||
|
},
|
||||||
|
consistsOf: [
|
||||||
|
{
|
||||||
|
'@class': 'IsIdentifiedBy',
|
||||||
|
header: {
|
||||||
|
'@class': 'Header',
|
||||||
|
uuid: '7fcff150-4007-4ad0-8618-a8f3ba83a366',
|
||||||
|
creator: 'luca.frosini',
|
||||||
|
modifiedBy: 'luca.frosini',
|
||||||
|
creationTime: '2109-06-29 12:00:00.000 CEST',
|
||||||
|
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
'@class': 'SoftwareFacet',
|
||||||
|
header: {
|
||||||
|
'@class': 'Header',
|
||||||
|
uuid: '4e664568-1669-4b38-a3db-acf1de789c96',
|
||||||
|
creator: 'luca.frosini',
|
||||||
|
modifiedBy: 'luca.frosini',
|
||||||
|
creationTime: '2109-06-29 12:00:00.000 CEST',
|
||||||
|
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
|
||||||
|
},
|
||||||
|
group: 'vre-management',
|
||||||
|
name: 'whn-manager',
|
||||||
|
version: '1.3.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
isRelatedTo: []
|
||||||
|
}
|
||||||
|
];
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue