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()">
<mat-sidenav-container>
......@@ -17,7 +19,7 @@
<footer class="footer page-footer font-small ">
<!-- 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>
</div>
<!-- Copyright -->
......@@ -30,4 +32,3 @@
</div>
<notifier-container></notifier-container>
\ No newline at end of file
......@@ -35,9 +35,27 @@ import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.
import { InstancesListComponent } from './components/instances-list/instances-list.component';
import { Ng2SearchPipeModule } from 'ng2-search-filter';
import { NgxEchartsModule } from 'ngx-echarts';
import { CourseDialogComponentComponent } from './components/course-dialog-component/course-dialog-component.component';
@NgModule({
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
Ng2SearchPipeModule,
HttpClientModule,
NgbModule,
NotifierModule,
BrowserAnimationsModule,
MaterialModule,
FlexLayoutModule,
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
}),
],
declarations: [
AppComponent,
LoginComponent,
......@@ -57,22 +75,7 @@ import { NgxEchartsModule } from 'ngx-echarts';
GroupboilComponent,
AddGroupboilComponent,
InstancesListComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
ReactiveFormsModule,
FormsModule,
Ng2SearchPipeModule,
HttpClientModule,
NgbModule,
NotifierModule,
BrowserAnimationsModule,
MaterialModule,
FlexLayoutModule,
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
}),
CourseDialogComponentComponent,
],
providers: [
AuthService,
......@@ -83,6 +86,6 @@ import { NgxEchartsModule } from 'ngx-echarts';
multi: true,
},
],
bootstrap: [AppComponent]
bootstrap: [AppComponent],
})
export class AppModule { }
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 { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
......@@ -41,19 +41,20 @@ export class AddBoilerplateComponent implements OnInit {
};
if (data.title != "") {
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)
.subscribe(
response => {
this.notifier.notify("success",(JSON.stringify(response)));
this.notifier.notify("success", "Requirement " + this.boilerplate.title + " created");
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 => {
console.log(error);
//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 {
}
prefixs = [
{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: '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: '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: '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 = [
{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: '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: '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: '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: '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: '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: '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: '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: '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: '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: '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: '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: '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: '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: '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: '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.' },
];
suffixs = [
{name: 'S1', details: "<numerical-afirmative> j <closed-interval> [per <time-unit>]", 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: 'S4', details: "at the beginning/at the end", explanation: ''},
{name: 'S5', details: "at even intervals", explanation: ''},
{name: 'S6', details: "sequentially", explanation: ''},
{ name: 'S1', details: "<numerical-afirmative> j <closed-interval> [per <time-unit>]", 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: 'S4', details: "at the beginning/at the end", explanation: '' },
{ name: 'S5', details: "at even intervals", 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 @@
</ol>
</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>
<div class="form-group">
<label for="title_bgroup">Requirement Title</label>
<input type="text" class="form-control" id="title_bgroup"
required
[(ngModel)]="groupboilerplate.title_bgroup" name="title_bgroup">
<label for="title_bgroup">Project title</label>
<input type="text" class="form-control" id="title_bgroup" required [(ngModel)]="groupboilerplate.title_bgroup"
name="title_bgroup">
</div>
<div class="form-group">
<label for="description">Description of project</label>
<textarea
type="text"
class="form-control"
id="description"
required
[(ngModel)]="groupboilerplate.description"
name="description"
></textarea>
<textarea type="text" class="form-control" id="description" required [(ngModel)]="groupboilerplate.description"
name="description"></textarea>
</div>
</form>
<button (click)="saveBoilerplate()" class="btn btn-success" >Submit</button>
</div>
\ No newline at end of file
<button (click)="saveBoilerplate()" class="btn btn-success">Submit</button>
</div>
\ No newline at end of file
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 { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
......@@ -18,7 +18,7 @@ export class AddGroupboilComponent implements OnInit {
submitted = false;
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;
}
......@@ -27,20 +27,21 @@ export class AddGroupboilComponent implements OnInit {
saveBoilerplate(): void {
const data = {
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)
.subscribe(
response => {
this.notifier.notify("success",(JSON.stringify(response)));
this.submitted = true;
this.notifier.notify("success", "Project " + this.groupboilerplate.title_bgroup + ' created');
this.submitted = false;
this.router.navigate(['/groupboilerplates']);
},
error => {
console.log(error);
//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 {
......
......@@ -9,28 +9,18 @@
</ol>
</nav>
<mat-grid-list cols="2">
<div class="first">
<div class="first">
<div *ngIf="currentboilerplate.id" class="edit-form">
<form ngNativeValidate>
<div class="form-group" style="display:flex; flex-direction: row; align-items: center">
<label for="title" style="margin-right: 50px;">Requirement title</label>
<input
name="title"
id="title"
type="text"
class="form-control"
required
[(ngModel)]="currentboilerplate.title"
(change)="this.updateBoilerplate()"
style="width: 63%;"/>
<input name="title" id="title" type="text" class="form-control" required
[(ngModel)]="currentboilerplate.title" (change)="this.updateBoilerplate()" style="width: 63%;" />
</div>
<div style="display: flex; flex-grow: grow; margin-top: 50px; ">
<form class="form-group form-inline ">
<mat-checkbox class="example-full-width"
[(ngModel)]="currentboilerplate.has_prefix"
(change)="this.updateBoilerplate()"
name="has_prefix"
>Prefix
<mat-checkbox class="example-full-width" [(ngModel)]="currentboilerplate.has_prefix"
(change)="this.updateBoilerplate()" name="has_prefix">Prefix
</mat-checkbox>
</form>
<div *ngIf="this.currentboilerplate.has_prefix" style="margin-left: 50px;">
......@@ -40,11 +30,8 @@
<mat-divider></mat-divider>
<div style="display: flex; flex-grow: grow; margin-top: 50px;">
<form class="form-group form-inline ">
<mat-checkbox class="example-full-width"
[(ngModel)]="currentboilerplate.has_main"
name="has_prefix"
[disabled]="true"
>Main
<mat-checkbox class="example-full-width" [(ngModel)]="currentboilerplate.has_main" name="has_prefix"
[disabled]="true">Main
</mat-checkbox>
</form>
<div *ngIf="this.currentboilerplate.has_main" style="margin-left: 50px;">
......@@ -54,11 +41,8 @@
<mat-divider></mat-divider>
<div style="display: flex; flex-grow: grow; margin-top: 50px;">
<form class="form-group form-inline ">
<mat-checkbox class="example-full-width"
[(ngModel)]="this.currentboilerplate.has_suffix"
(change)="this.updateBoilerplate()"
name="has_suffix"
>Suffix
<mat-checkbox class="example-full-width" [(ngModel)]="this.currentboilerplate.has_suffix"
(change)="this.updateBoilerplate()" name="has_suffix">Suffix
</mat-checkbox>
</form>
<div *ngIf="this.currentboilerplate.has_suffix" style="margin-left: 50px;">
......@@ -68,16 +52,11 @@
</form>
<div class="list row">
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="start">
<input class="btn btn-success"
type="button"
value=" Update Boilerplate"
(click)="updateDetailsOfBoilerplate()"/>
<input class="btn btn-success" type="button" value=" Update Boilerplate"
(click)="updateDetailsOfBoilerplate()" />
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<input class="btn btn-warning"
type="button"
value="Delete Boilerplate"
(click)="deleteBoilerplate()"/>
<input class="btn btn-warning" type="button" value="Delete Boilerplate" (click)="deleteBoilerplate()" />
</div>
</div>
<p>{{ message }}</p>
......@@ -88,17 +67,19 @@
<div *ngIf="!currentboilerplate.id">
<mat-spinner style="margin: auto;"></mat-spinner>
</div>
</div>
</div>
<!-- Dictionary -->
<div class="second">
<!-- Dictionary -->
<div class="second">
<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>
<mat-tab-group mat-align-tabs="center">
<div *ngFor="let section of systems| filter:searchText">
<mat-tab label={{section.Name}}>
<div *ngFor="let item of section.TheClasses| filter:searchText">
<div *ngIf="item.Class">
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
......@@ -111,7 +92,10 @@
</mat-expansion-panel-header>
{{ item.Comment }}
<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">
<li>
<mat-expansion-panel hideToggle>
......@@ -125,7 +109,8 @@
</li>
</div>
</ul>
<ul> <h4><b>Subclasses</b></h4>
<ul>
<h4><b>Subclasses</b></h4>
<div *ngFor="let sub of item.Subclass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
......@@ -135,7 +120,11 @@
</mat-panel-title>
</mat-expansion-panel-header>
<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">
<li>
<mat-expansion-panel hideToggle>
......@@ -158,13 +147,19 @@
</mat-expansion-panel>
</mat-accordion>
</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">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{genin.GeneralInstances}}
{{genin.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
{{genin.Comment}}
......@@ -179,9 +174,10 @@
<div *ngIf="!checklen(systems)">
<mat-spinner style="margin: auto;"></mat-spinner>
</div>
</div>
</mat-grid-list >
</div>
</mat-grid-list>
<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>
\ No newline at end of file
......@@ -4,25 +4,25 @@ import { Boilerplate } from 'src/app/models/boilerplate.model';
import { Sections } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { MainService } from 'src/app/services/main.service';
import {MainDetailsComponent} from 'src/app/components/main-details/main-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 { MainDetailsComponent } from 'src/app/components/main-details/main-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 { 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({
selector: 'app-boilerplate-details',
templateUrl: './boilerplate-details.component.html',
styleUrls: ['./boilerplate-details.component.scss']
})
export class BoilerplateDetailsComponent implements OnInit {
panelOpenState = false;
subjects:string[] = [];
subjects: string[] = [];
systems?: Sections [];
systems?: Sections[];
currentboilerplate: Boilerplate = {
group_of_boilerplate: this.route.snapshot.params.gb,
......@@ -36,14 +36,19 @@ export class BoilerplateDetailsComponent implements OnInit {
message = '';
searchText = '';
searchTextinstances = '';
addinstance = '';
private readonly notifier: NotifierService;
constructor(
private mainService: MainService,
private boilerplateService: BoilerplateService,
private route: ActivatedRoute,
notifierService: NotifierService,
private router: Router) { this.notifier = notifierService; }
private router: Router,
public dialog: MatDialog) { this.notifier = notifierService; }
@ViewChild(MainDetailsComponent) mainchild!: MainDetailsComponent;
@ViewChild(PrefixDetailsComponent) prefchild!: PrefixDetailsComponent;
......@@ -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)
.subscribe(
data => {
this.currentboilerplate = data;
console.log(data);
//console.log(data);
},
error => {
console.log(error);
......@@ -70,35 +75,37 @@ export class BoilerplateDetailsComponent implements OnInit {
updateBoilerplate(): any {
if (this.currentboilerplate.title != "") {
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(/[^\w\s]/gi, ' ')
this.currentboilerplate.title = this.currentboilerplate.title?.replace(/ /g, "_")
}
this.boilerplateService.update(this.route.snapshot.params.gb, this.currentboilerplate.id, this.currentboilerplate)
.subscribe(
response => {
//this.notifier.notify("success",(JSON.stringify("Requirement " + this.currentboilerplate.title + " updated")));
//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_suffix){this.sufchild.getAllSuffix(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); };
},
error => {
this.notifier.notify("warning",(JSON.stringify(error)));
});}
this.notifier.notify("warning", (JSON.stringify(error)));
});
}
updateDetailsOfBoilerplate(): any {
if (this.currentboilerplate.has_prefix){this.prefchild.updatePrefix()};
if (this.currentboilerplate.has_main){this.mainchild.updateMain();};
if (this.currentboilerplate.has_suffix){this.sufchild.updateSuffix();};
this.notifier.notify("success",(JSON.stringify("Requirement " + this.currentboilerplate.title + " updated")));
if (this.currentboilerplate.has_prefix) { this.prefchild.updatePrefix() };
if (this.currentboilerplate.has_main) { this.mainchild.updateMain(); };
if (this.currentboilerplate.has_suffix) { this.sufchild.updateSuffix(); };
this.notifier.notify("success", (JSON.stringify("Requirement " + this.currentboilerplate.title + " updated")));
}
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)
.subscribe(
response => {
console.log(response);
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates']);
//console.log(response);
this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates']);
},
error => {
console.log(error);
......@@ -106,22 +113,105 @@ export class BoilerplateDetailsComponent implements OnInit {
}
}
getchoices(gb : any): void{
getchoices(gb: any): void {
//System
this.mainService.getdictionary(gb)
.subscribe(
data => {
// console.log(data[0].Dictionary_Data);
this.systems = data[0].Dictionary_Data
},
error => {
console.log(error);
});
}
checklen(i:any): any {
if (i.length>1){ return true}
checklen(i: any): any {
if (i) {
if (i.length >= 1) { return true }
}
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 @@
<div class="list row">
<div class="col-md-14">
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<input
type="text"
class="form-control"
placeholder="Search"
(keyup)="applyFilter($event)"
#input/>
<input type="text" class="form-control" placeholder="Search" (keyup)="applyFilter($event)" #input />
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<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>
</ul>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul *ngFor="let inf of infer;" fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<input class="btn btn-info"
[disabled] = "exporting"
type="button"
value="Inferencing"
(click)="updateInfer(inf.id)"/>
<input class="btn btn-info" [disabled]="exporting" type="button" value="Inferencing"
(click)="updateInfer(inf.id)" />
</div>
</ul>
</div>
</div>
</div>
<div [hidden] = "!showSpinner">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
<div [hidden]="!showSpinner">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<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 -->
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> No. </th>
......@@ -54,7 +46,9 @@
<!-- Name Column -->
<ng-container matColumnDef="title_data">
<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>
</ng-container>
......@@ -78,14 +72,15 @@
<tr mat-header-row *matHeaderRowDef="newdisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: newdisplayedColumns;"></tr>
</table>
<mat-paginator #paginator [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator>
</table>
<mat-paginator #paginator [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator>
</div>
<div echarts [options]="chartOption" class="demo-chart"></div>
<div class="content">
<div fxLayout="row wrap">
<div fxFlex="33%">
<div fxFlex="33.3%">
<mat-card class="example-card">
<mat-card-header>
<div class="example-header-image"></div>
......@@ -93,18 +88,22 @@
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle>
</mat-card-header>
</mat-card>
</div>
<div fxFlex="33.3%">
<mat-card class="example-card">
<mat-card-header>
<div class="example-header-image"></div>
<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>
</div>
<div fxFlex="33.3%">
<mat-card class="example-card">
<mat-card-header>
<div class="example-header-image"></div>
<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>
</div>
......
......@@ -5,8 +5,8 @@ import { InferenceResults } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { PrefixService } from 'src/app/services/prefix.service';
import { ActivatedRoute, Router } from '@angular/router';
import {MatTableDataSource} from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';
import { MatPaginator } from '@angular/material/paginator';
import { EChartsOption } from 'echarts';
import { NotifierService } from "angular-notifier";
......@@ -34,12 +34,12 @@ export class BoilerplateListComponent implements OnInit {
type: 'pie',
radius: ['40%', '70%'],
data: [
{value: 0, name: '1'},
{value: 0, name: '2'},
{value: 0, name: '3'},
{value: 0, name: '4'},
{value: 0, name: '5'} ]
},
{ value: 0, name: '1' },
{ value: 0, name: '2' },
{ value: 0, name: '3' },
{ value: 0, name: '4' },
{ value: 0, name: '5' }]
}
],
};
private readonly notifier: NotifierService;
......@@ -54,27 +54,28 @@ export class BoilerplateListComponent implements OnInit {
currentIndex = -1;
title = '';
displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix', 'action'];
newdisplayedColumns: string[] = ['id','title_data' ,'prefix_data', 'main_data', 'suffix_data', 'action'];
dataSource :Boilerplate[] = [{}];
thenewdataSource:BoilerplateData[] = [{}];
newdisplayedColumns: string[] = ['id', 'title_data', 'prefix_data', 'main_data', 'suffix_data', 'action'];
dataSource: Boilerplate[] = [{}];
thenewdataSource: BoilerplateData[] = [{}];
newdataSource = new MatTableDataSource(this.thenewdataSource);
infer:InferenceResults[] = [{}];
infer: InferenceResults[] = [{}];
//when inference button is pressed
showSpinner = 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 [] = [];
aprefix: any [] = [];
dataofboilerplates: any[] = [];
aprefix: any[] = [];
main: any;
suffix: any;
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 {
this.boilerplateService.getAllData(this.route.snapshot.params.gb)
.subscribe(
data => {
this.boilerplatesdata =data;
this.boilerplatesdata = data;
this.thenewdataSource = data;
this.newdataSource = new MatTableDataSource(this.thenewdataSource);
this.newdataSource.paginator = this.paginator;
console.log(data)
//console.log(data)
},
error => {
console.log(error);
......@@ -127,13 +128,13 @@ export class BoilerplateListComponent implements OnInit {
SearchTitle(): void {
if (this.title != ''){
if (this.title != '') {
this.boilerplateService.findByTitle(this.route.snapshot.params.gb, this.title)
.subscribe(
data => {
this.boilerplates = data;
this.dataSource = data;
console.log(data);
//console.log(data);
},
error => {
console.log(error);
......@@ -145,30 +146,35 @@ export class BoilerplateListComponent implements OnInit {
}
}
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 {
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)
.subscribe(
data => {
this.currentInfer = data[0];
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 = []
for (let i of this.list_of_inference_metrics){
if(obj[i] != undefined){
for (let i of this.list_of_inference_metrics) {
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 = [{
type: 'pie',
radius: ['40%', '70%'],
data: final,
}]}}
}]
},
error => {
console.log(error);
......@@ -192,7 +198,7 @@ export class BoilerplateListComponent implements OnInit {
console.log(error);
this.showSpinner = !this.showSpinner;
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 {
this.newdataSource.filter = filterValue.trim().toLowerCase();
}
get_metrics(i:any): any {
if (this.currentInfer?.inference_data){
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g,"\""))
if (obj[i]){
get_metrics(i: any): any {
if (this.currentInfer?.inference_data) {
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
if (obj[i]) {
return obj[i]
}
}
return 0
}
getnumreq():any{
getnumreq(): any {
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 @@
<div class="list row">
<div class="col-md-8">
<div class="input-group mb-3">
<input
type="text"
class="form-control"
placeholder="Search"
[(ngModel)]="title"
name="search"
autocomplete="off"
/>
<input type="text" class="form-control" placeholder="Search" [(ngModel)]="title" name="search"
autocomplete="off" />
<!-- (keyup.enter)="SearchTitle()"-->
<!-- (click)="SearchTitle()" -->
<div class="input-group-append">
<button
class="btn btn-primary"
type="button"
>Search
<button class="btn btn-primary" type="button">Search
</button>
</div>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<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>
</ul>
</div>
......@@ -37,7 +28,8 @@
<div class="content">
<div fxLayout="row wrap">
<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>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>{{gb.title_bgroup}}</mat-card-title>
......@@ -49,11 +41,13 @@
{{gb.description}}
</p>
</mat-card-content>
</div>
<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>
</mat-card-actions>
</mat-card>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { GroupBoilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
@Component({
selector: 'app-groupboil',
......@@ -11,8 +12,10 @@ export class GroupboilComponent implements OnInit {
grouboilerplates?: GroupBoilerplate[];
title = '';
constructor(private boilerplateService: BoilerplateService) { }
private readonly notifier: NotifierService;
constructor(private boilerplateService: BoilerplateService, notifierService: NotifierService) {
this.notifier = notifierService;
}
ngOnInit(): void {
this.retrievegroupBoilerplates();
......@@ -23,7 +26,7 @@ export class GroupboilComponent implements OnInit {
.subscribe(
data => {
this.grouboilerplates = data;
console.log(data);
//console.log(data);
},
error => {
console.log(error);
......@@ -32,15 +35,17 @@ export class GroupboilComponent implements OnInit {
}
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)
.subscribe(
response => {
console.log(response);
//console.log(response);
this.notifier.notify("success", "Project deleted");
this.retrievegroupBoilerplates();
},
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';
styleUrls: ['./instances-list.component.scss']
})
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) { }
ngOnInit(): void {
this.getchoices();
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
}
getchoices(): void{
getchoices(): void {
this.mainService.getsubject()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.subjects.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.subjects.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -49,9 +47,10 @@ export class InstancesListComponent implements OnInit {
.subscribe(
data => {
//no data from State and Item
console.log(data);
for (let x=0; x < data.length; x++ ){
this.stateitem.push(data[x][1]);}
//console.log(data);
for (let x = 0; x < data.length; x++) {
this.stateitem.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -59,8 +58,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getstatevalue()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.statevalue.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.statevalue.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -68,8 +68,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getshall()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.shall.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.shall.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -77,8 +78,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getverb()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.verb.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.verb.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -86,8 +88,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getquantifier()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.quantifier.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.quantifier.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -96,8 +99,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getnumunit()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.numunit.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.numunit.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -105,8 +109,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getfifuintsysstatset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.fifuintsysstatset.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.fifuintsysstatset.push(data[x][1]);
}
},
error => {
console.log(error);
......@@ -114,8 +119,9 @@ export class InstancesListComponent implements OnInit {
this.mainService.getstsysconset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.stsysconset.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.stsysconset.push(data[x][1]);
}
},
error => {
console.log(error);
......
<div fxLayoutAlign="end"> <mat-chip color="primary"> MAIN TEMPLATE : {{this.main}}</mat-chip> </div>
<div class="form-row">
<div fxLayoutAlign="end">
<mat-chip color="primary"> MAIN TEMPLATE : {{this.main}}</mat-chip>
</div>
<div class="form-row">
<div class="col">
<form class="form-group form-inline" ngNativeValidate>
<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>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="subjectsControl"
required
[matAutocomplete]="automainsub"
style="width: 100%;">
<mat-autocomplete autoActiveFirstOption #automainsub="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-label *ngIf="this.subjectsControl.value !=null">Subject : {{this.subjectsControl.value.slice(0,
this.subjectsControl.value.indexOf(':'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="subjectsControl" 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">
{{option.split(" : ").pop()}}
</mat-option>
......@@ -21,17 +19,15 @@
</form>
</div>
<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-label *ngIf="this.stateitemControl.value !=null">State or Item : {{this.stateitemControl.value.slice(0, this.stateitemControl.value.indexOf(':'))}}</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="stateitemControl"
[matAutocomplete]="autostateitem"
>
<mat-autocomplete autoActiveFirstOption #autostateitem="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-label *ngIf="this.stateitemControl.value !=null">State or Item : {{this.stateitemControl.value.slice(0,
this.stateitemControl.value.indexOf(':'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="stateitemControl"
[matAutocomplete]="autostateitem">
<mat-autocomplete autoActiveFirstOption #autostateitem="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of stateitemfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
......@@ -40,17 +36,15 @@
</form>
</div>
<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-label *ngIf="statevalueControl.value !=null">State Value : {{statevalueControl.value.slice(0, statevalueControl.value.indexOf(':'))}}</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="statevalueControl"
[matAutocomplete]="autostatevalue"
>
<mat-autocomplete autoActiveFirstOption #autostatevalue="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-label *ngIf="statevalueControl.value !=null">State Value : {{statevalueControl.value.slice(0,
statevalueControl.value.indexOf(':'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="statevalueControl"
[matAutocomplete]="autostatevalue">
<mat-autocomplete autoActiveFirstOption #autostatevalue="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of statevaluefilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
......@@ -59,20 +53,14 @@
</form>
</div>
</div>
<div class="form-row" >
<div class="form-row">
<div class="col" style="width: 100px;">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Shall/shall not</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="shallControl"
required
[matAutocomplete]="autoshall"
>
<mat-autocomplete autoActiveFirstOption #autoshall ="matAutocomplete" >
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="shallControl" required
[matAutocomplete]="autoshall">
<mat-autocomplete autoActiveFirstOption #autoshall="matAutocomplete">
<mat-option *ngFor="let option of shallfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
......@@ -81,17 +69,13 @@
</form>
</div>
<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-label *ngIf="verbControl.value !=null">Verb : {{verbControl.value.slice(0, verbControl.value.indexOf(' : '))}}</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="verbControl"
required
[matAutocomplete]="autoverb"
>
<mat-label *ngIf="verbControl.value !=null">Verb : {{verbControl.value.slice(0, verbControl.value.indexOf(' :
'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="verbControl" required
[matAutocomplete]="autoverb">
<mat-autocomplete autoActiveFirstOption #autoverb="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of verbfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
......@@ -100,19 +84,14 @@
</mat-form-field>
</form>
</div>
<div class="col" >
<form class="form-group form-inline" [ngStyle]="(quantifierControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(quantifierControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width">
<mat-label>Quantifier</mat-label>
<input
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="quantifierControl"
type="text"
[matAutocomplete]="autoquantifier"
>
<mat-autocomplete autoActiveFirstOption #autoquantifier ="matAutocomplete">
<input placeholder="Pick one" aria-label="Number" matInput [formControl]="quantifierControl" type="text"
[matAutocomplete]="autoquantifier">
<mat-autocomplete autoActiveFirstOption #autoquantifier="matAutocomplete">
<mat-option *ngFor="let option of quantifierfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
......@@ -121,8 +100,9 @@
</form>
</div>
<!--NUmber Value-->
<div class="col" >
<form class="form-group form-inline" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label>
<input type="text" matInput [(ngModel)]="currentmain.numerical" name="numerical">
......@@ -130,17 +110,13 @@
</form>
</div>
<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-label>Number Unit</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="numunitControl"
[matAutocomplete]="autonumunit"
>
<mat-autocomplete autoActiveFirstOption #autonumunit ="matAutocomplete">
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="numunitControl"
[matAutocomplete]="autonumunit">
<mat-autocomplete autoActiveFirstOption #autonumunit="matAutocomplete">
<mat-option *ngFor="let option of numunitfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
......@@ -154,16 +130,12 @@
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="fifuintsysstatsetControl.value !=null">Object : {{fifuintsysstatsetControl.value.slice(0, fifuintsysstatsetControl.value.indexOf(':'))}}</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="fifuintsysstatsetControl"
required
[matAutocomplete]="autofifuintsysstatset"
>
<mat-autocomplete autoActiveFirstOption #autofifuintsysstatset ="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-label *ngIf="fifuintsysstatsetControl.value !=null">Object : {{fifuintsysstatsetControl.value.slice(0,
fifuintsysstatsetControl.value.indexOf(':'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="fifuintsysstatsetControl"
required [matAutocomplete]="autofifuintsysstatset">
<mat-autocomplete autoActiveFirstOption #autofifuintsysstatset="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of fifuintsysstatsetfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
......@@ -172,18 +144,15 @@
</form>
</div>
<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-label *ngIf="stsysconsetControl.value !=null">StateSet or StateValue or System or Connection : {{stsysconsetControl.value.slice(0, stsysconsetControl.value.indexOf(':'))}}</mat-label>
<input
placeholder="Pick one"
aria-label="Number"
type="text"
matInput
[formControl]="stsysconsetControl"
[matAutocomplete]="autostsysconset"
>
<mat-autocomplete autoActiveFirstOption #autostsysconset ="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-label *ngIf="stsysconsetControl.value !=null">StateSet or StateValue or System or Connection :
{{stsysconsetControl.value.slice(0, stsysconsetControl.value.indexOf(':'))}}</mat-label>
<input placeholder="Pick one" aria-label="Number" type="text" matInput [formControl]="stsysconsetControl"
[matAutocomplete]="autostsysconset">
<mat-autocomplete autoActiveFirstOption #autostsysconset="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of stsysconsetfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</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 { Main } from 'src/app/models/main.model';
import { Mainsyntax } from 'src/app/models/main.model';
import { MainService } from 'src/app/services/main.service';
import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs';
import {map, startWith} from 'rxjs/operators';
import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier";
@Component({
......@@ -15,63 +15,63 @@ import { NotifierService } from "angular-notifier";
})
export class MainDetailsComponent implements OnInit {
mainsyntax = [
{Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: []}];
mainsyntax11?: Mainsyntax ={
Attributes : [],
Quantifier : false,
Related_to_Subject : [],
Subject : [],
Verbs : []
{ Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: [] }];
mainsyntax11?: Mainsyntax = {
Attributes: [],
Quantifier: false,
Related_to_Subject: [],
Subject: [],
Verbs: []
};
subjectsControl = new FormControl();
subjects:string[] = [];
subjects: string[] = [];
subjectsfilteredOptions: Observable<string[]>;
stateitemControl = new FormControl();
stateitem:string[] = [];
stateitem: string[] = [];
stateitemfilteredOptions: Observable<string[]>;
stateitemControlisDivVisible = false
statevalueControl = new FormControl();
statevalue:string[] = [];
statevalue: string[] = [];
statevaluefilteredOptions: Observable<string[]>;
statevalueControlisDivVisible = false
shallControl = new FormControl();
shall:string[] = [];
shall: string[] = [];
shallfilteredOptions: Observable<string[]>;
verbControl = new FormControl();
verb:string[] = [];
verb: string[] = [];
verbfilteredOptions: Observable<string[]>;
verbControlisDivVisible = true
quantifierControl = new FormControl( );
quantifier:string[] = [];
quantifierControl = new FormControl();
quantifier: string[] = [];
quantifierfilteredOptions: Observable<string[]>;
quantifierControlisDivVisible = false
numunitControl = new FormControl();
numunit:string[] = [];
numunit: string[] = [];
numunitfilteredOptions: Observable<string[]>;
numunitControlisDivVisible = false
fifuintsysstatsetControl = new FormControl();
fifuintsysstatset:string[] = [];
fifuintsysstatset: string[] = [];
fifuintsysstatsetfilteredOptions: Observable<string[]>;
stsysconsetControl = new FormControl();
stsysconset:string[] = [];
stsysconset: string[] = [];
stsysconsetfilteredOptions: Observable<string[]>;
stsysconsetControlisDivVisible = false
numericalisDivVisible = false
public static id: any [] = [];
public static id: any[] = [];
private readonly notifier: NotifierService;
mains?: Main[];
......@@ -144,40 +144,32 @@ export class MainDetailsComponent implements OnInit {
this.dis();
}
dis(): any{
dis(): any {
//Check for each M1-M16
for (let x=0; x < this.mainsyntax.length; x++ ){
//for (let x=0; x < 1; x++ ){
//console.log(this.mainsyntax[x])
//console.log(this.mainsyntax[x].Id)
for (let s=0; s < this.mainsyntax[x].Subject.length; s++ ){
//console.log()
if (this.mainsyntax[x].Subject[s] == (this.subjectsControl.value.slice(0, this.subjectsControl.value.indexOf(':'))).replace(/\s/g, "")){
//console.log("okk")
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 ){
for (let x = 0; x < this.mainsyntax.length; x++) {
for (let s = 0; s < this.mainsyntax[x].Subject.length; s++) {
if (this.mainsyntax[x].Subject[s] == this.subjectsControl.value ? (this.subjectsControl.value.slice(0, this.subjectsControl.value.indexOf(':'))).replace(/\s/g, "") : this.subjectsControl.value) {
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, "")) {
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, "")) {
if (this.mainsyntax[x].Related_to_Subject.length > 0) {
this.stateitemControlisDivVisible = true
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; }
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; }
}
}
//console.log(this.mainsyntax[x].Quantifier)
if (this.mainsyntax[x].Quantifier){
//this.quantifierControl.enable();
if (this.mainsyntax[x].Quantifier) {
this.quantifierControlisDivVisible = true;
this.numericalisDivVisible = true;
//numerical value
this.numunitControlisDivVisible = true;
//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].Id.includes('M14') && !this.mainsyntax[x].Id.includes('M16')){
this.stsysconsetControlisDivVisible = true;}
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')) {
this.stsysconsetControlisDivVisible = true;
}
//add the connection data
}
this.main = this.mainsyntax[x].Id
......@@ -201,18 +193,18 @@ export class MainDetailsComponent implements OnInit {
this.stsysconsetControlisDivVisible = false;
this.main = "No boilerplate with this syntax"
}
}
}
displayFn(option:string): string {
displayFn(option: string): string {
if (option != null) {
let x = option.split(" : ");
if ( (x[x.length -2] == "") || (x[x.length -1]=="")) { return "";}
return (x[x.length -2]+" : "+x[x.length -1]);
if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return ""; }
return (x[x.length - 2] + " : " + x[x.length - 1]);
}
return "";
}
private _filter(data:string[], value: string): string[] {
private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue));
}
......@@ -221,7 +213,7 @@ export class MainDetailsComponent implements OnInit {
this.mainService.getAll(id)
.subscribe(
data => {
MainDetailsComponent.id.length =0;
MainDetailsComponent.id.length = 0;
this.mains = data;
for (var val of data) {
MainDetailsComponent.id.push(val.id);
......@@ -256,31 +248,32 @@ export class MainDetailsComponent implements OnInit {
updateMain(): void {
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.statevalueControlisDivVisible){this.currentmain.statevalue_before_verb = this.statevalueControl.value;}else{this.currentmain.statevalue_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 = '' }
this.currentmain.shall = this.shallControl.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
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;
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)
.subscribe(
response => {
this.message = response.message;
},
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)
.subscribe(
data => {
......@@ -319,61 +312,77 @@ export class MainDetailsComponent implements OnInit {
}
getsubject (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));}}
getsubject(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));
}
}
}
getstateitem (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.stateitem.indexOf(strIntoObj[x][1]) == -1) {
this.stateitem.push((strIntoObj[x][1]));}}
getstateitem(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.stateitem.indexOf(strIntoObj[x][1]) == -1) {
this.stateitem.push((strIntoObj[x][1]));
}
}
}
getstatevalue (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.statevalue.indexOf(strIntoObj[x][1]) == -1) {
this.statevalue.push((strIntoObj[x][1]));}}
getstatevalue(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.statevalue.indexOf(strIntoObj[x][1]) == -1) {
this.statevalue.push((strIntoObj[x][1]));
}
}
}
getverb (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.verb.indexOf(strIntoObj[x][1]) == -1) {
this.verb.push((strIntoObj[x][1]));}}
getverb(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.verb.indexOf(strIntoObj[x][1]) == -1) {
this.verb.push((strIntoObj[x][1]));
}
}
}
getquantifier (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.quantifier.indexOf(strIntoObj[x][1]) == -1) {
this.quantifier.push((strIntoObj[x][1]));}}
getquantifier(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.quantifier.indexOf(strIntoObj[x][1]) == -1) {
this.quantifier.push((strIntoObj[x][1]));
}
}
}
getfifuintsysstatset (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.fifuintsysstatset.indexOf(strIntoObj[x][1]) == -1) {
this.fifuintsysstatset.push((strIntoObj[x][1]));}}
getfifuintsysstatset(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.fifuintsysstatset.indexOf(strIntoObj[x][1]) == -1) {
this.fifuintsysstatset.push((strIntoObj[x][1]));
}
}
}
getstsysconset (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.stsysconset.indexOf(strIntoObj[x][1]) == -1) {
this.stsysconset.push((strIntoObj[x][1]));}}
getstsysconset(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.stsysconset.indexOf(strIntoObj[x][1]) == -1) {
this.stsysconset.push((strIntoObj[x][1]));
}
}
}
getnumunit (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.numunit.indexOf(strIntoObj[x][1]) == -1) {
this.numunit.push((strIntoObj[x][1]));}}
getnumunit(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.numunit.indexOf(strIntoObj[x][1]) == -1) {
this.numunit.push((strIntoObj[x][1]));
}
}
}
getchoices(): void{
getchoices(): void {
this.mainService.getmainsyntax()
.subscribe(
data => {
this.mainsyntax = data
console.log(data);
//console.log(data);
},
error => {
......@@ -383,14 +392,16 @@ export class MainDetailsComponent implements OnInit {
this.mainService.getshall()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.shall.indexOf(data[x][1]) == -1) {
this.shall.push(data[x][1]);}}
for (let x = 0; x < data.length; x++) {
if (this.shall.indexOf(data[x][1]) == -1) {
this.shall.push(data[x][1]);
}
}
},
error => {
console.log(error);
});
}
}
}
......@@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Prefix } from 'src/app/models/prefix.model';
import { PrefixService } from 'src/app/services/prefix.service';
import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs';
import {map, startWith} from 'rxjs/operators';
import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier";
......@@ -16,27 +16,27 @@ import { NotifierService } from "angular-notifier";
})
export class PrefixDetailsComponent implements OnInit {
simpleprefixControl = new FormControl();
simpleprefix:string[] = [];
simpleprefix: string[] = [];
simpleprefixfilteredOptions: Observable<string[]>;
subjectsControl = new FormControl();
subjects:string[] = [];
subjects: string[] = [];
subjectsfilteredOptions: Observable<string[]>;
verbsControl = new FormControl();
verbs:string[] = [];
verbs: string[] = [];
verbsfilteredOptions: Observable<string[]>;
objectsControl = new FormControl();
objects:string[] = [];
objects: string[] = [];
objectsfilteredOptions: Observable<string[]>;
logic_conControl = new FormControl();
logic_con:string[] = [];
logic_con: string[] = [];
logic_confilteredOptions: Observable<string[]>;
public static id: any [] = [];
public static id: any[] = [];
private readonly notifier: NotifierService;
prefixs?: Prefix[];
......@@ -54,8 +54,9 @@ export class PrefixDetailsComponent implements OnInit {
message = '';
constructor(private prefixService: PrefixService,private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) { this.notifier = notifierService;
constructor(private prefixService: PrefixService, private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) {
this.notifier = notifierService;
this.simpleprefixfilteredOptions = this.simpleprefixControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.simpleprefix, value))
......@@ -83,16 +84,16 @@ export class PrefixDetailsComponent implements OnInit {
this.getAllPrefix(this.route.snapshot.params.id);
}
displayFn(option:string): string {
displayFn(option: string): string {
if (option != null) {
let x = option.split(" : ");
if ( (x[x.length -2] == "") || (x[x.length -1]=="")) { return "";}
return (x[x.length -2]+" : "+x[x.length -1]);
if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return ""; }
return (x[x.length - 2] + " : " + x[x.length - 1]);
}
return "";
}
private _filter(data:string[], value: string): string[] {
private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue));
}
......@@ -101,7 +102,7 @@ export class PrefixDetailsComponent implements OnInit {
this.prefixService.getAll(id)
.subscribe(
data => {
PrefixDetailsComponent.id.length =0;
PrefixDetailsComponent.id.length = 0;
this.prefixs = data;
//console.log(data);
for (var val of data) {
......@@ -120,7 +121,7 @@ export class PrefixDetailsComponent implements OnInit {
.subscribe(
data => {
this.currentprefix = data;
console.log(data)
//console.log(data)
this.simpleprefixControl.setValue(this.currentprefix.prefix);
this.subjectsControl.setValue(this.currentprefix.system_fun_item);
this.verbsControl.setValue(this.currentprefix.state_or_verb);
......@@ -139,19 +140,20 @@ export class PrefixDetailsComponent implements OnInit {
this.currentprefix.state_or_verb = this.verbsControl.value;
this.currentprefix.item_function_flow_statevalue = this.objectsControl.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)
.subscribe(
response => {
this.message = response.message;
},
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)
.subscribe(
data => {
......@@ -176,35 +178,45 @@ export class PrefixDetailsComponent implements OnInit {
});
}
setprefix(strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.simpleprefix.indexOf(strIntoObj[x][1]) == -1) {
this.simpleprefix.push((strIntoObj[x][1]));}}
setprefix(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.simpleprefix.indexOf(strIntoObj[x][1]) == -1) {
this.simpleprefix.push((strIntoObj[x][1]));
}
}
}
setverb(strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.verbs.indexOf(strIntoObj[x][1]) == -1) {
this.verbs.push((strIntoObj[x][1]));}}
setverb(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.verbs.indexOf(strIntoObj[x][1]) == -1) {
this.verbs.push((strIntoObj[x][1]));
}
}
}
setsubject(strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));}}
setsubject(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));
}
}
}
setobject(strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.objects.indexOf(strIntoObj[x][1]) == -1) {
this.objects.push((strIntoObj[x][1]));}}
setobject(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.objects.indexOf(strIntoObj[x][1]) == -1) {
this.objects.push((strIntoObj[x][1]));
}
}
}
setlogcon(strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.logic_con.indexOf(strIntoObj[x][1]) == -1) {
this.logic_con.push((strIntoObj[x][1]));}}
setlogcon(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.logic_con.indexOf(strIntoObj[x][1]) == -1) {
this.logic_con.push((strIntoObj[x][1]));
}
}
}
}
\ No newline at end of file
......@@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Suffix } from 'src/app/models/suffix.model';
import { SuffixService } from 'src/app/services/suffix.service';
import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs';
import {map, startWith} from 'rxjs/operators';
import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier";
......@@ -16,20 +16,20 @@ import { NotifierService } from "angular-notifier";
export class SuffixDetailsComponent implements OnInit {
suffixControl = new FormControl();
suffix:string[] = [];
suffix: string[] = [];
suffixfilteredOptions: Observable<string[]>;
mumerical_unitsControl = new FormControl();
mumerical_units:string[] = [];
mumerical_units: string[] = [];
mumerical_unitsfilteredOptions: Observable<string[]>;
flowControl = new FormControl();
flow:string[] = [];
flow: string[] = [];
flowfilteredOptions: Observable<string[]>;
public static id: any [] = [];
public static id: any[] = [];
private readonly notifier: NotifierService;
suffixs?:Suffix[];
suffixs?: Suffix[];
currentsuffix: Suffix = {
s_choices: "",
......@@ -66,16 +66,16 @@ export class SuffixDetailsComponent implements OnInit {
}
displayFn(option:string): string {
displayFn(option: string): string {
if (option != null) {
let x = option.split(" : ");
if ( (x[x.length -2] == "") || (x[x.length -1]=="")) { return "";}
return (x[x.length -2]+" : "+x[x.length -1]);
if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return ""; }
return (x[x.length - 2] + " : " + x[x.length - 1]);
}
return "";
}
private _filter(data:string[], value: string): string[] {
private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue));
}
......@@ -87,11 +87,11 @@ export class SuffixDetailsComponent implements OnInit {
data => {
SuffixDetailsComponent.id.length = 0;
this.suffixs = data;
console.log(data)
//console.log(data)
for (var val of data) {
this.getSuffix(id, val.id);
SuffixDetailsComponent.id.push(val.id);
console.log(val.id)
//console.log(val.id)
}
},
error => {
......@@ -120,25 +120,28 @@ export class SuffixDetailsComponent implements OnInit {
this.currentsuffix.s_choices = this.suffixControl.value;
this.currentsuffix.mumerical_units = this.mumerical_unitsControl.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)
.subscribe(
response => {
this.message = response.message;
},
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()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.suffix.indexOf(data[x][1]) == -1) {
this.suffix.push(data[x][1]);}}
for (let x = 0; x < data.length; x++) {
if (this.suffix.indexOf(data[x][1]) == -1) {
this.suffix.push(data[x][1]);
}
}
},
error => {
console.log(error);
......@@ -146,9 +149,11 @@ export class SuffixDetailsComponent implements OnInit {
this.suffixService.getnumunits()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.mumerical_units.indexOf(data[x][1]) == -1) {
this.mumerical_units.push(data[x][1]);}}
for (let x = 0; x < data.length; x++) {
if (this.mumerical_units.indexOf(data[x][1]) == -1) {
this.mumerical_units.push(data[x][1]);
}
}
},
error => {
console.log(error);
......@@ -156,9 +161,11 @@ export class SuffixDetailsComponent implements OnInit {
this.suffixService.getflow()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.flow.indexOf(data[x][1]) == -1) {
this.flow.push(data[x][1]);}}
for (let x = 0; x < data.length; x++) {
if (this.flow.indexOf(data[x][1]) == -1) {
this.flow.push(data[x][1]);
}
}
},
error => {
console.log(error);
......
export class Boilerplate {
id?:any;
owner?:any;
id?: any;
owner?: any;
group_of_boilerplate?: any;
title?: string;
has_prefix?: boolean;
......@@ -9,7 +9,7 @@ export class Boilerplate {
}
export class BoilerplateData {
id?:any;
id?: any;
title_data?: string;
prefix_data?: string;
main_data?: string;
......@@ -17,36 +17,37 @@ export class BoilerplateData {
}
export class GroupBoilerplate {
id?:any;
id?: any;
title_bgroup?: string;
description?: string;
}
export class InferenceResults {
id?:any;
id?: any;
infer_group_of_boilerplate?: any;
inference_data?: any;
}
export class Sections {
Name?:string;
Name?: string;
TheClasses?: Classes[];
GeneralInstances?:Instances[];
GeneralInstances?: Instances[];
}
export class Classes {
Class?:string;
Class?: string;
Comment?: string;
Subclass?:SubClasses[];
Instance_of_Class?:Instances[];
Subclass?: SubClasses[];
Instance_of_Class?: Instances[];
}
export class SubClasses {
SubClass_name?:string;
SubclassComment?:string
InstanceOfSubclass?:Instances[];
SubClass_name?: any;
SubclassComment?: any
InstanceOfSubclass?: Instances[];
}
export class Instances {
Instance?: any;
Comment?: any;
}
......@@ -164,4 +164,8 @@ export class MainService {
getmainsyntax(): Observable<any> {
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 os
from django.db import models
from jsonfield import JSONField
#from django.contrib.postgres.fields import ArrayField
......@@ -73,18 +74,31 @@ def create_extra_prefix(instance, now_prefix):
prefix.save()
def create_infer_result(instance):
infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance, ontology_file=instance.ontology_file)
def create_infer_result(instance, destination):
infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance, ontology_file=destination)
infer.save()
#Here we have to give and the ontology file of the Boilerplate Group to get the current instances
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,
ontology_file=instance.ontology_file )
ontology_file= destination)
classes_inctances.save()
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()
return destination
'''Update instaces of the ontology after the inferencing'''
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),
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),
suffix_choices=json.dumps(S_CHOICES) )
suffix_choices=json.dumps(S_CHOICES), ontology_file=instance.ontology_file )
Dict_list=[]
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:
Dict_list.append(get_dmo_classes_and_comment(i, g))
#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):
class BoilerplateGroup(models.Model):
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
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)
description = models.CharField(max_length=500)
def save(self, **kwargs):
super(BoilerplateGroup, self).save(**kwargs)
initialize_instances(self)
create_infer_result(self)
destination = initialize_instances(self)
create_infer_result(self, destination)
......
......@@ -6,7 +6,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
#HERE
#Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
Ontology_file = "../../Ontologies/2022_AOCS.ttl"
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement",
"InconsistentRequirement","NoisyRequirement","OpaqueRequirement","RedundantRequirement"]
......@@ -21,11 +21,11 @@ def getclassofprefix(prefix):
def getclassofmain(main):
return(findclassofmain(main))
def getinstancefile(data):
def getinstancefile(data, g):
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):
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(" : ")
instance_file = out_list[j+1]
break
......@@ -51,7 +51,7 @@ def inferencing(ontfile, project, boilerlate, prefix, main, suffix):
#findclassofmain(listofmain)
ontology_with_new_req = exportboiltottl(ontfile, project, listofprefix, listofboil, listofmain, listofsuffix)
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),
# so -> 'REQ-1' : [Incomplete] ('REQ-1' : [Incomplete, Ambiguous])
for met in infer_result:
......@@ -80,7 +80,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
else :
g.load(ontfile, format="turtle")
#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))
for i in range(len(boilerplate)):
title = boilerplate[i][0]['title']
......@@ -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()))
for j in prefixmodel:
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])))
else:
prefix_verb_splitter = prefix[i][0]['state_or_verb'].split(" : ")
......@@ -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()))
for j in prefixmodel:
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])))
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+"_"+ main[i][0]['main_choices']), RDF.type, rbo + main[i][0]['main_choices']))
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])))
if main[i][0]['verb'] != "":
mainverb = main[i][0]['verb'].split(':')
......@@ -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"]
for j in mainmodel:
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])))
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(" ", "")))))
......@@ -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.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')
return (save_path+file_name)
#print(g.serialize(format="turtle").decode("utf-8"))
......
......@@ -13,7 +13,8 @@ Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
subClass_instances = "../../Ontologies/instances_subclass.txt"
#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-Automotive-AVP-instances", "<http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances"]
DSO = ["http://delab.csd.auth.gr/ontologies/2018/DSO#"]
......@@ -76,7 +77,7 @@ def get_verb_instances(keyword):
'''Get Verbs - return tuple'''
def get_verb_file_and_instances(keyword):
get_file_and_instances(keyword)
get_file_and_instances(keyword, g)
keywordspl = keyword.split("#")
in_list = []
out_list = []
......@@ -165,7 +166,7 @@ out_list = []
# A dict with all the info of classes, subclasses and instances
info_dict = {}
def get_file_and_instances(keyword):
def get_file_and_instances(keyword, g):
out_list = []
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-1]]
......@@ -258,7 +259,7 @@ def get_dmo_classes_and_comment(keyword, g):
pop = URIRef(urired2 + spl[len(spl) - 1])
for q1, w1, m1 in g.triples((pop, RDFS.comment, None)):
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)
for comment in out_list_instance:
instance_list = []
......@@ -323,7 +324,7 @@ def get_dmo_classes_and_comment(keyword, g):
return Dictionary_Data
#return dic_list_backup
else:
dmo_dic_backup = {"Class": " ", "Comment":" "}
dmo_dic_backup = {"Class": "", "Comment":""}
dic_list_backup.append(dmo_dic_backup)
Dictionary_Data = { "Name":section, "TheClasses" : dic_list_backup, "GeneralInstances": dic_list_in}
return Dictionary_Data
......
......@@ -34,6 +34,7 @@ urlpatterns = [
#MAIN CHOICES DATA
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'),
#SUFFIX CHOICES DATA
......
from rdflib import RDF, RDFS, Graph, URIRef, Literal
from rest_framework.generics import ListAPIView, RetrieveUpdateDestroyAPIView, ListAPIView
from rest_framework import permissions
......@@ -11,7 +12,7 @@ from reqman.apps.reqtool.rest_api.serializers.main_req import MainSerializer
from reqman.apps.permissions import IsOwnerOrReadOnly
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.views import APIView
......@@ -95,6 +96,18 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
numunit_data = data.values('number_unit_choices')[0]['number_unit_choices']
if( instance['mumerical_units'] not in numunit_data):
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)
if curmain_choices[0] == 'ERROR':
raise APIException("Main choices not in [M1-M16]")
......@@ -107,6 +120,8 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE
def perform_destroy(self, instance):
#instance = serializer.validated_data
instance.delete()
class MainChoicesViewSet(ListAPIView):
......@@ -121,6 +136,138 @@ class MainChoicesViewSet(ListAPIView):
queryset_cl= BoilerplateGroupClassesInstances.objects.filter(classes_instances_group_of_boilerplate = group_pk)
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):
......@@ -129,15 +276,9 @@ class ShallChoicesViewSet(APIView):
return response
#class DictionaryViewSet(APIView):
#def get(self, request):
# response = Response(Dictionary_Data_list)
# return response
class DictionaryViewSet(ListAPIView):
"""
API view to retrieve, update or delete
API view to retrieve list of Sections, Classes, Subclasses, Instances
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateGroupDictionarySerializer
......@@ -152,3 +293,5 @@ class MainSyntaxViewSet(APIView):
def get(self, request):
response = Response(MAIN_SYNTAX)
return response
import os
from rdflib import Graph, URIRef
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView, ListAPIView
from rest_framework import permissions
......@@ -61,6 +63,10 @@ class BoilerplateGroupDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE
def perform_destroy(self, instance):
try:
os.system('rm -rf ../../Ontologies/' + instance.title_bgroup +'/')
except:
print('No file exist')
instance.delete()
......@@ -116,6 +122,22 @@ class BoilerplateDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE
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()
......@@ -232,10 +254,10 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
prefixdata.append(self.getprefixdata(id.boilerplate_data_id.id))
maindata.append(self.getmaindata(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)
except:
raise APIException("Not all instances in the Ontology")
#except:
# raise APIException("Not all instances in the Ontology")
instance.update(inference_data = metrics, ontology_file=onto_file)
serializer.save()
......@@ -254,7 +276,7 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
class PrefixChoicesViewSet(ListAPIView):
"""
API view to retrieve, update or delete
API view to retrieve list of Prefix choices
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
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