Commit 30b459f4 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

RFT v0.2.1

parent 0dae831e
<div *ngIf="!LoggedIn()"> <router-outlet></router-outlet> </div> <div *ngIf="!LoggedIn()">
<router-outlet></router-outlet>
</div>
<div *ngIf="LoggedIn()"> <div *ngIf="LoggedIn()">
<mat-sidenav-container> <mat-sidenav-container>
...@@ -17,7 +19,7 @@ ...@@ -17,7 +19,7 @@
<footer class="footer page-footer font-small "> <footer class="footer page-footer font-small ">
<!-- Copyright --> <!-- Copyright -->
<div class="footer-copyright text-center py-3">© 2021 Copyright: <div class="footer-copyright text-center py-3">© 2022 Copyright:
<a href="https://depend.csd.auth.gr/">Depend Research Team</a> <a href="https://depend.csd.auth.gr/">Depend Research Team</a>
</div> </div>
<!-- Copyright --> <!-- Copyright -->
...@@ -30,4 +32,3 @@ ...@@ -30,4 +32,3 @@
</div> </div>
<notifier-container></notifier-container> <notifier-container></notifier-container>
\ No newline at end of file
...@@ -35,9 +35,27 @@ import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil. ...@@ -35,9 +35,27 @@ import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.
import { InstancesListComponent } from './components/instances-list/instances-list.component'; import { InstancesListComponent } from './components/instances-list/instances-list.component';
import { Ng2SearchPipeModule } from 'ng2-search-filter'; import { Ng2SearchPipeModule } from 'ng2-search-filter';
import { NgxEchartsModule } from 'ngx-echarts'; import { NgxEchartsModule } from 'ngx-echarts';
import { CourseDialogComponentComponent } from './components/course-dialog-component/course-dialog-component.component';
@NgModule({ @NgModule({
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
Ng2SearchPipeModule,
HttpClientModule,
NgbModule,
NotifierModule,
BrowserAnimationsModule,
MaterialModule,
FlexLayoutModule,
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
}),
],
declarations: [ declarations: [
AppComponent, AppComponent,
LoginComponent, LoginComponent,
...@@ -57,22 +75,7 @@ import { NgxEchartsModule } from 'ngx-echarts'; ...@@ -57,22 +75,7 @@ import { NgxEchartsModule } from 'ngx-echarts';
GroupboilComponent, GroupboilComponent,
AddGroupboilComponent, AddGroupboilComponent,
InstancesListComponent, InstancesListComponent,
], CourseDialogComponentComponent,
imports: [
BrowserModule,
AppRoutingModule,
ReactiveFormsModule,
FormsModule,
Ng2SearchPipeModule,
HttpClientModule,
NgbModule,
NotifierModule,
BrowserAnimationsModule,
MaterialModule,
FlexLayoutModule,
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
}),
], ],
providers: [ providers: [
AuthService, AuthService,
...@@ -83,6 +86,6 @@ import { NgxEchartsModule } from 'ngx-echarts'; ...@@ -83,6 +86,6 @@ import { NgxEchartsModule } from 'ngx-echarts';
multi: true, multi: true,
}, },
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent],
}) })
export class AppModule { } export class AppModule { }
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Boilerplate } from 'src/app/models/boilerplate.model'; import { Boilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service'; import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
...@@ -41,19 +41,20 @@ export class AddBoilerplateComponent implements OnInit { ...@@ -41,19 +41,20 @@ export class AddBoilerplateComponent implements OnInit {
}; };
if (data.title != "") { if (data.title != "") {
data.title = data.title?.replace(/[^\w\s]/gi, ' ') data.title = data.title?.replace(/[^\w\s]/gi, ' ')
data.title = data.title?.replace(/ /g,"_")} data.title = data.title?.replace(/ /g, "_")
}
this.boilerplatelService.create(this.route.snapshot.params.gb, data) this.boilerplatelService.create(this.route.snapshot.params.gb, data)
.subscribe( .subscribe(
response => { response => {
this.notifier.notify("success",(JSON.stringify(response))); this.notifier.notify("success", "Requirement " + this.boilerplate.title + " created");
this.submitted = true; this.submitted = true;
this.router.navigate(['/groupboilerplates/'+this.route.snapshot.params.gb+'/boilerplates/details/'+response.id]); this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates/details/' + response.id]);
}, },
error => { error => {
console.log(error); console.log(error);
//error, warning, success, info, default //error, warning, success, info, default
this.notifier.notify("warning",(JSON.stringify(error["error"]["title"][0]))); this.notifier.notify("warning", (JSON.stringify(error["error"]["title"][0])));
}); });
} }
...@@ -69,39 +70,39 @@ export class AddBoilerplateComponent implements OnInit { ...@@ -69,39 +70,39 @@ export class AddBoilerplateComponent implements OnInit {
} }
prefixs = [ prefixs = [
{name: 'P1', details: "If/Unless <logical expression>", explanation: 'Expresses a logical condition. Paraphrases: in case, provided that, on condition that.'}, { name: 'P1', details: "If/Unless <logical expression>", explanation: 'Expresses a logical condition. Paraphrases: in case, provided that, on condition that.' },
{name: 'P2', details: "As soon as <occuring functionality>", explanation: 'Expresses a temporal stimulation concerned with the point in time of an completed occuring functionality. Paraphrases: in the moment, immediately, once.'}, { name: 'P2', details: "As soon as <occuring functionality>", explanation: 'Expresses a temporal stimulation concerned with the point in time of an completed occuring functionality. Paraphrases: in the moment, immediately, once.' },
{name: 'P3', details: "As long as <occuring functionality>", explanation: 'Expresses a temporal condition concerned with a period. The prefix clause and the main clause take place simultaneously. Paraphrases: meanwhile'}, { name: 'P3', details: "As long as <occuring functionality>", explanation: 'Expresses a temporal condition concerned with a period. The prefix clause and the main clause take place simultaneously. Paraphrases: meanwhile' },
]; ];
mains = [ mains = [
{name: 'M1', details: "system/function shall [not] set [<quantifier>] item [to stateValue]", explanation: 'Sets item Paraphrases: initiate, reset, update.'}, { name: 'M1', details: "system/function shall [not] set [<quantifier>] item [to stateValue]", explanation: 'Sets item Paraphrases: initiate, reset, update.' },
{name: 'M2', details: "system/function shall [not] set state to stateValue", explanation: 'Sets state to value Paraphrases: initiate, reset, update.'}, { name: 'M2', details: "system/function shall [not] set state to stateValue", explanation: 'Sets state to value Paraphrases: initiate, reset, update.' },
{name: 'M3', details: "system/function shall [not] send [<quantifier>] item", explanation: 'Sends item Paraphrases: forward.'}, { name: 'M3', details: "system/function shall [not] send [<quantifier>] item", explanation: 'Sends item Paraphrases: forward.' },
{name: 'M4', details: "system/function shall [not] receive [<quantifier>] item", explanation: 'Receives item Paraphrases: accept, acquire.'}, { name: 'M4', details: "system/function shall [not] receive [<quantifier>] item", explanation: 'Receives item Paraphrases: accept, acquire.' },
{name: 'M5', details: "system/function shall [not] ingest flow", explanation: 'Ingests flow. Paraphrases: get.'}, { name: 'M5', details: "system/function shall [not] ingest flow", explanation: 'Ingests flow. Paraphrases: get.' },
{name: 'M6', details: "system/function shall [not] emit flow", explanation: 'Emits flow. Paraphrases: produce.'}, { name: 'M6', details: "system/function shall [not] emit flow", explanation: 'Emits flow. Paraphrases: produce.' },
{name: 'M7', details: "system shall [not] perform function", explanation: 'System requirement. Paraphrases: execute.'}, { name: 'M7', details: "system shall [not] perform function", explanation: 'System requirement. Paraphrases: execute.' },
{name: 'M8', details: "function shall [not] invoke function", explanation: 'Function invokes another function. Paraphrases: call, request'}, { name: 'M8', details: "function shall [not] invoke function", explanation: 'Function invokes another function. Paraphrases: call, request' },
{name: 'M9', details: "system shall [not] present interface [to system]", explanation: 'Presents interface. Paraphrases: provide'}, { name: 'M9', details: "system shall [not] present interface [to system]", explanation: 'Presents interface. Paraphrases: provide' },
{name: 'M10', details: "system/interface shall [not] transfer flow/item", explanation: 'Transfers TraversingConcept. Paraphrases: transmit, broadcast'}, { name: 'M10', details: "system/interface shall [not] transfer flow/item", explanation: 'Transfers TraversingConcept. Paraphrases: transmit, broadcast' },
{name: 'M11', details: "system shall [not] interact with system [using <connection>] [as defined in <text>]", explanation: 'System requirement expressing interface interraction'}, { name: 'M11', details: "system shall [not] interact with system [using <connection>] [as defined in <text>]", explanation: 'System requirement expressing interface interraction' },
{name: 'M12', details: "system shall [not] have state state [with values stateSet]", explanation: 'System requirement expressing system modes'}, { name: 'M12', details: "system shall [not] have state state [with values stateSet]", explanation: 'System requirement expressing system modes' },
{name: 'M13', details: "system state stateValue shall [not] have substate state [with values stateSet]", explanation: 'System requirement expressing system sub modes per mode'}, { name: 'M13', details: "system state stateValue shall [not] have substate state [with values stateSet]", explanation: 'System requirement expressing system sub modes per mode' },
{name: 'M14', details: "system item shall [not] take values from stateSet", explanation: 'System requirement expressing item stateSet'}, { name: 'M14', details: "system item shall [not] take values from stateSet", explanation: 'System requirement expressing item stateSet' },
{name: 'M15', details: "system item shall [not] be composed from item", explanation: 'System requirement expressing item decomposition stateSet'}, { name: 'M15', details: "system item shall [not] be composed from item", explanation: 'System requirement expressing item decomposition stateSet' },
{name: 'M16', details: "system shall [not] contain system", explanation: 'System decomposition.'}, { name: 'M16', details: "system shall [not] contain system", explanation: 'System decomposition.' },
]; ];
suffixs = [ suffixs = [
{name: 'S1', details: "<numerical-afirmative> j <closed-interval> [per <time-unit>]", explanation: ''}, { name: 'S1', details: "<numerical-afirmative> j <closed-interval> [per <time-unit>]", explanation: '' },
{name: 'S2', details: "after/before flow", explanation: ''}, { name: 'S2', details: "after/before flow", explanation: '' },
{name: 'S3', details: "[every/for a period of/within/for at least] <number> <time-unit> [from flow]", explanation: ''}, { name: 'S3', details: "[every/for a period of/within/for at least] <number> <time-unit> [from flow]", explanation: '' },
{name: 'S4', details: "at the beginning/at the end", explanation: ''}, { name: 'S4', details: "at the beginning/at the end", explanation: '' },
{name: 'S5', details: "at even intervals", explanation: ''}, { name: 'S5', details: "at even intervals", explanation: '' },
{name: 'S6', details: "sequentially", explanation: ''}, { name: 'S6', details: "sequentially", explanation: '' },
]; ];
systems = [{pos:"Prefix", data: this.prefixs}, {pos:"Main", data: this.mains}, {pos:"Suffix", data: this.suffixs}] systems = [{ pos: "Prefix", data: this.prefixs }, { pos: "Main", data: this.mains }, { pos: "Suffix", data: this.suffixs }]
} }
...@@ -5,28 +5,21 @@ ...@@ -5,28 +5,21 @@
</ol> </ol>
</nav> </nav>
<div class="submit-form"> <div [hidden]="!submitted">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<div class="submit-form">
<form name="myForm" ngNativeValidate> <form name="myForm" ngNativeValidate>
<div class="form-group"> <div class="form-group">
<label for="title_bgroup">Requirement Title</label> <label for="title_bgroup">Project title</label>
<input type="text" class="form-control" id="title_bgroup" <input type="text" class="form-control" id="title_bgroup" required [(ngModel)]="groupboilerplate.title_bgroup"
required name="title_bgroup">
[(ngModel)]="groupboilerplate.title_bgroup" name="title_bgroup">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="description">Description of project</label> <label for="description">Description of project</label>
<textarea <textarea type="text" class="form-control" id="description" required [(ngModel)]="groupboilerplate.description"
type="text" name="description"></textarea>
class="form-control"
id="description"
required
[(ngModel)]="groupboilerplate.description"
name="description"
></textarea>
</div> </div>
</form> </form>
<button (click)="saveBoilerplate()" class="btn btn-success" >Submit</button> <button (click)="saveBoilerplate()" class="btn btn-success">Submit</button>
</div>
\ No newline at end of file
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router'; import { Router } from '@angular/router';
import { GroupBoilerplate } from 'src/app/models/boilerplate.model'; import { GroupBoilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service'; import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
...@@ -18,7 +18,7 @@ export class AddGroupboilComponent implements OnInit { ...@@ -18,7 +18,7 @@ export class AddGroupboilComponent implements OnInit {
submitted = false; submitted = false;
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
constructor(private boilerplatelService: BoilerplateService, private router:Router, notifierService: NotifierService) { constructor(private boilerplatelService: BoilerplateService, private router: Router, notifierService: NotifierService) {
this.notifier = notifierService; this.notifier = notifierService;
} }
...@@ -27,20 +27,21 @@ export class AddGroupboilComponent implements OnInit { ...@@ -27,20 +27,21 @@ export class AddGroupboilComponent implements OnInit {
saveBoilerplate(): void { saveBoilerplate(): void {
const data = { const data = {
title_bgroup: this.groupboilerplate.title_bgroup, title_bgroup: this.groupboilerplate.title_bgroup,
description: this.groupboilerplate.description, description: this.groupboilerplate.description ? this.groupboilerplate.description : this.groupboilerplate.title_bgroup,
}; };
this.submitted = true;
this.boilerplatelService.creategroupboil(data) this.boilerplatelService.creategroupboil(data)
.subscribe( .subscribe(
response => { response => {
this.notifier.notify("success",(JSON.stringify(response))); this.notifier.notify("success", "Project " + this.groupboilerplate.title_bgroup + ' created');
this.submitted = true; this.submitted = false;
this.router.navigate(['/groupboilerplates']); this.router.navigate(['/groupboilerplates']);
}, },
error => { error => {
console.log(error); console.log(error);
//error, warning, success, info, default //error, warning, success, info, default
this.notifier.notify("warning",(JSON.stringify(error["error"]["title"][0]))); this.submitted = false;
this.notifier.notify("warning", (JSON.stringify(error["error"]["title"][0])));
}); });
} }
newBoilerplate(): void { newBoilerplate(): void {
......
...@@ -9,28 +9,18 @@ ...@@ -9,28 +9,18 @@
</ol> </ol>
</nav> </nav>
<mat-grid-list cols="2"> <mat-grid-list cols="2">
<div class="first"> <div class="first">
<div *ngIf="currentboilerplate.id" class="edit-form"> <div *ngIf="currentboilerplate.id" class="edit-form">
<form ngNativeValidate> <form ngNativeValidate>
<div class="form-group" style="display:flex; flex-direction: row; align-items: center"> <div class="form-group" style="display:flex; flex-direction: row; align-items: center">
<label for="title" style="margin-right: 50px;">Requirement title</label> <label for="title" style="margin-right: 50px;">Requirement title</label>
<input <input name="title" id="title" type="text" class="form-control" required
name="title" [(ngModel)]="currentboilerplate.title" (change)="this.updateBoilerplate()" style="width: 63%;" />
id="title"
type="text"
class="form-control"
required
[(ngModel)]="currentboilerplate.title"
(change)="this.updateBoilerplate()"
style="width: 63%;"/>
</div> </div>
<div style="display: flex; flex-grow: grow; margin-top: 50px; "> <div style="display: flex; flex-grow: grow; margin-top: 50px; ">
<form class="form-group form-inline "> <form class="form-group form-inline ">
<mat-checkbox class="example-full-width" <mat-checkbox class="example-full-width" [(ngModel)]="currentboilerplate.has_prefix"
[(ngModel)]="currentboilerplate.has_prefix" (change)="this.updateBoilerplate()" name="has_prefix">Prefix
(change)="this.updateBoilerplate()"
name="has_prefix"
>Prefix
</mat-checkbox> </mat-checkbox>
</form> </form>
<div *ngIf="this.currentboilerplate.has_prefix" style="margin-left: 50px;"> <div *ngIf="this.currentboilerplate.has_prefix" style="margin-left: 50px;">
...@@ -40,11 +30,8 @@ ...@@ -40,11 +30,8 @@
<mat-divider></mat-divider> <mat-divider></mat-divider>
<div style="display: flex; flex-grow: grow; margin-top: 50px;"> <div style="display: flex; flex-grow: grow; margin-top: 50px;">
<form class="form-group form-inline "> <form class="form-group form-inline ">
<mat-checkbox class="example-full-width" <mat-checkbox class="example-full-width" [(ngModel)]="currentboilerplate.has_main" name="has_prefix"
[(ngModel)]="currentboilerplate.has_main" [disabled]="true">Main
name="has_prefix"
[disabled]="true"
>Main
</mat-checkbox> </mat-checkbox>
</form> </form>
<div *ngIf="this.currentboilerplate.has_main" style="margin-left: 50px;"> <div *ngIf="this.currentboilerplate.has_main" style="margin-left: 50px;">
...@@ -54,11 +41,8 @@ ...@@ -54,11 +41,8 @@
<mat-divider></mat-divider> <mat-divider></mat-divider>
<div style="display: flex; flex-grow: grow; margin-top: 50px;"> <div style="display: flex; flex-grow: grow; margin-top: 50px;">
<form class="form-group form-inline "> <form class="form-group form-inline ">
<mat-checkbox class="example-full-width" <mat-checkbox class="example-full-width" [(ngModel)]="this.currentboilerplate.has_suffix"
[(ngModel)]="this.currentboilerplate.has_suffix" (change)="this.updateBoilerplate()" name="has_suffix">Suffix
(change)="this.updateBoilerplate()"
name="has_suffix"
>Suffix
</mat-checkbox> </mat-checkbox>
</form> </form>
<div *ngIf="this.currentboilerplate.has_suffix" style="margin-left: 50px;"> <div *ngIf="this.currentboilerplate.has_suffix" style="margin-left: 50px;">
...@@ -68,16 +52,11 @@ ...@@ -68,16 +52,11 @@
</form> </form>
<div class="list row"> <div class="list row">
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="start"> <div fxFlex fxLayout fxHide.xs fxLayoutAlign="start">
<input class="btn btn-success" <input class="btn btn-success" type="button" value=" Update Boilerplate"
type="button" (click)="updateDetailsOfBoilerplate()" />
value=" Update Boilerplate"
(click)="updateDetailsOfBoilerplate()"/>
</div> </div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end"> <div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<input class="btn btn-warning" <input class="btn btn-warning" type="button" value="Delete Boilerplate" (click)="deleteBoilerplate()" />
type="button"
value="Delete Boilerplate"
(click)="deleteBoilerplate()"/>
</div> </div>
</div> </div>
<p>{{ message }}</p> <p>{{ message }}</p>
...@@ -88,17 +67,19 @@ ...@@ -88,17 +67,19 @@
<div *ngIf="!currentboilerplate.id"> <div *ngIf="!currentboilerplate.id">
<mat-spinner style="margin: auto;"></mat-spinner> <mat-spinner style="margin: auto;"></mat-spinner>
</div> </div>
</div> </div>
<!-- Dictionary --> <!-- Dictionary -->
<div class="second"> <div class="second">
<div class="search-hero"> <div class="search-hero">
<input class="form-control" type="text" name="search" [(ngModel)]="searchText" autocomplete="off" placeholder="Start searching for a System, Function, etc."> <input class="form-control" type="text" name="search" [(ngModel)]="searchText" autocomplete="off"
placeholder="Start searching for a System, Function, etc.">
</div> </div>
<mat-tab-group mat-align-tabs="center"> <mat-tab-group mat-align-tabs="center">
<div *ngFor="let section of systems| filter:searchText"> <div *ngFor="let section of systems| filter:searchText">
<mat-tab label={{section.Name}}> <mat-tab label={{section.Name}}>
<div *ngFor="let item of section.TheClasses| filter:searchText"> <div *ngFor="let item of section.TheClasses| filter:searchText">
<div *ngIf="item.Class">
<mat-accordion> <mat-accordion>
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
...@@ -111,7 +92,10 @@ ...@@ -111,7 +92,10 @@
</mat-expansion-panel-header> </mat-expansion-panel-header>
{{ item.Comment }} {{ item.Comment }}
<ul> <ul>
<button mat-button [matMenuTriggerFor]="menu" #menuTrigger><h4><b>Instances</b></h4></button> <button mat-button [matMenuTriggerFor]="menu"
[matMenuTriggerData]="{section: section.Name ,class: item.Class}" #menuTrigger>
<h4><b>Instances</b></h4>
</button>
<div *ngFor="let instan of item.Instance_of_Class| filter:searchText"> <div *ngFor="let instan of item.Instance_of_Class| filter:searchText">
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
...@@ -125,7 +109,8 @@ ...@@ -125,7 +109,8 @@
</li> </li>
</div> </div>
</ul> </ul>
<ul> <h4><b>Subclasses</b></h4> <ul>
<h4><b>Subclasses</b></h4>
<div *ngFor="let sub of item.Subclass| filter:searchText"> <div *ngFor="let sub of item.Subclass| filter:searchText">
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
...@@ -135,7 +120,11 @@ ...@@ -135,7 +120,11 @@
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<p>{{sub.SubclassComment}}</p> <p>{{sub.SubclassComment}}</p>
<ul> <h5>Instances</h5> <ul> <button mat-button [matMenuTriggerFor]="menu"
[matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name}"
#menuTrigger>
<h5>Instances</h5>
</button>
<div *ngFor="let instansub of sub.InstanceOfSubclass| filter:searchText"> <div *ngFor="let instansub of sub.InstanceOfSubclass| filter:searchText">
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
...@@ -158,13 +147,19 @@ ...@@ -158,13 +147,19 @@
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
</div> </div>
<ul> <div *ngIf= checklen(section.GeneralInstances)><h4><b>Instances</b></h4></div> </div>
<ul>
<div *ngIf=checklen(section.GeneralInstances)>
<button mat-button [matMenuTriggerFor]="menu" [matMenuTriggerData]="{section: section.Name}" #menuTrigger>
<h4>Instances</h4>
</button>
</div>
<div *ngFor="let genin of section.GeneralInstances| filter:searchText"> <div *ngFor="let genin of section.GeneralInstances| filter:searchText">
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title>
{{genin.GeneralInstances}} {{genin.Instance}}
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
{{genin.Comment}} {{genin.Comment}}
...@@ -179,9 +174,10 @@ ...@@ -179,9 +174,10 @@
<div *ngIf="!checklen(systems)"> <div *ngIf="!checklen(systems)">
<mat-spinner style="margin: auto;"></mat-spinner> <mat-spinner style="margin: auto;"></mat-spinner>
</div> </div>
</div> </div>
</mat-grid-list > </mat-grid-list>
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
<button mat-menu-item >Add Instances</button> <ng-template let-class="class" let-section="section" let-subclass="subclass" matMenuContent><button mat-menu-item
(click)="openDialog(section, class, subclass)">Add Instances</button> </ng-template>
</mat-menu> </mat-menu>
\ No newline at end of file
...@@ -4,25 +4,25 @@ import { Boilerplate } from 'src/app/models/boilerplate.model'; ...@@ -4,25 +4,25 @@ import { Boilerplate } from 'src/app/models/boilerplate.model';
import { Sections } from 'src/app/models/boilerplate.model'; import { Sections } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service'; import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { MainService } from 'src/app/services/main.service'; import { MainService } from 'src/app/services/main.service';
import {MainDetailsComponent} from 'src/app/components/main-details/main-details.component' import { MainDetailsComponent } from 'src/app/components/main-details/main-details.component'
import {PrefixDetailsComponent} from 'src/app/components/prefix-details/prefix-details.component' import { PrefixDetailsComponent } from 'src/app/components/prefix-details/prefix-details.component'
import {SuffixDetailsComponent} from 'src/app/components/suffix-details/suffix-details.component' import { SuffixDetailsComponent } from 'src/app/components/suffix-details/suffix-details.component'
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { CourseDialogComponentComponent, DialogData } from 'src/app/components/course-dialog-component/course-dialog-component.component';
@Component({ @Component({
selector: 'app-boilerplate-details', selector: 'app-boilerplate-details',
templateUrl: './boilerplate-details.component.html', templateUrl: './boilerplate-details.component.html',
styleUrls: ['./boilerplate-details.component.scss'] styleUrls: ['./boilerplate-details.component.scss']
}) })
export class BoilerplateDetailsComponent implements OnInit { export class BoilerplateDetailsComponent implements OnInit {
panelOpenState = false; panelOpenState = false;
subjects:string[] = []; subjects: string[] = [];
systems?: Sections []; systems?: Sections[];
currentboilerplate: Boilerplate = { currentboilerplate: Boilerplate = {
group_of_boilerplate: this.route.snapshot.params.gb, group_of_boilerplate: this.route.snapshot.params.gb,
...@@ -36,14 +36,19 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -36,14 +36,19 @@ export class BoilerplateDetailsComponent implements OnInit {
message = ''; message = '';
searchText = ''; searchText = '';
searchTextinstances = ''; searchTextinstances = '';
addinstance = '';
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
constructor( constructor(
private mainService: MainService, private mainService: MainService,
private boilerplateService: BoilerplateService, private boilerplateService: BoilerplateService,
private route: ActivatedRoute, private route: ActivatedRoute,
notifierService: NotifierService, notifierService: NotifierService,
private router: Router) { this.notifier = notifierService; } private router: Router,
public dialog: MatDialog) { this.notifier = notifierService; }
@ViewChild(MainDetailsComponent) mainchild!: MainDetailsComponent; @ViewChild(MainDetailsComponent) mainchild!: MainDetailsComponent;
@ViewChild(PrefixDetailsComponent) prefchild!: PrefixDetailsComponent; @ViewChild(PrefixDetailsComponent) prefchild!: PrefixDetailsComponent;
...@@ -56,12 +61,12 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -56,12 +61,12 @@ export class BoilerplateDetailsComponent implements OnInit {
} }
getBoilerplate(gb:any, id: number): void { getBoilerplate(gb: any, id: number): void {
this.boilerplateService.get(gb, id) this.boilerplateService.get(gb, id)
.subscribe( .subscribe(
data => { data => {
this.currentboilerplate = data; this.currentboilerplate = data;
console.log(data); //console.log(data);
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -70,35 +75,37 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -70,35 +75,37 @@ export class BoilerplateDetailsComponent implements OnInit {
updateBoilerplate(): any { updateBoilerplate(): any {
if (this.currentboilerplate.title != "") { if (this.currentboilerplate.title != "") {
this.currentboilerplate.title = this.currentboilerplate.title ?.replace(/[^\w\s]/gi, ' ') this.currentboilerplate.title = this.currentboilerplate.title?.replace(/[^\w\s]/gi, ' ')
this.currentboilerplate.title = this.currentboilerplate.title?.replace(/ /g,"_")} this.currentboilerplate.title = this.currentboilerplate.title?.replace(/ /g, "_")
}
this.boilerplateService.update(this.route.snapshot.params.gb, this.currentboilerplate.id, this.currentboilerplate) this.boilerplateService.update(this.route.snapshot.params.gb, this.currentboilerplate.id, this.currentboilerplate)
.subscribe( .subscribe(
response => { response => {
//this.notifier.notify("success",(JSON.stringify("Requirement " + this.currentboilerplate.title + " updated"))); //this.notifier.notify("success",(JSON.stringify("Requirement " + this.currentboilerplate.title + " updated")));
//this.router.navigate(['/groupboilerplates/'+this.route.snapshot.params.gb+'/boilerplates']); //this.router.navigate(['/groupboilerplates/'+this.route.snapshot.params.gb+'/boilerplates']);
if (this.currentboilerplate.has_prefix){this.prefchild.getAllPrefix(this.currentboilerplate.id)}; if (this.currentboilerplate.has_prefix) { this.prefchild.getAllPrefix(this.currentboilerplate.id) };
if (this.currentboilerplate.has_suffix){this.sufchild.getAllSuffix(this.currentboilerplate.id);}; if (this.currentboilerplate.has_suffix) { this.sufchild.getAllSuffix(this.currentboilerplate.id); };
}, },
error => { error => {
this.notifier.notify("warning",(JSON.stringify(error))); this.notifier.notify("warning", (JSON.stringify(error)));
});} });
}
updateDetailsOfBoilerplate(): any { updateDetailsOfBoilerplate(): any {
if (this.currentboilerplate.has_prefix){this.prefchild.updatePrefix()}; if (this.currentboilerplate.has_prefix) { this.prefchild.updatePrefix() };
if (this.currentboilerplate.has_main){this.mainchild.updateMain();}; if (this.currentboilerplate.has_main) { this.mainchild.updateMain(); };
if (this.currentboilerplate.has_suffix){this.sufchild.updateSuffix();}; if (this.currentboilerplate.has_suffix) { this.sufchild.updateSuffix(); };
this.notifier.notify("success",(JSON.stringify("Requirement " + this.currentboilerplate.title + " updated"))); this.notifier.notify("success", (JSON.stringify("Requirement " + this.currentboilerplate.title + " updated")));
} }
deleteBoilerplate(): void { deleteBoilerplate(): void {
if(confirm("Αre you sure you want to delete this Boilerplate?")) { if (confirm("Αre you sure you want to delete this Boilerplate?")) {
this.boilerplateService.delete(this.route.snapshot.params.gb, this.currentboilerplate.id) this.boilerplateService.delete(this.route.snapshot.params.gb, this.currentboilerplate.id)
.subscribe( .subscribe(
response => { response => {
console.log(response); //console.log(response);
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates']); this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates']);
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -106,22 +113,105 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -106,22 +113,105 @@ export class BoilerplateDetailsComponent implements OnInit {
} }
} }
getchoices(gb : any): void{ getchoices(gb: any): void {
//System //System
this.mainService.getdictionary(gb) this.mainService.getdictionary(gb)
.subscribe( .subscribe(
data => { data => {
// console.log(data[0].Dictionary_Data); // console.log(data[0].Dictionary_Data);
this.systems = data[0].Dictionary_Data this.systems = data[0].Dictionary_Data
}, },
error => { error => {
console.log(error); console.log(error);
}); });
} }
checklen(i:any): any { checklen(i: any): any {
if (i.length>1){ return true} if (i) {
if (i.length >= 1) { return true }
}
return false return false
} }
currentDialog: DialogData = {
instance: "",
comment: "",
}
openDialog(section: any, classes: any, subclass: any) {
const dialogRef = this.dialog.open(CourseDialogComponentComponent, {
width: '500px',
data: { name: section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : ''), instance: this.currentDialog.instance, comment: this.currentDialog.comment },
});
dialogRef.afterClosed().subscribe(result => {
if (result.instance != "") {
result.instance = result.instance?.replace(/[^\w\s]/gi, ' ')
result.instance = result.instance?.replace(/ /g, "_")
}
if (result.instance) {
this.addinstance = section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + ' : ' + result.instance;
//console.log(this.addinstance);
this.mainService.setinstances(this.route.snapshot.params.gb, this.addinstance, (result.comment ? result.comment : " "))
.subscribe(
data => {
this.mainchild.getmainchoices(this.route.snapshot.params.gb);
//console.log(data);
},
error => {
if (error.error.text == 'Update Instance') {
this.notifier.notify("success", (JSON.stringify(error.error.text)));
if (this.systems) {
this.systems.forEach(function (value) {
if (section == value.Name) {
if (value.TheClasses) {
value.TheClasses.forEach(function (value) {
if (classes == value.Class) {
//UI - Add instance of a Class (e.g instance for System : Vehicle)
if (!subclass) {
if (value.Instance_of_Class) {
value.Instance_of_Class.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
}
else {
value.Instance_of_Class = [];
value.Instance_of_Class.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
}
}
//UI - Add instance of a SubClass (e.g instance for System : Software : Plan)
if (subclass) {
if (value.Subclass) {
value.Subclass.forEach(function (value) {
if (subclass == value.SubClass_name) {
//console.log('Add instance of a SubClass', value.InstanceOfSubclass);
if (value.InstanceOfSubclass) {
value.InstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
}
else {
value.InstanceOfSubclass = [];
value.InstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
}
}
})
}
}
}
});
}
if (!classes) { if (value.GeneralInstances) { value.GeneralInstances.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) } }
else { value.GeneralInstances = []; value.GeneralInstances.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }); }
}
})
}
this.mainchild.getmainchoices(this.route.snapshot.params.gb);
} else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); }
});
//this.ngOnInit();
//Call to update instances
}
});
}
} }
...@@ -7,39 +7,31 @@ ...@@ -7,39 +7,31 @@
<div class="list row"> <div class="list row">
<div class="col-md-14"> <div class="col-md-14">
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end"> <div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<input <input type="text" class="form-control" placeholder="Search" (keyup)="applyFilter($event)" #input />
type="text"
class="form-control"
placeholder="Search"
(keyup)="applyFilter($event)"
#input/>
</div> </div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end"> <div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items"> <ul fxLayout fxLayoutGap="15px" class="navigation-items">
<div> <div>
<input class="btn btn-success" type="button" value="Add Requirement" routerLink="add-boilerplate"/> <input class="btn btn-success" type="button" value="Add Requirement" routerLink="add-boilerplate" />
</div> </div>
</ul> </ul>
</div> </div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end"> <div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul *ngFor="let inf of infer;" fxLayout fxLayoutGap="15px" class="navigation-items"> <ul *ngFor="let inf of infer;" fxLayout fxLayoutGap="15px" class="navigation-items">
<div> <div>
<input class="btn btn-info" <input class="btn btn-info" [disabled]="exporting" type="button" value="Inferencing"
[disabled] = "exporting" (click)="updateInfer(inf.id)" />
type="button"
value="Inferencing"
(click)="updateInfer(inf.id)"/>
</div> </div>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
<div [hidden] = "!showSpinner"> <div [hidden]="!showSpinner">
<mat-progress-bar mode="indeterminate"></mat-progress-bar> <mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div> </div>
<div class="mat-elevation-z8"> <div class="mat-elevation-z8">
<table mat-table [dataSource]="newdataSource" class="mat-elevation-z8"> <table mat-table [dataSource]="newdataSource" class="mat-elevation-z8">
<!-- Position Column --> <!-- Position Column -->
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> No. </th> <th mat-header-cell *matHeaderCellDef> No. </th>
...@@ -54,7 +46,9 @@ ...@@ -54,7 +46,9 @@
<!-- Name Column --> <!-- Name Column -->
<ng-container matColumnDef="title_data"> <ng-container matColumnDef="title_data">
<th mat-header-cell *matHeaderCellDef> Title </th> <th mat-header-cell *matHeaderCellDef> Title </th>
<td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}}>{{element.title_data}} <span *ngIf="get_metrics(element.title_data).length > 0" matBadge={{get_metrics(element.title_data).length}} matBadgeColor="warn" matBadgeSize="small" position="above">&nbsp;&nbsp; </span> <td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}}>{{element.title_data}} <span
*ngIf="get_metrics(element.title_data).length > 0" matBadge={{get_metrics(element.title_data).length}}
matBadgeColor="warn" matBadgeSize="small" position="above">&nbsp;&nbsp; </span>
</td> </td>
</ng-container> </ng-container>
...@@ -78,14 +72,15 @@ ...@@ -78,14 +72,15 @@
<tr mat-header-row *matHeaderRowDef="newdisplayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="newdisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: newdisplayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: newdisplayedColumns;"></tr>
</table> </table>
<mat-paginator #paginator [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator> <mat-paginator #paginator [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator>
</div> </div>
<div echarts [options]="chartOption" class="demo-chart"></div> <div echarts [options]="chartOption" class="demo-chart"></div>
<div class="content"> <div class="content">
<div fxLayout="row wrap"> <div fxLayout="row wrap">
<div fxFlex="33%"> <div fxFlex="33.3%">
<mat-card class="example-card"> <mat-card class="example-card">
<mat-card-header> <mat-card-header>
<div class="example-header-image"></div> <div class="example-header-image"></div>
...@@ -93,18 +88,22 @@ ...@@ -93,18 +88,22 @@
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle> <mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle>
</mat-card-header> </mat-card-header>
</mat-card> </mat-card>
</div>
<div fxFlex="33.3%">
<mat-card class="example-card"> <mat-card class="example-card">
<mat-card-header> <mat-card-header>
<div class="example-header-image"></div> <div class="example-header-image"></div>
<mat-card-title>Complete Requirement</mat-card-title> <mat-card-title>Complete Requirement</mat-card-title>
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle> <mat-card-subtitle>{{getnumreq() - getincreq()}}</mat-card-subtitle>
</mat-card-header> </mat-card-header>
</mat-card> </mat-card>
</div>
<div fxFlex="33.3%">
<mat-card class="example-card"> <mat-card class="example-card">
<mat-card-header> <mat-card-header>
<div class="example-header-image"></div> <div class="example-header-image"></div>
<mat-card-title>Incomplete Requirement</mat-card-title> <mat-card-title>Incomplete Requirement</mat-card-title>
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle> <mat-card-subtitle>{{getincreq()}}</mat-card-subtitle>
</mat-card-header> </mat-card-header>
</mat-card> </mat-card>
</div> </div>
......
...@@ -5,8 +5,8 @@ import { InferenceResults } from 'src/app/models/boilerplate.model'; ...@@ -5,8 +5,8 @@ import { InferenceResults } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service'; import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { PrefixService } from 'src/app/services/prefix.service'; import { PrefixService } from 'src/app/services/prefix.service';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import {MatTableDataSource} from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { EChartsOption } from 'echarts'; import { EChartsOption } from 'echarts';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
...@@ -34,12 +34,12 @@ export class BoilerplateListComponent implements OnInit { ...@@ -34,12 +34,12 @@ export class BoilerplateListComponent implements OnInit {
type: 'pie', type: 'pie',
radius: ['40%', '70%'], radius: ['40%', '70%'],
data: [ data: [
{value: 0, name: '1'}, { value: 0, name: '1' },
{value: 0, name: '2'}, { value: 0, name: '2' },
{value: 0, name: '3'}, { value: 0, name: '3' },
{value: 0, name: '4'}, { value: 0, name: '4' },
{value: 0, name: '5'} ] { value: 0, name: '5' }]
}, }
], ],
}; };
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
...@@ -54,27 +54,28 @@ export class BoilerplateListComponent implements OnInit { ...@@ -54,27 +54,28 @@ export class BoilerplateListComponent implements OnInit {
currentIndex = -1; currentIndex = -1;
title = ''; title = '';
displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix', 'action']; displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix', 'action'];
newdisplayedColumns: string[] = ['id','title_data' ,'prefix_data', 'main_data', 'suffix_data', 'action']; newdisplayedColumns: string[] = ['id', 'title_data', 'prefix_data', 'main_data', 'suffix_data', 'action'];
dataSource :Boilerplate[] = [{}]; dataSource: Boilerplate[] = [{}];
thenewdataSource:BoilerplateData[] = [{}]; thenewdataSource: BoilerplateData[] = [{}];
newdataSource = new MatTableDataSource(this.thenewdataSource); newdataSource = new MatTableDataSource(this.thenewdataSource);
infer:InferenceResults[] = [{}]; infer: InferenceResults[] = [{}];
//when inference button is pressed //when inference button is pressed
showSpinner = false; showSpinner = false;
exporting = false; exporting = false;
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement","InconsistentRequirement","NoisyRequirement","OpaqueRequirement","RedundantRequirement"] list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement", "InconsistentRequirement", "NoisyRequirement", "OpaqueRequirement", "RedundantRequirement"]
@ViewChild(MatPaginator) paginator= this.newdataSource.paginator; @ViewChild(MatPaginator) paginator = this.newdataSource.paginator;
dataofboilerplates: any [] = []; dataofboilerplates: any[] = [];
aprefix: any [] = []; aprefix: any[] = [];
main: any; main: any;
suffix: any; suffix: any;
constructor(private boilerplateService: BoilerplateService, private prefixService: PrefixService, private route: ActivatedRoute, constructor(private boilerplateService: BoilerplateService, private prefixService: PrefixService, private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) { this.notifier = notifierService; private router: Router, notifierService: NotifierService) {
this.notifier = notifierService;
} }
...@@ -102,11 +103,11 @@ export class BoilerplateListComponent implements OnInit { ...@@ -102,11 +103,11 @@ export class BoilerplateListComponent implements OnInit {
this.boilerplateService.getAllData(this.route.snapshot.params.gb) this.boilerplateService.getAllData(this.route.snapshot.params.gb)
.subscribe( .subscribe(
data => { data => {
this.boilerplatesdata =data; this.boilerplatesdata = data;
this.thenewdataSource = data; this.thenewdataSource = data;
this.newdataSource = new MatTableDataSource(this.thenewdataSource); this.newdataSource = new MatTableDataSource(this.thenewdataSource);
this.newdataSource.paginator = this.paginator; this.newdataSource.paginator = this.paginator;
console.log(data) //console.log(data)
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -127,13 +128,13 @@ export class BoilerplateListComponent implements OnInit { ...@@ -127,13 +128,13 @@ export class BoilerplateListComponent implements OnInit {
SearchTitle(): void { SearchTitle(): void {
if (this.title != ''){ if (this.title != '') {
this.boilerplateService.findByTitle(this.route.snapshot.params.gb, this.title) this.boilerplateService.findByTitle(this.route.snapshot.params.gb, this.title)
.subscribe( .subscribe(
data => { data => {
this.boilerplates = data; this.boilerplates = data;
this.dataSource = data; this.dataSource = data;
console.log(data); //console.log(data);
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -145,30 +146,35 @@ export class BoilerplateListComponent implements OnInit { ...@@ -145,30 +146,35 @@ export class BoilerplateListComponent implements OnInit {
} }
} }
GetRoute(): void { GetRoute(): void {
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates/add-boilerplate']) this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates/add-boilerplate'])
} }
GetRoutedit(id: any): void { GetRoutedit(id: any): void {
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates'+ id]) this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates' + id])
} }
getInfer(): void{ getInfer(): void {
this.boilerplateService.getAllInfer(this.route.snapshot.params.gb) this.boilerplateService.getAllInfer(this.route.snapshot.params.gb)
.subscribe( .subscribe(
data => { data => {
this.currentInfer = data[0]; this.currentInfer = data[0];
this.infer = data; this.infer = data;
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g,"\"")) const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
var final = [] var final = []
for (let i of this.list_of_inference_metrics){ for (let i of this.list_of_inference_metrics) {
if(obj[i] != undefined){ if (obj[i] != undefined) {
final.push({ value: obj[i].length, name: i })
}
}
console.log(final);
final.push({value: obj[i].length, name: i})}
if (this.chartOption?.series ){
this.chartOption.series = [{ this.chartOption.series = [{
type: 'pie', type: 'pie',
radius: ['40%', '70%'], radius: ['40%', '70%'],
data: final, data: final,
}]}} }]
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -192,7 +198,7 @@ export class BoilerplateListComponent implements OnInit { ...@@ -192,7 +198,7 @@ export class BoilerplateListComponent implements OnInit {
console.log(error); console.log(error);
this.showSpinner = !this.showSpinner; this.showSpinner = !this.showSpinner;
this.exporting = !this.exporting this.exporting = !this.exporting
this.notifier.notify("warning",(JSON.stringify(error["error"]["detail"]))); this.notifier.notify("warning", (JSON.stringify(error["error"]["detail"])));
}); });
} }
...@@ -201,17 +207,21 @@ export class BoilerplateListComponent implements OnInit { ...@@ -201,17 +207,21 @@ export class BoilerplateListComponent implements OnInit {
this.newdataSource.filter = filterValue.trim().toLowerCase(); this.newdataSource.filter = filterValue.trim().toLowerCase();
} }
get_metrics(i:any): any { get_metrics(i: any): any {
if (this.currentInfer?.inference_data){ if (this.currentInfer?.inference_data) {
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g,"\"")) const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
if (obj[i]){ if (obj[i]) {
return obj[i] return obj[i]
} }
} }
return 0 return 0
} }
getnumreq():any{ getnumreq(): any {
return this.boilerplatesdata?.length return this.boilerplatesdata?.length
} }
getincreq(): any {
return this.get_metrics('IncompleteRequirement').length;
}
} }
<h1 mat-dialog-title>{{data.name}}</h1>
<div mat-dialog-content>
<mat-form-field appearance="fill">
<mat-label>Instance name</mat-label>
<input matInput required [(ngModel)]="data.instance">
</mat-form-field>
</div>
<div mat-dialog-content>
<mat-form-field appearance="fill">
<mat-label>Instance comment</mat-label>
<textarea matInput required [(ngModel)]="data.comment" ></textarea>
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">Cancel</button>
<button mat-button [mat-dialog-close]="data" cdkFocusInitial>Add</button>
</div>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CourseDialogComponentComponent } from './course-dialog-component.component';
describe('CourseDialogComponentComponent', () => {
let component: CourseDialogComponentComponent;
let fixture: ComponentFixture<CourseDialogComponentComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CourseDialogComponentComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(CourseDialogComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Inject, OnInit } from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
export interface DialogData {
comment: string;
instance: string;
name?: string;
}
@Component({
selector: 'app-course-dialog-component',
templateUrl: './course-dialog-component.component.html',
styleUrls: ['./course-dialog-component.component.scss']
})
export class CourseDialogComponentComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<CourseDialogComponentComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogData,) {}
ngOnInit(): void {}
onNoClick(): void {
this.dialogRef.close();
}
}
...@@ -6,28 +6,19 @@ ...@@ -6,28 +6,19 @@
<div class="list row"> <div class="list row">
<div class="col-md-8"> <div class="col-md-8">
<div class="input-group mb-3"> <div class="input-group mb-3">
<input <input type="text" class="form-control" placeholder="Search" [(ngModel)]="title" name="search"
type="text" autocomplete="off" />
class="form-control"
placeholder="Search"
[(ngModel)]="title"
name="search"
autocomplete="off"
/>
<!-- (keyup.enter)="SearchTitle()"--> <!-- (keyup.enter)="SearchTitle()"-->
<!-- (click)="SearchTitle()" --> <!-- (click)="SearchTitle()" -->
<div class="input-group-append"> <div class="input-group-append">
<button <button class="btn btn-primary" type="button">Search
class="btn btn-primary"
type="button"
>Search
</button> </button>
</div> </div>
</div> </div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end"> <div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items"> <ul fxLayout fxLayoutGap="15px" class="navigation-items">
<div> <div>
<input class="btn btn-success" type="button" value="Add New project" routerLink="add-groupboil"/> <input class="btn btn-success" type="button" value="Add New project" routerLink="add-groupboil" />
</div> </div>
</ul> </ul>
</div> </div>
...@@ -37,7 +28,8 @@ ...@@ -37,7 +28,8 @@
<div class="content"> <div class="content">
<div fxLayout="row wrap"> <div fxLayout="row wrap">
<div fxFlex="20%" *ngFor="let gb of grouboilerplates| filter:title"> <div fxFlex="20%" *ngFor="let gb of grouboilerplates| filter:title">
<mat-card class="example-card" routerLink="/groupboilerplates/{{gb.id}}/boilerplates"> <mat-card class="example-card">
<div routerLink="/groupboilerplates/{{gb.id}}/boilerplates">
<mat-card-header> <mat-card-header>
<div mat-card-avatar class="example-header-image"></div> <div mat-card-avatar class="example-header-image"></div>
<mat-card-title>{{gb.title_bgroup}}</mat-card-title> <mat-card-title>{{gb.title_bgroup}}</mat-card-title>
...@@ -49,11 +41,13 @@ ...@@ -49,11 +41,13 @@
{{gb.description}} {{gb.description}}
</p> </p>
</mat-card-content> </mat-card-content>
</div>
<mat-card-actions> <mat-card-actions>
<button class="btn btn-info" mat-button>EDIT</button> <button class="btn btn-info" routerLink="/groupboilerplates/{{gb.id}}/boilerplates"
mat-button>EDIT</button>
<button class="btn btn-warning" (click)="deleteGroupBoilerplate(gb)" mat-button>DELETE</button> <button class="btn btn-warning" (click)="deleteGroupBoilerplate(gb)" mat-button>DELETE</button>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { GroupBoilerplate } from 'src/app/models/boilerplate.model'; import { GroupBoilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service'; import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
@Component({ @Component({
selector: 'app-groupboil', selector: 'app-groupboil',
...@@ -11,8 +12,10 @@ export class GroupboilComponent implements OnInit { ...@@ -11,8 +12,10 @@ export class GroupboilComponent implements OnInit {
grouboilerplates?: GroupBoilerplate[]; grouboilerplates?: GroupBoilerplate[];
title = ''; title = '';
private readonly notifier: NotifierService;
constructor(private boilerplateService: BoilerplateService) { } constructor(private boilerplateService: BoilerplateService, notifierService: NotifierService) {
this.notifier = notifierService;
}
ngOnInit(): void { ngOnInit(): void {
this.retrievegroupBoilerplates(); this.retrievegroupBoilerplates();
...@@ -23,7 +26,7 @@ export class GroupboilComponent implements OnInit { ...@@ -23,7 +26,7 @@ export class GroupboilComponent implements OnInit {
.subscribe( .subscribe(
data => { data => {
this.grouboilerplates = data; this.grouboilerplates = data;
console.log(data); //console.log(data);
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -32,15 +35,17 @@ export class GroupboilComponent implements OnInit { ...@@ -32,15 +35,17 @@ export class GroupboilComponent implements OnInit {
} }
deleteGroupBoilerplate(id: any): void { deleteGroupBoilerplate(id: any): void {
if(confirm("Αre you sure you want to delete this Project?")) { if (confirm("Αre you sure you want to delete this Project?")) {
this.boilerplateService.deletegroupboil(id.id) this.boilerplateService.deletegroupboil(id.id)
.subscribe( .subscribe(
response => { response => {
console.log(response); //console.log(response);
this.notifier.notify("success", "Project deleted");
this.retrievegroupBoilerplates(); this.retrievegroupBoilerplates();
}, },
error => { error => {
console.log(error); this.notifier.notify("warning", (JSON.stringify(error["error"]["title"][0])));
}); });
} }
} }
......
...@@ -7,39 +7,37 @@ import { MainService } from 'src/app/services/main.service'; ...@@ -7,39 +7,37 @@ import { MainService } from 'src/app/services/main.service';
styleUrls: ['./instances-list.component.scss'] styleUrls: ['./instances-list.component.scss']
}) })
export class InstancesListComponent implements OnInit { export class InstancesListComponent implements OnInit {
subjects:string[] = []; subjects: string[] = [];
stateitem:string[] = []; stateitem: string[] = [];
statevalue:string[] = []; statevalue: string[] = [];
shall:string[] = []; shall: string[] = [];
verb:string[] = []; verb: string[] = [];
quantifier:string[] = []; quantifier: string[] = [];
numunit:string[] = []; numunit: string[] = [];
fifuintsysstatset:string[] = []; fifuintsysstatset: string[] = [];
stsysconset:string[] = []; stsysconset: string[] = [];
constructor(private mainService: MainService) { } constructor(private mainService: MainService) { }
ngOnInit(): void { ngOnInit(): void {
this.getchoices(); this.getchoices();
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
} }
getchoices(): void{ getchoices(): void {
this.mainService.getsubject() this.mainService.getsubject()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.subjects.push(data[x][1]);} this.subjects.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -49,9 +47,10 @@ export class InstancesListComponent implements OnInit { ...@@ -49,9 +47,10 @@ export class InstancesListComponent implements OnInit {
.subscribe( .subscribe(
data => { data => {
//no data from State and Item //no data from State and Item
console.log(data); //console.log(data);
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.stateitem.push(data[x][1]);} this.stateitem.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -59,8 +58,9 @@ export class InstancesListComponent implements OnInit { ...@@ -59,8 +58,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getstatevalue() this.mainService.getstatevalue()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.statevalue.push(data[x][1]);} this.statevalue.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -68,8 +68,9 @@ export class InstancesListComponent implements OnInit { ...@@ -68,8 +68,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getshall() this.mainService.getshall()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.shall.push(data[x][1]);} this.shall.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -77,8 +78,9 @@ export class InstancesListComponent implements OnInit { ...@@ -77,8 +78,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getverb() this.mainService.getverb()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.verb.push(data[x][1]);} this.verb.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -86,8 +88,9 @@ export class InstancesListComponent implements OnInit { ...@@ -86,8 +88,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getquantifier() this.mainService.getquantifier()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.quantifier.push(data[x][1]);} this.quantifier.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -96,8 +99,9 @@ export class InstancesListComponent implements OnInit { ...@@ -96,8 +99,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getnumunit() this.mainService.getnumunit()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.numunit.push(data[x][1]);} this.numunit.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -105,8 +109,9 @@ export class InstancesListComponent implements OnInit { ...@@ -105,8 +109,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getfifuintsysstatset() this.mainService.getfifuintsysstatset()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.fifuintsysstatset.push(data[x][1]);} this.fifuintsysstatset.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -114,8 +119,9 @@ export class InstancesListComponent implements OnInit { ...@@ -114,8 +119,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getstsysconset() this.mainService.getstsysconset()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
this.stsysconset.push(data[x][1]);} this.stsysconset.push(data[x][1]);
}
}, },
error => { error => {
console.log(error); console.log(error);
......
<div fxLayoutAlign="end"> <mat-chip color="primary"> MAIN TEMPLATE : {{this.main}}</mat-chip> </div> <div fxLayoutAlign="end">
<div class="form-row"> <mat-chip color="primary"> MAIN TEMPLATE : {{this.main}}</mat-chip>
</div>
<div class="form-row">
<div class="col"> <div class="col">
<form class="form-group form-inline" ngNativeValidate> <form class="form-group form-inline" ngNativeValidate>
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="this.subjectsControl.value !=null" >Subject : {{this.subjectsControl.value.slice(0, this.subjectsControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="this.subjectsControl.value !=null">Subject : {{this.subjectsControl.value.slice(0,
<input type="text" this.subjectsControl.value.indexOf(':'))}}</mat-label>
placeholder="Pick one" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="subjectsControl" required
aria-label="Number" [matAutocomplete]="automainsub" style="width: 100%;">
matInput <mat-autocomplete autoActiveFirstOption #automainsub="matAutocomplete" showPanel="true"
[formControl]="subjectsControl" [displayWith]="displayFn">
required
[matAutocomplete]="automainsub"
style="width: 100%;">
<mat-autocomplete autoActiveFirstOption #automainsub="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of subjectsfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of subjectsfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
...@@ -21,17 +19,15 @@ ...@@ -21,17 +19,15 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline" [ngStyle]="(stateitemControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}"> <form class="form-group form-inline"
[ngStyle]="(stateitemControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="this.stateitemControl.value !=null">State or Item : {{this.stateitemControl.value.slice(0, this.stateitemControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="this.stateitemControl.value !=null">State or Item : {{this.stateitemControl.value.slice(0,
<input type="text" this.stateitemControl.value.indexOf(':'))}}</mat-label>
placeholder="Pick one" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="stateitemControl"
aria-label="Number" [matAutocomplete]="autostateitem">
matInput <mat-autocomplete autoActiveFirstOption #autostateitem="matAutocomplete" showPanel="true"
[formControl]="stateitemControl" [displayWith]="displayFn">
[matAutocomplete]="autostateitem"
>
<mat-autocomplete autoActiveFirstOption #autostateitem="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of stateitemfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of stateitemfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
...@@ -40,17 +36,15 @@ ...@@ -40,17 +36,15 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline" [ngStyle]="(statevalueControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}"> <form class="form-group form-inline"
[ngStyle]="(statevalueControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="statevalueControl.value !=null">State Value : {{statevalueControl.value.slice(0, statevalueControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="statevalueControl.value !=null">State Value : {{statevalueControl.value.slice(0,
<input type="text" statevalueControl.value.indexOf(':'))}}</mat-label>
placeholder="Pick one" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="statevalueControl"
aria-label="Number" [matAutocomplete]="autostatevalue">
matInput <mat-autocomplete autoActiveFirstOption #autostatevalue="matAutocomplete" showPanel="true"
[formControl]="statevalueControl" [displayWith]="displayFn">
[matAutocomplete]="autostatevalue"
>
<mat-autocomplete autoActiveFirstOption #autostatevalue="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of statevaluefilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of statevaluefilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
...@@ -59,20 +53,14 @@ ...@@ -59,20 +53,14 @@
</form> </form>
</div> </div>
</div> </div>
<div class="form-row" > <div class="form-row">
<div class="col" style="width: 100px;"> <div class="col" style="width: 100px;">
<form class="form-group form-inline"> <form class="form-group form-inline">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Shall/shall not</mat-label> <mat-label>Shall/shall not</mat-label>
<input type="text" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="shallControl" required
placeholder="Pick one" [matAutocomplete]="autoshall">
aria-label="Number" <mat-autocomplete autoActiveFirstOption #autoshall="matAutocomplete">
matInput
[formControl]="shallControl"
required
[matAutocomplete]="autoshall"
>
<mat-autocomplete autoActiveFirstOption #autoshall ="matAutocomplete" >
<mat-option *ngFor="let option of shallfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of shallfilteredOptions | async" [value]="option">
{{option}} {{option}}
</mat-option> </mat-option>
...@@ -81,17 +69,13 @@ ...@@ -81,17 +69,13 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline" [ngStyle]="(verbControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}"> <form class="form-group form-inline"
[ngStyle]="(verbControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="verbControl.value !=null">Verb : {{verbControl.value.slice(0, verbControl.value.indexOf(' : '))}}</mat-label> <mat-label *ngIf="verbControl.value !=null">Verb : {{verbControl.value.slice(0, verbControl.value.indexOf(' :
<input type="text" '))}}</mat-label>
placeholder="Pick one" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="verbControl" required
aria-label="Number" [matAutocomplete]="autoverb">
matInput
[formControl]="verbControl"
required
[matAutocomplete]="autoverb"
>
<mat-autocomplete autoActiveFirstOption #autoverb="matAutocomplete" showPanel="true" [displayWith]="displayFn"> <mat-autocomplete autoActiveFirstOption #autoverb="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of verbfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of verbfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}} {{option.split(" : ").pop()}}
...@@ -100,19 +84,14 @@ ...@@ -100,19 +84,14 @@
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
<div class="col" > <div class="col">
<form class="form-group form-inline" [ngStyle]="(quantifierControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}"> <form class="form-group form-inline"
[ngStyle]="(quantifierControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Quantifier</mat-label> <mat-label>Quantifier</mat-label>
<input <input placeholder="Pick one" aria-label="Number" matInput [formControl]="quantifierControl" type="text"
placeholder="Pick one" [matAutocomplete]="autoquantifier">
aria-label="Number" <mat-autocomplete autoActiveFirstOption #autoquantifier="matAutocomplete">
matInput
[formControl]="quantifierControl"
type="text"
[matAutocomplete]="autoquantifier"
>
<mat-autocomplete autoActiveFirstOption #autoquantifier ="matAutocomplete">
<mat-option *ngFor="let option of quantifierfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of quantifierfilteredOptions | async" [value]="option">
{{option}} {{option}}
</mat-option> </mat-option>
...@@ -121,8 +100,9 @@ ...@@ -121,8 +100,9 @@
</form> </form>
</div> </div>
<!--NUmber Value--> <!--NUmber Value-->
<div class="col" > <div class="col">
<form class="form-group form-inline" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}"> <form class="form-group form-inline"
[ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label> <mat-label>Numerical Value</mat-label>
<input type="text" matInput [(ngModel)]="currentmain.numerical" name="numerical"> <input type="text" matInput [(ngModel)]="currentmain.numerical" name="numerical">
...@@ -130,17 +110,13 @@ ...@@ -130,17 +110,13 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline" [ngStyle]="(numunitControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}"> <form class="form-group form-inline"
[ngStyle]="(numunitControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Number Unit</mat-label> <mat-label>Number Unit</mat-label>
<input type="text" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="numunitControl"
placeholder="Pick one" [matAutocomplete]="autonumunit">
aria-label="Number" <mat-autocomplete autoActiveFirstOption #autonumunit="matAutocomplete">
matInput
[formControl]="numunitControl"
[matAutocomplete]="autonumunit"
>
<mat-autocomplete autoActiveFirstOption #autonumunit ="matAutocomplete">
<mat-option *ngFor="let option of numunitfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of numunitfilteredOptions | async" [value]="option">
{{option}} {{option}}
</mat-option> </mat-option>
...@@ -154,16 +130,12 @@ ...@@ -154,16 +130,12 @@
<div class="col"> <div class="col">
<form class="form-group form-inline"> <form class="form-group form-inline">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="fifuintsysstatsetControl.value !=null">Object : {{fifuintsysstatsetControl.value.slice(0, fifuintsysstatsetControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="fifuintsysstatsetControl.value !=null">Object : {{fifuintsysstatsetControl.value.slice(0,
<input type="text" fifuintsysstatsetControl.value.indexOf(':'))}}</mat-label>
placeholder="Pick one" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="fifuintsysstatsetControl"
aria-label="Number" required [matAutocomplete]="autofifuintsysstatset">
matInput <mat-autocomplete autoActiveFirstOption #autofifuintsysstatset="matAutocomplete" showPanel="true"
[formControl]="fifuintsysstatsetControl" [displayWith]="displayFn">
required
[matAutocomplete]="autofifuintsysstatset"
>
<mat-autocomplete autoActiveFirstOption #autofifuintsysstatset ="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of fifuintsysstatsetfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of fifuintsysstatsetfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
...@@ -172,18 +144,15 @@ ...@@ -172,18 +144,15 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline" [ngStyle]="(stsysconsetControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}"> <form class="form-group form-inline"
[ngStyle]="(stsysconsetControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="stsysconsetControl.value !=null">StateSet or StateValue or System or Connection : {{stsysconsetControl.value.slice(0, stsysconsetControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="stsysconsetControl.value !=null">StateSet or StateValue or System or Connection :
<input {{stsysconsetControl.value.slice(0, stsysconsetControl.value.indexOf(':'))}}</mat-label>
placeholder="Pick one" <input placeholder="Pick one" aria-label="Number" type="text" matInput [formControl]="stsysconsetControl"
aria-label="Number" [matAutocomplete]="autostsysconset">
type="text" <mat-autocomplete autoActiveFirstOption #autostsysconset="matAutocomplete" showPanel="true"
matInput [displayWith]="displayFn">
[formControl]="stsysconsetControl"
[matAutocomplete]="autostsysconset"
>
<mat-autocomplete autoActiveFirstOption #autostsysconset ="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of stsysconsetfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of stsysconsetfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
......
import { Component, OnInit, Output, EventEmitter} from '@angular/core'; import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Main } from 'src/app/models/main.model'; import { Main } from 'src/app/models/main.model';
import { Mainsyntax } from 'src/app/models/main.model'; import { Mainsyntax } from 'src/app/models/main.model';
import { MainService } from 'src/app/services/main.service'; import { MainService } from 'src/app/services/main.service';
import {FormControl} from '@angular/forms'; import { FormControl } from '@angular/forms';
import {Observable} from 'rxjs'; import { Observable } from 'rxjs';
import {map, startWith} from 'rxjs/operators'; import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
@Component({ @Component({
...@@ -15,63 +15,63 @@ import { NotifierService } from "angular-notifier"; ...@@ -15,63 +15,63 @@ import { NotifierService } from "angular-notifier";
}) })
export class MainDetailsComponent implements OnInit { export class MainDetailsComponent implements OnInit {
mainsyntax = [ mainsyntax = [
{Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: []}]; { Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: [] }];
mainsyntax11?: Mainsyntax ={ mainsyntax11?: Mainsyntax = {
Attributes : [], Attributes: [],
Quantifier : false, Quantifier: false,
Related_to_Subject : [], Related_to_Subject: [],
Subject : [], Subject: [],
Verbs : [] Verbs: []
}; };
subjectsControl = new FormControl(); subjectsControl = new FormControl();
subjects:string[] = []; subjects: string[] = [];
subjectsfilteredOptions: Observable<string[]>; subjectsfilteredOptions: Observable<string[]>;
stateitemControl = new FormControl(); stateitemControl = new FormControl();
stateitem:string[] = []; stateitem: string[] = [];
stateitemfilteredOptions: Observable<string[]>; stateitemfilteredOptions: Observable<string[]>;
stateitemControlisDivVisible = false stateitemControlisDivVisible = false
statevalueControl = new FormControl(); statevalueControl = new FormControl();
statevalue:string[] = []; statevalue: string[] = [];
statevaluefilteredOptions: Observable<string[]>; statevaluefilteredOptions: Observable<string[]>;
statevalueControlisDivVisible = false statevalueControlisDivVisible = false
shallControl = new FormControl(); shallControl = new FormControl();
shall:string[] = []; shall: string[] = [];
shallfilteredOptions: Observable<string[]>; shallfilteredOptions: Observable<string[]>;
verbControl = new FormControl(); verbControl = new FormControl();
verb:string[] = []; verb: string[] = [];
verbfilteredOptions: Observable<string[]>; verbfilteredOptions: Observable<string[]>;
verbControlisDivVisible = true verbControlisDivVisible = true
quantifierControl = new FormControl( ); quantifierControl = new FormControl();
quantifier:string[] = []; quantifier: string[] = [];
quantifierfilteredOptions: Observable<string[]>; quantifierfilteredOptions: Observable<string[]>;
quantifierControlisDivVisible = false quantifierControlisDivVisible = false
numunitControl = new FormControl(); numunitControl = new FormControl();
numunit:string[] = []; numunit: string[] = [];
numunitfilteredOptions: Observable<string[]>; numunitfilteredOptions: Observable<string[]>;
numunitControlisDivVisible = false numunitControlisDivVisible = false
fifuintsysstatsetControl = new FormControl(); fifuintsysstatsetControl = new FormControl();
fifuintsysstatset:string[] = []; fifuintsysstatset: string[] = [];
fifuintsysstatsetfilteredOptions: Observable<string[]>; fifuintsysstatsetfilteredOptions: Observable<string[]>;
stsysconsetControl = new FormControl(); stsysconsetControl = new FormControl();
stsysconset:string[] = []; stsysconset: string[] = [];
stsysconsetfilteredOptions: Observable<string[]>; stsysconsetfilteredOptions: Observable<string[]>;
stsysconsetControlisDivVisible = false stsysconsetControlisDivVisible = false
numericalisDivVisible = false numericalisDivVisible = false
public static id: any [] = []; public static id: any[] = [];
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
mains?: Main[]; mains?: Main[];
...@@ -144,40 +144,32 @@ export class MainDetailsComponent implements OnInit { ...@@ -144,40 +144,32 @@ export class MainDetailsComponent implements OnInit {
this.dis(); this.dis();
} }
dis(): any{ dis(): any {
//Check for each M1-M16 //Check for each M1-M16
for (let x=0; x < this.mainsyntax.length; x++ ){ for (let x = 0; x < this.mainsyntax.length; x++) {
//for (let x=0; x < 1; x++ ){ for (let s = 0; s < this.mainsyntax[x].Subject.length; s++) {
//console.log(this.mainsyntax[x]) if (this.mainsyntax[x].Subject[s] == this.subjectsControl.value ? (this.subjectsControl.value.slice(0, this.subjectsControl.value.indexOf(':'))).replace(/\s/g, "") : this.subjectsControl.value) {
//console.log(this.mainsyntax[x].Id) for (let v = 0; v < this.mainsyntax[x].Verbs.length; v++) {
for (let s=0; s < this.mainsyntax[x].Subject.length; s++ ){ if (this.mainsyntax[x].Verbs[v] == (this.verbControl.value.split(" : ").pop()).replace(/\s/g, "")) {
//console.log() for (let a = 0; a < this.mainsyntax[x].Attributes.length; a++) {
if (this.mainsyntax[x].Subject[s] == (this.subjectsControl.value.slice(0, this.subjectsControl.value.indexOf(':'))).replace(/\s/g, "")){ if (this.mainsyntax[x].Attributes[a] == (this.fifuintsysstatsetControl.value.slice(0, this.fifuintsysstatsetControl.value.indexOf(':'))).replace(/\s/g, "")) {
//console.log("okk") if (this.mainsyntax[x].Related_to_Subject.length > 0) {
for (let v=0; v < this.mainsyntax[x].Verbs.length; v++ ){
if (this.mainsyntax[x].Verbs[v] == (this.verbControl.value.split(" : ").pop()).replace(/\s/g, "")){
//console.log("Verb okk")
for (let a=0; a < this.mainsyntax[x].Attributes.length; a++ ){
if (this.mainsyntax[x].Attributes[a] == (this.fifuintsysstatsetControl.value.slice(0, this.fifuintsysstatsetControl.value.indexOf(':'))).replace(/\s/g, "")){
//console.log("Attribute okk", this.mainsyntax[x].Id)
if (this.mainsyntax[x].Related_to_Subject.length > 0 ){
this.stateitemControlisDivVisible = true this.stateitemControlisDivVisible = true
for (let r=0; r < this.mainsyntax[x].Related_to_Subject.length; r++ ){ for (let r = 0; r < this.mainsyntax[x].Related_to_Subject.length; r++) {
if (this.mainsyntax[x].Related_to_Subject[r] == "StateValue"){this.statevalueControlisDivVisible = true; } if (this.mainsyntax[x].Related_to_Subject[r] == "StateValue") { this.statevalueControlisDivVisible = true; }
} }
} }
//console.log(this.mainsyntax[x].Quantifier) if (this.mainsyntax[x].Quantifier) {
if (this.mainsyntax[x].Quantifier){
//this.quantifierControl.enable();
this.quantifierControlisDivVisible = true; this.quantifierControlisDivVisible = true;
this.numericalisDivVisible = true; this.numericalisDivVisible = true;
//numerical value //numerical value
this.numunitControlisDivVisible = true; this.numunitControlisDivVisible = true;
//add the numunit data //add the numunit data
} }
if (this.mainsyntax[x].Attributes.includes('StateValue') || this.mainsyntax[x].Attributes.includes('System')|| this.mainsyntax[x].Attributes.includes('Connection')|| this.mainsyntax[x].Attributes.includes('StateSet')) { if (this.mainsyntax[x].Attributes.includes('StateValue') || this.mainsyntax[x].Attributes.includes('System') || this.mainsyntax[x].Attributes.includes('Connection') || this.mainsyntax[x].Attributes.includes('StateSet')) {
if(!this.mainsyntax[x].Id.includes('M14') && !this.mainsyntax[x].Id.includes('M16')){ if (!this.mainsyntax[x].Id.includes('M14') && !this.mainsyntax[x].Id.includes('M16')) {
this.stsysconsetControlisDivVisible = true;} this.stsysconsetControlisDivVisible = true;
}
//add the connection data //add the connection data
} }
this.main = this.mainsyntax[x].Id this.main = this.mainsyntax[x].Id
...@@ -201,18 +193,18 @@ export class MainDetailsComponent implements OnInit { ...@@ -201,18 +193,18 @@ export class MainDetailsComponent implements OnInit {
this.stsysconsetControlisDivVisible = false; this.stsysconsetControlisDivVisible = false;
this.main = "No boilerplate with this syntax" this.main = "No boilerplate with this syntax"
} }
} }
displayFn(option:string): string { displayFn(option: string): string {
if (option != null) { if (option != null) {
let x = option.split(" : "); let x = option.split(" : ");
if ( (x[x.length -2] == "") || (x[x.length -1]=="")) { return "";} if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return ""; }
return (x[x.length -2]+" : "+x[x.length -1]); return (x[x.length - 2] + " : " + x[x.length - 1]);
} }
return ""; return "";
} }
private _filter(data:string[], value: string): string[] { private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase(); const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue)); return data.filter(option => option.toLowerCase().includes(filterValue));
} }
...@@ -221,7 +213,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -221,7 +213,7 @@ export class MainDetailsComponent implements OnInit {
this.mainService.getAll(id) this.mainService.getAll(id)
.subscribe( .subscribe(
data => { data => {
MainDetailsComponent.id.length =0; MainDetailsComponent.id.length = 0;
this.mains = data; this.mains = data;
for (var val of data) { for (var val of data) {
MainDetailsComponent.id.push(val.id); MainDetailsComponent.id.push(val.id);
...@@ -256,31 +248,32 @@ export class MainDetailsComponent implements OnInit { ...@@ -256,31 +248,32 @@ export class MainDetailsComponent implements OnInit {
updateMain(): void { updateMain(): void {
this.currentmain.sys_fun_inter = this.subjectsControl.value; this.currentmain.sys_fun_inter = this.subjectsControl.value;
if( this.stateitemControlisDivVisible){this.currentmain.state_item_before_verb = this.stateitemControl.value;}else{this.currentmain.state_item_before_verb =''} if (this.stateitemControlisDivVisible) { this.currentmain.state_item_before_verb = this.stateitemControl.value; } else { this.currentmain.state_item_before_verb = '' }
if (this.statevalueControlisDivVisible){this.currentmain.statevalue_before_verb = this.statevalueControl.value;}else{this.currentmain.statevalue_before_verb =''} if (this.statevalueControlisDivVisible) { this.currentmain.statevalue_before_verb = this.statevalueControl.value; } else { this.currentmain.statevalue_before_verb = '' }
this.currentmain.shall = this.shallControl.value; this.currentmain.shall = this.shallControl.value;
this.currentmain.verb = this.verbControl.value; this.currentmain.verb = this.verbControl.value;
if (this.quantifierControlisDivVisible){this.currentmain.quantifier = this.quantifierControl.value;}else{this.currentmain.quantifier =''} if (this.quantifierControlisDivVisible) { this.currentmain.quantifier = this.quantifierControl.value; } else { this.currentmain.quantifier = '' }
//num //num
if (this.numericalisDivVisible){this.currentmain.mumerical_units = this.numunitControl.value;}else{this.currentmain.mumerical_units =''} if (this.numericalisDivVisible) { this.currentmain.mumerical_units = this.numunitControl.value; } else { this.currentmain.mumerical_units = '' }
this.currentmain.flow_function_interface_item_system_state_stateset = this.fifuintsysstatsetControl.value; this.currentmain.flow_function_interface_item_system_state_stateset = this.fifuintsysstatsetControl.value;
if (this.stsysconsetControlisDivVisible){this.currentmain.statevalue_system_connection_stateset = this.stsysconsetControl.value;}else{this.currentmain.statevalue_system_connection_stateset =''} if (this.stsysconsetControlisDivVisible) { this.currentmain.statevalue_system_connection_stateset = this.stsysconsetControl.value; } else { this.currentmain.statevalue_system_connection_stateset = '' }
for (let i=0; i<MainDetailsComponent.id.length; i++){ for (let i = 0; i < MainDetailsComponent.id.length; i++) {
this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain) this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain)
.subscribe( .subscribe(
response => { response => {
this.message = response.message; this.message = response.message;
}, },
error => { error => {
this.notifier.notify("warning",("MAIN " + JSON.stringify(error["error"]))); this.notifier.notify("warning", ("MAIN " + JSON.stringify(error["error"])));
});} });
}
} }
getmainchoices(main: any): void{ getmainchoices(main: any): void {
this.mainService.getmain(main) this.mainService.getmain(main)
.subscribe( .subscribe(
data => { data => {
...@@ -319,61 +312,77 @@ export class MainDetailsComponent implements OnInit { ...@@ -319,61 +312,77 @@ export class MainDetailsComponent implements OnInit {
} }
getsubject (strIntoObj: any): void{ getsubject(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.subjects.indexOf(strIntoObj[x][1]) == -1) { if (this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));}} this.subjects.push((strIntoObj[x][1]));
}
}
} }
getstateitem (strIntoObj: any): void{ getstateitem(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.stateitem.indexOf(strIntoObj[x][1]) == -1) { if (this.stateitem.indexOf(strIntoObj[x][1]) == -1) {
this.stateitem.push((strIntoObj[x][1]));}} this.stateitem.push((strIntoObj[x][1]));
}
}
} }
getstatevalue (strIntoObj: any): void{ getstatevalue(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.statevalue.indexOf(strIntoObj[x][1]) == -1) { if (this.statevalue.indexOf(strIntoObj[x][1]) == -1) {
this.statevalue.push((strIntoObj[x][1]));}} this.statevalue.push((strIntoObj[x][1]));
}
}
} }
getverb (strIntoObj: any): void{ getverb(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.verb.indexOf(strIntoObj[x][1]) == -1) { if (this.verb.indexOf(strIntoObj[x][1]) == -1) {
this.verb.push((strIntoObj[x][1]));}} this.verb.push((strIntoObj[x][1]));
}
}
} }
getquantifier (strIntoObj: any): void{ getquantifier(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.quantifier.indexOf(strIntoObj[x][1]) == -1) { if (this.quantifier.indexOf(strIntoObj[x][1]) == -1) {
this.quantifier.push((strIntoObj[x][1]));}} this.quantifier.push((strIntoObj[x][1]));
}
}
} }
getfifuintsysstatset (strIntoObj: any): void{ getfifuintsysstatset(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.fifuintsysstatset.indexOf(strIntoObj[x][1]) == -1) { if (this.fifuintsysstatset.indexOf(strIntoObj[x][1]) == -1) {
this.fifuintsysstatset.push((strIntoObj[x][1]));}} this.fifuintsysstatset.push((strIntoObj[x][1]));
}
}
} }
getstsysconset (strIntoObj: any): void{ getstsysconset(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.stsysconset.indexOf(strIntoObj[x][1]) == -1) { if (this.stsysconset.indexOf(strIntoObj[x][1]) == -1) {
this.stsysconset.push((strIntoObj[x][1]));}} this.stsysconset.push((strIntoObj[x][1]));
}
}
} }
getnumunit (strIntoObj: any): void{ getnumunit(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.numunit.indexOf(strIntoObj[x][1]) == -1) { if (this.numunit.indexOf(strIntoObj[x][1]) == -1) {
this.numunit.push((strIntoObj[x][1]));}} this.numunit.push((strIntoObj[x][1]));
}
}
} }
getchoices(): void{ getchoices(): void {
this.mainService.getmainsyntax() this.mainService.getmainsyntax()
.subscribe( .subscribe(
data => { data => {
this.mainsyntax = data this.mainsyntax = data
console.log(data); //console.log(data);
}, },
error => { error => {
...@@ -383,14 +392,16 @@ export class MainDetailsComponent implements OnInit { ...@@ -383,14 +392,16 @@ export class MainDetailsComponent implements OnInit {
this.mainService.getshall() this.mainService.getshall()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
if(this.shall.indexOf(data[x][1]) == -1) { if (this.shall.indexOf(data[x][1]) == -1) {
this.shall.push(data[x][1]);}} this.shall.push(data[x][1]);
}
}
}, },
error => { error => {
console.log(error); console.log(error);
}); });
} }
} }
...@@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Prefix } from 'src/app/models/prefix.model'; import { Prefix } from 'src/app/models/prefix.model';
import { PrefixService } from 'src/app/services/prefix.service'; import { PrefixService } from 'src/app/services/prefix.service';
import {FormControl} from '@angular/forms'; import { FormControl } from '@angular/forms';
import {Observable} from 'rxjs'; import { Observable } from 'rxjs';
import {map, startWith} from 'rxjs/operators'; import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
...@@ -16,27 +16,27 @@ import { NotifierService } from "angular-notifier"; ...@@ -16,27 +16,27 @@ import { NotifierService } from "angular-notifier";
}) })
export class PrefixDetailsComponent implements OnInit { export class PrefixDetailsComponent implements OnInit {
simpleprefixControl = new FormControl(); simpleprefixControl = new FormControl();
simpleprefix:string[] = []; simpleprefix: string[] = [];
simpleprefixfilteredOptions: Observable<string[]>; simpleprefixfilteredOptions: Observable<string[]>;
subjectsControl = new FormControl(); subjectsControl = new FormControl();
subjects:string[] = []; subjects: string[] = [];
subjectsfilteredOptions: Observable<string[]>; subjectsfilteredOptions: Observable<string[]>;
verbsControl = new FormControl(); verbsControl = new FormControl();
verbs:string[] = []; verbs: string[] = [];
verbsfilteredOptions: Observable<string[]>; verbsfilteredOptions: Observable<string[]>;
objectsControl = new FormControl(); objectsControl = new FormControl();
objects:string[] = []; objects: string[] = [];
objectsfilteredOptions: Observable<string[]>; objectsfilteredOptions: Observable<string[]>;
logic_conControl = new FormControl(); logic_conControl = new FormControl();
logic_con:string[] = []; logic_con: string[] = [];
logic_confilteredOptions: Observable<string[]>; logic_confilteredOptions: Observable<string[]>;
public static id: any [] = []; public static id: any[] = [];
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
prefixs?: Prefix[]; prefixs?: Prefix[];
...@@ -54,8 +54,9 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -54,8 +54,9 @@ export class PrefixDetailsComponent implements OnInit {
message = ''; message = '';
constructor(private prefixService: PrefixService,private route: ActivatedRoute, constructor(private prefixService: PrefixService, private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) { this.notifier = notifierService; private router: Router, notifierService: NotifierService) {
this.notifier = notifierService;
this.simpleprefixfilteredOptions = this.simpleprefixControl.valueChanges.pipe( this.simpleprefixfilteredOptions = this.simpleprefixControl.valueChanges.pipe(
startWith(""), startWith(""),
map(value => this._filter(this.simpleprefix, value)) map(value => this._filter(this.simpleprefix, value))
...@@ -83,16 +84,16 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -83,16 +84,16 @@ export class PrefixDetailsComponent implements OnInit {
this.getAllPrefix(this.route.snapshot.params.id); this.getAllPrefix(this.route.snapshot.params.id);
} }
displayFn(option:string): string { displayFn(option: string): string {
if (option != null) { if (option != null) {
let x = option.split(" : "); let x = option.split(" : ");
if ( (x[x.length -2] == "") || (x[x.length -1]=="")) { return "";} if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return ""; }
return (x[x.length -2]+" : "+x[x.length -1]); return (x[x.length - 2] + " : " + x[x.length - 1]);
} }
return ""; return "";
} }
private _filter(data:string[], value: string): string[] { private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase(); const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue)); return data.filter(option => option.toLowerCase().includes(filterValue));
} }
...@@ -101,7 +102,7 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -101,7 +102,7 @@ export class PrefixDetailsComponent implements OnInit {
this.prefixService.getAll(id) this.prefixService.getAll(id)
.subscribe( .subscribe(
data => { data => {
PrefixDetailsComponent.id.length =0; PrefixDetailsComponent.id.length = 0;
this.prefixs = data; this.prefixs = data;
//console.log(data); //console.log(data);
for (var val of data) { for (var val of data) {
...@@ -120,7 +121,7 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -120,7 +121,7 @@ export class PrefixDetailsComponent implements OnInit {
.subscribe( .subscribe(
data => { data => {
this.currentprefix = data; this.currentprefix = data;
console.log(data) //console.log(data)
this.simpleprefixControl.setValue(this.currentprefix.prefix); this.simpleprefixControl.setValue(this.currentprefix.prefix);
this.subjectsControl.setValue(this.currentprefix.system_fun_item); this.subjectsControl.setValue(this.currentprefix.system_fun_item);
this.verbsControl.setValue(this.currentprefix.state_or_verb); this.verbsControl.setValue(this.currentprefix.state_or_verb);
...@@ -139,19 +140,20 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -139,19 +140,20 @@ export class PrefixDetailsComponent implements OnInit {
this.currentprefix.state_or_verb = this.verbsControl.value; this.currentprefix.state_or_verb = this.verbsControl.value;
this.currentprefix.item_function_flow_statevalue = this.objectsControl.value; this.currentprefix.item_function_flow_statevalue = this.objectsControl.value;
this.currentprefix.logic_connective = this.logic_conControl.value; this.currentprefix.logic_connective = this.logic_conControl.value;
for (let i=0; i<PrefixDetailsComponent.id.length; i++){ for (let i = 0; i < PrefixDetailsComponent.id.length; i++) {
this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix) this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix)
.subscribe( .subscribe(
response => { response => {
this.message = response.message; this.message = response.message;
}, },
error => { error => {
this.notifier.notify("warning",("PREFIX "+JSON.stringify(error["error"]))); this.notifier.notify("warning", ("PREFIX " + JSON.stringify(error["error"])));
});} });
}
} }
getchoices(prefix_group: any): void{ getchoices(prefix_group: any): void {
this.prefixService.getsimpleprefix(prefix_group) this.prefixService.getsimpleprefix(prefix_group)
.subscribe( .subscribe(
data => { data => {
...@@ -176,35 +178,45 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -176,35 +178,45 @@ export class PrefixDetailsComponent implements OnInit {
}); });
} }
setprefix(strIntoObj: any): void{ setprefix(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.simpleprefix.indexOf(strIntoObj[x][1]) == -1) { if (this.simpleprefix.indexOf(strIntoObj[x][1]) == -1) {
this.simpleprefix.push((strIntoObj[x][1]));}} this.simpleprefix.push((strIntoObj[x][1]));
}
}
} }
setverb(strIntoObj: any): void{ setverb(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.verbs.indexOf(strIntoObj[x][1]) == -1) { if (this.verbs.indexOf(strIntoObj[x][1]) == -1) {
this.verbs.push((strIntoObj[x][1]));}} this.verbs.push((strIntoObj[x][1]));
}
}
} }
setsubject(strIntoObj: any): void{ setsubject(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.subjects.indexOf(strIntoObj[x][1]) == -1) { if (this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));}} this.subjects.push((strIntoObj[x][1]));
}
}
} }
setobject(strIntoObj: any): void{ setobject(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.objects.indexOf(strIntoObj[x][1]) == -1) { if (this.objects.indexOf(strIntoObj[x][1]) == -1) {
this.objects.push((strIntoObj[x][1]));}} this.objects.push((strIntoObj[x][1]));
}
}
} }
setlogcon(strIntoObj: any): void{ setlogcon(strIntoObj: any): void {
for (let x=0; x < strIntoObj.length; x++ ){ for (let x = 0; x < strIntoObj.length; x++) {
if(this.logic_con.indexOf(strIntoObj[x][1]) == -1) { if (this.logic_con.indexOf(strIntoObj[x][1]) == -1) {
this.logic_con.push((strIntoObj[x][1]));}} this.logic_con.push((strIntoObj[x][1]));
}
}
} }
} }
\ No newline at end of file
...@@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Suffix } from 'src/app/models/suffix.model'; import { Suffix } from 'src/app/models/suffix.model';
import { SuffixService } from 'src/app/services/suffix.service'; import { SuffixService } from 'src/app/services/suffix.service';
import {FormControl} from '@angular/forms'; import { FormControl } from '@angular/forms';
import {Observable} from 'rxjs'; import { Observable } from 'rxjs';
import {map, startWith} from 'rxjs/operators'; import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
...@@ -16,20 +16,20 @@ import { NotifierService } from "angular-notifier"; ...@@ -16,20 +16,20 @@ import { NotifierService } from "angular-notifier";
export class SuffixDetailsComponent implements OnInit { export class SuffixDetailsComponent implements OnInit {
suffixControl = new FormControl(); suffixControl = new FormControl();
suffix:string[] = []; suffix: string[] = [];
suffixfilteredOptions: Observable<string[]>; suffixfilteredOptions: Observable<string[]>;
mumerical_unitsControl = new FormControl(); mumerical_unitsControl = new FormControl();
mumerical_units:string[] = []; mumerical_units: string[] = [];
mumerical_unitsfilteredOptions: Observable<string[]>; mumerical_unitsfilteredOptions: Observable<string[]>;
flowControl = new FormControl(); flowControl = new FormControl();
flow:string[] = []; flow: string[] = [];
flowfilteredOptions: Observable<string[]>; flowfilteredOptions: Observable<string[]>;
public static id: any [] = []; public static id: any[] = [];
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
suffixs?:Suffix[]; suffixs?: Suffix[];
currentsuffix: Suffix = { currentsuffix: Suffix = {
s_choices: "", s_choices: "",
...@@ -66,16 +66,16 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -66,16 +66,16 @@ export class SuffixDetailsComponent implements OnInit {
} }
displayFn(option:string): string { displayFn(option: string): string {
if (option != null) { if (option != null) {
let x = option.split(" : "); let x = option.split(" : ");
if ( (x[x.length -2] == "") || (x[x.length -1]=="")) { return "";} if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return ""; }
return (x[x.length -2]+" : "+x[x.length -1]); return (x[x.length - 2] + " : " + x[x.length - 1]);
} }
return ""; return "";
} }
private _filter(data:string[], value: string): string[] { private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase(); const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue)); return data.filter(option => option.toLowerCase().includes(filterValue));
} }
...@@ -87,11 +87,11 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -87,11 +87,11 @@ export class SuffixDetailsComponent implements OnInit {
data => { data => {
SuffixDetailsComponent.id.length = 0; SuffixDetailsComponent.id.length = 0;
this.suffixs = data; this.suffixs = data;
console.log(data) //console.log(data)
for (var val of data) { for (var val of data) {
this.getSuffix(id, val.id); this.getSuffix(id, val.id);
SuffixDetailsComponent.id.push(val.id); SuffixDetailsComponent.id.push(val.id);
console.log(val.id) //console.log(val.id)
} }
}, },
error => { error => {
...@@ -120,25 +120,28 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -120,25 +120,28 @@ export class SuffixDetailsComponent implements OnInit {
this.currentsuffix.s_choices = this.suffixControl.value; this.currentsuffix.s_choices = this.suffixControl.value;
this.currentsuffix.mumerical_units = this.mumerical_unitsControl.value; this.currentsuffix.mumerical_units = this.mumerical_unitsControl.value;
this.currentsuffix.flow = this.flowControl.value; this.currentsuffix.flow = this.flowControl.value;
for (let i=0; i<SuffixDetailsComponent.id.length; i++){ for (let i = 0; i < SuffixDetailsComponent.id.length; i++) {
this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix) this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix)
.subscribe( .subscribe(
response => { response => {
this.message = response.message; this.message = response.message;
}, },
error => { error => {
this.notifier.notify("warning",("SUFFIX "+JSON.stringify(error["error"]))); this.notifier.notify("warning", ("SUFFIX " + JSON.stringify(error["error"])));
});} });
}
} }
getchoices(): void{ getchoices(): void {
this.suffixService.getsuffix() this.suffixService.getsuffix()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
if(this.suffix.indexOf(data[x][1]) == -1) { if (this.suffix.indexOf(data[x][1]) == -1) {
this.suffix.push(data[x][1]);}} this.suffix.push(data[x][1]);
}
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -146,9 +149,11 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -146,9 +149,11 @@ export class SuffixDetailsComponent implements OnInit {
this.suffixService.getnumunits() this.suffixService.getnumunits()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
if(this.mumerical_units.indexOf(data[x][1]) == -1) { if (this.mumerical_units.indexOf(data[x][1]) == -1) {
this.mumerical_units.push(data[x][1]);}} this.mumerical_units.push(data[x][1]);
}
}
}, },
error => { error => {
console.log(error); console.log(error);
...@@ -156,9 +161,11 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -156,9 +161,11 @@ export class SuffixDetailsComponent implements OnInit {
this.suffixService.getflow() this.suffixService.getflow()
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x = 0; x < data.length; x++) {
if(this.flow.indexOf(data[x][1]) == -1) { if (this.flow.indexOf(data[x][1]) == -1) {
this.flow.push(data[x][1]);}} this.flow.push(data[x][1]);
}
}
}, },
error => { error => {
console.log(error); console.log(error);
......
export class Boilerplate { export class Boilerplate {
id?:any; id?: any;
owner?:any; owner?: any;
group_of_boilerplate?: any; group_of_boilerplate?: any;
title?: string; title?: string;
has_prefix?: boolean; has_prefix?: boolean;
...@@ -9,7 +9,7 @@ export class Boilerplate { ...@@ -9,7 +9,7 @@ export class Boilerplate {
} }
export class BoilerplateData { export class BoilerplateData {
id?:any; id?: any;
title_data?: string; title_data?: string;
prefix_data?: string; prefix_data?: string;
main_data?: string; main_data?: string;
...@@ -17,36 +17,37 @@ export class BoilerplateData { ...@@ -17,36 +17,37 @@ export class BoilerplateData {
} }
export class GroupBoilerplate { export class GroupBoilerplate {
id?:any; id?: any;
title_bgroup?: string; title_bgroup?: string;
description?: string; description?: string;
} }
export class InferenceResults { export class InferenceResults {
id?:any; id?: any;
infer_group_of_boilerplate?: any; infer_group_of_boilerplate?: any;
inference_data?: any; inference_data?: any;
} }
export class Sections { export class Sections {
Name?:string; Name?: string;
TheClasses?: Classes[]; TheClasses?: Classes[];
GeneralInstances?:Instances[]; GeneralInstances?: Instances[];
} }
export class Classes { export class Classes {
Class?:string; Class?: string;
Comment?: string; Comment?: string;
Subclass?:SubClasses[]; Subclass?: SubClasses[];
Instance_of_Class?:Instances[]; Instance_of_Class?: Instances[];
} }
export class SubClasses { export class SubClasses {
SubClass_name?:string; SubClass_name?: any;
SubclassComment?:string SubclassComment?: any
InstanceOfSubclass?:Instances[]; InstanceOfSubclass?: Instances[];
} }
export class Instances { export class Instances {
Instance?: any; Instance?: any;
Comment?: any;
} }
...@@ -164,4 +164,8 @@ export class MainService { ...@@ -164,4 +164,8 @@ export class MainService {
getmainsyntax(): Observable<any> { getmainsyntax(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/mainsyntax`); return this.http.get(`http://155.207.131.19:8000/api-auth/mainsyntax`);
} }
setinstances(gb : any, instance: any, comment:any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/add`+`/${instance}`+`/${comment}/`);
}
} }
import json import json
import os
from django.db import models from django.db import models
from jsonfield import JSONField from jsonfield import JSONField
#from django.contrib.postgres.fields import ArrayField #from django.contrib.postgres.fields import ArrayField
...@@ -73,18 +74,31 @@ def create_extra_prefix(instance, now_prefix): ...@@ -73,18 +74,31 @@ def create_extra_prefix(instance, now_prefix):
prefix.save() prefix.save()
def create_infer_result(instance): def create_infer_result(instance, destination):
infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance, ontology_file=instance.ontology_file) infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance, ontology_file=destination)
infer.save() infer.save()
#Here we have to give and the ontology file of the Boilerplate Group to get the current instances #Here we have to give and the ontology file of the Boilerplate Group to get the current instances
def initialize_instances(instance): def initialize_instances(instance):
try :
g = Graph()
file_name = instance.title_bgroup.replace('/', '')
save_path = "../../Ontologies/"+file_name+"/"
if (os.path.exists("../../Ontologies/"+file_name+"/") == False):
os.mkdir("../../Ontologies/"+file_name)
completeName = os.path.join(save_path, file_name)
g.load(instance.ontology_file, format="turtle")
destination=save_path+file_name+'.ttl'
g.serialize(destination, format='turtle')
except:
print('Cannot load Ontology')
classes_inctances = BoilerplateGroupClassesInstances ( classes_instances_owner= instance.boilerplate_owner, classes_instances_group_of_boilerplate = instance, classes_inctances = BoilerplateGroupClassesInstances ( classes_instances_owner= instance.boilerplate_owner, classes_instances_group_of_boilerplate = instance,
ontology_file=instance.ontology_file ) ontology_file= destination)
classes_inctances.save() classes_inctances.save()
dict = BoilerplateGroupDictionary( classes_instances_owner_dic= instance.boilerplate_owner, classes_instances_group_of_boilerplate_dic = instance, dict = BoilerplateGroupDictionary( classes_instances_owner_dic= instance.boilerplate_owner, classes_instances_group_of_boilerplate_dic = instance,
ontology_file_dic=instance.ontology_file ) ontology_file_dic= destination)
dict.save() dict.save()
return destination
'''Update instaces of the ontology after the inferencing''' '''Update instaces of the ontology after the inferencing'''
def update_instances(instance): def update_instances(instance):
...@@ -108,13 +122,13 @@ def update_instances(instance): ...@@ -108,13 +122,13 @@ def update_instances(instance):
inteface_choices=json.dumps(INTERFACE_CHOICES), connection_choices=json.dumps(CONNECTION_CHOICES), flow_choices=json.dumps(FLOW_CHOICES), inteface_choices=json.dumps(INTERFACE_CHOICES), connection_choices=json.dumps(CONNECTION_CHOICES), flow_choices=json.dumps(FLOW_CHOICES),
state_choices=json.dumps(STATE_CHOICES),state_set_choices=json.dumps(STATE_SET_CHOICES), state_value_choices=json.dumps(STATE_VALUE_CHOICES), state_choices=json.dumps(STATE_CHOICES),state_set_choices=json.dumps(STATE_SET_CHOICES), state_value_choices=json.dumps(STATE_VALUE_CHOICES),
main_verb_choices=json.dumps(VERB_CHOICES), numerical_affirmative_choices=json.dumps(NUMERICAL_AFFIRMATIVE_CHOICES), main_verb_choices=json.dumps(VERB_CHOICES), numerical_affirmative_choices=json.dumps(NUMERICAL_AFFIRMATIVE_CHOICES),
suffix_choices=json.dumps(S_CHOICES) ) suffix_choices=json.dumps(S_CHOICES), ontology_file=instance.ontology_file )
Dict_list=[] Dict_list=[]
sao_names=['SAO#System', 'SAO#Function', 'SAO#Item', 'SAO#Interface', 'SAO#Connection', 'SAO#Flow', 'SAO#State', 'SAO#StateSet', 'SAO#StateValue'] sao_names=['SAO#System', 'SAO#Function', 'SAO#Item', 'SAO#Interface', 'SAO#Connection', 'SAO#Flow', 'SAO#State', 'SAO#StateSet', 'SAO#StateValue']
for i in sao_names: for i in sao_names:
Dict_list.append(get_dmo_classes_and_comment(i, g)) Dict_list.append(get_dmo_classes_and_comment(i, g))
#Dictionary_Data_list.append #Dictionary_Data_list.append
BoilerplateGroupDictionary.objects.filter(classes_instances_owner_dic= instance.owner_infer, classes_instances_group_of_boilerplate_dic = instance.infer_group_of_boilerplate).update(Dictionary_Data =Dict_list) BoilerplateGroupDictionary.objects.filter(classes_instances_owner_dic= instance.owner_infer, classes_instances_group_of_boilerplate_dic = instance.infer_group_of_boilerplate).update(ontology_file_dic =instance.ontology_file, Dictionary_Data =Dict_list)
...@@ -122,14 +136,14 @@ def update_instances(instance): ...@@ -122,14 +136,14 @@ def update_instances(instance):
class BoilerplateGroup(models.Model): class BoilerplateGroup(models.Model):
boilerplate_owner = models.ForeignKey(User, related_name='boilerplate_group_owner', on_delete=models.CASCADE) boilerplate_owner = models.ForeignKey(User, related_name='boilerplate_group_owner', on_delete=models.CASCADE)
#add Boilerplate path, so each Boilerplate Group can hace it's own Ontology file #add Boilerplate path, so each Boilerplate Group can hace it's own Ontology file
ontology_file = models.CharField(default="../../Ontologies/Autonomy_v1.ttl", max_length=100, blank=True) ontology_file = models.CharField(default="../../Ontologies/2022_AOCS.ttl", max_length=100, blank=True)
title_bgroup = models.CharField(max_length=100, unique=True) title_bgroup = models.CharField(max_length=100, unique=True)
description = models.CharField(max_length=500) description = models.CharField(max_length=500)
def save(self, **kwargs): def save(self, **kwargs):
super(BoilerplateGroup, self).save(**kwargs) super(BoilerplateGroup, self).save(**kwargs)
initialize_instances(self) destination = initialize_instances(self)
create_infer_result(self) create_infer_result(self, destination)
......
...@@ -6,7 +6,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import * ...@@ -6,7 +6,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
#HERE #HERE
#Ontology_file = "../../Ontologies/Autonomy_v1.ttl" #Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
Ontology_file = "../../Ontologies/Autonomy_v1.ttl" Ontology_file = "../../Ontologies/2022_AOCS.ttl"
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement", list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement",
"InconsistentRequirement","NoisyRequirement","OpaqueRequirement","RedundantRequirement"] "InconsistentRequirement","NoisyRequirement","OpaqueRequirement","RedundantRequirement"]
...@@ -21,11 +21,11 @@ def getclassofprefix(prefix): ...@@ -21,11 +21,11 @@ def getclassofprefix(prefix):
def getclassofmain(main): def getclassofmain(main):
return(findclassofmain(main)) return(findclassofmain(main))
def getinstancefile(data): def getinstancefile(data, g):
datam = data.split(":") datam = data.split(":")
out_list = get_file_and_instances('SAO#'+ datam[0].strip()) out_list = get_file_and_instances('SAO#'+ datam[0].strip(), g)
for j in range(0,(len(out_list)-1),2): for j in range(0,(len(out_list)-1),2):
if out_list[j]==data: if ( datam[len(datam) -2].strip()+' : '+ datam[len(datam) -1].strip() ) in out_list[j]:
splitter = out_list[j].split(" : ") splitter = out_list[j].split(" : ")
instance_file = out_list[j+1] instance_file = out_list[j+1]
break break
...@@ -51,7 +51,7 @@ def inferencing(ontfile, project, boilerlate, prefix, main, suffix): ...@@ -51,7 +51,7 @@ def inferencing(ontfile, project, boilerlate, prefix, main, suffix):
#findclassofmain(listofmain) #findclassofmain(listofmain)
ontology_with_new_req = exportboiltottl(ontfile, project, listofprefix, listofboil, listofmain, listofsuffix) ontology_with_new_req = exportboiltottl(ontfile, project, listofprefix, listofboil, listofmain, listofsuffix)
infer_result = shacl(ontology_with_new_req) infer_result = shacl(ontology_with_new_req)
ontology_with_new_req_and_infer = ontology_with_new_req+"infer.ttl" ontology_with_new_req_and_infer = ontology_with_new_req #+"infer.ttl"
#find in which metrics the requirements belongs e.g. title:REQ-1 is only an Incomplete req (and Ambiguous req), #find in which metrics the requirements belongs e.g. title:REQ-1 is only an Incomplete req (and Ambiguous req),
# so -> 'REQ-1' : [Incomplete] ('REQ-1' : [Incomplete, Ambiguous]) # so -> 'REQ-1' : [Incomplete] ('REQ-1' : [Incomplete, Ambiguous])
for met in infer_result: for met in infer_result:
...@@ -80,7 +80,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix): ...@@ -80,7 +80,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
else : else :
g.load(ontfile, format="turtle") g.load(ontfile, format="turtle")
#remove the requirements from the RDO-instances #remove the requirements from the RDO-instances
previous_req = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances") previous_req = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#")
g.remove((previous_req, None, None)) g.remove((previous_req, None, None))
for i in range(len(boilerplate)): for i in range(len(boilerplate)):
title = boilerplate[i][0]['title'] title = boilerplate[i][0]['title']
...@@ -96,7 +96,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix): ...@@ -96,7 +96,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.add((per_instances+("SystemStateValueContraint_"+title), rbo+"isRelatedToState", lo + prefix_attr_splitter[1].strip())) g.add((per_instances+("SystemStateValueContraint_"+title), rbo+"isRelatedToState", lo + prefix_attr_splitter[1].strip()))
for j in prefixmodel: for j in prefixmodel:
if prefix[i][0][j] != "": if prefix[i][0][j] != "":
sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j]) sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j], g)
g.add((per_instances+("SystemStateValueContraint_"+title), rbo+"isRelatedTo"+prefix_subject_splitter[0], URIRef(str(sub_instance_file))+"#"+ str(prefix_subject_splitter[len(prefix_subject_splitter) -1]))) g.add((per_instances+("SystemStateValueContraint_"+title), rbo+"isRelatedTo"+prefix_subject_splitter[0], URIRef(str(sub_instance_file))+"#"+ str(prefix_subject_splitter[len(prefix_subject_splitter) -1])))
else: else:
prefix_verb_splitter = prefix[i][0]['state_or_verb'].split(" : ") prefix_verb_splitter = prefix[i][0]['state_or_verb'].split(" : ")
...@@ -105,13 +105,14 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix): ...@@ -105,13 +105,14 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), rbo+"isRelatedToAction", lo + prefix_verb_splitter[1].strip())) g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), rbo+"isRelatedToAction", lo + prefix_verb_splitter[1].strip()))
for j in prefixmodel: for j in prefixmodel:
if prefix[i][0][j] != "": if prefix[i][0][j] != "":
sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j]) sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j], g)
g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), rbo+"isRelatedTo"+prefix_subject_splitter[0], URIRef(str(sub_instance_file))+"#"+ str(prefix_subject_splitter[len(prefix_subject_splitter) -1]))) g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), rbo+"isRelatedTo"+prefix_subject_splitter[0], URIRef(str(sub_instance_file))+"#"+ str(prefix_subject_splitter[len(prefix_subject_splitter) -1])))
if (boilerplate[i][0]['has_main'] == True): #If the requirement has Main if (boilerplate[i][0]['has_main'] == True): #If the requirement has Main
g.add((per_instances + title, rdo + 'hasMain', per_instances+(title+"_"+ main[i][0]['main_choices']))) g.add((per_instances + title, rdo + 'hasMain', per_instances+(title+"_"+ main[i][0]['main_choices'])))
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), RDF.type, rbo + main[i][0]['main_choices'])) g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), RDF.type, rbo + main[i][0]['main_choices']))
if main[i][0]['sys_fun_inter'] != "": if main[i][0]['sys_fun_inter'] != "":
instance_file, splitter_1 = getinstancefile(main[i][0]['sys_fun_inter']) print(main[i][0]['sys_fun_inter'])
instance_file, splitter_1 = getinstancefile(main[i][0]['sys_fun_inter'], g)
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToSubject", URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1]))) g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToSubject", URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1])))
if main[i][0]['verb'] != "": if main[i][0]['verb'] != "":
mainverb = main[i][0]['verb'].split(':') mainverb = main[i][0]['verb'].split(':')
...@@ -119,7 +120,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix): ...@@ -119,7 +120,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
mainmodel=["flow_function_interface_item_system_state_stateset", "state_item_before_verb", "statevalue_before_verb", "statevalue_system_connection_stateset"] mainmodel=["flow_function_interface_item_system_state_stateset", "state_item_before_verb", "statevalue_before_verb", "statevalue_system_connection_stateset"]
for j in mainmodel: for j in mainmodel:
if main[i][0][j] != "": if main[i][0][j] != "":
instance_file, splitter_1 = getinstancefile(main[i][0][j]) instance_file, splitter_1 = getinstancefile(main[i][0][j], g)
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedTo"+splitter_1[0], URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1]))) g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedTo"+splitter_1[0], URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1])))
if main[i][0]['quantifier'] != "": if main[i][0]['quantifier'] != "":
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), sao+"isRelatedTo", (per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", ""))))) g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), sao+"isRelatedTo", (per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")))))
...@@ -142,7 +143,10 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix): ...@@ -142,7 +143,10 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.add((per_instances+(title+"_"+ suffix[i][0]['suffix_choices']), RDF.type, URIRef(rbo+ suffix[i][0]['suffix_choices']))) g.add((per_instances+(title+"_"+ suffix[i][0]['suffix_choices']), RDF.type, URIRef(rbo+ suffix[i][0]['suffix_choices'])))
#g.remove((per_instances + title, None, None)) #g.remove((per_instances + title, None, None))
try :
g.serialize(destination=ontfile+'.ttl', format='turtle')
return (ontfile)
except:
g.serialize(destination=save_path+file_name+'.ttl', format='turtle') g.serialize(destination=save_path+file_name+'.ttl', format='turtle')
return (save_path+file_name) return (save_path+file_name)
#print(g.serialize(format="turtle").decode("utf-8")) #print(g.serialize(format="turtle").decode("utf-8"))
......
...@@ -13,7 +13,8 @@ Ontology_file = "../../Ontologies/Autonomy_v1.ttl" ...@@ -13,7 +13,8 @@ Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
subClass_instances = "../../Ontologies/instances_subclass.txt" subClass_instances = "../../Ontologies/instances_subclass.txt"
#HERE #HERE
list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances#"] #list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances#","http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"]
list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS-instances#","http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"]
#list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances", "<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"] #list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances", "<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"]
#list_of_RMO = ["RMO", "RMO-instances", "DSO-Automotive-AVP-instances", "<http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances"] #list_of_RMO = ["RMO", "RMO-instances", "DSO-Automotive-AVP-instances", "<http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances"]
DSO = ["http://delab.csd.auth.gr/ontologies/2018/DSO#"] DSO = ["http://delab.csd.auth.gr/ontologies/2018/DSO#"]
...@@ -76,7 +77,7 @@ def get_verb_instances(keyword): ...@@ -76,7 +77,7 @@ def get_verb_instances(keyword):
'''Get Verbs - return tuple''' '''Get Verbs - return tuple'''
def get_verb_file_and_instances(keyword): def get_verb_file_and_instances(keyword):
get_file_and_instances(keyword) get_file_and_instances(keyword, g)
keywordspl = keyword.split("#") keywordspl = keyword.split("#")
in_list = [] in_list = []
out_list = [] out_list = []
...@@ -165,7 +166,7 @@ out_list = [] ...@@ -165,7 +166,7 @@ out_list = []
# A dict with all the info of classes, subclasses and instances # A dict with all the info of classes, subclasses and instances
info_dict = {} info_dict = {}
def get_file_and_instances(keyword): def get_file_and_instances(keyword, g):
out_list = [] out_list = []
keywordspl = keyword.split("#") keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-1]] in_list = [keywordspl[len(keywordspl)-1]]
...@@ -258,7 +259,7 @@ def get_dmo_classes_and_comment(keyword, g): ...@@ -258,7 +259,7 @@ def get_dmo_classes_and_comment(keyword, g):
pop = URIRef(urired2 + spl[len(spl) - 1]) pop = URIRef(urired2 + spl[len(spl) - 1])
for q1, w1, m1 in g.triples((pop, RDFS.comment, None)): for q1, w1, m1 in g.triples((pop, RDFS.comment, None)):
find_comment_gen_instance = (str(m1).replace("\r","")).replace("\n","") find_comment_gen_instance = (str(m1).replace("\r","")).replace("\n","")
dmo_dic_in = {'GeneralInstances': spl[len(spl) - 1], "Comment": find_comment_gen_instance} dmo_dic_in = {'Instance': spl[len(spl) - 1], "Comment": find_comment_gen_instance}
dic_list_in.append(dmo_dic_in) dic_list_in.append(dmo_dic_in)
for comment in out_list_instance: for comment in out_list_instance:
instance_list = [] instance_list = []
...@@ -323,7 +324,7 @@ def get_dmo_classes_and_comment(keyword, g): ...@@ -323,7 +324,7 @@ def get_dmo_classes_and_comment(keyword, g):
return Dictionary_Data return Dictionary_Data
#return dic_list_backup #return dic_list_backup
else: else:
dmo_dic_backup = {"Class": " ", "Comment":" "} dmo_dic_backup = {"Class": "", "Comment":""}
dic_list_backup.append(dmo_dic_backup) dic_list_backup.append(dmo_dic_backup)
Dictionary_Data = { "Name":section, "TheClasses" : dic_list_backup, "GeneralInstances": dic_list_in} Dictionary_Data = { "Name":section, "TheClasses" : dic_list_backup, "GeneralInstances": dic_list_in}
return Dictionary_Data return Dictionary_Data
......
...@@ -34,6 +34,7 @@ urlpatterns = [ ...@@ -34,6 +34,7 @@ urlpatterns = [
#MAIN CHOICES DATA #MAIN CHOICES DATA
path('groupboilerplates/<int:groupboil>/main/choices/', main_req_views.MainChoicesViewSet.as_view(), name='mainchoices'), path('groupboilerplates/<int:groupboil>/main/choices/', main_req_views.MainChoicesViewSet.as_view(), name='mainchoices'),
path('groupboilerplates/<int:groupboil>/main/choices/add/<str:instance>/<str:comment>/', main_req_views.MainChoicesAPIView.as_view(), name='setmainchoices'),
path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'), path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
#SUFFIX CHOICES DATA #SUFFIX CHOICES DATA
......
from rdflib import RDF, RDFS, Graph, URIRef, Literal
from rest_framework.generics import ListAPIView, RetrieveUpdateDestroyAPIView, ListAPIView from rest_framework.generics import ListAPIView, RetrieveUpdateDestroyAPIView, ListAPIView
from rest_framework import permissions from rest_framework import permissions
...@@ -11,7 +12,7 @@ from reqman.apps.reqtool.rest_api.serializers.main_req import MainSerializer ...@@ -11,7 +12,7 @@ from reqman.apps.reqtool.rest_api.serializers.main_req import MainSerializer
from reqman.apps.permissions import IsOwnerOrReadOnly from reqman.apps.permissions import IsOwnerOrReadOnly
from reqman.apps.reqtool.rest_api.services import fuseki, inference from reqman.apps.reqtool.rest_api.services import fuseki, inference
from reqman.apps.reqtool.rest_api.services.parse_ontologies import Dictionary_Data_list from reqman.apps.reqtool.rest_api.services.parse_ontologies import Dictionary_Data_list, Ontology_file
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView
...@@ -95,6 +96,18 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -95,6 +96,18 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
numunit_data = data.values('number_unit_choices')[0]['number_unit_choices'] numunit_data = data.values('number_unit_choices')[0]['number_unit_choices']
if( instance['mumerical_units'] not in numunit_data): if( instance['mumerical_units'] not in numunit_data):
raise APIException("MAIN : Instance of Number Unit does not exist") raise APIException("MAIN : Instance of Number Unit does not exist")
#remove requirement if exists in the ontology
g = Graph()
g.load(data.values('ontology_file')[0]['ontology_file'], format="turtle")
rdo_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'])
g.remove((rdo_instance, None, None))
g.remove((None, None, rdo_instance))
main = Main.objects.filter(boilerplate_of_main = instance['boilerplate_of_main'])
rdo_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'] +'_'+ main.values('main_choices')[0]['main_choices'])
g.remove((rdo_instance, None, None))
g.remove((None, None, rdo_instance))
g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle')
#
curmain_choices = inference.getclassofmain(instance) curmain_choices = inference.getclassofmain(instance)
if curmain_choices[0] == 'ERROR': if curmain_choices[0] == 'ERROR':
raise APIException("Main choices not in [M1-M16]") raise APIException("Main choices not in [M1-M16]")
...@@ -107,6 +120,8 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -107,6 +120,8 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE #Custom actions when DELETE
def perform_destroy(self, instance): def perform_destroy(self, instance):
#instance = serializer.validated_data #instance = serializer.validated_data
instance.delete() instance.delete()
class MainChoicesViewSet(ListAPIView): class MainChoicesViewSet(ListAPIView):
...@@ -121,6 +136,138 @@ class MainChoicesViewSet(ListAPIView): ...@@ -121,6 +136,138 @@ class MainChoicesViewSet(ListAPIView):
queryset_cl= BoilerplateGroupClassesInstances.objects.filter(classes_instances_group_of_boilerplate = group_pk) queryset_cl= BoilerplateGroupClassesInstances.objects.filter(classes_instances_group_of_boilerplate = group_pk)
return queryset_cl return queryset_cl
class MainChoicesAPIView(APIView):
def get(self, request, groupboil, instance, comment, format=None):
data = BoilerplateGroupClassesInstances.objects.filter(classes_instances_group_of_boilerplate = groupboil)
Dictdata = BoilerplateGroupDictionary.objects.filter(classes_instances_group_of_boilerplate_dic = groupboil)
g = Graph()
g.load(data.values('ontology_file')[0]['ontology_file'], format="turtle")
#onotlogy_prefix=self.getontologyfile(g)
es_instance = instance.rsplit(':')
#print(Dictdata.values('Dictionary_Data')[0]['Dictionary_Data'])
class_prefix = self.getClassontologyfile(g,es_instance)
for s, p, o in g.triples((URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , RDF.type, URIRef(class_prefix))):
raise APIException("This instance already exist")
try:
g.add(( URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , RDF.type, URIRef(class_prefix) ))
g.add(( URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , RDFS.comment , Literal(comment) ))
g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle')
except:
raise APIException("Cannot Add instance")
tempDict = []
flag = 0
for sao in Dictdata.values('Dictionary_Data')[0]['Dictionary_Data']:
if sao['Name'] == es_instance[0].strip():
for sao2 in sao['TheClasses']:
if sao2['Class'] == es_instance[1].strip():
flag = 1
for sao3 in sao2['Subclass']:
if sao3['SubClass_name'] == es_instance[2].strip():
flag = 2
if(sao3 ['InstanceOfSubclass'] == ''):
sao3 ['InstanceOfSubclass'] = []
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
else:
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
if (flag == 1):
if(sao2 ['Instance_of_Class'] == ''):
print('sao2')
sao2 ['Instance_of_Class'] = []
sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment })
else:
sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment })
if(flag==0):
sao['GeneralInstances'].append({"Instance": es_instance[1].strip(), "Comment": comment })
tempDict.append(sao)
Dictdata.update(Dictionary_Data= tempDict)
if (es_instance[0].strip() == 'System'):
m = data.values('system_choices')[0]['system_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(system_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Function'):
m = data.values('function_choices')[0]['function_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(function_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Item'):
m = data.values('item_choices')[0]['item_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(item_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Interface'):
m = data.values('inteface_choices')[0]['inteface_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(inteface_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Flow'):
m = data.values('flow_choices')[0]['flow_choices'][:-1]
print('data',m)
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(flow_choices = str(m))
print(m)
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'State'):
m = data.values('state_choices')[0]['state_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(state_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'StateSet'):
m = data.values('state_set_choices')[0]['state_set_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(state_set_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'StateValue'):
m = data.values('state_value_choices')[0]['state_value_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(state_value_choices = str(m))
return HttpResponse('Update Instance')
def getontologyfile(self, g):
for ns_prefix, namespace in g.namespaces():
if ('DSO' in namespace and 'instance' in namespace):
return namespace
raise APIException("There is no file for instances")
def getClassontologyfile(self, g, es_instance):
for ns_prefix, namespace in g.namespaces():
for s, p, o in g.triples((URIRef( namespace+ es_instance[len(es_instance)-2].strip() ) ,None, None)):
return URIRef( namespace+ es_instance[len(es_instance)-2].strip() )
raise APIException("There is no Class in the Ontology ")
class ShallChoicesViewSet(APIView): class ShallChoicesViewSet(APIView):
...@@ -129,15 +276,9 @@ class ShallChoicesViewSet(APIView): ...@@ -129,15 +276,9 @@ class ShallChoicesViewSet(APIView):
return response return response
#class DictionaryViewSet(APIView):
#def get(self, request):
# response = Response(Dictionary_Data_list)
# return response
class DictionaryViewSet(ListAPIView): class DictionaryViewSet(ListAPIView):
""" """
API view to retrieve, update or delete API view to retrieve list of Sections, Classes, Subclasses, Instances
""" """
permission_classes = [permissions.IsAuthenticatedOrReadOnly] permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateGroupDictionarySerializer serializer_class = BoilerplateGroupDictionarySerializer
...@@ -152,3 +293,5 @@ class MainSyntaxViewSet(APIView): ...@@ -152,3 +293,5 @@ class MainSyntaxViewSet(APIView):
def get(self, request): def get(self, request):
response = Response(MAIN_SYNTAX) response = Response(MAIN_SYNTAX)
return response return response
import os
from rdflib import Graph, URIRef
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView, ListAPIView from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView, ListAPIView
from rest_framework import permissions from rest_framework import permissions
...@@ -61,6 +63,10 @@ class BoilerplateGroupDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -61,6 +63,10 @@ class BoilerplateGroupDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE #Custom actions when DELETE
def perform_destroy(self, instance): def perform_destroy(self, instance):
try:
os.system('rm -rf ../../Ontologies/' + instance.title_bgroup +'/')
except:
print('No file exist')
instance.delete() instance.delete()
...@@ -116,6 +122,22 @@ class BoilerplateDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -116,6 +122,22 @@ class BoilerplateDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE #Custom actions when DELETE
def perform_destroy(self, instance): def perform_destroy(self, instance):
#boildata = BoilerplateData.objects.filter(boilerplate_data_id=self.kwargs['pk'])
#data = BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= boildata.values('owner_data')[0]['owner_data'], classes_instances_group_of_boilerplate = boildata.values('group_of_boilerplate_data')[0]['group_of_boilerplate_data'])
#g = Graph()
#g.load(data.values('ontology_file')[0]['ontology_file'], format="turtle")
#rdo_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'])
#g.remove((rdo_instance, None, None))
#g.remove((None, None, rdo_instance))
#prefix = Prefix.objects.filter(prefix_boilerplate = instance)
#pre_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'] +'_'+ prefix.values('simple_prefix')[0]['simple_prefix'])
#g.remove((pre_instance, None, None))
#g.remove((None, None, pre_instance))
#main = Main.objects.filter(boilerplate_of_main = instance)
#rdo_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'] +'_'+ main.values('main_choices')[0]['main_choices'])
#g.remove((rdo_instance, None, None))
#g.remove((None, None, rdo_instance))
#g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle')
instance.delete() instance.delete()
...@@ -232,10 +254,10 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -232,10 +254,10 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
prefixdata.append(self.getprefixdata(id.boilerplate_data_id.id)) prefixdata.append(self.getprefixdata(id.boilerplate_data_id.id))
maindata.append(self.getmaindata(id.boilerplate_data_id.id)) maindata.append(self.getmaindata(id.boilerplate_data_id.id))
suffixdata.append(self.getsuffixdata(id.boilerplate_data_id.id)) suffixdata.append(self.getsuffixdata(id.boilerplate_data_id.id))
try: #try:
metrics, onto_file = inference.inferencing(instance['ontology_file'], project_title, boildata, prefixdata, maindata, suffixdata) metrics, onto_file = inference.inferencing(instance['ontology_file'], project_title, boildata, prefixdata, maindata, suffixdata)
except: #except:
raise APIException("Not all instances in the Ontology") # raise APIException("Not all instances in the Ontology")
instance.update(inference_data = metrics, ontology_file=onto_file) instance.update(inference_data = metrics, ontology_file=onto_file)
serializer.save() serializer.save()
...@@ -254,7 +276,7 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -254,7 +276,7 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
class PrefixChoicesViewSet(ListAPIView): class PrefixChoicesViewSet(ListAPIView):
""" """
API view to retrieve, update or delete API view to retrieve list of Prefix choices
""" """
permission_classes = [permissions.IsAuthenticatedOrReadOnly] permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateGroupClassesInstancesSerializer serializer_class = BoilerplateGroupClassesInstancesSerializer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment