Commit a250d052 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

Instances with automated requirements

parent 7c0f0c79
...@@ -74,8 +74,8 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -74,8 +74,8 @@ export class BoilerplateDetailsComponent implements OnInit {
console.log(data); console.log(data);
}, },
error => { error => {
if(error.error.detail){ this.notifier.notify("warning", (JSON.stringify(error.error.detail))); } if (error.error.detail) { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); }
if(error.error.text != 'There is no Class in the Ontology'){ if (error.error.text != 'There is no Class in the Ontology') {
this.searchInstance_list = [error.error.text] this.searchInstance_list = [error.error.text]
//console.log(error.error.text); //console.log(error.error.text);
} }
...@@ -345,18 +345,8 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -345,18 +345,8 @@ export class BoilerplateDetailsComponent implements OnInit {
} }
} }
currentDialog: DialogData = {
instance: "",
comment: "",
}
openDialog(section: any, classes: any, subclass: any, subsubclass: any, subsubsubclass: any, subsubsubsubclass: any) {
const dialogRef = this.dialog.open(CourseDialogComponentComponent, {
width: '500px',
data: { name: section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : ''), instance: this.currentDialog.instance, comment: this.currentDialog.comment },
});
dialogRef.afterClosed().subscribe(result => { addInstance(result: any, section: any, classes: any, subclass: any, subsubclass: any, subsubsubclass: any, subsubsubsubclass: any, isInstance: any, currentInstance: any): void {
if (result.instance != "") { if (result.instance != "") {
result.instance = result.instance?.replace(/[^\w\s]/gi, ' ') result.instance = result.instance?.replace(/[^\w\s]/gi, ' ')
result.instance = result.instance?.replace(/ /g, "_") result.instance = result.instance?.replace(/ /g, "_")
...@@ -502,15 +492,65 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -502,15 +492,65 @@ export class BoilerplateDetailsComponent implements OnInit {
if (this.prefchild) { this.prefchild.getchoices(this.route.snapshot.params.gb); } if (this.prefchild) { this.prefchild.getchoices(this.route.snapshot.params.gb); }
if (this.mainchild) { this.mainchild.getmainchoices(this.route.snapshot.params.gb); } if (this.mainchild) { this.mainchild.getmainchoices(this.route.snapshot.params.gb); }
if (this.sufchild) { this.sufchild.getflowchoices(this.route.snapshot.params.gb); } if (this.sufchild) { this.sufchild.getflowchoices(this.route.snapshot.params.gb); }
//write requirements in the ontology (invokation, contain, belongsTo)
if (isInstance) {
this.mainService.setsecondaryrequirement(this.route.snapshot.params.gb, section, currentInstance, result.instance, " ").subscribe(
data => { },
error => { if (error.error.text == 'Update Instance') { } else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); } })
}
if (result.selectedValue) {
{
this.mainService.setsecondaryrequirement(this.route.snapshot.params.gb, section, result.instance, result.selectedValue, " ").subscribe(
data => { },
error => { if (error.error.text == 'Update Instance') { } else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); } })
}
}
} else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); } } else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); }
}); });
//this.ngOnInit(); //this.ngOnInit();
//Call to update instances //Call to update instances
} }
}
currentDialog: DialogData = {
instance: "",
comment: "",
}
openDialog(section: any, classes: any, subclass: any, subsubclass: any, subsubsubclass: any, subsubsubsubclass: any) {
const dialogRef = this.dialog.open(CourseDialogComponentComponent, {
width: ((section == 'StateValue') ? '60%' : 'auto'),
data: {
name: section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : ''), instance: this.currentDialog.instance, comment: this.currentDialog.comment,
isInstance: false, currentInstance: "", currentSection: section
},
});
dialogRef.afterClosed().subscribe(result => {
this.addInstance(result, section, classes, subclass, subsubclass, subsubsubclass, subsubsubsubclass, false, "")
});
}
openInstanceDialog(currentInstance: any, section: any, classes: any, subclass: any, subsubclass: any, subsubsubclass: any, subsubsubsubclass: any) {
const dialogRef = this.dialog.open(CourseDialogComponentComponent, {
width: '60%',
data: {
name: section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : ''), instance: this.currentDialog.instance, comment: this.currentDialog.comment,
isInstance: true, currentInstance: currentInstance, currentSection: section
},
});
dialogRef.afterClosed().subscribe(result => {
this.addInstance(result, section, classes, subclass, subsubclass, subsubsubclass, subsubsubsubclass, true, currentInstance)
}); });
} }
prefixs = [ prefixs = [
{ name: 'P1', details: "If/Unless <logical expression>", explanation: 'Expresses a logical condition. Paraphrases: in case, provided that, on condition that.' }, { name: 'P1', details: "If/Unless <logical expression>", explanation: 'Expresses a logical condition. Paraphrases: in case, provided that, on condition that.' },
{ name: 'P2', details: "As soon as <occuring functionality>", explanation: 'Expresses a temporal stimulation concerned with the point in time of an completed occuring functionality. Paraphrases: in the moment, immediately, once.' }, { name: 'P2', details: "As soon as <occuring functionality>", explanation: 'Expresses a temporal stimulation concerned with the point in time of an completed occuring functionality. Paraphrases: in the moment, immediately, once.' },
......
...@@ -38,6 +38,20 @@ ...@@ -38,6 +38,20 @@
</div> </div>
<div class="mat-elevation-z8"> <div class="mat-elevation-z8">
<table mat-table [dataSource]="newdataSource" class="mat-elevation-z8"> <table mat-table [dataSource]="newdataSource" class="mat-elevation-z8">
<!-- Checkbox Column -->
<ng-container matColumnDef="select">
<th mat-header-cell *matHeaderCellDef>
<mat-checkbox style="margin-top: 8px; margin-right:8px;" (change)="$event ? masterToggle() : null"
[checked]="selection.hasValue() && isAllSelected()"
[indeterminate]="selection.hasValue() && !isAllSelected()">
</mat-checkbox>
</th>
<td mat-cell *matCellDef="let row">
<mat-checkbox (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null"
[checked]="selection.isSelected(row)">
</mat-checkbox>
</td>
</ng-container>
<!-- Position Column --> <!-- Position Column -->
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> No. </th> <th mat-header-cell *matHeaderCellDef> No. </th>
...@@ -68,16 +82,17 @@ ...@@ -68,16 +82,17 @@
<td mat-cell *matCellDef="let element"> {{element.suffix_data}} </td> <td mat-cell *matCellDef="let element"> {{element.suffix_data}} </td>
</ng-container> </ng-container>
<!-- Action Column --> <!--
<ng-container matColumnDef="action"> <ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef> Action </th> <th mat-header-cell *matHeaderCellDef> Action </th>
<td mat-cell *matCellDef="let element" class="action-link"> <td mat-cell *matCellDef="let element" class="action-link">
<a class="btn btn-info" routerLink="details/{{element.boilerplate_data_id}}">Edit</a> <a class="btn btn-info" routerLink="details/{{element.boilerplate_data_id}}">Edit</a>
</td> </td>
</ng-container> </ng-container>Action Column -->
<tr mat-header-row *matHeaderRowDef="newdisplayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="newdisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: newdisplayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: newdisplayedColumns;" routerLink="details/{{row.boilerplate_data_id}}">
</tr>
</table> </table>
<mat-paginator #paginator [pageSizeOptions]="[20, 50]" showFirstLastButtons></mat-paginator> <mat-paginator #paginator [pageSizeOptions]="[20, 50]" showFirstLastButtons></mat-paginator>
</div> </div>
......
...@@ -2,13 +2,26 @@ ...@@ -2,13 +2,26 @@
text-align: left; text-align: left;
max-width: 750px; max-width: 750px;
margin: auto; margin: auto;
} }
table { table {
width: 100%; width: 100%;
} }
.example-card {
.example-card {
width: auto; width: auto;
height: auto; height: auto;
margin-right: 5px; margin-right: 5px;
} }
\ No newline at end of file
.demo-table {
width: 100%;
}
.mat-row .mat-cell {
cursor: pointer;
}
.mat-row:hover .mat-cell {
border-color: currentColor;
}
\ No newline at end of file
...@@ -9,6 +9,7 @@ import { MatTableDataSource } from '@angular/material/table'; ...@@ -9,6 +9,7 @@ import { MatTableDataSource } from '@angular/material/table';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { EChartsOption } from 'echarts'; import { EChartsOption } from 'echarts';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
import { SelectionModel } from '@angular/cdk/collections';
...@@ -53,8 +54,8 @@ export class BoilerplateListComponent implements OnInit { ...@@ -53,8 +54,8 @@ export class BoilerplateListComponent implements OnInit {
} }
currentIndex = -1; currentIndex = -1;
title = ''; title = '';
displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix', 'action']; displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix'];
newdisplayedColumns: string[] = ['id', 'title_data', 'prefix_data', 'main_data', 'suffix_data', 'action']; newdisplayedColumns: string[] = ['select', 'id', 'title_data', 'prefix_data', 'main_data', 'suffix_data'];
dataSource: Boilerplate[] = [{}]; dataSource: Boilerplate[] = [{}];
thenewdataSource: BoilerplateData[] = [{}]; thenewdataSource: BoilerplateData[] = [{}];
newdataSource = new MatTableDataSource(this.thenewdataSource); newdataSource = new MatTableDataSource(this.thenewdataSource);
...@@ -62,6 +63,8 @@ export class BoilerplateListComponent implements OnInit { ...@@ -62,6 +63,8 @@ export class BoilerplateListComponent implements OnInit {
//when inference button is pressed //when inference button is pressed
showSpinner = false; showSpinner = false;
exporting = false; exporting = false;
selection = new SelectionModel<Boilerplate>(true, []);
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement", "InconsistentRequirement", "NoisyRequirement", "OpaqueRequirement", "RedundantRequirement"] list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement", "InconsistentRequirement", "NoisyRequirement", "OpaqueRequirement", "RedundantRequirement"]
...@@ -88,7 +91,7 @@ export class BoilerplateListComponent implements OnInit { ...@@ -88,7 +91,7 @@ export class BoilerplateListComponent implements OnInit {
getCurrentOntology(): void { getCurrentOntology(): void {
this.boilerplateService.getCurrentOntolgies(this.route.snapshot.params.gb) this.boilerplateService.getCurrentOntolgies(this.route.snapshot.params.gb)
.subscribe(res => { .subscribe(res => {
var url= window.URL.createObjectURL(res); var url = window.URL.createObjectURL(res);
window.open(url); window.open(url);
}, },
error => { error => {
...@@ -235,9 +238,24 @@ export class BoilerplateListComponent implements OnInit { ...@@ -235,9 +238,24 @@ export class BoilerplateListComponent implements OnInit {
} }
getincreq(): any { getincreq(): any {
if(this.get_metrics('IncompleteRequirement').length>0){ if (this.get_metrics('IncompleteRequirement').length > 0) {
return this.get_metrics('IncompleteRequirement').length;} return this.get_metrics('IncompleteRequirement').length;
}
else return 0; else return 0;
} }
/** Whether the number of selected elements matches the total number of rows. */
isAllSelected() {
const numSelected = this.selection.selected.length;
const numRows = this.newdataSource.data.length;
return numSelected === numRows;
}
/** Selects all rows if they are not all selected; otherwise clear selection. */
masterToggle() {
this.isAllSelected() ?
this.selection.clear() :
this.newdataSource.data.forEach(row => this.selection.select(row));
}
} }
<h1 mat-dialog-title>{{data.name}}</h1> <h1 mat-dialog-title>{{data.name}}</h1>
<mat-divider></mat-divider>
<div mat-dialog-content> <div *ngIf="!data.isInstance && data.currentSection !== 'StateValue'" class="text-center" mat-dialog-content>
<div style="margin-top: 8px; ">
<mat-form-field appearance="fill"> <mat-form-field appearance="fill">
<mat-label>Instance name</mat-label> <mat-label>Instance name</mat-label>
<input matInput required [(ngModel)]="data.instance"> <input matInput required [(ngModel)]="data.instance">
</mat-form-field> </mat-form-field>
</div>
<div style="margin-top: 8px;">
<mat-form-field appearance="fill">
<mat-label>Instance comment</mat-label>
<textarea matInput required [(ngModel)]="data.comment"></textarea>
</mat-form-field>
</div>
</div> </div>
<div *ngIf="data.isInstance">
<mat-grid-list cols="2" rowHeight="2:1">
<mat-grid-tile>
<div mat-dialog-content> <div mat-dialog-content>
<div style="margin-top: 8px; ">
<mat-form-field appearance="fill">
<mat-label>Instance name</mat-label>
<input matInput required [(ngModel)]="data.instance">
</mat-form-field>
</div>
<div style="margin-top: 8px;">
<mat-form-field appearance="fill"> <mat-form-field appearance="fill">
<mat-label>Instance comment</mat-label> <mat-label>Instance comment</mat-label>
<textarea matInput required [(ngModel)]="data.comment" ></textarea> <textarea matInput required [(ngModel)]="data.comment"></textarea>
</mat-form-field> </mat-form-field>
</div>
</div>
<div style="margin-left: 100px;">
<mat-divider vertical style="height:250px"></mat-divider>
</div>
</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>
<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>
<h1><u>{{data.currentInstance}} shall contain {{data.instance}}</u></h1>
</div>
</mat-grid-tile>
</mat-grid-list>
</div>
<div *ngIf="data.currentSection === 'StateValue'">
<mat-grid-list cols="2" rowHeight="2:1">
<mat-grid-tile>
<div mat-dialog-content>
<div style="margin-top: 8px; ">
<mat-form-field appearance="fill">
<mat-label>Instance name</mat-label>
<input matInput required [(ngModel)]="data.instance">
</mat-form-field>
</div>
<div style="margin-top: 8px;">
<mat-form-field appearance="fill">
<mat-label>Instance comment</mat-label>
<textarea matInput required [(ngModel)]="data.comment"></textarea>
</mat-form-field>
</div>
</div>
<div style="margin-left: 100px;">
<mat-divider vertical style="height:250px"></mat-divider>
</div>
</mat-grid-tile>
<mat-grid-tile>
<div class="col">
<p>The current instance will add the above requirement 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>
<mat-select [(ngModel)]="data.selectedValue" name="stateset">
<mat-option *ngFor="let stateset of stateSet" [value]="stateset">
{{stateset}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</mat-grid-tile>
</mat-grid-list>
</div> </div>
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-button (click)="onNoClick()">Cancel</button> <button mat-button (click)="onNoClick()">Cancel</button>
<button mat-button [mat-dialog-close]="data" cdkFocusInitial>Add</button> <button mat-button [mat-dialog-close]="data" cdkFocusInitial>Add</button>
</div> </div>
\ No newline at end of file
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { statesetfordialog } from '../main-details/main-details.component';
export interface DialogData { export interface DialogData {
comment: string; comment: string;
instance: string; instance: string;
name?: string; name?: string;
isInstance?: boolean;
currentInstance?: any,
currentSection?: any,
selectedValue?: any,
} }
@Component({ @Component({
...@@ -13,14 +18,18 @@ export interface DialogData { ...@@ -13,14 +18,18 @@ export interface DialogData {
styleUrls: ['./course-dialog-component.component.scss'] styleUrls: ['./course-dialog-component.component.scss']
}) })
export class CourseDialogComponentComponent implements OnInit { export class CourseDialogComponentComponent implements OnInit {
stateSet = statesetfordialog;
//selectedValue?: string;
constructor( constructor(
public dialogRef: MatDialogRef<CourseDialogComponentComponent>, public dialogRef: MatDialogRef<CourseDialogComponentComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogData,) {} @Inject(MAT_DIALOG_DATA) public data: DialogData,) { }
ngOnInit(): void {} ngOnInit(): void { }
onNoClick(): void { onNoClick(): void {
this.dialogRef.close(); this.dialogRef.close();
} }
......
...@@ -8,11 +8,14 @@ import { Observable } from 'rxjs'; ...@@ -8,11 +8,14 @@ import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators'; import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier"; import { NotifierService } from "angular-notifier";
export const statesetfordialog: string[] = [];
@Component({ @Component({
selector: 'app-main-details', selector: 'app-main-details',
templateUrl: './main-details.component.html', templateUrl: './main-details.component.html',
styleUrls: ['./main-details.component.scss'] styleUrls: ['./main-details.component.scss']
}) })
export class MainDetailsComponent implements OnInit { export class MainDetailsComponent implements OnInit {
mainsyntax = [ mainsyntax = [
{ Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: [] }]; { Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: [] }];
...@@ -89,7 +92,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -89,7 +92,7 @@ export class MainDetailsComponent implements OnInit {
}; };
message = ''; message = '';
main = ''; main = '';
color_badge='danger' color_badge = 'danger'
constructor( constructor(
private mainService: MainService, private mainService: MainService,
...@@ -142,7 +145,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -142,7 +145,7 @@ export class MainDetailsComponent implements OnInit {
} }
ngDoCheck() { ngDoCheck() {
this.color_badge='danger' this.color_badge = 'danger'
this.dis(); this.dis();
} }
...@@ -175,7 +178,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -175,7 +178,7 @@ export class MainDetailsComponent implements OnInit {
//add the connection data //add the connection data
} }
this.main = this.mainsyntax[x].Id this.main = this.mainsyntax[x].Id
this.color_badge='success' this.color_badge = 'success'
return 1; return 1;
} }
} }
...@@ -301,6 +304,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -301,6 +304,7 @@ export class MainDetailsComponent implements OnInit {
this.getfifuintsysstatset(JSON.parse(data[0].system_choices)); this.getfifuintsysstatset(JSON.parse(data[0].system_choices));
this.getfifuintsysstatset(JSON.parse(data[0].state_choices)); this.getfifuintsysstatset(JSON.parse(data[0].state_choices));
this.getfifuintsysstatset(JSON.parse(data[0].state_set_choices)); this.getfifuintsysstatset(JSON.parse(data[0].state_set_choices));
this.getfordialog(JSON.parse(data[0].state_set_choices));
//stsysconset //stsysconset
this.getstsysconset(JSON.parse(data[0].state_set_choices)); this.getstsysconset(JSON.parse(data[0].state_set_choices));
this.getstsysconset(JSON.parse(data[0].system_choices)); this.getstsysconset(JSON.parse(data[0].system_choices));
...@@ -380,6 +384,13 @@ export class MainDetailsComponent implements OnInit { ...@@ -380,6 +384,13 @@ export class MainDetailsComponent implements OnInit {
} }
} }
getfordialog(strIntoObj: any): void {
statesetfordialog.length = 0
for (let x = 0; x < strIntoObj.length; x++) {
statesetfordialog.push((strIntoObj[x][1]));
}
}
getchoices(id: string): void { getchoices(id: string): void {
this.mainService.getmainsyntax(id) this.mainService.getmainsyntax(id)
.subscribe( .subscribe(
......
...@@ -170,6 +170,11 @@ export class MainService { ...@@ -170,6 +170,11 @@ export class MainService {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/add`+`/${instance}`+`/${comment}/`); return this.http.get(`${baseUrl2}${gb}`+`/main/choices/add`+`/${instance}`+`/${comment}/`);
} }
setsecondaryrequirement(gb : any,section:any, instance1: any, instance2:any, instance3: any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/addsecondary`+`/${section}`+`/${instance1}`+`/${instance2}`+`/${instance3}/`);
}
deleteinstances(gb : any, instance: any, comment:any): Observable<any> { deleteinstances(gb : any, instance: any, comment:any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/delete`+`/${instance}`+`/${comment}/`); return this.http.get(`${baseUrl2}${gb}`+`/main/choices/delete`+`/${instance}`+`/${comment}/`);
} }
......
...@@ -38,6 +38,7 @@ urlpatterns = [ ...@@ -38,6 +38,7 @@ urlpatterns = [
#MAIN CHOICES DATA #MAIN CHOICES DATA
path('groupboilerplates/<int:groupboil>/main/choices/', main_req_views.MainChoicesViewSet.as_view(), name='mainchoices'), path('groupboilerplates/<int:groupboil>/main/choices/', main_req_views.MainChoicesViewSet.as_view(), name='mainchoices'),
path('groupboilerplates/<int:groupboil>/main/choices/add/<str:instance>/<str:comment>/', main_req_views.MainChoicesAPIView.as_view(), name='setmainchoices'), path('groupboilerplates/<int:groupboil>/main/choices/add/<str:instance>/<str:comment>/', main_req_views.MainChoicesAPIView.as_view(), name='setmainchoices'),
path('groupboilerplates/<int:groupboil>/main/choices/addsecondary/<str:section>/<str:instance1>/<str:instance2>/<str:instance3>/', main_req_views.AddSecondaryRequirementAPIView.as_view(), name='addsecondaryrequirement'),
path('groupboilerplates/<int:groupboil>/main/choices/delete/<str:instance>/<str:comment>/', main_req_views.DeleteMainChoicesAPIView.as_view(), name='deletemainchoices'), path('groupboilerplates/<int:groupboil>/main/choices/delete/<str:instance>/<str:comment>/', main_req_views.DeleteMainChoicesAPIView.as_view(), name='deletemainchoices'),
path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'), path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
......
...@@ -174,6 +174,52 @@ class SearchinOntologyAPIView(APIView): ...@@ -174,6 +174,52 @@ class SearchinOntologyAPIView(APIView):
raise APIException("There is no Class in the Ontology") raise APIException("There is no Class in the Ontology")
class AddSecondaryRequirementAPIView(APIView):
def get(self, request, groupboil, section, instance1, instance2, instance3, format=None):
data = BoilerplateGroupClassesInstances.objects.filter(classes_instances_group_of_boilerplate = groupboil)
Dictdata = BoilerplateGroupDictionary.objects.filter(classes_instances_group_of_boilerplate_dic = groupboil)
g = Graph()
g.load(data.values('ontology_file')[0]['ontology_file'], format="turtle")
per_instances = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#")
rdo = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO#")
sao = URIRef("http://delab.csd.auth.gr/ontologies/2018/SAO#")
rbo = URIRef("http://delab.csd.auth.gr/ontologies/2018/RBO#")
lo = URIRef("http://delab.csd.auth.gr/ontologies/2018/LO-instances#")
#print(section+instance1+instance2)
if (section == 'Function'):
g.add((per_instances + section+instance1+instance2, RDF.type, rdo + 'Requirement'))
g.add((per_instances + section+instance1+instance2, rdo + 'hasMain', per_instances+(section+instance1+instance2+"_M7")))
g.add((per_instances+(section+instance1+instance2+"_M7"), RDF.type, rbo + "M7"))
g.add((per_instances+(section+instance1+instance2+"_M7"), rbo+"isRelatedToSubject", per_instances+instance1))
g.add((per_instances+(section+instance1+instance2+"_M7"), rbo+"isRelatedToFunction", per_instances+instance2))
g.add((per_instances+(section+instance1+instance2+"_M7"), rbo+"isRelatedToAction", lo+"invoke"))
g.serialize(data.values('ontology_file')[0]['ontology_file'], format="turtle")
if (section == 'System'):
g.add((per_instances + section+instance1+instance2, RDF.type, rdo + 'Requirement'))
g.add((per_instances + section+instance1+instance2, rdo + 'hasMain', per_instances+(section+instance1+instance2+"_M16")))
g.add((per_instances+(section+instance1+instance2+"_M16"), RDF.type, rbo + "M16"))
g.add((per_instances+(section+instance1+instance2+"_M16"), rbo+"isRelatedToSubject", per_instances+instance1))
g.add((per_instances+(section+instance1+instance2+"_M16"), rbo+"isRelatedToSystem", per_instances+instance2))
g.add((per_instances+(section+instance1+instance2+"_M16"), rbo+"isRelatedToAction", lo+"contain"))
g.serialize(data.values('ontology_file')[0]['ontology_file'], format="turtle")
if (section == 'StateValue'):
stateset =instance2.rsplit(':')
print(per_instances+(instance1),sao+"belongsTo", per_instances + stateset[len(stateset)-1].strip())
g.add((per_instances+(instance1),sao+"belongsTo", per_instances + stateset[len(stateset)-1].strip()))
g.serialize(data.values('ontology_file')[0]['ontology_file'], format="turtle")
#print(section)
return HttpResponse('Update Instance')
def getClassontologyfile(self, g, es_instance):
for ns_prefix, namespace in g.namespaces():
for s, p, o in g.triples((URIRef( namespace+ es_instance.strip() ) ,None, None)):
return URIRef( namespace+ es_instance.strip() )
raise APIException("There is no Class in the Ontology ")
class MainChoicesAPIView(APIView): class MainChoicesAPIView(APIView):
def get(self, request, groupboil, instance, comment, format=None): def get(self, request, groupboil, instance, comment, format=None):
...@@ -368,7 +414,17 @@ class DeleteMainChoicesAPIView(APIView): ...@@ -368,7 +414,17 @@ class DeleteMainChoicesAPIView(APIView):
exist =1 exist =1
if( exist ==0 ): if( exist ==0 ):
raise APIException("This instance cannot be deleted or it not exists") raise APIException("This instance cannot be deleted or it not exists")
rdodata1=''
for s, p, o in g.triples((None , None, URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#") + es_instance[len(es_instance)-1].strip())):
rdodata1= s
rdodata2=''
for s, p, o in g.triples((None , URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO#") + 'hasMain', rdodata1)):
rdodata2= s
try: try:
if(rdodata1 != ''):
g.remove(( rdodata1 , None, None ))
if(rdodata2 != ''):
g.remove(( rdodata2 , None, None ))
g.remove(( URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , None, None )) g.remove(( URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , None, None ))
g.remove(( URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , RDFS.comment , None)) g.remove(( URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , RDFS.comment , None))
g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle') g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle')
......
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