Commit 30b459f4 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

RFT v0.2.1

parent 0dae831e
<div *ngIf="!LoggedIn()"> <router-outlet></router-outlet> </div>
<div *ngIf="!LoggedIn()">
<router-outlet></router-outlet>
</div>
<div *ngIf="LoggedIn()">
<mat-sidenav-container>
<mat-sidenav #sidenav role="navigation">
<mat-sidenav #sidenav role="navigation">
<app-sidenav-list (sidenavClose)="sidenav.close()"></app-sidenav-list>
</mat-sidenav>
<mat-sidenav-content>
<app-sidenav-list (sidenavClose)="sidenav.close()"></app-sidenav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-sidenav-content>
<app-header (sidenavToggle)="sidenav.toggle()"></app-header>
<main>
<router-outlet></router-outlet>
</main>
<!-- Footer -->
<footer class="footer page-footer font-small ">
<mat-sidenav-content>
<app-header (sidenavToggle)="sidenav.toggle()"></app-header>
<main>
<router-outlet></router-outlet>
</main>
<!-- Footer -->
<footer class="footer page-footer font-small ">
<!-- Copyright -->
<div class="footer-copyright text-center py-3">© 2021 Copyright:
<a href="https://depend.csd.auth.gr/">Depend Research Team</a>
</div>
<!-- Copyright -->
<!-- Copyright -->
<div class="footer-copyright text-center py-3">© 2022 Copyright:
<a href="https://depend.csd.auth.gr/">Depend Research Team</a>
</div>
<!-- Copyright -->
</footer>
<!-- Footer -->
</mat-sidenav-content>
</mat-sidenav-content>
</footer>
<!-- Footer -->
</mat-sidenav-content>
</mat-sidenav-content>
</mat-sidenav-container>
</div>
<notifier-container></notifier-container>
<notifier-container></notifier-container>
\ No newline at end of file
......@@ -35,9 +35,27 @@ import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.
import { InstancesListComponent } from './components/instances-list/instances-list.component';
import { Ng2SearchPipeModule } from 'ng2-search-filter';
import { NgxEchartsModule } from 'ngx-echarts';
import { CourseDialogComponentComponent } from './components/course-dialog-component/course-dialog-component.component';
@NgModule({
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
Ng2SearchPipeModule,
HttpClientModule,
NgbModule,
NotifierModule,
BrowserAnimationsModule,
MaterialModule,
FlexLayoutModule,
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
}),
],
declarations: [
AppComponent,
LoginComponent,
......@@ -57,22 +75,7 @@ import { NgxEchartsModule } from 'ngx-echarts';
GroupboilComponent,
AddGroupboilComponent,
InstancesListComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
ReactiveFormsModule,
FormsModule,
Ng2SearchPipeModule,
HttpClientModule,
NgbModule,
NotifierModule,
BrowserAnimationsModule,
MaterialModule,
FlexLayoutModule,
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
}),
CourseDialogComponentComponent,
],
providers: [
AuthService,
......@@ -83,6 +86,6 @@ import { NgxEchartsModule } from 'ngx-echarts';
multi: true,
},
],
bootstrap: [AppComponent]
bootstrap: [AppComponent],
})
export class AppModule { }
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Boilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
......@@ -26,7 +26,7 @@ export class AddBoilerplateComponent implements OnInit {
constructor(private boilerplatelService: BoilerplateService, private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) {
this.notifier = notifierService;
}
}
ngOnInit(): void {
}
......@@ -41,19 +41,20 @@ export class AddBoilerplateComponent implements OnInit {
};
if (data.title != "") {
data.title = data.title?.replace(/[^\w\s]/gi, ' ')
data.title = data.title?.replace(/ /g,"_")}
data.title = data.title?.replace(/ /g, "_")
}
this.boilerplatelService.create(this.route.snapshot.params.gb, data)
.subscribe(
response => {
this.notifier.notify("success",(JSON.stringify(response)));
this.notifier.notify("success", "Requirement " + this.boilerplate.title + " created");
this.submitted = true;
this.router.navigate(['/groupboilerplates/'+this.route.snapshot.params.gb+'/boilerplates/details/'+response.id]);
this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates/details/' + response.id]);
},
error => {
console.log(error);
//error, warning, success, info, default
this.notifier.notify("warning",(JSON.stringify(error["error"]["title"][0])));
this.notifier.notify("warning", (JSON.stringify(error["error"]["title"][0])));
});
}
......@@ -69,39 +70,39 @@ export class AddBoilerplateComponent implements OnInit {
}
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.'},
{name: 'P3', details: "As long as <occuring functionality>", explanation: 'Expresses a temporal condition concerned with a period. The prefix clause and the main clause take place simultaneously. Paraphrases: meanwhile'},
{ 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: 'P3', details: "As long as <occuring functionality>", explanation: 'Expresses a temporal condition concerned with a period. The prefix clause and the main clause take place simultaneously. Paraphrases: meanwhile' },
];
mains = [
{name: 'M1', details: "system/function shall [not] set [<quantifier>] item [to stateValue]", explanation: 'Sets item Paraphrases: initiate, reset, update.'},
{name: 'M2', details: "system/function shall [not] set state to stateValue", explanation: 'Sets state to value Paraphrases: initiate, reset, update.'},
{name: 'M3', details: "system/function shall [not] send [<quantifier>] item", explanation: 'Sends item Paraphrases: forward.'},
{name: 'M4', details: "system/function shall [not] receive [<quantifier>] item", explanation: 'Receives item Paraphrases: accept, acquire.'},
{name: 'M5', details: "system/function shall [not] ingest flow", explanation: 'Ingests flow. Paraphrases: get.'},
{name: 'M6', details: "system/function shall [not] emit flow", explanation: 'Emits flow. Paraphrases: produce.'},
{name: 'M7', details: "system shall [not] perform function", explanation: 'System requirement. Paraphrases: execute.'},
{name: 'M8', details: "function shall [not] invoke function", explanation: 'Function invokes another function. Paraphrases: call, request'},
{name: 'M9', details: "system shall [not] present interface [to system]", explanation: 'Presents interface. Paraphrases: provide'},
{name: 'M10', details: "system/interface shall [not] transfer flow/item", explanation: 'Transfers TraversingConcept. Paraphrases: transmit, broadcast'},
{name: 'M11', details: "system shall [not] interact with system [using <connection>] [as defined in <text>]", explanation: 'System requirement expressing interface interraction'},
{name: 'M12', details: "system shall [not] have state state [with values stateSet]", explanation: 'System requirement expressing system modes'},
{name: 'M13', details: "system state stateValue shall [not] have substate state [with values stateSet]", explanation: 'System requirement expressing system sub modes per mode'},
{name: 'M14', details: "system item shall [not] take values from stateSet", explanation: 'System requirement expressing item stateSet'},
{name: 'M15', details: "system item shall [not] be composed from item", explanation: 'System requirement expressing item decomposition stateSet'},
{name: 'M16', details: "system shall [not] contain system", explanation: 'System decomposition.'},
{ name: 'M1', details: "system/function shall [not] set [<quantifier>] item [to stateValue]", explanation: 'Sets item Paraphrases: initiate, reset, update.' },
{ name: 'M2', details: "system/function shall [not] set state to stateValue", explanation: 'Sets state to value Paraphrases: initiate, reset, update.' },
{ name: 'M3', details: "system/function shall [not] send [<quantifier>] item", explanation: 'Sends item Paraphrases: forward.' },
{ name: 'M4', details: "system/function shall [not] receive [<quantifier>] item", explanation: 'Receives item Paraphrases: accept, acquire.' },
{ name: 'M5', details: "system/function shall [not] ingest flow", explanation: 'Ingests flow. Paraphrases: get.' },
{ name: 'M6', details: "system/function shall [not] emit flow", explanation: 'Emits flow. Paraphrases: produce.' },
{ name: 'M7', details: "system shall [not] perform function", explanation: 'System requirement. Paraphrases: execute.' },
{ name: 'M8', details: "function shall [not] invoke function", explanation: 'Function invokes another function. Paraphrases: call, request' },
{ name: 'M9', details: "system shall [not] present interface [to system]", explanation: 'Presents interface. Paraphrases: provide' },
{ name: 'M10', details: "system/interface shall [not] transfer flow/item", explanation: 'Transfers TraversingConcept. Paraphrases: transmit, broadcast' },
{ name: 'M11', details: "system shall [not] interact with system [using <connection>] [as defined in <text>]", explanation: 'System requirement expressing interface interraction' },
{ name: 'M12', details: "system shall [not] have state state [with values stateSet]", explanation: 'System requirement expressing system modes' },
{ name: 'M13', details: "system state stateValue shall [not] have substate state [with values stateSet]", explanation: 'System requirement expressing system sub modes per mode' },
{ name: 'M14', details: "system item shall [not] take values from stateSet", explanation: 'System requirement expressing item stateSet' },
{ name: 'M15', details: "system item shall [not] be composed from item", explanation: 'System requirement expressing item decomposition stateSet' },
{ name: 'M16', details: "system shall [not] contain system", explanation: 'System decomposition.' },
];
suffixs = [
{name: 'S1', details: "<numerical-afirmative> j <closed-interval> [per <time-unit>]", explanation: ''},
{name: 'S2', details: "after/before flow", explanation: ''},
{name: 'S3', details: "[every/for a period of/within/for at least] <number> <time-unit> [from flow]", explanation: ''},
{name: 'S4', details: "at the beginning/at the end", explanation: ''},
{name: 'S5', details: "at even intervals", explanation: ''},
{name: 'S6', details: "sequentially", explanation: ''},
{ name: 'S1', details: "<numerical-afirmative> j <closed-interval> [per <time-unit>]", explanation: '' },
{ name: 'S2', details: "after/before flow", explanation: '' },
{ name: 'S3', details: "[every/for a period of/within/for at least] <number> <time-unit> [from flow]", explanation: '' },
{ name: 'S4', details: "at the beginning/at the end", explanation: '' },
{ name: 'S5', details: "at even intervals", explanation: '' },
{ name: 'S6', details: "sequentially", explanation: '' },
];
systems = [{pos:"Prefix", data: this.prefixs}, {pos:"Main", data: this.mains}, {pos:"Suffix", data: this.suffixs}]
systems = [{ pos: "Prefix", data: this.prefixs }, { pos: "Main", data: this.mains }, { pos: "Suffix", data: this.suffixs }]
}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a routerLink="../">Projects</a></li>
<li class="breadcrumb-item"><a routerLink="../">Projects</a></li>
<li class="breadcrumb-item" aria-current="page">Add Project</li>
</ol>
</nav>
<div class="submit-form">
<form name="myForm" ngNativeValidate>
<div class="form-group">
<label for="title_bgroup">Requirement Title</label>
<input type="text" class="form-control" id="title_bgroup"
required
[(ngModel)]="groupboilerplate.title_bgroup" name="title_bgroup">
</div>
<div class="form-group">
<label for="description">Description of project</label>
<textarea
type="text"
class="form-control"
id="description"
required
[(ngModel)]="groupboilerplate.description"
name="description"
></textarea>
</div>
</form>
<button (click)="saveBoilerplate()" class="btn btn-success" >Submit</button>
</div>
\ No newline at end of file
<div [hidden]="!submitted">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<div class="submit-form">
<form name="myForm" ngNativeValidate>
<div class="form-group">
<label for="title_bgroup">Project title</label>
<input type="text" class="form-control" id="title_bgroup" required [(ngModel)]="groupboilerplate.title_bgroup"
name="title_bgroup">
</div>
<div class="form-group">
<label for="description">Description of project</label>
<textarea type="text" class="form-control" id="description" required [(ngModel)]="groupboilerplate.description"
name="description"></textarea>
</div>
</form>
<button (click)="saveBoilerplate()" class="btn btn-success">Submit</button>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';
import { Router } from '@angular/router';
import { GroupBoilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
......@@ -18,29 +18,30 @@ export class AddGroupboilComponent implements OnInit {
submitted = false;
private readonly notifier: NotifierService;
constructor(private boilerplatelService: BoilerplateService, private router:Router, notifierService: NotifierService) {
constructor(private boilerplatelService: BoilerplateService, private router: Router, notifierService: NotifierService) {
this.notifier = notifierService;
}
}
ngOnInit(): void {
}
saveBoilerplate(): void {
const data = {
title_bgroup: this.groupboilerplate.title_bgroup,
description: this.groupboilerplate.description,
description: this.groupboilerplate.description ? this.groupboilerplate.description : this.groupboilerplate.title_bgroup,
};
this.submitted = true;
this.boilerplatelService.creategroupboil(data)
.subscribe(
response => {
this.notifier.notify("success",(JSON.stringify(response)));
this.submitted = true;
this.notifier.notify("success", "Project " + this.groupboilerplate.title_bgroup + ' created');
this.submitted = false;
this.router.navigate(['/groupboilerplates']);
},
error => {
console.log(error);
//error, warning, success, info, default
this.notifier.notify("warning",(JSON.stringify(error["error"]["title"][0])));
this.submitted = false;
this.notifier.notify("warning", (JSON.stringify(error["error"]["title"][0])));
});
}
newBoilerplate(): void {
......
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a routerLink="../../">Projects</a></li>
<li class="breadcrumb-item"><a routerLink="../../">Projects</a></li>
<li class="breadcrumb-item" aria-current="page">Requirement List</li>
</ol>
</nav>
<div class="list row">
<div class="col-md-14">
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<input
type="text"
class="form-control"
placeholder="Search"
(keyup)="applyFilter($event)"
#input/>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<input class="btn btn-success" type="button" value="Add Requirement" routerLink="add-boilerplate"/>
</div>
</ul>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul *ngFor="let inf of infer;" fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<input class="btn btn-info"
[disabled] = "exporting"
type="button"
value="Inferencing"
(click)="updateInfer(inf.id)"/>
</div>
</ul>
<div class="col-md-14">
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<input type="text" class="form-control" placeholder="Search" (keyup)="applyFilter($event)" #input />
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<input class="btn btn-success" type="button" value="Add Requirement" routerLink="add-boilerplate" />
</div>
</ul>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul *ngFor="let inf of infer;" fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<input class="btn btn-info" [disabled]="exporting" type="button" value="Inferencing"
(click)="updateInfer(inf.id)" />
</div>
</ul>
</div>
</div>
</div>
<div [hidden] = "!showSpinner">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
<div [hidden]="!showSpinner">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<div class="mat-elevation-z8">
<table mat-table [dataSource]="newdataSource" class="mat-elevation-z8">
<!-- Position Column -->
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> No. </th>
<td mat-cell *matCellDef="let element"> {{element.id}} </td>
</ng-container>
<table mat-table [dataSource]="newdataSource" class="mat-elevation-z8">
<!-- Position Column -->
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> No. </th>
<td mat-cell *matCellDef="let element"> {{element.id}} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="prefix_data">
<th mat-header-cell *matHeaderCellDef> Prefix </th>
<td mat-cell *matCellDef="let element">{{element.prefix_data}} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="title_data">
<th mat-header-cell *matHeaderCellDef> Title </th>
<td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}}>{{element.title_data}} <span
*ngIf="get_metrics(element.title_data).length > 0" matBadge={{get_metrics(element.title_data).length}}
matBadgeColor="warn" matBadgeSize="small" position="above">&nbsp;&nbsp; </span>
</td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="prefix_data">
<th mat-header-cell *matHeaderCellDef> Prefix </th>
<td mat-cell *matCellDef="let element">{{element.prefix_data}} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="title_data">
<th mat-header-cell *matHeaderCellDef> Title </th>
<td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}}>{{element.title_data}} <span *ngIf="get_metrics(element.title_data).length > 0" matBadge={{get_metrics(element.title_data).length}} matBadgeColor="warn" matBadgeSize="small" position="above">&nbsp;&nbsp; </span>
</td>
</ng-container>
<ng-container matColumnDef="main_data">
<th mat-header-cell *matHeaderCellDef> Main </th>
<td mat-cell *matCellDef="let element"> {{element.main_data}} </td>
</ng-container>
<ng-container matColumnDef="main_data">
<th mat-header-cell *matHeaderCellDef> Main </th>
<td mat-cell *matCellDef="let element"> {{element.main_data}} </td>
</ng-container>
<ng-container matColumnDef="suffix_data">
<th mat-header-cell *matHeaderCellDef> Suffix </th>
<td mat-cell *matCellDef="let element"> {{element.suffix_data}} </td>
</ng-container>
<ng-container matColumnDef="suffix_data">
<th mat-header-cell *matHeaderCellDef> Suffix </th>
<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>
<!-- 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>
<tr mat-header-row *matHeaderRowDef="newdisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: newdisplayedColumns;"></tr>
</table>
<mat-paginator #paginator [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator>
<tr mat-header-row *matHeaderRowDef="newdisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: newdisplayedColumns;"></tr>
</table>
<mat-paginator #paginator [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator>
</div>
<div echarts [options]="chartOption" class="demo-chart"></div>
<div class="content">
<div fxLayout="row wrap">
<div fxFlex="33%">
<div fxFlex="33.3%">
<mat-card class="example-card">
<mat-card-header>
<div class="example-header-image"></div>
<mat-card-title>N. Requirements</mat-card-title>
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle>
<div class="example-header-image"></div>
<mat-card-title>N. Requirements</mat-card-title>
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle>
</mat-card-header>
</mat-card>
</div>
<div fxFlex="33.3%">
<mat-card class="example-card">
<mat-card-header>
<div class="example-header-image"></div>
<mat-card-title>Complete Requirement</mat-card-title>
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle>
<div class="example-header-image"></div>
<mat-card-title>Complete Requirement</mat-card-title>
<mat-card-subtitle>{{getnumreq() - getincreq()}}</mat-card-subtitle>
</mat-card-header>
</mat-card>
</div>
<div fxFlex="33.3%">
<mat-card class="example-card">
<mat-card-header>
<div class="example-header-image"></div>
<mat-card-title>Incomplete Requirement</mat-card-title>
<mat-card-subtitle>{{getnumreq()}}</mat-card-subtitle>
<div class="example-header-image"></div>
<mat-card-title>Incomplete Requirement</mat-card-title>
<mat-card-subtitle>{{getincreq()}}</mat-card-subtitle>
</mat-card-header>
</mat-card>
</div>
......
......@@ -5,8 +5,8 @@ import { InferenceResults } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { PrefixService } from 'src/app/services/prefix.service';
import { ActivatedRoute, Router } from '@angular/router';
import {MatTableDataSource} from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';
import { MatPaginator } from '@angular/material/paginator';
import { EChartsOption } from 'echarts';
import { NotifierService } from "angular-notifier";
......@@ -22,24 +22,24 @@ import { NotifierService } from "angular-notifier";
export class BoilerplateListComponent implements OnInit {
chartOption: EChartsOption = {
tooltip: {
trigger: 'item'
},
legend: {
top: '5%',
left: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
top: '5%',
left: 'center'
},
series: [
{
type: 'pie',
radius: ['40%', '70%'],
data: [
{value: 0, name: '1'},
{value: 0, name: '2'},
{value: 0, name: '3'},
{value: 0, name: '4'},
{value: 0, name: '5'} ]
},
{ value: 0, name: '1' },
{ value: 0, name: '2' },
{ value: 0, name: '3' },
{ value: 0, name: '4' },
{ value: 0, name: '5' }]
}
],
};
private readonly notifier: NotifierService;
......@@ -54,29 +54,30 @@ 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'];
dataSource :Boilerplate[] = [{}];
thenewdataSource:BoilerplateData[] = [{}];
newdisplayedColumns: string[] = ['id', 'title_data', 'prefix_data', 'main_data', 'suffix_data', 'action'];
dataSource: Boilerplate[] = [{}];
thenewdataSource: BoilerplateData[] = [{}];
newdataSource = new MatTableDataSource(this.thenewdataSource);
infer:InferenceResults[] = [{}];
infer: InferenceResults[] = [{}];
//when inference button is pressed
showSpinner = false;
exporting = false;
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement","InconsistentRequirement","NoisyRequirement","OpaqueRequirement","RedundantRequirement"]
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement", "InconsistentRequirement", "NoisyRequirement", "OpaqueRequirement", "RedundantRequirement"]
@ViewChild(MatPaginator) paginator= this.newdataSource.paginator;
@ViewChild(MatPaginator) paginator = this.newdataSource.paginator;
dataofboilerplates: any [] = [];
aprefix: any [] = [];
dataofboilerplates: any[] = [];
aprefix: any[] = [];
main: any;
suffix: any;
constructor(private boilerplateService: BoilerplateService, private prefixService: PrefixService, private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) { this.notifier = notifierService;
}
private router: Router, notifierService: NotifierService) {
this.notifier = notifierService;
}
ngOnInit(): void {
this.retrieveBoilerplates();
......@@ -102,11 +103,11 @@ export class BoilerplateListComponent implements OnInit {
this.boilerplateService.getAllData(this.route.snapshot.params.gb)
.subscribe(
data => {
this.boilerplatesdata =data;
this.boilerplatesdata = data;
this.thenewdataSource = data;
this.newdataSource = new MatTableDataSource(this.thenewdataSource);
this.newdataSource.paginator = this.paginator;
console.log(data)
//console.log(data)
},
error => {
console.log(error);
......@@ -127,52 +128,57 @@ export class BoilerplateListComponent implements OnInit {
SearchTitle(): void {
if (this.title != ''){
if (this.title != '') {
this.boilerplateService.findByTitle(this.route.snapshot.params.gb, this.title)
.subscribe(
data => {
this.boilerplates = data;
this.dataSource = data;
console.log(data);
//console.log(data);
},
error => {
console.log(error);
});
}
}
else {
this.retrieveBoilerplates();
}
}
GetRoute(): void {
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates/add-boilerplate'])
this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates/add-boilerplate'])
}
GetRoutedit(id: any): void {
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates'+ id])
this.router.navigate(['/groupboilerplates/' + this.route.snapshot.params.gb + '/boilerplates' + id])
}
getInfer(): void{
getInfer(): void {
this.boilerplateService.getAllInfer(this.route.snapshot.params.gb)
.subscribe(
data => {
this.currentInfer = data[0];
this.infer = data;
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g,"\""))
var final = []
for (let i of this.list_of_inference_metrics){
if(obj[i] != undefined){
final.push({value: obj[i].length, name: i})}
if (this.chartOption?.series ){
this.chartOption.series = [{
type: 'pie',
radius: ['40%', '70%'],
data: final,
}]}}
},
error => {
console.log(error);
});
.subscribe(
data => {
this.currentInfer = data[0];
this.infer = data;
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
var final = []
for (let i of this.list_of_inference_metrics) {
if (obj[i] != undefined) {
final.push({ value: obj[i].length, name: i })
}
}
console.log(final);
this.chartOption.series = [{
type: 'pie',
radius: ['40%', '70%'],
data: final,
}]
},
error => {
console.log(error);
});
}
......@@ -180,20 +186,20 @@ export class BoilerplateListComponent implements OnInit {
this.showSpinner = !this.showSpinner;
this.exporting = !this.exporting
this.boilerplateService.inferUpdate(this.route.snapshot.params.gb, id, this.currentInfer)
.subscribe(
data => {
this.currentInfer = data[0];
//this.infer = data;
this.showSpinner = !this.showSpinner;
this.exporting = !this.exporting;
location.reload();
},
error => {
console.log(error);
this.showSpinner = !this.showSpinner;
this.exporting = !this.exporting
this.notifier.notify("warning",(JSON.stringify(error["error"]["detail"])));
});
.subscribe(
data => {
this.currentInfer = data[0];
//this.infer = data;
this.showSpinner = !this.showSpinner;
this.exporting = !this.exporting;
location.reload();
},
error => {
console.log(error);
this.showSpinner = !this.showSpinner;
this.exporting = !this.exporting
this.notifier.notify("warning", (JSON.stringify(error["error"]["detail"])));
});
}
applyFilter(event: Event) {
......@@ -201,17 +207,21 @@ export class BoilerplateListComponent implements OnInit {
this.newdataSource.filter = filterValue.trim().toLowerCase();
}
get_metrics(i:any): any {
if (this.currentInfer?.inference_data){
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g,"\""))
if (obj[i]){
get_metrics(i: any): any {
if (this.currentInfer?.inference_data) {
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
if (obj[i]) {
return obj[i]
}
}
return 0
return 0
}
getnumreq():any{
getnumreq(): any {
return this.boilerplatesdata?.length
}
getincreq(): any {
return this.get_metrics('IncompleteRequirement').length;
}
}
<h1 mat-dialog-title>{{data.name}}</h1>
<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>
<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>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">Cancel</button>
<button mat-button [mat-dialog-close]="data" cdkFocusInitial>Add</button>
</div>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CourseDialogComponentComponent } from './course-dialog-component.component';
describe('CourseDialogComponentComponent', () => {
let component: CourseDialogComponentComponent;
let fixture: ComponentFixture<CourseDialogComponentComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CourseDialogComponentComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(CourseDialogComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Inject, OnInit } from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
export interface DialogData {
comment: string;
instance: string;
name?: string;
}
@Component({
selector: 'app-course-dialog-component',
templateUrl: './course-dialog-component.component.html',
styleUrls: ['./course-dialog-component.component.scss']
})
export class CourseDialogComponentComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<CourseDialogComponentComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogData,) {}
ngOnInit(): void {}
onNoClick(): void {
this.dialogRef.close();
}
}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item" aria-current="page">Projects</li>
<li class="breadcrumb-item" aria-current="page">Projects</li>
</ol>
</nav>
<div class="list row">
<div class="col-md-8">
<div class="input-group mb-3">
<input
type="text"
class="form-control"
placeholder="Search"
[(ngModel)]="title"
name="search"
autocomplete="off"
/>
<input type="text" class="form-control" placeholder="Search" [(ngModel)]="title" name="search"
autocomplete="off" />
<!-- (keyup.enter)="SearchTitle()"-->
<!-- (click)="SearchTitle()" -->
<div class="input-group-append">
<button
class="btn btn-primary"
type="button"
>Search
</button>
</div>
<div class="input-group-append">
<button class="btn btn-primary" type="button">Search
</button>
</div>
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<input class="btn btn-success" type="button" value="Add New project" routerLink="add-groupboil"/>
<input class="btn btn-success" type="button" value="Add New project" routerLink="add-groupboil" />
</div>
</ul>
</div>
</div>
</div>
<div class="content">
<div fxLayout="row wrap">
<div fxFlex="20%" *ngFor="let gb of grouboilerplates| filter:title">
<mat-card class="example-card" routerLink="/groupboilerplates/{{gb.id}}/boilerplates">
<mat-card-header>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>{{gb.title_bgroup}}</mat-card-title>
<mat-card-subtitle></mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>
{{gb.description}}
</p>
</mat-card-content>
<mat-card-actions>
<button class="btn btn-info" mat-button>EDIT</button>
<button class="btn btn-warning" (click)="deleteGroupBoilerplate(gb)" mat-button>DELETE</button>
</mat-card-actions>
</mat-card>
</div>
</div>
</div>
<div fxFlex="20%" *ngFor="let gb of grouboilerplates| filter:title">
<mat-card class="example-card">
<div routerLink="/groupboilerplates/{{gb.id}}/boilerplates">
<mat-card-header>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>{{gb.title_bgroup}}</mat-card-title>
<mat-card-subtitle></mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>
{{gb.description}}
</p>
</mat-card-content>
</div>
<mat-card-actions>
<button class="btn btn-info" routerLink="/groupboilerplates/{{gb.id}}/boilerplates"
mat-button>EDIT</button>
<button class="btn btn-warning" (click)="deleteGroupBoilerplate(gb)" mat-button>DELETE</button>
</mat-card-actions>
</mat-card>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { GroupBoilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
@Component({
selector: 'app-groupboil',
......@@ -10,9 +11,11 @@ import { BoilerplateService } from 'src/app/services/boilerplate.service';
export class GroupboilComponent implements OnInit {
grouboilerplates?: GroupBoilerplate[];
title = '';
constructor(private boilerplateService: BoilerplateService) { }
private readonly notifier: NotifierService;
constructor(private boilerplateService: BoilerplateService, notifierService: NotifierService) {
this.notifier = notifierService;
}
ngOnInit(): void {
this.retrievegroupBoilerplates();
......@@ -23,7 +26,7 @@ export class GroupboilComponent implements OnInit {
.subscribe(
data => {
this.grouboilerplates = data;
console.log(data);
//console.log(data);
},
error => {
console.log(error);
......@@ -32,17 +35,19 @@ export class GroupboilComponent implements OnInit {
}
deleteGroupBoilerplate(id: any): void {
if(confirm("Αre you sure you want to delete this Project?")) {
if (confirm("Αre you sure you want to delete this Project?")) {
this.boilerplateService.deletegroupboil(id.id)
.subscribe(
response => {
console.log(response);
//console.log(response);
this.notifier.notify("success", "Project deleted");
this.retrievegroupBoilerplates();
},
error => {
console.log(error);
this.notifier.notify("warning", (JSON.stringify(error["error"]["title"][0])));
});
}
}
}
}
......@@ -7,119 +7,125 @@ import { MainService } from 'src/app/services/main.service';
styleUrls: ['./instances-list.component.scss']
})
export class InstancesListComponent implements OnInit {
subjects:string[] = [];
subjects: string[] = [];
stateitem:string[] = [];
stateitem: string[] = [];
statevalue:string[] = [];
statevalue: string[] = [];
shall:string[] = [];
shall: string[] = [];
verb:string[] = [];
verb: string[] = [];
quantifier:string[] = [];
quantifier: string[] = [];
numunit:string[] = [];
numunit: string[] = [];
fifuintsysstatset:string[] = [];
fifuintsysstatset: string[] = [];
stsysconset:string[] = [];
stsysconset: string[] = [];
constructor(private mainService: MainService) { }
ngOnInit(): void {
this.getchoices();
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
this.getchoices();
}
getchoices(): void{
getchoices(): void {
this.mainService.getsubject()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.subjects.push(data[x][1]);}
for (let x = 0; x < data.length; x++) {
this.subjects.push(data[x][1]);
}
},
error => {
console.log(error);
});
this.mainService.getstateitem()
.subscribe(
data => {
//no data from State and Item
console.log(data);
for (let x=0; x < data.length; x++ ){
this.stateitem.push(data[x][1]);}
},
error => {
console.log(error);
});
.subscribe(
data => {
//no data from State and Item
//console.log(data);
for (let x = 0; x < data.length; x++) {
this.stateitem.push(data[x][1]);
}
},
error => {
console.log(error);
});
this.mainService.getstatevalue()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.statevalue.push(data[x][1]);}
},
error => {
console.log(error);
});
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
this.statevalue.push(data[x][1]);
}
},
error => {
console.log(error);
});
this.mainService.getshall()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.shall.push(data[x][1]);}
},
error => {
console.log(error);
});
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
this.shall.push(data[x][1]);
}
},
error => {
console.log(error);
});
this.mainService.getverb()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.verb.push(data[x][1]);}
},
error => {
console.log(error);
});
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
this.verb.push(data[x][1]);
}
},
error => {
console.log(error);
});
this.mainService.getquantifier()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.quantifier.push(data[x][1]);}
},
error => {
console.log(error);
});
//num
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
this.quantifier.push(data[x][1]);
}
},
error => {
console.log(error);
});
//num
this.mainService.getnumunit()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.numunit.push(data[x][1]);}
},
error => {
console.log(error);
});
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
this.numunit.push(data[x][1]);
}
},
error => {
console.log(error);
});
this.mainService.getfifuintsysstatset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.fifuintsysstatset.push(data[x][1]);}
},
error => {
console.log(error);
});
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
this.fifuintsysstatset.push(data[x][1]);
}
},
error => {
console.log(error);
});
this.mainService.getstsysconset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.stsysconset.push(data[x][1]);}
},
error => {
console.log(error);
});
}
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
this.stsysconset.push(data[x][1]);
}
},
error => {
console.log(error);
});
}
}
......@@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Suffix } from 'src/app/models/suffix.model';
import { SuffixService } from 'src/app/services/suffix.service';
import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs';
import {map, startWith} from 'rxjs/operators';
import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { NotifierService } from "angular-notifier";
......@@ -16,22 +16,22 @@ import { NotifierService } from "angular-notifier";
export class SuffixDetailsComponent implements OnInit {
suffixControl = new FormControl();
suffix:string[] = [];
suffix: string[] = [];
suffixfilteredOptions: Observable<string[]>;
mumerical_unitsControl = new FormControl();
mumerical_units:string[] = [];
mumerical_units: string[] = [];
mumerical_unitsfilteredOptions: Observable<string[]>;
flowControl = new FormControl();
flow:string[] = [];
flow: string[] = [];
flowfilteredOptions: Observable<string[]>;
public static id: any [] = [];
public static id: any[] = [];
private readonly notifier: NotifierService;
suffixs?:Suffix[];
suffixs?: Suffix[];
currentsuffix: Suffix = {
currentsuffix: Suffix = {
s_choices: "",
numerical: 0,
mumerical_units: "",
......@@ -42,13 +42,13 @@ export class SuffixDetailsComponent implements OnInit {
constructor(
private suffixService: SuffixService,
private route: ActivatedRoute,
private router: Router,
notifierService: NotifierService) {
private router: Router,
notifierService: NotifierService) {
this.notifier = notifierService;
this.suffixfilteredOptions = this.suffixControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.suffix, value))
);
);
this.mumerical_unitsfilteredOptions = this.mumerical_unitsControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.mumerical_units, value))
......@@ -57,25 +57,25 @@ export class SuffixDetailsComponent implements OnInit {
startWith(""),
map(value => this._filter(this.flow, value))
);
}
ngOnInit(): void {
this.getchoices();
this.getchoices();
this.getAllSuffix(this.route.snapshot.params.id);
}
displayFn(option:string): string {
displayFn(option: string): string {
if (option != null) {
let x = option.split(" : ");
if ( (x[x.length -2] == "") || (x[x.length -1]=="")) { return "";}
return (x[x.length -2]+" : "+x[x.length -1]);
if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return ""; }
return (x[x.length - 2] + " : " + x[x.length - 1]);
}
return "";
}
private _filter(data:string[], value: string): string[] {
private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue));
}
......@@ -87,11 +87,11 @@ export class SuffixDetailsComponent implements OnInit {
data => {
SuffixDetailsComponent.id.length = 0;
this.suffixs = data;
console.log(data)
//console.log(data)
for (var val of data) {
this.getSuffix(id, val.id);
SuffixDetailsComponent.id.push(val.id);
console.log(val.id)
//console.log(val.id)
}
},
error => {
......@@ -109,7 +109,7 @@ export class SuffixDetailsComponent implements OnInit {
this.suffixControl.setValue(this.currentsuffix.s_choices);
this.mumerical_unitsControl.setValue(this.currentsuffix.mumerical_units);
this.flowControl.setValue(this.currentsuffix.flow);
},
},
error => {
console.log(error);
});
......@@ -120,50 +120,57 @@ export class SuffixDetailsComponent implements OnInit {
this.currentsuffix.s_choices = this.suffixControl.value;
this.currentsuffix.mumerical_units = this.mumerical_unitsControl.value;
this.currentsuffix.flow = this.flowControl.value;
for (let i=0; i<SuffixDetailsComponent.id.length; i++){
this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix)
.subscribe(
response => {
this.message = response.message;
},
error => {
this.notifier.notify("warning",("SUFFIX "+JSON.stringify(error["error"])));
});}
for (let i = 0; i < SuffixDetailsComponent.id.length; i++) {
this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix)
.subscribe(
response => {
this.message = response.message;
},
error => {
this.notifier.notify("warning", ("SUFFIX " + JSON.stringify(error["error"])));
});
}
}
getchoices(): void{
getchoices(): void {
this.suffixService.getsuffix()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.suffix.indexOf(data[x][1]) == -1) {
this.suffix.push(data[x][1]);}}
for (let x = 0; x < data.length; x++) {
if (this.suffix.indexOf(data[x][1]) == -1) {
this.suffix.push(data[x][1]);
}
}
},
error => {
console.log(error);
});
this.suffixService.getnumunits()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.mumerical_units.indexOf(data[x][1]) == -1) {
this.mumerical_units.push(data[x][1]);}}
},
error => {
console.log(error);
});
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
if (this.mumerical_units.indexOf(data[x][1]) == -1) {
this.mumerical_units.push(data[x][1]);
}
}
},
error => {
console.log(error);
});
this.suffixService.getflow()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.flow.indexOf(data[x][1]) == -1) {
this.flow.push(data[x][1]);}}
},
error => {
console.log(error);
});
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
if (this.flow.indexOf(data[x][1]) == -1) {
this.flow.push(data[x][1]);
}
}
},
error => {
console.log(error);
});
}
}
}
export class Boilerplate {
id?:any;
owner?:any;
id?: any;
owner?: any;
group_of_boilerplate?: any;
title?: string;
has_prefix?: boolean;
......@@ -9,7 +9,7 @@ export class Boilerplate {
}
export class BoilerplateData {
id?:any;
id?: any;
title_data?: string;
prefix_data?: string;
main_data?: string;
......@@ -17,36 +17,37 @@ export class BoilerplateData {
}
export class GroupBoilerplate {
id?:any;
id?: any;
title_bgroup?: string;
description?: string;
}
export class InferenceResults {
id?:any;
id?: any;
infer_group_of_boilerplate?: any;
inference_data?: any;
}
export class Sections {
Name?:string;
Name?: string;
TheClasses?: Classes[];
GeneralInstances?:Instances[];
GeneralInstances?: Instances[];
}
export class Classes {
Class?:string;
Class?: string;
Comment?: string;
Subclass?:SubClasses[];
Instance_of_Class?:Instances[];
Subclass?: SubClasses[];
Instance_of_Class?: Instances[];
}
export class SubClasses {
SubClass_name?:string;
SubclassComment?:string
InstanceOfSubclass?:Instances[];
SubClass_name?: any;
SubclassComment?: any
InstanceOfSubclass?: Instances[];
}
export class Instances {
Instance?: any;
}
\ No newline at end of file
Comment?: any;
}
......@@ -164,4 +164,8 @@ export class MainService {
getmainsyntax(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/mainsyntax`);
}
setinstances(gb : any, instance: any, comment:any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/add`+`/${instance}`+`/${comment}/`);
}
}
import json
import os
from django.db import models
from jsonfield import JSONField
#from django.contrib.postgres.fields import ArrayField
......@@ -73,18 +74,31 @@ def create_extra_prefix(instance, now_prefix):
prefix.save()
def create_infer_result(instance):
infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance, ontology_file=instance.ontology_file)
def create_infer_result(instance, destination):
infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance, ontology_file=destination)
infer.save()
#Here we have to give and the ontology file of the Boilerplate Group to get the current instances
def initialize_instances(instance):
try :
g = Graph()
file_name = instance.title_bgroup.replace('/', '')
save_path = "../../Ontologies/"+file_name+"/"
if (os.path.exists("../../Ontologies/"+file_name+"/") == False):
os.mkdir("../../Ontologies/"+file_name)
completeName = os.path.join(save_path, file_name)
g.load(instance.ontology_file, format="turtle")
destination=save_path+file_name+'.ttl'
g.serialize(destination, format='turtle')
except:
print('Cannot load Ontology')
classes_inctances = BoilerplateGroupClassesInstances ( classes_instances_owner= instance.boilerplate_owner, classes_instances_group_of_boilerplate = instance,
ontology_file=instance.ontology_file )
ontology_file= destination)
classes_inctances.save()
dict = BoilerplateGroupDictionary( classes_instances_owner_dic= instance.boilerplate_owner, classes_instances_group_of_boilerplate_dic = instance,
ontology_file_dic=instance.ontology_file )
ontology_file_dic= destination)
dict.save()
return destination
'''Update instaces of the ontology after the inferencing'''
def update_instances(instance):
......@@ -108,13 +122,13 @@ def update_instances(instance):
inteface_choices=json.dumps(INTERFACE_CHOICES), connection_choices=json.dumps(CONNECTION_CHOICES), flow_choices=json.dumps(FLOW_CHOICES),
state_choices=json.dumps(STATE_CHOICES),state_set_choices=json.dumps(STATE_SET_CHOICES), state_value_choices=json.dumps(STATE_VALUE_CHOICES),
main_verb_choices=json.dumps(VERB_CHOICES), numerical_affirmative_choices=json.dumps(NUMERICAL_AFFIRMATIVE_CHOICES),
suffix_choices=json.dumps(S_CHOICES) )
suffix_choices=json.dumps(S_CHOICES), ontology_file=instance.ontology_file )
Dict_list=[]
sao_names=['SAO#System', 'SAO#Function', 'SAO#Item', 'SAO#Interface', 'SAO#Connection', 'SAO#Flow', 'SAO#State', 'SAO#StateSet', 'SAO#StateValue']
for i in sao_names:
Dict_list.append(get_dmo_classes_and_comment(i, g))
#Dictionary_Data_list.append
BoilerplateGroupDictionary.objects.filter(classes_instances_owner_dic= instance.owner_infer, classes_instances_group_of_boilerplate_dic = instance.infer_group_of_boilerplate).update(Dictionary_Data =Dict_list)
BoilerplateGroupDictionary.objects.filter(classes_instances_owner_dic= instance.owner_infer, classes_instances_group_of_boilerplate_dic = instance.infer_group_of_boilerplate).update(ontology_file_dic =instance.ontology_file, Dictionary_Data =Dict_list)
......@@ -122,14 +136,14 @@ def update_instances(instance):
class BoilerplateGroup(models.Model):
boilerplate_owner = models.ForeignKey(User, related_name='boilerplate_group_owner', on_delete=models.CASCADE)
#add Boilerplate path, so each Boilerplate Group can hace it's own Ontology file
ontology_file = models.CharField(default="../../Ontologies/Autonomy_v1.ttl", max_length=100, blank=True)
ontology_file = models.CharField(default="../../Ontologies/2022_AOCS.ttl", max_length=100, blank=True)
title_bgroup = models.CharField(max_length=100, unique=True)
description = models.CharField(max_length=500)
def save(self, **kwargs):
super(BoilerplateGroup, self).save(**kwargs)
initialize_instances(self)
create_infer_result(self)
destination = initialize_instances(self)
create_infer_result(self, destination)
......
......@@ -6,7 +6,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
#HERE
#Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
Ontology_file = "../../Ontologies/2022_AOCS.ttl"
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement",
"InconsistentRequirement","NoisyRequirement","OpaqueRequirement","RedundantRequirement"]
......@@ -21,11 +21,11 @@ def getclassofprefix(prefix):
def getclassofmain(main):
return(findclassofmain(main))
def getinstancefile(data):
def getinstancefile(data, g):
datam = data.split(":")
out_list = get_file_and_instances('SAO#'+ datam[0].strip())
out_list = get_file_and_instances('SAO#'+ datam[0].strip(), g)
for j in range(0,(len(out_list)-1),2):
if out_list[j]==data:
if ( datam[len(datam) -2].strip()+' : '+ datam[len(datam) -1].strip() ) in out_list[j]:
splitter = out_list[j].split(" : ")
instance_file = out_list[j+1]
break
......@@ -51,7 +51,7 @@ def inferencing(ontfile, project, boilerlate, prefix, main, suffix):
#findclassofmain(listofmain)
ontology_with_new_req = exportboiltottl(ontfile, project, listofprefix, listofboil, listofmain, listofsuffix)
infer_result = shacl(ontology_with_new_req)
ontology_with_new_req_and_infer = ontology_with_new_req+"infer.ttl"
ontology_with_new_req_and_infer = ontology_with_new_req #+"infer.ttl"
#find in which metrics the requirements belongs e.g. title:REQ-1 is only an Incomplete req (and Ambiguous req),
# so -> 'REQ-1' : [Incomplete] ('REQ-1' : [Incomplete, Ambiguous])
for met in infer_result:
......@@ -80,7 +80,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
else :
g.load(ontfile, format="turtle")
#remove the requirements from the RDO-instances
previous_req = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances")
previous_req = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#")
g.remove((previous_req, None, None))
for i in range(len(boilerplate)):
title = boilerplate[i][0]['title']
......@@ -96,7 +96,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.add((per_instances+("SystemStateValueContraint_"+title), rbo+"isRelatedToState", lo + prefix_attr_splitter[1].strip()))
for j in prefixmodel:
if prefix[i][0][j] != "":
sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j])
sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j], g)
g.add((per_instances+("SystemStateValueContraint_"+title), rbo+"isRelatedTo"+prefix_subject_splitter[0], URIRef(str(sub_instance_file))+"#"+ str(prefix_subject_splitter[len(prefix_subject_splitter) -1])))
else:
prefix_verb_splitter = prefix[i][0]['state_or_verb'].split(" : ")
......@@ -105,13 +105,14 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), rbo+"isRelatedToAction", lo + prefix_verb_splitter[1].strip()))
for j in prefixmodel:
if prefix[i][0][j] != "":
sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j])
sub_instance_file, prefix_subject_splitter = getinstancefile(prefix[i][0][j], g)
g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), rbo+"isRelatedTo"+prefix_subject_splitter[0], URIRef(str(sub_instance_file))+"#"+ str(prefix_subject_splitter[len(prefix_subject_splitter) -1])))
if (boilerplate[i][0]['has_main'] == True): #If the requirement has Main
g.add((per_instances + title, rdo + 'hasMain', per_instances+(title+"_"+ main[i][0]['main_choices'])))
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), RDF.type, rbo + main[i][0]['main_choices']))
if main[i][0]['sys_fun_inter'] != "":
instance_file, splitter_1 = getinstancefile(main[i][0]['sys_fun_inter'])
print(main[i][0]['sys_fun_inter'])
instance_file, splitter_1 = getinstancefile(main[i][0]['sys_fun_inter'], g)
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToSubject", URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1])))
if main[i][0]['verb'] != "":
mainverb = main[i][0]['verb'].split(':')
......@@ -119,7 +120,7 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
mainmodel=["flow_function_interface_item_system_state_stateset", "state_item_before_verb", "statevalue_before_verb", "statevalue_system_connection_stateset"]
for j in mainmodel:
if main[i][0][j] != "":
instance_file, splitter_1 = getinstancefile(main[i][0][j])
instance_file, splitter_1 = getinstancefile(main[i][0][j], g)
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedTo"+splitter_1[0], URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1])))
if main[i][0]['quantifier'] != "":
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), sao+"isRelatedTo", (per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")))))
......@@ -142,9 +143,12 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.add((per_instances+(title+"_"+ suffix[i][0]['suffix_choices']), RDF.type, URIRef(rbo+ suffix[i][0]['suffix_choices'])))
#g.remove((per_instances + title, None, None))
g.serialize(destination=save_path+file_name+'.ttl', format='turtle')
return (save_path+file_name)
try :
g.serialize(destination=ontfile+'.ttl', format='turtle')
return (ontfile)
except:
g.serialize(destination=save_path+file_name+'.ttl', format='turtle')
return (save_path+file_name)
#print(g.serialize(format="turtle").decode("utf-8"))
def shacl(ontotlogy_file):
......
......@@ -12,8 +12,9 @@ Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
subClass_instances = "../../Ontologies/instances_subclass.txt"
#HERE
list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances#"]
#HERE
#list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances#","http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"]
list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS-instances#","http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"]
#list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances", "<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"]
#list_of_RMO = ["RMO", "RMO-instances", "DSO-Automotive-AVP-instances", "<http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances"]
DSO = ["http://delab.csd.auth.gr/ontologies/2018/DSO#"]
......@@ -76,7 +77,7 @@ def get_verb_instances(keyword):
'''Get Verbs - return tuple'''
def get_verb_file_and_instances(keyword):
get_file_and_instances(keyword)
get_file_and_instances(keyword, g)
keywordspl = keyword.split("#")
in_list = []
out_list = []
......@@ -165,7 +166,7 @@ out_list = []
# A dict with all the info of classes, subclasses and instances
info_dict = {}
def get_file_and_instances(keyword):
def get_file_and_instances(keyword, g):
out_list = []
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-1]]
......@@ -258,7 +259,7 @@ def get_dmo_classes_and_comment(keyword, g):
pop = URIRef(urired2 + spl[len(spl) - 1])
for q1, w1, m1 in g.triples((pop, RDFS.comment, None)):
find_comment_gen_instance = (str(m1).replace("\r","")).replace("\n","")
dmo_dic_in = {'GeneralInstances': spl[len(spl) - 1], "Comment": find_comment_gen_instance}
dmo_dic_in = {'Instance': spl[len(spl) - 1], "Comment": find_comment_gen_instance}
dic_list_in.append(dmo_dic_in)
for comment in out_list_instance:
instance_list = []
......@@ -323,7 +324,7 @@ def get_dmo_classes_and_comment(keyword, g):
return Dictionary_Data
#return dic_list_backup
else:
dmo_dic_backup = {"Class": " ", "Comment":" "}
dmo_dic_backup = {"Class": "", "Comment":""}
dic_list_backup.append(dmo_dic_backup)
Dictionary_Data = { "Name":section, "TheClasses" : dic_list_backup, "GeneralInstances": dic_list_in}
return Dictionary_Data
......
......@@ -34,6 +34,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('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
#SUFFIX CHOICES DATA
......
import os
from rdflib import Graph, URIRef
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView, ListAPIView
from rest_framework import permissions
......@@ -61,6 +63,10 @@ class BoilerplateGroupDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE
def perform_destroy(self, instance):
try:
os.system('rm -rf ../../Ontologies/' + instance.title_bgroup +'/')
except:
print('No file exist')
instance.delete()
......@@ -116,6 +122,22 @@ class BoilerplateDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when DELETE
def perform_destroy(self, instance):
#boildata = BoilerplateData.objects.filter(boilerplate_data_id=self.kwargs['pk'])
#data = BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= boildata.values('owner_data')[0]['owner_data'], classes_instances_group_of_boilerplate = boildata.values('group_of_boilerplate_data')[0]['group_of_boilerplate_data'])
#g = Graph()
#g.load(data.values('ontology_file')[0]['ontology_file'], format="turtle")
#rdo_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'])
#g.remove((rdo_instance, None, None))
#g.remove((None, None, rdo_instance))
#prefix = Prefix.objects.filter(prefix_boilerplate = instance)
#pre_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'] +'_'+ prefix.values('simple_prefix')[0]['simple_prefix'])
#g.remove((pre_instance, None, None))
#g.remove((None, None, pre_instance))
#main = Main.objects.filter(boilerplate_of_main = instance)
#rdo_instance= URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + boildata.values('title_data')[0]['title_data'] +'_'+ main.values('main_choices')[0]['main_choices'])
#g.remove((rdo_instance, None, None))
#g.remove((None, None, rdo_instance))
#g.serialize(data.values('ontology_file')[0]['ontology_file'], format='turtle')
instance.delete()
......@@ -232,10 +254,10 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
prefixdata.append(self.getprefixdata(id.boilerplate_data_id.id))
maindata.append(self.getmaindata(id.boilerplate_data_id.id))
suffixdata.append(self.getsuffixdata(id.boilerplate_data_id.id))
try:
metrics, onto_file = inference.inferencing(instance['ontology_file'], project_title, boildata, prefixdata, maindata, suffixdata)
except:
raise APIException("Not all instances in the Ontology")
#try:
metrics, onto_file = inference.inferencing(instance['ontology_file'], project_title, boildata, prefixdata, maindata, suffixdata)
#except:
# raise APIException("Not all instances in the Ontology")
instance.update(inference_data = metrics, ontology_file=onto_file)
serializer.save()
......@@ -254,7 +276,7 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
class PrefixChoicesViewSet(ListAPIView):
"""
API view to retrieve, update or delete
API view to retrieve list of Prefix choices
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateGroupClassesInstancesSerializer
......
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