Commit a250d052 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

Instances with automated requirements

parent 7c0f0c79
......@@ -25,10 +25,10 @@
</ul>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<div>
<input class="btn btn-info" [disabled]="exporting" type="button" value="Download"
(click)="getCurrentOntology()" />
</div>
<div>
<input class="btn btn-info" [disabled]="exporting" type="button" value="Download"
(click)="getCurrentOntology()" />
</div>
</div>
</div>
......@@ -38,6 +38,20 @@
</div>
<div 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 -->
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> No. </th>
......@@ -68,16 +82,17 @@
<td mat-cell *matCellDef="let element"> {{element.suffix_data}} </td>
</ng-container>
<!-- Action Column -->
<!--
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef> Action </th>
<td mat-cell *matCellDef="let element" class="action-link">
<a class="btn btn-info" routerLink="details/{{element.boilerplate_data_id}}">Edit</a>
</td>
</ng-container>
</ng-container>Action Column -->
<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>
<mat-paginator #paginator [pageSizeOptions]="[20, 50]" showFirstLastButtons></mat-paginator>
</div>
......
.list {
text-align: left;
max-width: 750px;
margin: auto;
}
table {
width: 100%;
}
.example-card {
width: auto;
height: auto;
margin-right: 5px;
}
\ No newline at end of file
text-align: left;
max-width: 750px;
margin: auto;
}
table {
width: 100%;
}
.example-card {
width: auto;
height: auto;
margin-right: 5px;
}
.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';
import { MatPaginator } from '@angular/material/paginator';
import { EChartsOption } from 'echarts';
import { NotifierService } from "angular-notifier";
import { SelectionModel } from '@angular/cdk/collections';
......@@ -53,8 +54,8 @@ export class BoilerplateListComponent implements OnInit {
}
currentIndex = -1;
title = '';
displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix', 'action'];
newdisplayedColumns: string[] = ['id', 'title_data', 'prefix_data', 'main_data', 'suffix_data', 'action'];
displayedColumns: string[] = ['id', 'title', 'has_prefix', 'has_main', 'has_suffix'];
newdisplayedColumns: string[] = ['select', 'id', 'title_data', 'prefix_data', 'main_data', 'suffix_data'];
dataSource: Boilerplate[] = [{}];
thenewdataSource: BoilerplateData[] = [{}];
newdataSource = new MatTableDataSource(this.thenewdataSource);
......@@ -62,6 +63,8 @@ export class BoilerplateListComponent implements OnInit {
//when inference button is pressed
showSpinner = false;
exporting = false;
selection = new SelectionModel<Boilerplate>(true, []);
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement", "InconsistentRequirement", "NoisyRequirement", "OpaqueRequirement", "RedundantRequirement"]
......@@ -87,13 +90,13 @@ export class BoilerplateListComponent implements OnInit {
getCurrentOntology(): void {
this.boilerplateService.getCurrentOntolgies(this.route.snapshot.params.gb)
.subscribe(res => {
var url= window.URL.createObjectURL(res);
window.open(url);
},
error => {
this.notifier.notify("warning", 'Fail to download ontology file');
});
.subscribe(res => {
var url = window.URL.createObjectURL(res);
window.open(url);
},
error => {
this.notifier.notify("warning", 'Fail to download ontology file');
});
}
......@@ -235,9 +238,24 @@ export class BoilerplateListComponent implements OnInit {
}
getincreq(): any {
if(this.get_metrics('IncompleteRequirement').length>0){
return this.get_metrics('IncompleteRequirement').length;}
if (this.get_metrics('IncompleteRequirement').length > 0) {
return this.get_metrics('IncompleteRequirement').length;
}
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>
<mat-divider></mat-divider>
<div mat-dialog-content>
<mat-form-field appearance="fill">
<mat-label>Instance name</mat-label>
<input matInput required [(ngModel)]="data.instance">
</mat-form-field>
<div *ngIf="!data.isInstance && data.currentSection !== 'StateValue'" class="text-center" 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 mat-dialog-content>
<mat-form-field appearance="fill">
<mat-label>Instance comment</mat-label>
<textarea matInput required [(ngModel)]="data.comment" ></textarea>
</mat-form-field>
<div *ngIf="data.isInstance">
<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" *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 mat-dialog-actions>
<button mat-button (click)="onNoClick()">Cancel</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 {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 {
comment: string;
instance: string;
name?: string;
isInstance?: boolean;
currentInstance?: any,
currentSection?: any,
selectedValue?: any,
}
@Component({
......@@ -13,14 +18,18 @@ export interface DialogData {
styleUrls: ['./course-dialog-component.component.scss']
})
export class CourseDialogComponentComponent implements OnInit {
stateSet = statesetfordialog;
//selectedValue?: string;
constructor(
public dialogRef: MatDialogRef<CourseDialogComponentComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogData,) {}
@Inject(MAT_DIALOG_DATA) public data: DialogData,) { }
ngOnInit(): void {}
ngOnInit(): void { }
onNoClick(): void {
this.dialogRef.close();
}
......
......@@ -8,11 +8,14 @@ import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier";
export const statesetfordialog: string[] = [];
@Component({
selector: 'app-main-details',
templateUrl: './main-details.component.html',
styleUrls: ['./main-details.component.scss']
})
export class MainDetailsComponent implements OnInit {
mainsyntax = [
{ Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: [] }];
......@@ -89,7 +92,7 @@ export class MainDetailsComponent implements OnInit {
};
message = '';
main = '';
color_badge='danger'
color_badge = 'danger'
constructor(
private mainService: MainService,
......@@ -142,7 +145,7 @@ export class MainDetailsComponent implements OnInit {
}
ngDoCheck() {
this.color_badge='danger'
this.color_badge = 'danger'
this.dis();
}
......@@ -175,7 +178,7 @@ export class MainDetailsComponent implements OnInit {
//add the connection data
}
this.main = this.mainsyntax[x].Id
this.color_badge='success'
this.color_badge = 'success'
return 1;
}
}
......@@ -301,6 +304,7 @@ export class MainDetailsComponent implements OnInit {
this.getfifuintsysstatset(JSON.parse(data[0].system_choices));
this.getfifuintsysstatset(JSON.parse(data[0].state_choices));
this.getfifuintsysstatset(JSON.parse(data[0].state_set_choices));
this.getfordialog(JSON.parse(data[0].state_set_choices));
//stsysconset
this.getstsysconset(JSON.parse(data[0].state_set_choices));
this.getstsysconset(JSON.parse(data[0].system_choices));
......@@ -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 {
this.mainService.getmainsyntax(id)
.subscribe(
......
......@@ -170,6 +170,11 @@ export class MainService {
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> {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/delete`+`/${instance}`+`/${comment}/`);
}
......
......@@ -38,6 +38,7 @@ urlpatterns = [
#MAIN CHOICES DATA
path('groupboilerplates/<int:groupboil>/main/choices/', main_req_views.MainChoicesViewSet.as_view(), name='mainchoices'),
path('groupboilerplates/<int:groupboil>/main/choices/add/<str:instance>/<str:comment>/', main_req_views.MainChoicesAPIView.as_view(), name='setmainchoices'),
path('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('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
......
......@@ -174,6 +174,52 @@ class SearchinOntologyAPIView(APIView):
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):
def get(self, request, groupboil, instance, comment, format=None):
......@@ -213,17 +259,17 @@ class MainChoicesAPIView(APIView):
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 })
break
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 })
break
if(flag == 4):
#print(instance, "Instance", es_instance[5].strip(), "Comment", comment )
if(sao5 ['SubInstanceOfSubclass'] == ''):
......@@ -368,7 +414,17 @@ class DeleteMainChoicesAPIView(APIView):
exist =1
if( exist ==0 ):
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:
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() ) , RDFS.comment , None))
g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle')
......@@ -398,8 +454,8 @@ class DeleteMainChoicesAPIView(APIView):
sao6['SubInstanceOfSubclass'].remove({"Instance": es_instance[6].strip(), "Comment": comment })
if(flag == 4):
sao5['SubInstanceOfSubclass'].remove({"Instance": es_instance[5].strip(), "Comment": comment })
if(flag == 3):
sao4['SubInstanceOfSubclass'].remove({"Instance": es_instance[4].strip(), "Comment": comment })
if(flag == 3):
sao4['SubInstanceOfSubclass'].remove({"Instance": es_instance[4].strip(), "Comment": comment })
# SubSubClass_name
if(flag == 2):
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