Commit 18b0de4a authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

tool v0.9

parent 32b8bb89
......@@ -14,7 +14,7 @@ export class AppComponent {
title = 'ReqmanAngular11';
LoggedIn() {
console.log(this.authService.isLoggedIn())
//console.log(this.authService.isLoggedIn())
return this.authService.isLoggedIn();
}
......
......@@ -30,6 +30,13 @@
<input name="title" id="title" type="text" class="form-control" required
[(ngModel)]="currentboilerplate.title" (change)="this.updateBoilerplate()" style="width: 63%;" />
</div>
<div class="form-group" style="display:flex; flex-direction: row; align-items: center">
<label for="title" style="margin-right: 35px;"><b>Extracted property</b></label>
<textarea id="clipboard-example-textarea" class="form-control" style="width: 63%;">{{this.property_text}}</textarea>
<button [cdkCopyToClipboard]="this.property_text" mat-mini-fab color="gray" style="margin-left: 8px;" ><mat-icon>content_copy</mat-icon></button>
</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"
......@@ -158,6 +165,9 @@
<button mat-button [matMenuTriggerFor]="menu"
[matMenuTriggerData]="{section: section.Name ,class: item.Class}" #menuTrigger>
<h4><b>Instances</b></h4>
<div *ngIf="this.instaspiner">
<mat-spinner [diameter]='15' style="position: absolute; z-index: 1;top: 10%;left: 125%;"></mat-spinner>
</div>
</button>
<div *ngFor="let instan of item.Instance_of_Class| filter:searchText">
<li>
......@@ -238,7 +248,10 @@
<ul> <button mat-button [matMenuTriggerFor]="menu"
[matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name, subsubclass:subsub.SubSubClass_name , subsubsubclass: subsubsub.SubSubClass_name, subsubsubsubclass: subsubsubsub.SubSubClass_name}"
#menuTrigger>
<h5>AAA-Instances</h5>
<h5>Instances</h5>
<div *ngIf="this.instaspiner">
<mat-spinner [diameter]='15' style="position: absolute; z-index: 1;top: 10%;left: 125%;"></mat-spinner>
</div>
</button>
<div
*ngFor="let subsubsubsubinstansub of subsubsubsub.SubInstanceOfSubclass| filter:searchText">
......@@ -277,6 +290,9 @@
[matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name, subsubclass:subsub.SubSubClass_name , subsubsubclass: subsubsub.SubSubClass_name}"
#menuTrigger>
<h5>Instances</h5>
<div *ngIf="this.instaspiner">
<mat-spinner [diameter]='15' style="position: absolute; z-index: 1;top: 10%;left: 125%;"></mat-spinner>
</div>
</button>
<div *ngFor="let subsubsubinstansub of subsubsub.SubInstanceOfSubclass| filter:searchText">
<li>
......@@ -313,6 +329,9 @@
[matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name, subsubclass:subsub.SubSubClass_name }"
#menuTrigger>
<h5>Instances</h5>
<div *ngIf="this.instaspiner">
<mat-spinner [diameter]='15' style="position: absolute; z-index: 1;top: 10%;left: 125%;"></mat-spinner>
</div>
</button>
<div *ngFor="let subsubinstansub of subsub.SubInstanceOfSubclass| filter:searchText">
<li>
......@@ -349,6 +368,9 @@
[matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name}"
#menuTrigger>
<h5>Instances</h5>
<div *ngIf="this.instaspiner">
<mat-spinner [diameter]='15' style="position: absolute; z-index: 1;top: 10%;left: 125%;"></mat-spinner>
</div>
</button>
<div *ngFor="let instansub of sub.InstanceOfSubclass| filter:searchText">
<li>
......@@ -408,6 +430,9 @@
<ul>
<button mat-button [matMenuTriggerFor]="menu" [matMenuTriggerData]="{section: section.Name}" #menuTrigger>
<h4>Instances</h4>
<div *ngIf="this.instaspiner">
<mat-spinner [diameter]='15' style="position: absolute; z-index: 1;top: 10%;left: 125%;"></mat-spinner>
</div>
</button>
<div *ngFor="let genin of section.GeneralInstances| filter:searchText">
<li>
......
......@@ -46,6 +46,8 @@ export class BoilerplateDetailsComponent implements OnInit {
mes_list = [] as any;
searchInstance_list = [] as any;
private readonly notifier: NotifierService;
instaspiner=false;
property_text ='';
......@@ -66,6 +68,7 @@ export class BoilerplateDetailsComponent implements OnInit {
this.getchoices(this.route.snapshot.params.gb);
this.getBoilerplate(this.route.snapshot.params.gb, this.route.snapshot.params.id);
this.getInfer();
this.getProperty();
}
searchInstance(): void {
......@@ -133,6 +136,7 @@ export class BoilerplateDetailsComponent implements OnInit {
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")));
//setTimeout(() => this.getProperty(),1500);
}
deleteBoilerplate(): void {
......@@ -209,6 +213,7 @@ export class BoilerplateDetailsComponent implements OnInit {
deleteInstance(section: any, classes: any, subclass: any, subsubclass: any, subsubsubclass: any, subsubsubsubclass: any, instance: any, comment: any): void {
if (confirm("Αre you sure you want to delete this Instance?")) {
this.instaspiner=true;
const removeinstance = section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : '') + ' : ' + instance;
this.mainService.deleteinstances(this.route.snapshot.params.gb, removeinstance, (comment ? comment : ' '))
.subscribe(
......@@ -220,6 +225,7 @@ export class BoilerplateDetailsComponent implements OnInit {
error => {
if (error.error.text == 'Instance deleted') {
this.notifier.notify("success", (JSON.stringify(error.error.text)));
this.instaspiner=false;
if (this.systems) {
this.systems.forEach(function (value) {
if (section == value.Name) {
......@@ -353,8 +359,9 @@ export class BoilerplateDetailsComponent implements OnInit {
result.instance = result.instance?.replace(/ /g, "_")
}
if (result.instance) {
this.instaspiner=true;
this.addinstance = section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : '') + ' : ' + result.instance;
//console.log(this.addinstance);
console.log(this.addinstance);
this.mainService.setinstances(this.route.snapshot.params.gb, this.addinstance, (result.comment ? result.comment : " "))
.subscribe(
data => {
......@@ -366,6 +373,7 @@ export class BoilerplateDetailsComponent implements OnInit {
error => {
if (error.error.text == 'Update Instance') {
this.notifier.notify("success", (JSON.stringify(error.error.text)));
this.instaspiner=false;
if (this.systems) {
this.systems.forEach(function (value) {
if (section == value.Name) {
......@@ -561,6 +569,16 @@ export class BoilerplateDetailsComponent implements OnInit {
});
}
getProperty(): void {
this.boilerplateService.getProperties(this.route.snapshot.params.gb, this.route.snapshot.params.id).subscribe(
data => {
this.property_text=data;
},
error => {
this.property_text=((JSON.stringify(error.error.text)));
});
}
prefixs = [
......
......@@ -28,10 +28,16 @@
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<div>
<input class="btn btn-info" [disabled]="exporting" type="button" value="Download"
<input class="btn btn-info" [disabled]="exporting" type="button" value="Ontology"
(click)="getCurrentOntology()" />
</div>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<div>
<input class="btn btn-info" [disabled]="exporting" type="button" value="Properties"
(click)="getCurrentProperties()" />
</div>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end" *ngIf="this.selection.selected.length >= 1">
<div>
<button mat-mini-fab color="warn" (click)="deleteBoilerplateList()">
......@@ -39,8 +45,6 @@
</button>
</div>
</div>
</div>
</div>
<div [hidden]="!showSpinner">
......@@ -62,11 +66,11 @@
</mat-checkbox>
</td>
</ng-container>
<!-- Position Column -->
<!-- Position Column
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> No. </th>
<td mat-cell *matCellDef="let element"> {{element.id}} </td>
</ng-container>
</ng-container> -->
<!-- Name Column -->
<ng-container matColumnDef="prefix_data" >
......
......@@ -26,6 +26,20 @@ table {
border-color: currentColor;
}
.form-control {
border: none;
border-radius: 5px;
padding: 10px;
font-size: 16px;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
outline: none;
transition: box-shadow 0.3s ease-in-out;
}
.form-control:focus {
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}
::ng-deep .custom-tooltip {
background-color: #333;
color: #fff;
......
......@@ -57,7 +57,7 @@ export class BoilerplateListComponent implements OnInit {
currentIndex = -1;
title = '';
displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix'];
newdisplayedColumns: string[] = ['select', 'id', 'title_data', 'prefix_data', 'main_data', 'suffix_data'];
newdisplayedColumns: string[] = ['select', 'title_data', 'prefix_data', 'main_data', 'suffix_data'];
dataSource: Boilerplate[] = [{}];
thenewdataSource: BoilerplateData[] = [{}];
newdataSource = new MatTableDataSource(this.thenewdataSource);
......@@ -104,6 +104,26 @@ export class BoilerplateListComponent implements OnInit {
}
getCurrentProperties(): void {
this.boilerplateService.getFileProperties(this.route.snapshot.params.gb)
.subscribe(res => {
let blob = new Blob([res], { type: 'text/plain' });
var url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'properties.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
},
error => {
this.notifier.notify("warning", 'Fail to download properties file');
});
}
retrieveBoilerplates(): void {
this.boilerplateService.getAll(this.route.snapshot.params.gb)
.subscribe(
......
......@@ -41,15 +41,15 @@
</mat-grid-tile>
<mat-grid-tile>
<div class="col" *ngIf="data.currentSection == 'Function'">
<p>The current instance will add the above requirement in the ontology :</p>
<p>The current instance will add the bellow information in the ontology :</p>
<h1><u>{{data.currentInstance}} shall invoke {{data.instance}}</u></h1>
</div>
<div class="col" *ngIf="data.currentSection == 'System'">
<p>The current instance will add the above requirement in the ontology :</p>
<p>The current instance will add the bellow information in the ontology :</p>
<h1><u>{{data.currentInstance}} shall contain {{data.instance}}</u></h1>
</div>
<div class="col" *ngIf="data.currentSection == 'Item'">
<p>The current instance will add the above requirement in the ontology :</p>
<p>The current instance will add the bellow information in the ontology :</p>
<mat-form-field style="width: 100%;" appearance="fill">
<mat-label>Select System</mat-label>
<mat-select required [(ngModel)]="data.selectedValue" name="system">
......@@ -87,7 +87,7 @@
</mat-grid-tile>
<mat-grid-tile>
<div class="col">
<p>The current instance will add the above requirement in the ontology :</p>
<p>The current instance will add the bellow information in the ontology :</p>
<h1><u>{{data.instance}} belongs to </u></h1>
<mat-form-field style="width: 100%;" appearance="fill">
<mat-label>Select StateSet</mat-label>
......@@ -130,7 +130,7 @@
</mat-grid-tile>
<mat-grid-tile>
<div class="col">
<p>The current instance will add the above requirement in the ontology :</p>
<p>The current instance will add the bellow information in the ontology :</p>
<mat-form-field style="width: 100%;" appearance="fill">
<mat-label>Select System</mat-label>
<mat-select required [(ngModel)]="data.selectedValue" name="system1">
......@@ -187,7 +187,7 @@
</mat-checkbox>
</section>
<div *ngIf="checked">
<p>The current instance will add the above requirement in the ontology :</p>
<p>The current instance will add the bellow information in the ontology :</p>
<mat-form-field style="width: 100%;" appearance="fill">
<mat-label>Select System</mat-label>
<mat-select required [(ngModel)]="data.selectedValue" name="system">
......
......@@ -14,4 +14,18 @@
text-align: left;
max-width: 750px;
margin: auto;
}
.form-control {
border: none;
border-radius: 5px;
padding: 10px;
font-size: 16px;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
outline: none;
transition: box-shadow 0.3s ease-in-out;
}
.form-control:focus {
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}
\ No newline at end of file
......@@ -10,7 +10,7 @@
<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.split(':')[0]}}:{{this.subjectsControl.value.split(':')[1]}}</mat-label>
{{this.subjectsControl.value.split(':')[0]}}:{{this.subjectsControl.value.split(':')[this.subjectsControl.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Subject" matInput [formControl]="subjectsControl"
required [matAutocomplete]="automainsub" style="width: 100%;" (blur)="closed($event, this.subjectsControl)">
<mat-autocomplete autoActiveFirstOption #automainsub="matAutocomplete" showPanel="true"
......@@ -27,7 +27,7 @@
[ngStyle]="(stateitemControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<mat-form-field class="example-full-width">
<mat-label *ngIf="this.stateitemControl.value !=null">State or Item :
{{this.stateitemControl.value.split(':')[0]}}:{{this.stateitemControl.value.split(':')[1]}} </mat-label>
{{this.stateitemControl.value.split(':')[0]}}:{{this.stateitemControl.value.split(':')[this.stateitemControl.value.split(':').length -2]}} </mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="stateitemControl"
[matAutocomplete]="autostateitem" (blur)="closed($event, this.stateitemControl)">
<mat-autocomplete autoActiveFirstOption #autostateitem="matAutocomplete" showPanel="true"
......@@ -44,7 +44,7 @@
[ngStyle]="(statevalueControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<mat-form-field class="example-full-width">
<mat-label *ngIf="statevalueControl.value !=null">State Value :
{{this.statevalueControl.value.split(':')[0]}}:{{this.statevalueControl.value.split(':')[1]}}</mat-label>
{{this.statevalueControl.value.split(':')[0]}}:{{this.statevalueControl.value.split(':')[this.statevalueControl.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="StateValue" matInput [formControl]="statevalueControl"
[matAutocomplete]="autostatevalue" (blur)="closed($event, this.statevalueControl)">
<mat-autocomplete autoActiveFirstOption #autostatevalue="matAutocomplete" showPanel="true"
......@@ -58,7 +58,7 @@
</div>
</div>
<div class="form-row">
<div class="col" style="width: 100px;">
<div class="col" >
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Shall/shall not</mat-label>
......@@ -73,8 +73,7 @@
</form>
</div>
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(verbControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="verbControl.value !=null">Verb :
{{this.verbControl.value.split(':')[0]}}:{{this.verbControl.value.split(':')[1]}}</mat-label>
......@@ -89,9 +88,8 @@
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(quantifierControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<div class="col" [ngStyle]="(quantifierControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}" >
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="quantifierControl.value !=null">Quantifier :
{{this.quantifierControl.value.split(':')[1]}}</mat-label>
......@@ -106,20 +104,16 @@
</mat-form-field>
</form>
</div>
<!--NUmber Value-->
<div class="form-row">
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<div class="col" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label>
<input type="text" matInput [(ngModel)]="currentmain.numerical" name="numerical">
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(numunitControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<div class="col" [ngStyle]="(numunitControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<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"
......@@ -134,14 +128,13 @@
</form>
</div>
</div>
</div>
<!-- <mat-label *ngIf=".value !=null">State or Item : {{.value.slice(0, .value.indexOf(':'))}}</mat-label> -->
<div class="form-row">
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="fifuintsysstatsetControl.value !=null">Object :
{{this.fifuintsysstatsetControl.value.split(':')[0]}}:{{this.fifuintsysstatsetControl.value.split(':')[1]}}
{{this.fifuintsysstatsetControl.value.split(':')[0]}}:{{this.fifuintsysstatsetControl.value.split(':')[this.fifuintsysstatsetControl.value.split(':').length -2]}}
</mat-label>
<input type="text" placeholder="Pick one" aria-label="Item" matInput
[formControl]="fifuintsysstatsetControl" required [matAutocomplete]="autofifuintsysstatset"
......@@ -155,12 +148,11 @@
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(stsysconsetControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<div class="col" [ngStyle]="(stsysconsetControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="stsysconsetControl.value !=null">StateSet or StateValue or System or Connection :
{{this.stsysconsetControl.value.split(':')[0]}}:{{this.stsysconsetControl.value.split(':')[1]}}
{{this.stsysconsetControl.value.split(':')[0]}}:{{this.stsysconsetControl.value.split(':')[this.stsysconsetControl.value.split(':').length -2]}}
</mat-label>
<input placeholder="Pick one" aria-label="stsysconset" type="text" matInput [formControl]="stsysconsetControl"
[matAutocomplete]="autostsysconset" (blur)="closed($event, this.stsysconsetControl)">
......
......@@ -106,39 +106,39 @@ export class MainDetailsComponent implements OnInit {
this.notifier = notifierService;
this.subjectsfilteredOptions = this.subjectsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.subjects, value))
map(value => this._filter(this.subjects, value ? value : ''))
);
this.stateitemfilteredOptions = this.stateitemControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.stateitem, value))
map(value => this._filter(this.stateitem, value ? value : ''))
);
this.statevaluefilteredOptions = this.statevalueControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.statevalue, value))
map(value => this._filter(this.statevalue, value ? value : ''))
);
this.shallfilteredOptions = this.shallControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.shall, value))
map(value => this._filter(this.shall, value ? value : ''))
);
this.verbfilteredOptions = this.verbControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.verb, value))
map(value => this._filter(this.verb, value ? value : ''))
);
this.quantifierfilteredOptions = this.quantifierControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.quantifier, value))
map(value => this._filter(this.quantifier, value ? value : ''))
);
this.numunitfilteredOptions = this.numunitControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.numunit, value))
map(value => this._filter(this.numunit, value ? value : ''))
);
this.fifuintsysstatsetfilteredOptions = this.fifuintsysstatsetControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.fifuintsysstatset, value))
map(value => this._filter(this.fifuintsysstatset, value ? value : ''))
);
this.stsysconsetfilteredOptions = this.stsysconsetControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.stsysconset, value))
map(value => this._filter(this.stsysconset, value ? value : ''))
);
}
......@@ -266,8 +266,8 @@ export class MainDetailsComponent implements OnInit {
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 = '' }
//num
if (this.numericalisDivVisible) { this.currentmain.mumerical_units = this.numunitControl.value; } else { this.currentmain.mumerical_units = '' }
if (!this.numericalisDivVisible) { this.currentmain.numerical = null }
if (this.numunitControlisDivVisible) { 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 = '' }
......
<div class="form-row">
<div class="col">
<form class="form-group form-inline" ngNativeValidate>
<mat-form-field class="example-full-width">
<mat-label>Prefix</mat-label>
<input type="text" placeholder="Pick one" aria-label="SPrefix" matInput required
[formControl]="simpleprefixControl" [matAutocomplete]="autosimpleprefix"
(blur)="closed($event, this.simpleprefixControl)">
<mat-autocomplete autoActiveFirstOption #autosimpleprefix="matAutocomplete">
<mat-option *ngFor="let option of simpleprefixfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col" style="width: 300px;">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="subjectsControl.value !=null">Subject :
{{this.subjectsControl.value.split(':')[0]}}:{{this.subjectsControl.value.split(':')[this.subjectsControl.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="SubC" matInput [formControl]="subjectsControl" required
[matAutocomplete]="autosub" (blur)="closed($event, this.subjectsControl)">
<mat-autocomplete autoActiveFirstOption #autosub="matAutocomplete" showPanel="true" [displayWith]="displayFn" panelWidth="string" panelWidth="string">
<mat-option *ngFor="let option of subjectsfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
</div>
<div class="form-row">
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Verb or State</mat-label>
<mat-label *ngIf="verbsControl.value !=null">Subject : {{this.verbsControl.value.split(':')[0]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Verb" matInput required [formControl]="verbsControl"
[matAutocomplete]="autoverb" (blur)="closed($event, this.verbsControl)">
<mat-autocomplete autoActiveFirstOption #autoverb="matAutocomplete" showPanel="true" [displayWith]="displayFn" panelWidth="string">
<mat-option *ngFor="let option of verbsfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Quantifier</mat-label>
<input placeholder="Pick one" aria-label="PrefixQ" matInput [formControl]="prefix_quantifierControl" type="text"
[matAutocomplete]="autoprefix_quantifier" (blur)="closed($event, this.prefix_quantifierControl)">
<mat-autocomplete autoActiveFirstOption #autoprefix_quantifier="matAutocomplete" showPanel="true"
[displayWith]="displayFn" panelWidth="string">
<mat-option *ngFor="let option of prefix_quantifierfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline"
>
<mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label>
<input type="text" matInput [(ngModel)]="currentprefix.prefix_numerical" name="numerical">
</mat-form-field>
</form>
</div>
<div class="col" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Number Unit</mat-label>
<input type="text" placeholder="Pick one" aria-label="PNumUnit" matInput
[formControl]="prefix_mumerical_unitsControl" [matAutocomplete]="autoprefix_mumerical_units">
<mat-autocomplete autoActiveFirstOption #autoprefix_mumerical_units="matAutocomplete" showPanel="true"
[displayWith]="displayFn" panelWidth="string" (blur)="closed($event, this.prefix_mumerical_unitsControl)">
<mat-option *ngFor="let option of prefix_mumerical_unitsfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
</div>
<div class="form-row">
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="objectsControl.value !=null">Object :
{{this.objectsControl.value.split(':')[0]}}:{{this.objectsControl.value.split(':')[this.objectsControl.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="PreObj" matInput required [formControl]="objectsControl"
[matAutocomplete]="autobjects" (blur)="closed($event, this.objectsControl)">
<mat-autocomplete autoActiveFirstOption #autobjects="matAutocomplete" showPanel="true"
[displayWith]="displayFn" panelWidth="string">
<mat-option *ngFor="let option of objectsfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline">
<fieldset>
<mat-form-field class="example-full-width">
<mat-label>Logic connectivity</mat-label>
<input type="text" placeholder="Pick one" aria-label="PreLogic_c" matInput [formControl]="logic_conControl"
[matAutocomplete]="autolog_con" >
<mat-autocomplete autoActiveFirstOption #autolog_con="matAutocomplete">
<mat-option *ngFor="let option of logic_confilteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</fieldset>
</form>
</div>
</div>
<!--EXTRA PREFIX-->
<div *ngIf="secondprefix">
<div class="form-row">
<div class="col">
<form class="form-group form-inline" ngNativeValidate>
<mat-form-field class="example-full-width">
<mat-label>Prefix</mat-label>
<input type="text" placeholder="Pick one" aria-label="SPrefix" matInput required
[formControl]="simpleprefixControl" [matAutocomplete]="autosimpleprefix"
(blur)="closed($event, this.simpleprefixControl)">
<mat-autocomplete autoActiveFirstOption #autosimpleprefix="matAutocomplete">
<mat-option *ngFor="let option of simpleprefixfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col" style="width: 300px;">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="subjectsControl.value !=null">Subject :
{{this.subjectsControl.value.split(':')[0]}}:{{this.subjectsControl.value.split(':')[1]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="SubC" matInput [formControl]="subjectsControl" required
[matAutocomplete]="autosub" (blur)="closed($event, this.subjectsControl)">
<mat-autocomplete autoActiveFirstOption #autosub="matAutocomplete" showPanel="true" [displayWith]="displayFn" panelWidth="string" panelWidth="string">
<mat-option *ngFor="let option of subjectsfilteredOptions | async" [value]="option">
<mat-label *ngIf="subjects2Control.value !=null">Subject :
{{this.subjects2Control.value.split(':')[0]}}:{{this.subjects2Control.value.split(':')[this.subjects2Control.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="SubC2" matInput [formControl]="subjects2Control" required
[matAutocomplete]="autosub2" (blur)="closed($event, this.subjects2Control)">
<mat-autocomplete autoActiveFirstOption #autosub2="matAutocomplete" showPanel="true" [displayWith]="displayFn" panelWidth="string" panelWidth="string">
<mat-option *ngFor="let option of subjects2filteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
</div>
<div class="form-row">
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Verb or State</mat-label>
<mat-label *ngIf="verbsControl.value !=null">Subject : {{this.verbsControl.value.split(':')[0]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Verb" matInput required [formControl]="verbsControl"
[matAutocomplete]="autoverb" (blur)="closed($event, this.verbsControl)">
<mat-autocomplete autoActiveFirstOption #autoverb="matAutocomplete" showPanel="true" [displayWith]="displayFn" panelWidth="string">
<mat-option *ngFor="let option of verbsfilteredOptions | async" [value]="option">
<mat-label *ngIf="verbs2Control.value !=null">Subject : {{this.verbs2Control.value.split(':')[0]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Verb" matInput required [formControl]="verbs2Control"
[matAutocomplete]="autoverb2" (blur)="closed($event, this.verbs2Control)">
<mat-autocomplete autoActiveFirstOption #autoverb2="matAutocomplete" showPanel="true" [displayWith]="displayFn" panelWidth="string">
<mat-option *ngFor="let option of verbs2filteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<div class="col" [ngStyle]="(numericalis2DivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Quantifier</mat-label>
<input placeholder="Pick one" aria-label="PrefixQ" matInput [formControl]="prefix_quantifierControl" type="text"
[matAutocomplete]="autoprefix_quantifier" (blur)="closed($event, this.prefix_quantifierControl)">
<mat-autocomplete autoActiveFirstOption #autoprefix_quantifier="matAutocomplete" showPanel="true"
<input placeholder="Pick one" aria-label="PrefixQ" matInput [formControl]="prefix_quantifier2Control" type="text"
[matAutocomplete]="autoprefix_quantifier2" (blur)="closed($event, this.prefix_quantifier2Control)">
<mat-autocomplete autoActiveFirstOption #autoprefix_quantifier2="matAutocomplete" showPanel="true"
[displayWith]="displayFn" panelWidth="string">
<mat-option *ngFor="let option of prefix_quantifierfilteredOptions | async" [value]="option">
<mat-option *ngFor="let option of prefix_quantifier2filteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<div class="col" [ngStyle]="(numericalis2DivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label>
<input type="text" matInput [(ngModel)]="currentprefix.prefix_numerical" name="numerical">
<!--ERROR-->
<input type="text" matInput [(ngModel)]="secondcurrentprefix.prefix_numerical" name="numerical2">
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline"
[ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<div class="col" [ngStyle]="(numericalis2DivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden', 'width':'0%'}">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Number Unit</mat-label>
<input type="text" placeholder="Pick one" aria-label="PNumUnit" matInput
[formControl]="prefix_mumerical_unitsControl" [matAutocomplete]="autoprefix_mumerical_units">
<mat-autocomplete autoActiveFirstOption #autoprefix_mumerical_units="matAutocomplete" showPanel="true"
[displayWith]="displayFn" panelWidth="string" (blur)="closed($event, this.prefix_mumerical_unitsControl)">
<mat-option *ngFor="let option of prefix_mumerical_unitsfilteredOptions | async" [value]="option">
[formControl]="prefix_mumerical2_unitsControl" [matAutocomplete]="autoprefix_mumerical_units2">
<mat-autocomplete autoActiveFirstOption #autoprefix_mumerical_units2="matAutocomplete" showPanel="true"
[displayWith]="displayFn" panelWidth="string" (blur)="closed($event, this.prefix_mumerical2_unitsControl)">
<mat-option *ngFor="let option of prefix_mumerical2_unitsfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
</div>
<div class="form-row">
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="objectsControl.value !=null">Object :
{{this.objectsControl.value.split(':')[0]}}:{{this.objectsControl.value.split(':')[1]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="PreObj" matInput required [formControl]="objectsControl"
[matAutocomplete]="autobjects" (blur)="closed($event, this.objectsControl)">
<mat-autocomplete autoActiveFirstOption #autobjects="matAutocomplete" showPanel="true"
<mat-label *ngIf="objects2Control.value !=null">Object :
{{this.objects2Control.value.split(':')[0]}}:{{this.objects2Control.value.split(':')[this.objects2Control.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="PreObj2" matInput required [formControl]="objects2Control"
[matAutocomplete]="autobjects2" (blur)="closed($event, this.objects2Control)">
<mat-autocomplete autoActiveFirstOption #autobjects2="matAutocomplete" showPanel="true"
[displayWith]="displayFn" panelWidth="string">
<mat-option *ngFor="let option of objectsfilteredOptions | async" [value]="option">
<mat-option *ngFor="let option of objects2filteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col">
<form matTooltip="Under development" matTooltipPosition="right" class="form-group form-inline">
<fieldset disabled>
<mat-form-field class="example-full-width">
<mat-label>Logic connectivity</mat-label>
<input type="text" placeholder="Pick one" aria-label="PreLogic_c" matInput [formControl]="logic_conControl"
[matAutocomplete]="autolog_con" (blur)="closed($event, this.logic_conControl)">
<mat-autocomplete autoActiveFirstOption #autolog_con="matAutocomplete">
<mat-option *ngFor="let option of logic_confilteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</fieldset>
</form>
</div>
</div>
<!--
<ng-container *ngFor= "let prefix of simpleprefix">
<ul>
<li>{{prefix[1]}}</li>
</ul>
-->
\ No newline at end of file
\ No newline at end of file
......@@ -39,6 +39,26 @@ export class PrefixDetailsComponent implements OnInit {
objects: string[] = [];
objectsfilteredOptions: Observable<string[]>;
subjects2Control = new FormControl();
subjects2: string[] = [];
subjects2filteredOptions: Observable<string[]>;
prefix_quantifier2Control = new FormControl();
prefix_quantifier2: string[] = [];
prefix_quantifier2filteredOptions: Observable<string[]>;
prefix_mumerical2_unitsControl = new FormControl();
prefix_mumerical2_units: string[] = [];
prefix_mumerical2_unitsfilteredOptions: Observable<string[]>;
verbs2Control = new FormControl();
verbs2: string[] = [];
verbs2filteredOptions: Observable<string[]>;
objects2Control = new FormControl();
objects2: string[] = [];
objects2filteredOptions: Observable<string[]>;
logic_conControl = new FormControl();
logic_con: string[] = [];
logic_confilteredOptions: Observable<string[]>;
......@@ -46,7 +66,7 @@ export class PrefixDetailsComponent implements OnInit {
public static id: any[] = [];
private readonly notifier: NotifierService;
prefixs?: Prefix[];
prefixs?: Prefix['id'];
//for the moment only one prefix can showed/updates
currentprefix: Prefix = {
......@@ -62,9 +82,25 @@ export class PrefixDetailsComponent implements OnInit {
logic_connective: "",
simple_prefix: "",
};
secondcurrentprefix: Prefix = {
prefix_group: "",
prefix: "",
system_fun_item: "",
state_or_verb: "",
prefix_quantifier: "",
prefix_numerical: 0,
prefix_mumerical_units: "",
item_function_flow_statevalue: "",
logical_expression: "",
logic_connective: "",
simple_prefix: "",
};
message = '';
numericalisDivVisible = false
filter:any;
numericalis2DivVisible = false
secondprefix = false
filter=[''];
......@@ -73,31 +109,51 @@ export class PrefixDetailsComponent implements OnInit {
this.notifier = notifierService;
this.simpleprefixfilteredOptions = this.simpleprefixControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.simpleprefix, value))
map(value => this._filter(this.simpleprefix, value ? value : ''))
);
this.subjectsfilteredOptions = this.subjectsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.subjects, value))
map(value => this._filter(this.subjects, value ? value : ''))
);
this.verbsfilteredOptions = this.verbsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.verbs, value))
map(value => this._filter(this.verbs, value ? value : ''))
);
this.prefix_quantifierfilteredOptions = this.prefix_quantifierControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.prefix_quantifier, value))
map(value => this._filter(this.prefix_quantifier, value ? value : ''))
);
this.prefix_mumerical_unitsfilteredOptions = this.prefix_mumerical_unitsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.prefix_mumerical_units, value))
map(value => this._filter(this.prefix_mumerical_units, value ? value : ''))
);
this.objectsfilteredOptions = this.objectsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.objects, value))
map(value => this._filter(this.objects, value ? value : ''))
);
this.subjects2filteredOptions = this.subjects2Control.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.subjects2, value ? value : ''))
);
this.verbs2filteredOptions = this.verbs2Control.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.verbs2, value ? value : ''))
);
this.prefix_quantifier2filteredOptions = this.prefix_quantifier2Control.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.prefix_quantifier2, value ? value : ''))
);
this.prefix_mumerical2_unitsfilteredOptions = this.prefix_mumerical2_unitsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.prefix_mumerical2_units, value ? value : ''))
);
this.objects2filteredOptions = this.objects2Control.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.objects2, value ? value : ''))
);
this.logic_confilteredOptions = this.logic_conControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.logic_con, value))
map(value => this._filter(this.logic_con, value ? value : ''))
);
}
......@@ -120,10 +176,18 @@ export class PrefixDetailsComponent implements OnInit {
}
dis(): any {
if (this.logic_conControl.value == "AND" || this.logic_conControl.value == "OR" ) {
this.secondprefix = true;
}
else (this.secondprefix = false);
if (this.verbsControl.value?.split(" : ")[0] == "Set" || this.verbsControl.value?.split(" : ")[0] == "Send" || this.verbsControl.value?.split(" : ")[0] == "Receive") {
this.numericalisDivVisible = true;
}
else (this.numericalisDivVisible = false);
if (this.verbs2Control.value?.split(" : ")[0] == "Set" || this.verbs2Control.value?.split(" : ")[0] == "Send" || this.verbs2Control.value?.split(" : ")[0] == "Receive") {
this.numericalis2DivVisible = true;
}
else (this.numericalis2DivVisible = false);
}
private _filter(data: string[], value: string): string[] {
......@@ -136,26 +200,23 @@ 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) {
this.getPrefix(id, val.id);
PrefixDetailsComponent.id.push(val.id);
}
console.log("AAAA", data);
//for (var val of data) {
this.getPrefix(id, data[0].id, data[1].id);
// PrefixDetailsComponent.id.push(val.id);}
},
error => {
console.log(error);
});
}
getPrefix(prefix: any, id: string): void {
//PrefixDetailsComponent.id = id;
getPrefix(prefix: any, id: string, id2: string): void {
this.prefixService.get(prefix, id)
.subscribe(
data => {
this.currentprefix = 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);
......@@ -167,6 +228,19 @@ export class PrefixDetailsComponent implements OnInit {
error => {
console.log(error);
});
this.prefixService.get(prefix, id2)
.subscribe(
data => {
this.secondcurrentprefix = data;
this.subjects2Control.setValue(this.secondcurrentprefix.system_fun_item);
this.verbs2Control.setValue(this.secondcurrentprefix.state_or_verb);
this.prefix_quantifier2Control.setValue(this.secondcurrentprefix.prefix_quantifier);
this.prefix_mumerical2_unitsControl.setValue(this.secondcurrentprefix.prefix_mumerical_units);
this.objects2Control.setValue(this.secondcurrentprefix.item_function_flow_statevalue);
},
error => {
console.log(error);
});
}
......@@ -179,8 +253,27 @@ export class PrefixDetailsComponent implements OnInit {
if (!this.numericalisDivVisible) { this.currentprefix.prefix_numerical = null }
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++) {
this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix)
this.prefixService.update(this.route.snapshot.params.id, this.prefixs[0].id, this.currentprefix)
.subscribe(
response => {
this.updatePrefixsecond()
this.message = response.message;
},
error => {
this.notifier.notify("warning", ("PREFIX " + JSON.stringify(error["error"]['detail'])));
});
}
updatePrefixsecond(): any {
if(this.logic_conControl.value != ''){
this.secondcurrentprefix.prefix = this.simpleprefixControl.value;
this.secondcurrentprefix.system_fun_item = this.subjects2Control.value;
this.secondcurrentprefix.state_or_verb = this.verbs2Control.value;
if (this.numericalis2DivVisible) { this.secondcurrentprefix.prefix_quantifier = this.prefix_quantifier2Control.value } else { this.secondcurrentprefix.prefix_quantifier = '' }
if (this.numericalis2DivVisible) { this.secondcurrentprefix.prefix_mumerical_units = this.prefix_mumerical2_unitsControl.value; } else { this.secondcurrentprefix.prefix_mumerical_units = '' }
if (!this.numericalis2DivVisible) { this.secondcurrentprefix.prefix_numerical = null }
this.secondcurrentprefix.item_function_flow_statevalue = this.objects2Control.value;
this.prefixService.update(this.route.snapshot.params.id, this.prefixs[1].id, this.secondcurrentprefix)
.subscribe(
response => {
this.message = response.message;
......@@ -233,6 +326,7 @@ export class PrefixDetailsComponent implements OnInit {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.verbs.indexOf(strIntoObj[x][1]) == -1) {
this.verbs.push((strIntoObj[x][1]));
this.verbs2.push((strIntoObj[x][1]));
}
}
}
......@@ -240,6 +334,7 @@ export class PrefixDetailsComponent implements OnInit {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.prefix_quantifier.indexOf(strIntoObj[x][1]) == -1) {
this.prefix_quantifier.push((strIntoObj[x][1]));
this.prefix_quantifier2.push((strIntoObj[x][1]));
}
}
}
......@@ -248,6 +343,7 @@ export class PrefixDetailsComponent implements OnInit {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));
this.subjects2.push((strIntoObj[x][1]));
}
}
}
......@@ -256,6 +352,7 @@ export class PrefixDetailsComponent implements OnInit {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.objects.indexOf(strIntoObj[x][1]) == -1) {
this.objects.push((strIntoObj[x][1]));
this.objects2.push((strIntoObj[x][1]));
}
}
......@@ -273,6 +370,7 @@ export class PrefixDetailsComponent implements OnInit {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.prefix_mumerical_units.indexOf(strIntoObj[x][1]) == -1) {
this.prefix_mumerical_units.push((strIntoObj[x][1]));
this.prefix_mumerical2_units.push((strIntoObj[x][1]));
}
}
}
......
......@@ -2,7 +2,7 @@
<div class="col">
<form class="form-group form-inline" ngNativeValidate>
<mat-form-field class="example-full-width">
<mat-label *ngIf="this.suffixControl.value !=null">Suffix : {{this.suffixControl.value.split(':')[0]}}:{{this.suffixControl.value.split(':')[1]}}</mat-label>
<mat-label *ngIf="this.suffixControl.value !=null">Suffix : {{this.suffixControl.value.split(':')[0]}}:{{this.suffixControl.value.split(':')[this.suffixControl.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Suf" matInput [formControl]="suffixControl" required
[matAutocomplete]="autosuffix" (blur)="closed($event, this.suffixControl)">
<mat-autocomplete autoActiveFirstOption #autosuffix="matAutocomplete" showPanel="true"
......@@ -42,7 +42,7 @@
<form class="form-group form-inline"
[ngStyle]=" showflow(this.suffixControl.value) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width">
<mat-label *ngIf="flowControl.value !=null">Flow or Function : {{this.flowControl.value.split(':')[0]}}:{{this.flowControl.value.split(':')[1]}}</mat-label>
<mat-label *ngIf="flowControl.value !=null">Flow or Function : {{this.flowControl.value.split(':')[0]}}:{{this.flowControl.value.split(':')[this.flowControl.value.split(':').length -2]}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="SufFlow" matInput [formControl]="flowControl" required
[matAutocomplete]="autoflow" (blur)="closed($event, this.flowControl)" >
<mat-autocomplete autoActiveFirstOption #autoflow="matAutocomplete" showPanel="true" [displayWith]="displayFn" panelWidth="string" panelWidth="string">
......
......@@ -49,15 +49,15 @@ export class SuffixDetailsComponent implements OnInit {
this.notifier = notifierService;
this.suffixfilteredOptions = this.suffixControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.suffix, value))
map(value => this._filter(this.suffix, value ? value : ''))
);
this.mumerical_unitsfilteredOptions = this.mumerical_unitsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.mumerical_units, value))
map(value => this._filter(this.mumerical_units, value ? value : ''))
);
this.flowfilteredOptions = this.flowControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.flow, value))
map(value => this._filter(this.flow, value ? value : ''))
);
}
......
......@@ -38,6 +38,10 @@ export class BoilerplateService {
return this.http.put(`${baseUrlgb}${gb}${inferUrl}${id}/`, data);
}
getFileProperties (gb: any): Observable<any> {
return this.http.get(`${genericbaseUrl}`+`/propertydata/${gb}`, { responseType: "blob" });
}
getAll(gb: any): Observable<Boilerplate[]> {
//console.log(baseUrlgb + gb + baseUrl)
return this.http.get<Boilerplate[]>(baseUrlgb + gb + baseUrl);
......@@ -79,4 +83,8 @@ export class BoilerplateService {
return this.http.get(`${genericbaseUrl}`+`/getontology/${gb}`, { responseType: "blob" });
}
getProperties(gb: any, id: any): Observable<any> {
return this.http.get(`${baseUrlgb}${gb}`+`/boilerplates/${id}`+`/property/`);
}
}
......@@ -30,7 +30,6 @@ SIMPLE_PREFIX_CHOICES = ( ("",""),
LOGIC_CONNECTIVE = ( ("or","OR"),
("and", "AND"),
("xor", "XOR")
)
LOGICAL_EXPRESSION = ( ("",""),
......@@ -68,6 +67,7 @@ def create_prefixgroup(instance):
def create_prefix(instance):
prefix = Prefix(prefix_boilerplate = instance.boilerplate, prefixgroup = instance)
prefix.save()
create_extra_prefix(prefix, 'AND')
def create_data(instance):
......@@ -261,8 +261,9 @@ class Prefix(models.Model):
orig = '__original_%s' % field
previous_simple_prefix = getattr(self, orig)
prev_prefix_list.append(previous_simple_prefix)
if previous_simple_prefix == "" and not self.logic_connective == "" :
create_extra_prefix ( self, self.logic_connective)
print("DEBUG-------->",previous_simple_prefix)
#if previous_simple_prefix == "" and not self.logic_connective == "" :
# create_extra_prefix ( self, self.logic_connective)
class Meta:
......
......@@ -10,6 +10,7 @@ urlpatterns = [
path('users/<uuid:pk>/', user_views.UserDetail.as_view(), name='api-post-details'),
path('ontologies/', requirements_views.OntologiesChoicesViewSet.as_view(), name='api-get-ontologies'),
path('getontology/<int:groupboil>/', requirements_views.GetOntology.as_view(), name='get-current-ontology'),
path('propertydata/<int:groupboil>/', requirements_views.PropertyListAPIView.as_view(), name='api-property-list-data'),
path('groupboilerplates/', requirements_views.BoilerplateGroupCreateAPIView.as_view(), name='api-groupboilerplates-create'),
path('groupboilerplates/<int:pk>/', requirements_views.BoilerplateGroupDetailsAPIView.as_view(), name='api-groupboilerplates-list'),
......@@ -54,5 +55,8 @@ urlpatterns = [
#Search In Ontology
path('groupboilerplates/<int:groupboil>/search/<str:instance>/', main_req_views.SearchinOntologyAPIView.as_view(), name='setmainchoices'),
#Properties
path('groupboilerplates/<int:groupboil>/boilerplates/<int:boilerplate>/property/', requirements_views.ExtractedPropertyAPIView.as_view(), name='api-property-list'),
]
\ No newline at end of file
......@@ -163,7 +163,6 @@ class BoilerplateDetailsAPIView(RetrieveUpdateDestroyAPIView):
#g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle')
instance.delete()
class PrefixListAPIView(ListAPIView):
"""
API view to retrieve list of posts or create new
......@@ -176,18 +175,26 @@ class PrefixListAPIView(ListAPIView):
queryset_prefix = Prefix.objects.filter(prefix_boilerplate = group_pk)
return queryset_prefix
class ExtractedPropertyAPIView(APIView):
def get(self, request, groupboil, boilerplate, format=None):
return Response(getExtractedProperty(boilerplate))
class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = PrefixSerializer
previous_values = []
def get_queryset(self):
group_pk = self.kwargs['boilerplate']
queryset_prefix = Prefix.objects.filter(prefix_boilerplate = group_pk)
return queryset_prefix
#Custom actions when PUT
def perform_update(self, serializer):
instance = serializer.validated_data
......@@ -228,12 +235,21 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
if prefix_choices[0] == 'ERROR':
raise APIException("Prefix choices not in [P1-P3]")
else:
boildata.update(prefix_data = pr )
serializer.save(simple_prefix = prefix_choices)
if (len(self.previous_values) !=0):
boildata.update(prefix_data = self.previous_values[0] + pr )
self.previous_values.clear()
serializer.save(simple_prefix = prefix_choices)
return
if (instance['logic_connective'] !=''):
prefixstring = pr +' '+instance['logic_connective']+' '
self.previous_values.append(prefixstring)
else:
boildata.update(prefix_data = pr )
serializer.save(simple_prefix = prefix_choices)
#Custom actions when DELETE
def perform_destroy(self, instance):
def perform_destroy(self,serializer, instance):
instance = serializer.validated_data
instance.delete()
......@@ -251,6 +267,39 @@ class BoilerplateDataListAPIView(ListAPIView):
queryset_boil_data = BoilerplateData.objects.filter(owner_data = self.request.user, group_of_boilerplate_data = group_gb)
return queryset_boil_data
import mimetypes
import tempfile
import shutil
class PropertyListAPIView(APIView):
"""
API view to retrieve property file
"""
serializer_class = BoilerplateDataSerializer
def get(self, request, groupboil, format=None):
group_gb = groupboil
queryset_boil_data = BoilerplateData.objects.filter(owner_data = self.request.user, group_of_boilerplate_data = group_gb)
#temp_file = NamedTemporaryFile(delete=False)
a =list(queryset_boil_data.values())
with tempfile.NamedTemporaryFile(mode='w+t', delete=False) as f:
for boil_data in a:
req= (boil_data['title_data']+': '+ boil_data['prefix_data']+','+boil_data['main_data']+','+boil_data['suffix_data'] + '.\n')
prop =(boil_data['title_data']+'_Property: '+getExtractedProperty(boil_data['id']) + '\n \n')
f.write(req+prop)
f.write('-' * 150 + '\n \n')
temp_file_name = f.name
new_file_name = 'properties.txt'
shutil.copyfile(temp_file_name, new_file_name)
path = open(new_file_name, 'r')
mime_type, _ = mimetypes.guess_type(new_file_name)
# Set the return value of the HttpResponse
response = HttpResponse(path, content_type=mime_type)
# Set the HTTP header for sending to browser
response['Content-Disposition'] = "attachment; filename=%s" % temp_file_name
# Return the response value
return response
class InferListAPIView(ListAPIView):
"""
......@@ -324,7 +373,7 @@ class PrefixChoicesViewSet(ListAPIView):
return queryset_cl
import mimetypes
class GetOntology(APIView):
serializer_class = BoilerplateGroupClassesInstances
......@@ -345,4 +394,100 @@ class GetOntology(APIView):
response['Content-Disposition'] = "attachment; filename=%s" % filename
# Return the response value
return response
\ No newline at end of file
'''Return extracted Properties based on the Property patterns'''
def getExtractedProperty(group_pk):
queryset_prefix = Prefix.objects.filter(prefix_boilerplate = group_pk)
queryset_main = Main.objects.filter(boilerplate_of_main = group_pk)
queryset_suffix = Suffix.objects.filter(boilerplate_of_suffix = group_pk)
prefixdata= list(queryset_prefix.values())
maindata= list(queryset_main.values())
suffixdata= list(queryset_suffix.values())
if(prefixdata==[] and suffixdata ==[]):
return 'This requirement cannot export runtime monitor property.'
mains_to_be_properties = ['M1','M2','M3','M4','M5','M6','M7','M10']
if (maindata[0]['main_choices'] in mains_to_be_properties):
if(maindata[0]['shall'] == 'shall'):
mainverbsub=maindata[0]['verb'].split(':')[-1].strip() + '('+ maindata[0]['sys_fun_inter'].split(':')[-1].strip()
else:
mainverbsub= '!'+maindata[0]['verb'].split(':')[-1].strip() + '('+ maindata[0]['sys_fun_inter'].split(':')[-1].strip()
if(maindata[0]['statevalue_system_connection_stateset'] == '' and (maindata[0]['numerical'] == None or maindata[0]['numerical'] =='')):
main_predicate= mainverbsub+','+ maindata[0]['flow_function_interface_item_system_state_stateset'].split(':')[-1].strip()+')'
elif(maindata[0]['numerical'] == None or maindata[0]['numerical'] ==''):
main_predicate= mainverbsub+','+ maindata[0]['flow_function_interface_item_system_state_stateset'].split(':')[-1].strip()+','+maindata[0]['statevalue_system_connection_stateset'].split(':')[-1].strip() +')'
else:
main_predicate= mainverbsub+',' + maindata[0]['flow_function_interface_item_system_state_stateset'].split(':')[-1].strip()+' '+maindata[0]['quantifier'].split(':')[-1].strip()+' '+maindata[0]['numerical'].split(':')[-1].strip()+' '+maindata[0]['mumerical_units'].split(':')[-1].strip()+')'
if(suffixdata !=[]):
#update main predicate with the suffix options
if(suffixdata[0]['s_choices'] !=''):
if('TimeFrameRelated' in suffixdata[0]['s_choices'] or 'TimeSpaceRelated' in suffixdata[0]['s_choices']):
pass
elif('EventRelated' in suffixdata[0]['s_choices']):
if( 'after' in suffixdata[0]['s_choices'] and 'Flow' in suffixdata[0]['flow']):
flow=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate = '('+main_predicate+' | !@(!'+main_predicate+' S '+flow+'))'
if( 'before' in suffixdata[0]['s_choices'] and 'Flow' in suffixdata[0]['flow']):
flow=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate = flow+'-> @(!'+flow+' S '+main_predicate+')'
elif('TimeRangeRelated' in suffixdata[0]['s_choices']):
num=suffixdata[0]['numerical']
numunti=suffixdata[0]['mumerical_units'].split(':')[-1].strip()
if( 'every' in suffixdata[0]['s_choices'] and 'Flow' in suffixdata[0]['flow']):
flow=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate='(H '+flow+' & !'+main_predicate+') -> P [<='+num+' <'+numunti+'> ] '+main_predicate
elif('every' in suffixdata[0]['s_choices']):
main_predicate='!'+main_predicate+' -> P [<='+num+' <'+numunti+'> ] '+main_predicate
elif( 'for_a_period_of' in suffixdata[0]['s_choices'] and 'Flow' in suffixdata[0]['flow']):
flow=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate= '( !'+flow+' & '+main_predicate+') -> true S [<='+num+' <'+numunti+'> ] '+flow
elif( 'for_a_period_of' in suffixdata[0]['s_choices']):
main_predicate=main_predicate+' -> '+'true S [<='+num+' <'+numunti+'> ] FTP'
elif( 'within' in suffixdata[0]['s_choices'] and 'Flow' in suffixdata[0]['flow']):
flow=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate='! (!'+main_predicate+' S [<'+num+' <'+numunti+'> ]'+flow
elif( 'within' in suffixdata[0]['s_choices']):
main_predicate='H (!'+main_predicate+') -> true S [<'+num+' <'+numunti+'> ] FTP'
elif( 'for_at_least' in suffixdata[0]['s_choices'] and 'Flow' in suffixdata[0]['flow']):
flow=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate=main_predicate+'S [<='+num+' <'+numunti+'> ] '+flow
elif( 'for_at_least' in suffixdata[0]['s_choices']):
main_predicate='(true S [<='+num+' <'+numunti+'> ] FTP) -> '+main_predicate
elif('ExecutionRelated' in suffixdata[0]['s_choices']):
if( 'concurrently' in suffixdata[0]['s_choices'] and 'Function' in suffixdata[0]['flow']):
function=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate=main_predicate+' | (!@'+function+')'
elif( 'sequentially' in suffixdata[0]['s_choices'] and 'Function' in suffixdata[0]['flow']):
function=suffixdata[0]['flow'].split(':')[-1].strip()
main_predicate=main_predicate+' | (!@'+function+' & @(!'+function+' S !'+function+'))'
if(prefixdata!=[]):
#add code for complex Prefix
if(prefixdata[0]['state_or_verb'] !=''):
prefixverbsub=prefixdata[0]['state_or_verb'].split(':')[-1].strip() + '('+ prefixdata[0]['system_fun_item'].split(':')[-1].strip()
if(prefixdata[0]['prefix_numerical'] == None or prefixdata[0]['prefix_numerical'] ==''):
prefix_predicate=prefixverbsub + ',' + prefixdata[0]['item_function_flow_statevalue'].split(':')[-1].strip() +')'
else:
prefix_predicate=prefixverbsub + ',' + prefixdata[0]['item_function_flow_statevalue'].split(':')[-1].strip()+' '+ prefixdata[0]['prefix_quantifier'].split(':')[-1].strip() +' '+ prefixdata[0]['prefix_numerical'].split(':')[-1].strip() +' '+ prefixdata[0]['prefix_mumerical_units'].split(':')[-1].strip() +')'
if(prefixdata[1]['state_or_verb'] !=''):
prefix2verbsub=prefixdata[1]['state_or_verb'].split(':')[-1].strip() + '('+ prefixdata[1]['system_fun_item'].split(':')[-1].strip()
if(prefixdata[1]['prefix_numerical'] == None or prefixdata[1]['prefix_numerical'] ==''):
prefix2_predicate=prefix2verbsub + ',' + prefixdata[1]['item_function_flow_statevalue'].split(':')[-1].strip() +')'
else:
prefix2_predicate=prefix2verbsub + ',' + prefixdata[1]['item_function_flow_statevalue'].split(':')[-1].strip()+' '+ prefixdata[1]['prefix_quantifier'].split(':')[-1].strip() +' '+ prefixdata[1]['prefix_numerical'].split(':')[-1].strip() +' '+ prefixdata[1]['prefix_mumerical_units'].split(':')[-1].strip() +')'
if(prefixdata[0]['logic_connective']=='OR'):
prefix_predicate = '('+prefix_predicate+' | '+prefix2_predicate+')'
elif(prefixdata[0]['logic_connective']=='AND'):
prefix_predicate = '('+prefix_predicate+' & '+prefix2_predicate+')'
if (prefixdata[0]['simple_prefix'] == 'P1'):
p1main= '( '+main_predicate+' | ! @('+main_predicate+' S '+prefix_predicate+')'+')'
return p1main
elif (prefixdata[0]['simple_prefix'] == 'P2'):
p2main= '('+main_predicate+' | (! @('+main_predicate+' & @(∃ temp, !'+prefix_predicate+' S '+ prefixverbsub +',temp) & !(temp='+ (prefix_predicate.replace(prefixverbsub, '')).strip(')').strip(',') +')' '))'+')))'
return p2main
elif (prefixdata[0]['simple_prefix'] == 'P3'):
p3main= '('+main_predicate+' | (! @('+prefix_predicate+')'
return p3main
else:
return main_predicate
else:
return 'This main cannot export runtime monitor property.'
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