Commit a250d052 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

Instances with automated requirements

parent 7c0f0c79
......@@ -163,15 +163,24 @@
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{instan.Instance}}
<mat-panel-title class="d-flex justify-content-between">
<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-expansion-panel-header>
<div fxLayout="column">
<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>
</mat-expansion-panel>
</li>
......@@ -236,16 +245,26 @@
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubsubsubinstansub.Instance}}
</mat-panel-title>
<mat-panel-title class="d-flex justify-content-between">
<span div fxLayout="row"
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>
<div fxLayout="column">
<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>
</mat-expansion-panel>
</li>
......@@ -263,15 +282,25 @@
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubsubinstansub.Instance}}
<mat-panel-title class="d-flex justify-content-between">
<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-expansion-panel-header>
<div fxLayout="column">
<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>
</mat-expansion-panel>
</li>
......@@ -289,15 +318,24 @@
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subsubinstansub.Instance}}
<mat-panel-title class="d-flex justify-content-between">
<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-expansion-panel-header>
<div fxLayout="column">
<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>
</mat-expansion-panel>
</li>
......@@ -316,19 +354,27 @@
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ instansub.Instance}}
<mat-panel-title class="d-flex justify-content-between">
<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-expansion-panel-header>
<div fxLayout="column">
<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>
</mat-expansion-panel>
</li>
</div>
</ul>
</mat-expansion-panel>
......@@ -351,9 +397,11 @@
</mat-panel-description>
</mat-expansion-panel-header>
<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"
[(ngModel)]="searchTextinstances" autocomplete="off"
placeholder="Searching for properties about an Class/Instance in the DSO.">
<button fxLayout fxLayoutGap="15px" (click)="searchInstance()" class="btn btn-success">Search</button></div>
<button fxLayout fxLayoutGap="15px" (click)="searchInstance()" class="btn btn-success">Search</button>
</div>
<p [innerHTML]="searchInstance_list"></p>
</mat-expansion-panel>
</mat-accordion>
......@@ -365,14 +413,23 @@
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{genin.Instance}}
<mat-panel-title class="d-flex justify-content-between">
<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-expansion-panel-header>
<div fxLayout="column">
<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>
</mat-expansion-panel>
</li>
......
......@@ -74,8 +74,8 @@ export class BoilerplateDetailsComponent implements OnInit {
console.log(data);
},
error => {
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.detail) { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); }
if (error.error.text != 'There is no Class in the Ontology') {
this.searchInstance_list = [error.error.text]
//console.log(error.error.text);
}
......@@ -345,18 +345,8 @@ export class BoilerplateDetailsComponent implements OnInit {
}
}
currentDialog: DialogData = {
instance: "",
comment: "",
}
openDialog(section: any, classes: any, subclass: any, subsubclass: any, subsubsubclass: any, subsubsubsubclass: any) {
const dialogRef = this.dialog.open(CourseDialogComponentComponent, {
width: '500px',
data: { name: section + (classes ? ' : ' + classes : '') + (subclass ? ' : ' + subclass : '') + (subsubclass ? ' : ' + subsubclass : '') + (subsubsubclass ? ' : ' + subsubsubclass : '') + (subsubsubsubclass ? ' : ' + subsubsubsubclass : ''), instance: this.currentDialog.instance, comment: this.currentDialog.comment },
});
dialogRef.afterClosed().subscribe(result => {
addInstance(result: any, section: any, classes: any, subclass: any, subsubclass: any, subsubsubclass: any, subsubsubsubclass: any, isInstance: any, currentInstance: any): void {
if (result.instance != "") {
result.instance = result.instance?.replace(/[^\w\s]/gi, ' ')
result.instance = result.instance?.replace(/ /g, "_")
......@@ -502,15 +492,65 @@ export class BoilerplateDetailsComponent implements OnInit {
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))); } })
}
}
} else { this.notifier.notify("warning", (JSON.stringify(error.error.detail))); }
});
//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 = [
{ 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.' },
......
......@@ -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>
......
......@@ -2,13 +2,26 @@
text-align: left;
max-width: 750px;
margin: auto;
}
}
table {
table {
width: 100%;
}
.example-card {
}
.example-card {
width: auto;
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';
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"]
......@@ -88,7 +91,7 @@ export class BoilerplateListComponent implements OnInit {
getCurrentOntology(): void {
this.boilerplateService.getCurrentOntolgies(this.route.snapshot.params.gb)
.subscribe(res => {
var url= window.URL.createObjectURL(res);
var url = window.URL.createObjectURL(res);
window.open(url);
},
error => {
......@@ -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>
<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 *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>
<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>
\ 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):
......@@ -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')
......
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