Commit a250d052 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

Instances with automated requirements

parent 7c0f0c79
...@@ -113,31 +113,31 @@ ...@@ -113,31 +113,31 @@
</mat-expansion-panel-header> </mat-expansion-panel-header>
<p>Details : {{item.explanation}}</p> <p>Details : {{item.explanation}}</p>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
</div> </div>
<mat-accordion> <mat-accordion>
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title>
Find triples Find triples
</mat-panel-title> </mat-panel-title>
<mat-panel-description> <mat-panel-description>
<h5>You can search the information that is in the DSOs for a specifix input</h5> <h5>You can search the information that is in the DSOs for a specifix input</h5>
</mat-panel-description> </mat-panel-description>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div class="list row"> <div class="list row">
<input fxFlex fxLayout fxHide.xs class="form-control" type="text" name="search" <input fxFlex fxLayout fxHide.xs class="form-control" type="text" name="search"
[(ngModel)]="searchTextinstances" autocomplete="off" [(ngModel)]="searchTextinstances" autocomplete="off"
placeholder="Searching for properties about an Class/Instance in the DSO."> placeholder="Searching for properties about an Class/Instance in the DSO.">
<button fxLayout fxLayoutGap="15px" (click)="searchInstance()" class="btn btn-success">Search</button> <button fxLayout fxLayoutGap="15px" (click)="searchInstance()" class="btn btn-success">Search</button>
</div> </div>
<p [innerHTML]="searchInstance_list"></p> <p [innerHTML]="searchInstance_list"></p>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
</mat-tab> </mat-tab>
</div> </div>
<mat-tab label={{section.Name}}> <mat-tab label={{section.Name}}>
...@@ -163,15 +163,24 @@ ...@@ -163,15 +163,24 @@
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title class="d-flex justify-content-between">
{{instan.Instance}} <span div fxLayout="row" fxLayoutAlign="space-around center">{{instan.Instance}}</span>
<div style="margin-bottom: 4px;">
<button
*ngIf="section.Name == 'Function' || section.Name == 'System' || section.Name == 'Item'"
mat-mini-fab color="primary" style="margin-right: 8px;"
(click)="openInstanceDialog(instan.Instance, section.Name, item.Class, '', '', '', '')">
<mat-icon>add</mat-icon>
</button>
<button mat-mini-fab color="warn"
(click)="deleteInstance(section.Name , item.Class, '', '', '', '', instan.Instance, instan.Comment)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div fxLayout="column"> <div fxLayout="column">
<p fxFlex fxHide.xs>{{instan.Comment}}</p> <p fxFlex fxHide.xs>{{instan.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, '', '', '', '', instan.Instance, instan.Comment)" />
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</li> </li>
...@@ -236,16 +245,26 @@ ...@@ -236,16 +245,26 @@
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title class="d-flex justify-content-between">
{{ subsubsubsubinstansub.Instance}} <span div fxLayout="row"
</mat-panel-title> fxLayoutAlign="space-around center">{{subsubsubsubinstansub.Instance}}</span>
<div style="margin-bottom: 4px;">
<button
*ngIf="section.Name == 'Function' || section.Name == 'System' || section.Name == 'Item' "
mat-mini-fab color="primary" style="margin-right: 8px;"
(click)="openInstanceDialog(subsubsubsubinstansub.Instance, section.Name, item.Class, sub.SubClass_name, subsub.SubSubClass_name, subsubsub.SubSubClass_name, subsubsubsub.SubSubClass_name)">
<mat-icon>add</mat-icon>
</button>
<button mat-mini-fab color="warn"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , subsubsub.SubSubClass_name, subsubsubsub.SubSubClass_name, subsubsubsubinstansub.Instance, subsubsubsubinstansub.Comment)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div fxLayout="column"> <div fxLayout="column">
<p fxFlex fxHide.xs>{{subsubsubsubinstansub.Comment}}</p> <p fxFlex fxHide.xs>{{subsubsubsubinstansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , subsubsub.SubSubClass_name, subsubsubsub.SubSubClass_name, subsubsubsubinstansub.Instance, subsubsubsubinstansub.Comment)" />
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</li> </li>
...@@ -263,15 +282,25 @@ ...@@ -263,15 +282,25 @@
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title class="d-flex justify-content-between">
{{ subsubsubinstansub.Instance}} <span div fxLayout="row"
fxLayoutAlign="space-around center">{{subsubsubinstansub.Instance}}</span>
<div style="margin-bottom: 4px;">
<button
*ngIf="section.Name == 'Function' || section.Name == 'System' || section.Name == 'Item' "
mat-mini-fab color="primary" style="margin-right: 8px;"
(click)="openInstanceDialog(subsubsubinstansub.Instance, section.Name, item.Class, sub.SubClass_name, subsub.SubSubClass_name, subsubsub.SubSubClass_name, '')">
<mat-icon>add</mat-icon>
</button>
<button mat-mini-fab color="warn"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , subsubsub.SubSubClass_name, '', subsubsubinstansub.Instance, subsubsubinstansub.Comment)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div fxLayout="column"> <div fxLayout="column">
<p fxFlex fxHide.xs>{{subsubsubinstansub.Comment}}</p> <p fxFlex fxHide.xs>{{subsubsubinstansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , subsubsub.SubSubClass_name, '', subsubsubinstansub.Instance, subsubsubinstansub.Comment)" />
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</li> </li>
...@@ -289,15 +318,24 @@ ...@@ -289,15 +318,24 @@
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title class="d-flex justify-content-between">
{{ subsubinstansub.Instance}} <span div fxLayout="row" fxLayoutAlign="space-around center">{{subsubinstansub.Instance}}</span>
<div style="margin-bottom: 4px;">
<button
*ngIf="section.Name == 'Function' || section.Name == 'System' || section.Name == 'Item' "
mat-mini-fab color="primary" style="margin-right: 8px;"
(click)="openInstanceDialog(subsubinstansub.Instance, section.Name, item.Class, sub.SubClass_name, subsub.SubSubClass_name, '', '')">
<mat-icon>add</mat-icon>
</button>
<button mat-mini-fab color="warn"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , '', '', subsubinstansub.Instance, subsubinstansub.Comment)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div fxLayout="column"> <div fxLayout="column">
<p fxFlex fxHide.xs>{{subsubinstansub.Comment}}</p> <p fxFlex fxHide.xs>{{subsubinstansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , '', '', subsubinstansub.Instance, subsubinstansub.Comment)" />
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</li> </li>
...@@ -316,19 +354,27 @@ ...@@ -316,19 +354,27 @@
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title class="d-flex justify-content-between">
{{ instansub.Instance}} <span div fxLayout="row" fxLayoutAlign="space-around center">{{instansub.Instance}}</span>
<div style="margin-bottom: 4px;">
<button
*ngIf="section.Name == 'Function' || section.Name == 'System' || section.Name == 'Item' "
mat-mini-fab color="primary" style="margin-right: 8px;"
(click)="openInstanceDialog(instansub.Instance, section.Name, item.Class, sub.SubClass_name, '', '', '')">
<mat-icon>add</mat-icon>
</button>
<button mat-mini-fab color="warn"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, '', '', '', instansub.Instance, instansub.Comment)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div fxLayout="column"> <div fxLayout="column">
<p fxFlex fxHide.xs>{{instansub.Comment}}</p> <p fxFlex fxHide.xs>{{instansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, '', '', '', instansub.Instance, instansub.Comment)" />
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</li> </li>
</div> </div>
</ul> </ul>
</mat-expansion-panel> </mat-expansion-panel>
...@@ -351,10 +397,12 @@ ...@@ -351,10 +397,12 @@
</mat-panel-description> </mat-panel-description>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div class="list row"> <div class="list row">
<input fxFlex fxLayout fxHide.xs class="form-control" type="text" name="search" [(ngModel)]="searchTextinstances" autocomplete="off" <input fxFlex fxLayout fxHide.xs class="form-control" type="text" name="search"
placeholder="Searching for properties about an Class/Instance in the DSO."> [(ngModel)]="searchTextinstances" autocomplete="off"
<button fxLayout fxLayoutGap="15px" (click)="searchInstance()" class="btn btn-success">Search</button></div> placeholder="Searching for properties about an Class/Instance in the DSO.">
<p [innerHTML]="searchInstance_list"></p> <button fxLayout fxLayoutGap="15px" (click)="searchInstance()" class="btn btn-success">Search</button>
</div>
<p [innerHTML]="searchInstance_list"></p>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
<ul> <ul>
...@@ -365,14 +413,23 @@ ...@@ -365,14 +413,23 @@
<li> <li>
<mat-expansion-panel hideToggle> <mat-expansion-panel hideToggle>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title class="d-flex justify-content-between">
{{genin.Instance}} <span div fxLayout="row" fxLayoutAlign="space-around center">{{genin.Instance}}</span>
<div style="margin-bottom: 4px;">
<button *ngIf="section.Name == 'Function' || section.Name == 'System' || section.Name == 'Item' "
mat-mini-fab color="primary" style="margin-right: 8px;"
(click)="openInstanceDialog(genin.Instance, section.Name, '', '', '', '', '')">
<mat-icon>add</mat-icon>
</button>
<button mat-mini-fab color="warn"
(click)="deleteInstance(section.Name , '', '', '' , '', '', genin.Instance, genin.Comment)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div fxLayout="column"> <div fxLayout="column">
<p fxFlex fxHide.xs> {{genin.Comment}}</p> <p fxFlex fxHide.xs> {{genin.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button" value="Delete Instance"
(click)="deleteInstance(section.Name , '', '', '' , '', '', genin.Instance, genin.Comment)" />
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</li> </li>
......
...@@ -74,11 +74,11 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -74,11 +74,11 @@ 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,172 +345,212 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -345,172 +345,212 @@ 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, "_")
} }
if (result.instance) { if (result.instance) {
this.addinstance = section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : '') + ' : ' + result.instance; this.addinstance = section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : '') + ' : ' + result.instance;
//console.log(this.addinstance); //console.log(this.addinstance);
this.mainService.setinstances(this.route.snapshot.params.gb, this.addinstance, (result.comment ? result.comment : " ")) this.mainService.setinstances(this.route.snapshot.params.gb, this.addinstance, (result.comment ? result.comment : " "))
.subscribe( .subscribe(
data => { data => {
this.prefchild.getchoices(this.route.snapshot.params.gb); this.prefchild.getchoices(this.route.snapshot.params.gb);
this.mainchild.getmainchoices(this.route.snapshot.params.gb); this.mainchild.getmainchoices(this.route.snapshot.params.gb);
this.sufchild.getflowchoices(this.route.snapshot.params.gb); this.sufchild.getflowchoices(this.route.snapshot.params.gb);
//console.log(data); //console.log(data);
}, },
error => { error => {
if (error.error.text == 'Update Instance') { if (error.error.text == 'Update Instance') {
this.notifier.notify("success", (JSON.stringify(error.error.text))); this.notifier.notify("success", (JSON.stringify(error.error.text)));
if (this.systems) { if (this.systems) {
this.systems.forEach(function (value) { this.systems.forEach(function (value) {
if (section == value.Name) { if (section == value.Name) {
if (value.TheClasses) { if (value.TheClasses) {
value.TheClasses.forEach(function (value) { value.TheClasses.forEach(function (value) {
if (classes == value.Class) { if (classes == value.Class) {
//UI - Add instance of a Class (e.g instance for System : Vehicle) //UI - Add instance of a Class (e.g instance for System : Vehicle)
if (!subclass && !subsubclass) { if (!subclass && !subsubclass) {
if (value.Instance_of_Class) { if (value.Instance_of_Class) {
value.Instance_of_Class.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) value.Instance_of_Class.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
}
else {
value.Instance_of_Class = [];
value.Instance_of_Class.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
}
} }
//UI - Add instance of a SubClass (e.g instance for System : Software : Plan) else {
if (subclass && !subsubclass) { value.Instance_of_Class = [];
if (value.Subclass) { value.Instance_of_Class.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
value.Subclass.forEach(function (value) { }
if (subclass == value.SubClass_name) { }
//console.log('Add instance of a SubClass', value.InstanceOfSubclass); //UI - Add instance of a SubClass (e.g instance for System : Software : Plan)
if (subclass && !subsubclass) {
if (value.InstanceOfSubclass) { if (value.Subclass) {
value.InstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) value.Subclass.forEach(function (value) {
} if (subclass == value.SubClass_name) {
else { //console.log('Add instance of a SubClass', value.InstanceOfSubclass);
value.InstanceOfSubclass = [];
value.InstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) if (value.InstanceOfSubclass) {
} value.InstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
} }
}) else {
} value.InstanceOfSubclass = [];
value.InstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
}
}
})
} }
if (subsubclass && !subsubsubclass) { }
if (value.Subclass) { if (subsubclass && !subsubsubclass) {
value.Subclass.forEach(function (value) { if (value.Subclass) {
if (subclass == value.SubClass_name) { value.Subclass.forEach(function (value) {
if (value.SubSubClass) { if (subclass == value.SubClass_name) {
value.SubSubClass.forEach(function (value1) { if (value.SubSubClass) {
if (value1.SubSubClass_name == subsubclass) { value.SubSubClass.forEach(function (value1) {
if (value1.SubInstanceOfSubclass) { if (value1.SubSubClass_name == subsubclass) {
value1.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) if (value1.SubInstanceOfSubclass) {
} else { value1.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
value1.SubInstanceOfSubclass = []; } else {
value1.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) value1.SubInstanceOfSubclass = [];
} value1.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
} }
}) }
} })
} }
}) }
} })
} }
if (subsubsubclass && !subsubsubsubclass) { }
if (value.Subclass) { if (subsubsubclass && !subsubsubsubclass) {
value.Subclass.forEach(function (value) { if (value.Subclass) {
if (subclass == value.SubClass_name) { value.Subclass.forEach(function (value) {
if (value.SubSubClass) { if (subclass == value.SubClass_name) {
value.SubSubClass.forEach(function (value1) { if (value.SubSubClass) {
if (value1.SubSubClass_name == subsubclass) { value.SubSubClass.forEach(function (value1) {
if (value1.SubSubClass) { if (value1.SubSubClass_name == subsubclass) {
value1.SubSubClass.forEach(function (value2) { if (value1.SubSubClass) {
if (value2.SubSubClass_name == subsubsubclass) { value1.SubSubClass.forEach(function (value2) {
if (value2.SubInstanceOfSubclass) { if (value2.SubSubClass_name == subsubsubclass) {
value2.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) if (value2.SubInstanceOfSubclass) {
} else { value2.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
value2.SubInstanceOfSubclass = []; } else {
value2.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) value2.SubInstanceOfSubclass = [];
} value2.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
} }
}
}) })
}
} }
})
} }
})
} }
}) }
} })
} }
if (subsubsubsubclass) { }
if (value.Subclass) { if (subsubsubsubclass) {
value.Subclass.forEach(function (value) { if (value.Subclass) {
if (subclass == value.SubClass_name) { value.Subclass.forEach(function (value) {
if (value.SubSubClass) { if (subclass == value.SubClass_name) {
value.SubSubClass.forEach(function (value1) { if (value.SubSubClass) {
if (value1.SubSubClass_name == subsubclass) { value.SubSubClass.forEach(function (value1) {
if (value1.SubSubClass) { if (value1.SubSubClass_name == subsubclass) {
value1.SubSubClass.forEach(function (value2) { if (value1.SubSubClass) {
if (value2.SubSubClass_name == subsubsubclass) { value1.SubSubClass.forEach(function (value2) {
if (value2.SubSubClass) { if (value2.SubSubClass_name == subsubsubclass) {
value2.SubSubClass.forEach(function (value3) { if (value2.SubSubClass) {
if (value3.SubSubClass_name == subsubsubsubclass) { value2.SubSubClass.forEach(function (value3) {
if (value3.SubInstanceOfSubclass) { if (value3.SubSubClass_name == subsubsubsubclass) {
value3.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) if (value3.SubInstanceOfSubclass) {
} else { value3.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
value3.SubInstanceOfSubclass = []; } else {
value3.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) value3.SubInstanceOfSubclass = [];
} value3.SubInstanceOfSubclass.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " })
} }
}) }
} })
} }
}) }
} })
} }
}) }
} })
} }
}) }
} })
} }
} }
}); }
} });
if (!classes) {
if (value.GeneralInstances) { value.GeneralInstances.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) }
else { value.GeneralInstances = []; value.GeneralInstances.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }); }
}
} }
}) if (!classes) {
if (value.GeneralInstances) { value.GeneralInstances.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }) }
else { value.GeneralInstances = []; value.GeneralInstances.push({ "Instance": result.instance, "Comment": result.comment ? result.comment : " " }); }
}
}
})
}
if (this.prefchild) { this.prefchild.getchoices(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); }
//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))); } })
} }
if (this.prefchild) { this.prefchild.getchoices(this.route.snapshot.params.gb); } }
if (this.mainchild) { this.mainchild.getmainchoices(this.route.snapshot.params.gb); } } else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); }
if (this.sufchild) { this.sufchild.getflowchoices(this.route.snapshot.params.gb); } });
} else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); } //this.ngOnInit();
}); //Call to update instances
//this.ngOnInit();
//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.' },
......
...@@ -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