Commit a250d052 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

Instances with automated requirements

parent 7c0f0c79
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
</ul> </ul>
</div> </div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end"> <div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<div> <div>
<input class="btn btn-info" [disabled]="exporting" type="button" value="Download" <input class="btn btn-info" [disabled]="exporting" type="button" value="Download"
(click)="getCurrentOntology()" /> (click)="getCurrentOntology()" />
</div> </div>
</div> </div>
</div> </div>
...@@ -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>
......
.list { .list {
text-align: left; text-align: left;
max-width: 750px; max-width: 750px;
margin: auto; margin: auto;
} }
table { table {
width: 100%; width: 100%;
} }
.example-card {
width: auto; .example-card {
height: auto; width: auto;
margin-right: 5px; height: auto;
} 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"]
...@@ -87,13 +90,13 @@ export class BoilerplateListComponent implements OnInit { ...@@ -87,13 +90,13 @@ 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 => {
this.notifier.notify("warning", 'Fail to download ontology file'); this.notifier.notify("warning", 'Fail to download ontology file');
}); });
} }
...@@ -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>
<mat-form-field appearance="fill"> <div style="margin-top: 8px; ">
<mat-label>Instance name</mat-label> <mat-form-field appearance="fill">
<input matInput required [(ngModel)]="data.instance"> <mat-label>Instance name</mat-label>
</mat-form-field> <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>
<div mat-dialog-content>
<mat-form-field appearance="fill"> <div *ngIf="data.isInstance">
<mat-label>Instance comment</mat-label> <mat-grid-list cols="2" rowHeight="2:1">
<textarea matInput required [(ngModel)]="data.comment" ></textarea> <mat-grid-tile>
</mat-form-field> <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" *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):
...@@ -213,17 +259,17 @@ class MainChoicesAPIView(APIView): ...@@ -213,17 +259,17 @@ class MainChoicesAPIView(APIView):
flag =3 flag =3
for sao5 in sao4['SubSubClass']: for sao5 in sao4['SubSubClass']:
if es_instance[4] and sao5['SubSubClass_name'] == es_instance[4].strip(): if es_instance[4] and sao5['SubSubClass_name'] == es_instance[4].strip():
flag =4 flag =4
for sao6 in sao5['SubSubClass']: for sao6 in sao5['SubSubClass']:
if es_instance[5] and sao6['SubSubClass_name'] == es_instance[5].strip(): if es_instance[5] and sao6['SubSubClass_name'] == es_instance[5].strip():
flag = 5 flag = 5
if(flag == 5): if(flag == 5):
if(sao6 ['SubInstanceOfSubclass'] == ''): if(sao6 ['SubInstanceOfSubclass'] == ''):
sao6 ['SubInstanceOfSubclass'] = [] sao6 ['SubInstanceOfSubclass'] = []
sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment }) sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment })
else: else:
sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment }) sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment })
break break
if(flag == 4): if(flag == 4):
#print(instance, "Instance", es_instance[5].strip(), "Comment", comment ) #print(instance, "Instance", es_instance[5].strip(), "Comment", comment )
if(sao5 ['SubInstanceOfSubclass'] == ''): if(sao5 ['SubInstanceOfSubclass'] == ''):
...@@ -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')
...@@ -398,8 +454,8 @@ class DeleteMainChoicesAPIView(APIView): ...@@ -398,8 +454,8 @@ class DeleteMainChoicesAPIView(APIView):
sao6['SubInstanceOfSubclass'].remove({"Instance": es_instance[6].strip(), "Comment": comment }) sao6['SubInstanceOfSubclass'].remove({"Instance": es_instance[6].strip(), "Comment": comment })
if(flag == 4): if(flag == 4):
sao5['SubInstanceOfSubclass'].remove({"Instance": es_instance[5].strip(), "Comment": comment }) sao5['SubInstanceOfSubclass'].remove({"Instance": es_instance[5].strip(), "Comment": comment })
if(flag == 3): if(flag == 3):
sao4['SubInstanceOfSubclass'].remove({"Instance": es_instance[4].strip(), "Comment": comment }) sao4['SubInstanceOfSubclass'].remove({"Instance": es_instance[4].strip(), "Comment": comment })
# SubSubClass_name # SubSubClass_name
if(flag == 2): if(flag == 2):
sao3['InstanceOfSubclass'].remove({"Instance": es_instance[3].strip(), "Comment": comment }) sao3['InstanceOfSubclass'].remove({"Instance": es_instance[3].strip(), "Comment": comment })
......
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