Commit a80c458d authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

5 step instances level, details about inference results

parent e52b17aa
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
</nav> </nav>
<mat-grid-list cols="2"> <mat-grid-list cols="2">
<div class="first"> <div class="first">
<div *ngIf="get_metrics(currentboilerplate.title)" style="margin-right: 50px;width: 90%;"
class="alert alert-warning" role="alert">
<p [innerHTML]="getinferdata()"></p>
</div>
<div *ngIf="currentboilerplate.id" class="edit-form"> <div *ngIf="currentboilerplate.id" class="edit-form">
<form ngNativeValidate> <form ngNativeValidate>
<div class="form-group" style="display:flex; flex-direction: row; align-items: center"> <div class="form-group" style="display:flex; flex-direction: row; align-items: center">
...@@ -77,7 +81,7 @@ ...@@ -77,7 +81,7 @@
</div> </div>
<mat-tab-group mat-align-tabs="center"> <mat-tab-group mat-align-tabs="center">
<div *ngFor="let section of systems| filter:searchText"> <div *ngFor="let section of systems| filter:searchText">
<div *ngIf= "section.Name == 'System' "> <div *ngIf="section.Name == 'System' ">
<mat-tab label=Syntax> <mat-tab label=Syntax>
<div *ngFor="let items of syntax| filter:searchText"> <div *ngFor="let items of syntax| filter:searchText">
<mat-accordion> <mat-accordion>
...@@ -94,7 +98,7 @@ ...@@ -94,7 +98,7 @@
<mat-panel-title> <mat-panel-title>
{{ item.name }} {{ item.name }}
</mat-panel-title> </mat-panel-title>
<mat-panel-description > <mat-panel-description>
<h5>{{ item.details }}</h5> <h5>{{ item.details }}</h5>
</mat-panel-description> </mat-panel-description>
</mat-expansion-panel-header> </mat-expansion-panel-header>
...@@ -152,6 +156,107 @@ ...@@ -152,6 +156,107 @@
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<p>{{sub.SubclassComment}}</p> <p>{{sub.SubclassComment}}</p>
<div *ngIf=checklen(sub.SubSubClass)>
<h5><b>Subclasses</b></h5>
</div>
<div *ngFor="let subsub of sub.SubSubClass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsub.SubSubClass_name}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsub.SubSubclassComment}}</p>
<div *ngIf=checklen(subsub.SubSubClass)>
<h5><b>Subclasses</b></h5>
</div>
<div *ngFor="let subsubsub of subsub.SubSubClass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubsub.SubSubClass_name}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubsub.SubSubclassComment}}</p>
<div *ngIf=checklen(subsubsub.SubSubClass)>
<h5><b>Subclasses</b></h5>
</div>
<div *ngFor="let subsubsubsub of subsubsub.SubSubClass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubsubsub.SubSubClass_name}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubsubsub.SubSubclassComment}} </p>
<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>Instances</h5>
</button>
<div
*ngFor="let subsubsubsubinstansub of subsubsubsub.SubInstanceOfSubclass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubsubsubinstansub.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubsubsubinstansub.Comment}}</p>
</mat-expansion-panel>
</li>
</div>
</ul>
</mat-expansion-panel>
</li>
</div>
<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}"
#menuTrigger>
<h5>Instances</h5>
</button>
<div *ngFor="let subsubsubinstansub of subsubsub.SubInstanceOfSubclass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubsubinstansub.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubsubinstansub.Comment}}</p>
</mat-expansion-panel>
</li>
</div>
</ul>
</mat-expansion-panel>
</li>
</div>
<ul> <button mat-button [matMenuTriggerFor]="menu"
[matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name, subsubclass:subsub.SubSubClass_name }"
#menuTrigger>
<h5>Instances</h5>
</button>
<div *ngFor="let subsubinstansub of subsub.SubInstanceOfSubclass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubinstansub.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubinstansub.Comment}}</p>
</mat-expansion-panel>
</li>
</div>
</ul>
</mat-expansion-panel>
</li>
</div>
<ul> <button mat-button [matMenuTriggerFor]="menu" <ul> <button mat-button [matMenuTriggerFor]="menu"
[matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name}" [matMenuTriggerData]="{section: section.Name ,class: item.Class, subclass: sub.SubClass_name}"
#menuTrigger> #menuTrigger>
...@@ -181,11 +286,9 @@ ...@@ -181,11 +286,9 @@
</div> </div>
</div> </div>
<ul> <ul>
<div *ngIf=checklen(section.GeneralInstances)>
<button mat-button [matMenuTriggerFor]="menu" [matMenuTriggerData]="{section: section.Name}" #menuTrigger> <button mat-button [matMenuTriggerFor]="menu" [matMenuTriggerData]="{section: section.Name}" #menuTrigger>
<h4>Instances</h4> <h4>Instances</h4>
</button> </button>
</div>
<div *ngFor="let genin of section.GeneralInstances| filter:searchText"> <div *ngFor="let genin of section.GeneralInstances| filter:searchText">
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
...@@ -210,6 +313,8 @@ ...@@ -210,6 +313,8 @@
</mat-grid-list> </mat-grid-list>
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
<ng-template let-class="class" let-section="section" let-subclass="subclass" matMenuContent><button mat-menu-item <ng-template let-class="class" let-section="section" let-subclass="subclass" let-subsubclass="subsubclass"
(click)="openDialog(section, class, subclass)">Add Instances</button> </ng-template> let-subsubsubclass="subsubsubclass" let-subsubsubsubclass="subsubsubsubclass" matMenuContent><button mat-menu-item
(click)="openDialog(section, class, subclass, subsubclass, subsubsubclass, subsubsubsubclass)">Add
Instances</button> </ng-template>
</mat-menu> </mat-menu>
\ No newline at end of file
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
<!-- Name Column --> <!-- Name Column -->
<ng-container matColumnDef="title_data"> <ng-container matColumnDef="title_data">
<th mat-header-cell *matHeaderCellDef> Title </th> <th mat-header-cell *matHeaderCellDef> Title </th>
<td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}} > {{element.title_data}} <span <td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}}> {{element.title_data}}
*ngIf="get_metrics(element.title_data).length > 0" matBadge={{get_metrics(element.title_data).length}} <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> matBadgeColor="warn" matBadgeSize="small" position="above"> &nbsp;&nbsp; </span>
</td> </td>
</ng-container> </ng-container>
......
...@@ -156,8 +156,10 @@ export class BoilerplateListComponent implements OnInit { ...@@ -156,8 +156,10 @@ export class BoilerplateListComponent implements OnInit {
this.boilerplateService.getAllInfer(this.route.snapshot.params.gb) this.boilerplateService.getAllInfer(this.route.snapshot.params.gb)
.subscribe( .subscribe(
data => { data => {
console.log(data);
this.currentInfer = data[0]; this.currentInfer = data[0];
this.infer = data; this.infer = data;
if (data[0]) {
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\"")) const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
var final = [] var final = []
for (let i of this.list_of_inference_metrics) { for (let i of this.list_of_inference_metrics) {
...@@ -167,8 +169,8 @@ export class BoilerplateListComponent implements OnInit { ...@@ -167,8 +169,8 @@ export class BoilerplateListComponent implements OnInit {
} }
} }
console.log(final); }
//console.log(final);
this.chartOption.series = [{ this.chartOption.series = [{
type: 'pie', type: 'pie',
radius: ['40%', '70%'], radius: ['40%', '70%'],
......
<div fxLayoutAlign="end"> <div fxLayoutAlign="end">
<mat-chip color="primary"> MAIN TEMPLATE : {{this.main}}</mat-chip> <h2><span class="badge badge-secondary"> MAIN TEMPLATE : {{this.main}}</span></h2>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="col"> <div class="col">
...@@ -91,9 +91,10 @@ ...@@ -91,9 +91,10 @@
<mat-label>Quantifier</mat-label> <mat-label>Quantifier</mat-label>
<input placeholder="Pick one" aria-label="Number" matInput [formControl]="quantifierControl" type="text" <input placeholder="Pick one" aria-label="Number" matInput [formControl]="quantifierControl" type="text"
[matAutocomplete]="autoquantifier"> [matAutocomplete]="autoquantifier">
<mat-autocomplete autoActiveFirstOption #autoquantifier="matAutocomplete"> <mat-autocomplete autoActiveFirstOption #autoquantifier="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of quantifierfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of quantifierfilteredOptions | async" [value]="option">
{{option}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
</mat-autocomplete> </mat-autocomplete>
</mat-form-field> </mat-form-field>
...@@ -116,9 +117,10 @@ ...@@ -116,9 +117,10 @@
<mat-label>Number Unit</mat-label> <mat-label>Number Unit</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="numunitControl" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="numunitControl"
[matAutocomplete]="autonumunit"> [matAutocomplete]="autonumunit">
<mat-autocomplete autoActiveFirstOption #autonumunit="matAutocomplete"> <mat-autocomplete autoActiveFirstOption #autonumunit="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of numunitfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of numunitfilteredOptions | async" [value]="option">
{{option}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
</mat-autocomplete> </mat-autocomplete>
</mat-form-field> </mat-form-field>
......
...@@ -2,24 +2,20 @@ ...@@ -2,24 +2,20 @@
<div class="col"> <div class="col">
<form class="form-group form-inline" ngNativeValidate> <form class="form-group form-inline" ngNativeValidate>
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Suffix</mat-label> <mat-label *ngIf="this.suffixControl.value !=null">Suffix :{{this.suffixControl.value.slice(0,
<input type="text" this.suffixControl.value.indexOf(':'))}}</mat-label>
placeholder="Pick one" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="suffixControl" required
aria-label="Number" [matAutocomplete]="autosuffix">
matInput <mat-autocomplete autoActiveFirstOption #autosuffix="matAutocomplete" showPanel="true"
[formControl]="suffixControl" [displayWith]="displayFn">
required
[matAutocomplete]="autosuffix"
>
<mat-autocomplete autoActiveFirstOption #autosuffix="matAutocomplete">
<mat-option *ngFor="let option of suffixfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of suffixfilteredOptions | async" [value]="option">
{{option}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
</mat-autocomplete> </mat-autocomplete>
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
<div class="col" > <div class="col">
<form class="form-group form-inline"> <form class="form-group form-inline">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label> <mat-label>Numerical Value</mat-label>
...@@ -30,34 +26,28 @@ ...@@ -30,34 +26,28 @@
<div class="col"> <div class="col">
<form class="form-group form-inline"> <form class="form-group form-inline">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Unit</mat-label> <mat-label *ngIf="this.mumerical_unitsControl.value !=null">Numerical Value
<input type="text" : {{this.mumerical_unitsControl.value.slice(0,
placeholder="Pick one" this.mumerical_unitsControl.value.indexOf(':'))}}</mat-label>
aria-label="Number" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="mumerical_unitsControl"
matInput [matAutocomplete]="autonumsuffix">
[formControl]="mumerical_unitsControl" <mat-autocomplete autoActiveFirstOption #autonumsuffix="matAutocomplete" showPanel="true"
[matAutocomplete]="automumerical_units" [displayWith]="displayFn">
>
<mat-autocomplete autoActiveFirstOption #automumerical_units="matAutocomplete">
<mat-option *ngFor="let option of mumerical_unitsfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of mumerical_unitsfilteredOptions | async" [value]="option">
{{option}} {{option.split(" : ").pop()}}
</mat-option> </mat-option>
</mat-autocomplete> </mat-autocomplete>
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
<div class="col"> <div class="col" *ngIf="this.mumerical_unitsControl.value !=null">
<form class="form-group form-inline"> <form class="form-group form-inline"
[ngStyle]=" showflow(this.suffixControl.value) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="flowControl.value !=null">Flow : {{flowControl.value.slice(0, flowControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="flowControl.value !=null">Flow or Function : {{flowControl.value.slice(0,
<mat-label>Flow</mat-label> flowControl.value.indexOf(':'))}}</mat-label>
<input type="text" <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="flowControl" required
placeholder="Pick one" [matAutocomplete]="autoflow">
aria-label="Number"
matInput
[formControl]="flowControl"
[matAutocomplete]="autoflow"
>
<mat-autocomplete autoActiveFirstOption #autoflow="matAutocomplete" showPanel="true" [displayWith]="displayFn"> <mat-autocomplete autoActiveFirstOption #autoflow="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of flowfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of flowfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}} {{option.split(" : ").pop()}}
......
...@@ -26,6 +26,7 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -26,6 +26,7 @@ export class SuffixDetailsComponent implements OnInit {
flowControl = new FormControl(); flowControl = new FormControl();
flow: string[] = []; flow: string[] = [];
flowfilteredOptions: Observable<string[]>; flowfilteredOptions: Observable<string[]>;
flowControlisDivVisible = false
public static id: any[] = []; public static id: any[] = [];
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
...@@ -61,7 +62,10 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -61,7 +62,10 @@ export class SuffixDetailsComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.getchoices(); //this.getchoices();
this.getflowchoices(this.route.snapshot.params.gb);
console.log('aaa', this.route.snapshot.params.gb);
this.getAllSuffix(this.route.snapshot.params.id); this.getAllSuffix(this.route.snapshot.params.id);
} }
...@@ -75,6 +79,16 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -75,6 +79,16 @@ export class SuffixDetailsComponent implements OnInit {
return ""; return "";
} }
showflow(option: string): boolean {
this.flowControlisDivVisible = false
if (option != null) {
let x = option.split(" : ");
if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return false; }
if (x[x.length - 2] == 'EventRelated' || x[x.length - 2] == 'TimeRangeRelated' || x[x.length - 2] == 'ExecutionRelated') { this.flowControlisDivVisible = true; return true; }
}
return false;
}
private _filter(data: string[], value: string): string[] { private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase(); const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue)); return data.filter(option => option.toLowerCase().includes(filterValue));
...@@ -119,7 +133,7 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -119,7 +133,7 @@ export class SuffixDetailsComponent implements OnInit {
updateSuffix(): void { updateSuffix(): void {
this.currentsuffix.s_choices = this.suffixControl.value; this.currentsuffix.s_choices = this.suffixControl.value;
this.currentsuffix.mumerical_units = this.mumerical_unitsControl.value; this.currentsuffix.mumerical_units = this.mumerical_unitsControl.value;
this.currentsuffix.flow = this.flowControl.value; if (this.flowControlisDivVisible) { this.currentsuffix.flow = this.flowControl.value; } else { this.currentsuffix.flow = '' }
for (let i = 0; i < SuffixDetailsComponent.id.length; i++) { for (let i = 0; i < SuffixDetailsComponent.id.length; i++) {
this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix) this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix)
.subscribe( .subscribe(
...@@ -133,32 +147,50 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -133,32 +147,50 @@ export class SuffixDetailsComponent implements OnInit {
} }
getchoices(): void { getflowchoices(prefix_group: any): void {
this.suffixService.getsuffix() this.suffixService.getsuffixflow(prefix_group)
.subscribe( .subscribe(
data => { data => {
for (let x = 0; x < data.length; x++) { //set flow choices
if (this.suffix.indexOf(data[x][1]) == -1) { this.setflow(JSON.parse(data[0].flow_choices));
this.suffix.push(data[x][1]); this.setflow(JSON.parse(data[0].function_choices));
} this.setsuffix(JSON.parse(data[0].suffix_choices));
} this.setmumerical_units(JSON.parse(data[0].number_unit_choices));
}, },
error => { error => {
console.log(error); console.log(error);
}); });
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]);
} }
setflow(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.flow.indexOf(strIntoObj[x][1]) == -1) {
this.flow.push((strIntoObj[x][1]));
} }
}, }
error => { }
console.log(error);
}); setsuffix(strIntoObj: any): void {
this.suffixService.getflow() for (let x = 0; x < strIntoObj.length; x++) {
if (this.suffix.indexOf(strIntoObj[x][1]) == -1) {
this.suffix.push((strIntoObj[x][1]));
}
}
}
setmumerical_units(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.mumerical_units.indexOf(strIntoObj[x][1]) == -1) {
this.mumerical_units.push((strIntoObj[x][1]));
}
}
}
}
/*this.suffixService.getflow()
.subscribe( .subscribe(
data => { data => {
for (let x = 0; x < data.length; x++) { for (let x = 0; x < data.length; x++) {
...@@ -169,8 +201,4 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -169,8 +201,4 @@ export class SuffixDetailsComponent implements OnInit {
}, },
error => { error => {
console.log(error); console.log(error);
}); });*/
\ No newline at end of file
}
}
...@@ -45,6 +45,27 @@ export class SubClasses { ...@@ -45,6 +45,27 @@ export class SubClasses {
SubClass_name?: any; SubClass_name?: any;
SubclassComment?: any SubclassComment?: any
InstanceOfSubclass?: Instances[]; InstanceOfSubclass?: Instances[];
SubSubClass?: SubSubClasses[];
}
export class SubSubClasses {
SubSubClass_name?: any;
SubSubclassComment?: any
SubInstanceOfSubclass?: Instances[];
SubSubClass?:SubSubSubClasses[];
}
export class SubSubSubClasses {
SubSubClass_name?: any;
SubSubclassComment?: any
SubInstanceOfSubclass?: Instances[];
SubSubClass?:SubSubSubSubClasses[];
}
export class SubSubSubSubClasses {
SubSubClass_name?: any;
SubSubclassComment?: any
SubInstanceOfSubclass?: Instances[];
} }
export class Instances { export class Instances {
......
...@@ -6,6 +6,7 @@ import { environment } from '../../environments/environment'; ...@@ -6,6 +6,7 @@ import { environment } from '../../environments/environment';
const baseUrl = environment.apiroot + 'api-auth/groupboilerplates/0/boilerplates/'; const baseUrl = environment.apiroot + 'api-auth/groupboilerplates/0/boilerplates/';
const Url = '/suffix/'; const Url = '/suffix/';
const baseUrl2 = environment.apiroot + 'api-auth/groupboilerplates/';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -46,4 +47,8 @@ export class SuffixService { ...@@ -46,4 +47,8 @@ export class SuffixService {
return this.http.get(environment.apiroot +`api-auth/suffix/choices/flow/`); return this.http.get(environment.apiroot +`api-auth/suffix/choices/flow/`);
} }
getsuffixflow(gb: any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/prefix/choices/simpleprefix/`);
}
} }
...@@ -45,11 +45,17 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1"), ...@@ -45,11 +45,17 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1"),
#FUNCTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Function") #FUNCTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Function")
# #
SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not")) SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not"))
QUANTIFIER_CHOICES = ( ("None","None"), ("All", "All"), ("Only", "Only"), #QUANTIFIER_CHOICES = ( ("None","None"), ("All", "All"), ("Only", "Only"),
("More Than", "More Than"), ("Less Than", "Less Than"), ("Exactly","Exactly"), # ("More Than", "More Than"), ("Less Than", "Less Than"), ("Exactly","Exactly"),
("At Least", "At Least"), ("At Most", "At Most") # ("At Least", "At Least"), ("At Most", "At Most")
) # )
NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"), ("Number", "Number")) #NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"), ("Number", "Number"))
##g = Graph()
#g.load('../../Ontologies/2022_AOCS.ttl', format="turtle")
#PREFIX_SYNTAX = get_prefix_syntax(g)
#S_CHOICES = get_instances_g("RBO#Preposition",g) + get_instances_g("RBO#NumericalAffirmative",g)
#print(S_CHOICES)
#ITEM #ITEM
#ITEM_CHOICES = get_instances("SAO#Item") #ITEM_CHOICES = get_instances("SAO#Item")
#ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item") #ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item")
...@@ -91,7 +97,6 @@ NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^ ...@@ -91,7 +97,6 @@ NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^
#VERB_CHOICES = get_verb_instances("LO#Verb") #VERB_CHOICES = get_verb_instances("LO#Verb")
VERB_CHOICES = get_verb_file_and_instances("LO#Verb") VERB_CHOICES = get_verb_file_and_instances("LO#Verb")
#test to add M #test to add M
CLASS_CHOICES = (("SYSTEM","SYSTEM"), ("FUNCTION","FUNCTION"), ("SHALL","SHALL/SHALL NOT"), CLASS_CHOICES = (("SYSTEM","SYSTEM"), ("FUNCTION","FUNCTION"), ("SHALL","SHALL/SHALL NOT"),
("QUANTIFIER","QUANTIFIER"), ("NUMBER_UNITS","NUMBER_UNITS"), ("ITEM","ITEM"), ("QUANTIFIER","QUANTIFIER"), ("NUMBER_UNITS","NUMBER_UNITS"), ("ITEM","ITEM"),
......
...@@ -36,6 +36,9 @@ LOGICAL_EXPRESSION = ( ("",""), ...@@ -36,6 +36,9 @@ LOGICAL_EXPRESSION = ( ("",""),
#Need fixing #Need fixing
#VERB_CHOICES_PREFIX = ( ("","")) #VERB_CHOICES_PREFIX = ( ("",""))
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/RDO-instances#"]#,
list_of_RBO = ["http://delab.csd.auth.gr/ontologies/2018/LO#","http://delab.csd.auth.gr/ontologies/2018/RBO#","http://delab.csd.auth.gr/ontologies/2018/LO-instances#"]
#list_of_LO = ["http://delab.csd.auth.gr/ontologies/2018/LO#","http://delab.csd.auth.gr/ontologies/2018/RBO#","http://delab.csd.auth.gr/ontologies/2018/LO-instances#"]
#Must read this info from the Ontology #Must read this info from the Ontology
...@@ -106,15 +109,19 @@ def update_instances(instance): ...@@ -106,15 +109,19 @@ def update_instances(instance):
g.load(instance.ontology_file, format="turtle") g.load(instance.ontology_file, format="turtle")
#PREFIX_SYNTAX = get_prefix_syntax(g) #PREFIX_SYNTAX = get_prefix_syntax(g)
VERB_CHOICES_PREFIX = get_prefix_verbs(g) VERB_CHOICES_PREFIX = get_prefix_verbs(g)
SYSTEM_CHOICES = get_instances_g("SAO#System",g) SYSTEM_CHOICES = get_instances_g("SAO#System",g, list_of_DSO)
FUNCTION_CHOICES = get_instances_g("SAO#Function",g) FUNCTION_CHOICES = get_instances_g("SAO#Function",g, list_of_DSO)
ITEM_CHOICES = get_instances_g("SAO#Item",g) ITEM_CHOICES = get_instances_g("SAO#Item",g, list_of_DSO)
INTERFACE_CHOICES = get_instances_g("SAO#Interface",g) INTERFACE_CHOICES = get_instances_g("SAO#Interface",g, list_of_DSO)
CONNECTION_CHOICES = get_instances_g("SAO#Connection",g) CONNECTION_CHOICES = get_instances_g("SAO#Connection",g, list_of_DSO)
FLOW_CHOICES = get_instances_g("SAO#Flow",g) FLOW_CHOICES = get_instances_g("SAO#Flow",g, list_of_DSO)
STATE_CHOICES = get_instances_g("SAO#State",g) STATE_CHOICES = get_instances_g("SAO#State",g, list_of_DSO)
STATE_SET_CHOICES = get_instances_g("SAO#StateSet",g) STATE_SET_CHOICES = get_instances_g("SAO#StateSet",g, list_of_DSO)
STATE_VALUE_CHOICES =get_instances_g("SAO#StateValue",g) STATE_VALUE_CHOICES =get_instances_g("SAO#StateValue",g, list_of_DSO)
NUMBER_UNITS_CHOICES = get_instances_g("RBO#NumberUnit",g, list_of_RBO)
QUANTIFIER_CHOICES = get_instances_g("RBO#Quantifier",g, list_of_RBO)
NUMERICAL_AFFIRMATIVE_CHOICES = get_instances_g("RBO#NumericalAffirmative",g, list_of_RBO)
S_CHOICES = get_instances_g("RBO#Preposition",g, list_of_RBO) + get_instances_g("RBO#NumericalAffirmative",g, list_of_RBO)
BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= instance.owner_infer, classes_instances_group_of_boilerplate = instance.infer_group_of_boilerplate).update( BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= instance.owner_infer, classes_instances_group_of_boilerplate = instance.infer_group_of_boilerplate).update(
prefix_choices = json.dumps(PREFIX_CHOICES), prefix_logcon_choices =json.dumps(LOGIC_CONNECTIVE), prefix_verb_choices =json.dumps(STATE_CHOICES + VERB_CHOICES_PREFIX), prefix_choices = json.dumps(PREFIX_CHOICES), prefix_logcon_choices =json.dumps(LOGIC_CONNECTIVE), prefix_verb_choices =json.dumps(STATE_CHOICES + VERB_CHOICES_PREFIX),
main_class_choices =json.dumps(MAIN_CHOICES), system_choices = json.dumps(SYSTEM_CHOICES), function_choices =json.dumps(FUNCTION_CHOICES), main_class_choices =json.dumps(MAIN_CHOICES), system_choices = json.dumps(SYSTEM_CHOICES), function_choices =json.dumps(FUNCTION_CHOICES),
......
...@@ -18,16 +18,26 @@ SUFFIX_CHOICES = (("",""), ('S1', 'S1: <numerical-affirmative> j <closed-interva ...@@ -18,16 +18,26 @@ SUFFIX_CHOICES = (("",""), ('S1', 'S1: <numerical-affirmative> j <closed-interva
) )
NUMERICAL_AFFIRMATIVE_CHOICES = (("MORE THAN", "MORE THAN"), ("LESS THAN", "LESS THAN"), ("EXACTLY","EXACTLY"), NUMERICAL_AFFIRMATIVE_CHOICES = (("MORE THAN", "MORE THAN"), ("LESS THAN", "LESS THAN"), ("EXACTLY","EXACTLY"),
("AT LEAST", "AT LEAST"), ("AT MOST", "AT MOST")) ("AT LEAST", "AT LEAST"), ("AT MOST", "AT MOST"))
NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT")) #NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"))
TIME_UNITS_CHOICES = (("SECONDS","SECONDS"), ("MINUTES","MINUTES"), ("MILLISECONDS","MILLISECONDS"), ("CYCLES","CYCLES"))
FLOW_CHOICES = get_instances("SAO#Flow") #TIME_UNITS_CHOICES = (("SECONDS","SECONDS"), ("MINUTES","MINUTES"), ("MILLISECONDS","MILLISECONDS"), ("CYCLES","CYCLES"))
#FLOW_CHOICES = get_instances("SAO#Flow")
# FLOW returns () # FLOW returns ()
S2_CHOICES = (("BEFORE","BEFORE"), ("AFTER","AFTER")) S2_CHOICES = (("BEFORE","BEFORE"), ("AFTER","AFTER"))
S3_CHOICES = (("EVERY","EVERY"), ("FOR A PERIOD OF","FOR A PERIOD OF"), ("WITHIN", "WITHIN"), ("FOR AT LEAST", "FOR AT LEAST")) S3_CHOICES = (("EVERY","EVERY"), ("FOR A PERIOD OF","FOR A PERIOD OF"), ("WITHIN", "WITHIN"), ("FOR AT LEAST", "FOR AT LEAST"))
S4_CHOICES = (("AT THE BEGINNING","AT THE BEGINNING"), ("AT THE END","AT THE END")) S4_CHOICES = (("AT THE BEGINNING","AT THE BEGINNING"), ("AT THE END","AT THE END"))
S5_6_CHOICES = (("AT EVEN INTERVALS","AT EVEN INTERVALS"), ("SEQUENTIALLY","SEQUENTIALLY")) S5_6_CHOICES = (("AT EVEN INTERVALS","AT EVEN INTERVALS"), ("SEQUENTIALLY","SEQUENTIALLY"))
S5_6_CHOICES = (("AT EVEN INTERVALS","AT EVEN INTERVALS"), ("SEQUENTIALLY","SEQUENTIALLY"))
#S_CHOICES = NUMERICAL_AFFIRMATIVE_CHOICES + S2_CHOICES + S3_CHOICES + S4_CHOICES + S5_6_CHOICES
S_CHOICES = NUMERICAL_AFFIRMATIVE_CHOICES + S2_CHOICES + S3_CHOICES + S4_CHOICES + S5_6_CHOICES '''g = Graph()
g.load('../../Ontologies/2022_AOCS.ttl', format="turtle")
S_CHOICES = get_instances_g("RBO#Preposition",g) + get_instances_g("RBO#NumericalAffirmative",g)
FLOW_CHOICES=(("SECONDS","SECONDS"), ("MINUTES","MINUTES"), ("MILLISECONDS","MILLISECONDS"), ("CYCLES","CYCLES"))
NUMBER_UNITS_CHOICES=get_instances_g("LO#NumberUnit",g)
SYSTEM_CHOICES = get_instances_g("SAO#System",g)
print(SYSTEM_CHOICES)'''
def create_suffix(instance): def create_suffix(instance):
...@@ -49,13 +59,16 @@ class Suffix(models.Model): ...@@ -49,13 +59,16 @@ class Suffix(models.Model):
boilerplate_of_suffix = models.ForeignKey('reqtool.Boilerplate', related_name='suffix_boilerplate', on_delete=models.CASCADE) boilerplate_of_suffix = models.ForeignKey('reqtool.Boilerplate', related_name='suffix_boilerplate', on_delete=models.CASCADE)
suffix_owner = models.ForeignKey(User, related_name='suffix_owner', on_delete=models.CASCADE) suffix_owner = models.ForeignKey(User, related_name='suffix_owner', on_delete=models.CASCADE)
#prefix templates #prefix templates
s_choices = models.CharField(choices=S_CHOICES, max_length=100, blank=True) #s_choices = models.CharField(choices=S_CHOICES, max_length=100, blank=True)
s_choices = models.CharField(max_length=100, blank=True)
#if S1 #if S1
numerical = models.CharField(blank=True, null=True, max_length=10) numerical = models.CharField(blank=True, null=True, max_length=10)
mumerical_units = models.CharField(choices=NUMBER_UNITS_CHOICES + TIME_UNITS_CHOICES, max_length=100, blank=True) #mumerical_units = models.CharField(choices=NUMBER_UNITS_CHOICES, max_length=100, blank=True)
mumerical_units = models.CharField(max_length=100, blank=True)
#time_units = models.CharField(choices=TIME_UNITS_CHOICES, max_length=100, blank=True) #time_units = models.CharField(choices=TIME_UNITS_CHOICES, max_length=100, blank=True)
#if S2/S3 #if S2/S3
flow = models.CharField(choices=FLOW_CHOICES, max_length=100, blank=True) #flow = models.CharField(choices=FLOW_CHOICES, max_length=100, blank=True)
flow = models.CharField(max_length=100, blank=True)
#find suffix #find suffix
suffix_choices = models.CharField(choices=SUFFIX_CHOICES, max_length=100, blank=True) suffix_choices = models.CharField(choices=SUFFIX_CHOICES, max_length=100, blank=True)
#custom suffix #custom suffix
......
...@@ -38,9 +38,9 @@ urlpatterns = [ ...@@ -38,9 +38,9 @@ urlpatterns = [
path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'), path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
#SUFFIX CHOICES DATA #SUFFIX CHOICES DATA
path('suffix/choices/suffix/', suffix_req_views.SuffixChoicesViewSet.as_view(), name='suffixsuffix'), ##path('suffix/choices/suffix/', suffix_req_views.SuffixChoicesViewSet.as_view(), name='suffixsuffix'),
path('suffix/choices/numunits/', suffix_req_views.NumChoicesViewSet.as_view(), name='suffixnum'), #path('suffix/choices/numunits/', suffix_req_views.NumChoicesViewSet.as_view(), name='suffixnum'),
path('suffix/choices/flow/', suffix_req_views.FlowChoicesViewSet.as_view(), name='suffixflow'), #path('suffix/choices/flow/', suffix_req_views.FlowChoicesViewSet.as_view(), name='suffixflow'),
#Dictionary #Dictionary
path('groupboilerplates/<int:groupboil>/dictionary/', main_req_views.DictionaryViewSet.as_view(), name='dictionary'), path('groupboilerplates/<int:groupboil>/dictionary/', main_req_views.DictionaryViewSet.as_view(), name='dictionary'),
......
...@@ -97,7 +97,9 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -97,7 +97,9 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
if( instance['mumerical_units'] not in numunit_data): if( instance['mumerical_units'] not in numunit_data):
raise APIException("MAIN : Instance of Number Unit does not exist") raise APIException("MAIN : Instance of Number Unit does not exist")
curmain_choices = inference.getclassofmain(instance) curmain_choices = inference.getclassofmain(instance)
if curmain_choices[0] == 'ERROR': if(curmain_choices==None):
raise APIException("Main choices not in [M1-M16]")
if (curmain_choices[0] == 'ERROR'):
raise APIException("Main choices not in [M1-M16]") raise APIException("Main choices not in [M1-M16]")
else: else:
instance = serializer.save(main_choices = curmain_choices[0]) instance = serializer.save(main_choices = curmain_choices[0])
...@@ -136,7 +138,7 @@ class MainChoicesAPIView(APIView): ...@@ -136,7 +138,7 @@ class MainChoicesAPIView(APIView):
#print(Dictdata.values('Dictionary_Data')[0]['Dictionary_Data']) #print(Dictdata.values('Dictionary_Data')[0]['Dictionary_Data'])
class_prefix = self.getClassontologyfile(g,es_instance) 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))): 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") raise APIException("This instance already exist")
try: 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() ) , RDF.type, URIRef(class_prefix) ))
...@@ -146,6 +148,7 @@ class MainChoicesAPIView(APIView): ...@@ -146,6 +148,7 @@ class MainChoicesAPIView(APIView):
raise APIException("Cannot Add instance") raise APIException("Cannot Add instance")
tempDict = [] tempDict = []
flag = 0 flag = 0
#PROBLEMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
for sao in Dictdata.values('Dictionary_Data')[0]['Dictionary_Data']: for sao in Dictdata.values('Dictionary_Data')[0]['Dictionary_Data']:
if sao['Name'] == es_instance[0].strip(): if sao['Name'] == es_instance[0].strip():
for sao2 in sao['TheClasses']: for sao2 in sao['TheClasses']:
...@@ -154,6 +157,36 @@ class MainChoicesAPIView(APIView): ...@@ -154,6 +157,36 @@ class MainChoicesAPIView(APIView):
for sao3 in sao2['Subclass']: for sao3 in sao2['Subclass']:
if sao3['SubClass_name'] == es_instance[2].strip(): if sao3['SubClass_name'] == es_instance[2].strip():
flag = 2 flag = 2
print(sao3)
for sao4 in sao3['SubSubClass']:
if es_instance[3] and sao4['SubSubClass_name'] == es_instance[3].strip():
flag =3
for sao5 in sao4['SubSubClass']:
if es_instance[4] and sao5['SubSubClass_name'] == es_instance[4].strip():
flag =4
for sao6 in sao5['SubSubClass']:
if es_instance[5] and sao6['SubSubClass_name'] == es_instance[5].strip():
flag = 5
if(flag == 5):
if(sao6 ['SubInstanceOfSubclass'] == ''):
sao6 ['SubInstanceOfSubclass'] = []
sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment })
else:
sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment })
if(flag == 4):
if(sao5 ['SubInstanceOfSubclass'] == ''):
sao5 ['SubInstanceOfSubclass'] = []
sao5['SubInstanceOfSubclass'].append({"Instance": es_instance[5].strip(), "Comment": comment })
else:
sao5['SubInstanceOfSubclass'].append({"Instance": es_instance[5].strip(), "Comment": comment })
if(flag == 3):
if(sao4 ['SubInstanceOfSubclass'] == ''):
sao4 ['SubInstanceOfSubclass'] = []
sao4['SubInstanceOfSubclass'].append({"Instance": es_instance[4].strip(), "Comment": comment })
else:
sao4['InstanceOfSubclass'].append({"Instance": es_instance[4].strip(), "Comment": comment })
# SubSubClass_name
if(flag == 2):
if(sao3 ['InstanceOfSubclass'] == ''): if(sao3 ['InstanceOfSubclass'] == ''):
sao3 ['InstanceOfSubclass'] = [] sao3 ['InstanceOfSubclass'] = []
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment }) sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
...@@ -161,15 +194,17 @@ class MainChoicesAPIView(APIView): ...@@ -161,15 +194,17 @@ class MainChoicesAPIView(APIView):
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment }) sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
if (flag == 1): if (flag == 1):
if(sao2 ['Instance_of_Class'] == ''): if(sao2 ['Instance_of_Class'] == ''):
print('sao2')
sao2 ['Instance_of_Class'] = [] sao2 ['Instance_of_Class'] = []
sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment }) sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment })
else: else:
sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment }) sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment })
if(flag==0): if(flag==0):
sao['GeneralInstances'].append({"Instance": es_instance[1].strip(), "Comment": comment }) sao['GeneralInstances'].append({"Instance": es_instance[1].strip(), "Comment": comment })
print('aaaaaaaaaaaaaaaaa', flag)
tempDict.append(sao) tempDict.append(sao)
Dictdata.update(Dictionary_Data= tempDict) Dictdata.update(Dictionary_Data= tempDict)
if(len(es_instance) == 2):
instance=es_instance[0] +': ' + instance
if (es_instance[0].strip() == 'System'): if (es_instance[0].strip() == 'System'):
m = data.values('system_choices')[0]['system_choices'][:-1] m = data.values('system_choices')[0]['system_choices'][:-1]
if (len(m) ==1 ): if (len(m) ==1 ):
...@@ -204,13 +239,12 @@ class MainChoicesAPIView(APIView): ...@@ -204,13 +239,12 @@ class MainChoicesAPIView(APIView):
return HttpResponse('Update Instance') return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Flow'): if (es_instance[0].strip() == 'Flow'):
m = data.values('flow_choices')[0]['flow_choices'][:-1] m = data.values('flow_choices')[0]['flow_choices'][:-1]
print('data',m)
if (len(m) ==1 ): if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']' m+= '["'+instance+'","'+instance+'"]'+']'
else : else :
m+= ',["'+instance+'","'+instance+'"]'+']' m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(flow_choices = str(m))
print(m) print(m)
data.update(flow_choices = str(m))
return HttpResponse('Update Instance') return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'State'): if (es_instance[0].strip() == 'State'):
m = data.values('state_choices')[0]['state_choices'][:-1] m = data.values('state_choices')[0]['state_choices'][:-1]
...@@ -236,6 +270,14 @@ class MainChoicesAPIView(APIView): ...@@ -236,6 +270,14 @@ class MainChoicesAPIView(APIView):
m+= ',["'+instance+'","'+instance+'"]'+']' m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(state_value_choices = str(m)) data.update(state_value_choices = str(m))
return HttpResponse('Update Instance') return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Connection'):
m = data.values('connection_choices')[0]['connection_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(connection_choices = str(m))
return HttpResponse('Update Instance')
...@@ -248,6 +290,13 @@ class MainChoicesAPIView(APIView): ...@@ -248,6 +290,13 @@ class MainChoicesAPIView(APIView):
raise APIException("There is no file for instances") raise APIException("There is no file for instances")
def getClassontologyfile(self, g, es_instance): def getClassontologyfile(self, g, es_instance):
if(len(es_instance) == 2 ):
for ns_prefix, namespace in g.namespaces():
for s, p, o in g.triples((URIRef( 'http://delab.csd.auth.gr/ontologies/2018/SAO#'+ es_instance[len(es_instance)-2].strip() ) ,None, None)):
print(p,s)
return URIRef( 'http://delab.csd.auth.gr/ontologies/2018/SAO#'+ es_instance[len(es_instance)-2].strip() )
raise APIException("There is no Class in the Ontology ")
else:
for ns_prefix, namespace in g.namespaces(): 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)): 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() ) return URIRef( namespace+ es_instance[len(es_instance)-2].strip() )
...@@ -257,6 +306,7 @@ class MainChoicesAPIView(APIView): ...@@ -257,6 +306,7 @@ class MainChoicesAPIView(APIView):
class ShallChoicesViewSet(APIView): class ShallChoicesViewSet(APIView):
def get(self, request): def get(self, request):
......
...@@ -14,8 +14,8 @@ from reqman.apps.reqtool.rest_api.services import fuseki ...@@ -14,8 +14,8 @@ from reqman.apps.reqtool.rest_api.services import fuseki
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView
from reqman.apps.reqtool.models.suffix_req import S_CHOICES, NUMBER_UNITS_CHOICES, TIME_UNITS_CHOICES, FLOW_CHOICES #from reqman.apps.reqtool.models.suffix_req import S_CHOICES, NUMBER_UNITS_CHOICES, TIME_UNITS_CHOICES, FLOW_CHOICES
from reqman.apps.reqtool.models.suffix_req import NUMERICAL_AFFIRMATIVE_CHOICES, S2_CHOICES, S3_CHOICES, S4_CHOICES, S5_6_CHOICES #from reqman.apps.reqtool.models.suffix_req import NUMERICAL_AFFIRMATIVE_CHOICES, S2_CHOICES, S3_CHOICES, S4_CHOICES, S5_6_CHOICES
from reqman.apps.reqtool.models.requirements import BoilerplateData from reqman.apps.reqtool.models.requirements import BoilerplateData
...@@ -77,42 +77,6 @@ class SuffixDetailsAPIView(RetrieveUpdateDestroyAPIView): ...@@ -77,42 +77,6 @@ class SuffixDetailsAPIView(RetrieveUpdateDestroyAPIView):
instance.delete() instance.delete()
def getclassofsuffix(self, suffix): def getclassofsuffix(self, suffix):
for sys in NUMERICAL_AFFIRMATIVE_CHOICES:
if sys[0] == suffix:
return ("S1") return ("S1")
for sys in S2_CHOICES:
if sys[0] == suffix:
return ("S2")
for sys in S3_CHOICES:
if sys[0] == suffix:
return ("S3")
for sys in S4_CHOICES:
if sys[0] == suffix:
return ("S4")
#special case only one option for S5, S6
if S5_6_CHOICES[0][0] == suffix:
return ("S5")
if S5_6_CHOICES[1][0] == suffix:
return ("S6")
class SuffixChoicesViewSet(APIView):
def get(self, request):
response = Response(S_CHOICES)
return response
class NumChoicesViewSet(APIView):
def get(self, request):
response = Response(NUMBER_UNITS_CHOICES+TIME_UNITS_CHOICES)
return response
class FlowChoicesViewSet(APIView):
def get(self, request):
response = Response(FLOW_CHOICES)
return response
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