Commit 0dae831e authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

RFT v0.2

parent 08bac18c
......@@ -110,7 +110,8 @@
</mat-panel-description>
</mat-expansion-panel-header>
{{ item.Comment }}
<ul> <h4><b>Instances</b></h4>
<ul>
<button mat-button [matMenuTriggerFor]="menu" #menuTrigger><h4><b>Instances</b></h4></button>
<div *ngFor="let instan of item.Instance_of_Class| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
......@@ -180,4 +181,7 @@
</div>
</div>
</mat-grid-list >
\ No newline at end of file
<mat-menu #menu="matMenu">
<button mat-menu-item >Add Instances</button>
</mat-menu>
\ No newline at end of file
......@@ -11,6 +11,7 @@ import { NotifierService } from "angular-notifier";
@Component({
selector: 'app-boilerplate-details',
templateUrl: './boilerplate-details.component.html',
......@@ -50,7 +51,7 @@ export class BoilerplateDetailsComponent implements OnInit {
ngOnInit(): void {
this.message = '';
this.getchoices();
this.getchoices(this.route.snapshot.params.gb);
this.getBoilerplate(this.route.snapshot.params.gb, this.route.snapshot.params.id);
}
......@@ -105,12 +106,14 @@ export class BoilerplateDetailsComponent implements OnInit {
}
}
getchoices(): void{
getchoices(gb : any): void{
//System
this.mainService.getdictionary()
this.mainService.getdictionary(gb)
.subscribe(
data => {
this.systems = data
// console.log(data[0].Dictionary_Data);
this.systems = data[0].Dictionary_Data
},
error => {
console.log(error);
......
......@@ -8,6 +8,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import {MatTableDataSource} from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator';
import { EChartsOption } from 'echarts';
import { NotifierService } from "angular-notifier";
......@@ -41,7 +42,7 @@ export class BoilerplateListComponent implements OnInit {
},
],
};
private readonly notifier: NotifierService;
boilerplates?: Boilerplate[];
boilerplatesdata?: BoilerplateData[];
currentBoilerplate?: Boilerplate;
......@@ -73,7 +74,9 @@ export class BoilerplateListComponent implements OnInit {
suffix: any;
constructor(private boilerplateService: BoilerplateService, private prefixService: PrefixService, private route: ActivatedRoute,
private router: Router) { }
private router: Router, notifierService: NotifierService) { this.notifier = notifierService;
}
ngOnInit(): void {
this.retrieveBoilerplates();
......@@ -189,6 +192,7 @@ export class BoilerplateListComponent implements OnInit {
console.log(error);
this.showSpinner = !this.showSpinner;
this.exporting = !this.exporting
this.notifier.notify("warning",(JSON.stringify(error["error"]["detail"])));
});
}
......
......@@ -29,6 +29,8 @@ export class InstancesListComponent implements OnInit {
ngOnInit(): void {
this.getchoices();
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
}
......
......@@ -174,7 +174,7 @@
<div class="col">
<form class="form-group form-inline" [ngStyle]="(stsysconsetControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width">
<mat-label *ngIf="stsysconsetControl.value !=null">Connection : {{stsysconsetControl.value.slice(0, stsysconsetControl.value.indexOf(':'))}}</mat-label>
<mat-label *ngIf="stsysconsetControl.value !=null">StateSet or StateValue or System or Connection : {{stsysconsetControl.value.slice(0, stsysconsetControl.value.indexOf(':'))}}</mat-label>
<input
placeholder="Pick one"
aria-label="Number"
......
......@@ -15,7 +15,7 @@ import { NotifierService } from "angular-notifier";
})
export class MainDetailsComponent implements OnInit {
mainsyntax = [
{Attributes: [], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: []}];
{Attributes: [''], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: []}];
mainsyntax11?: Mainsyntax ={
Attributes : [],
Quantifier : false,
......@@ -136,6 +136,7 @@ export class MainDetailsComponent implements OnInit {
ngOnInit(): void {
this.getchoices();
this.getmainchoices(this.route.snapshot.params.gb);
this.getAllMain(this.route.snapshot.params.id);
}
......@@ -150,7 +151,7 @@ export class MainDetailsComponent implements OnInit {
//console.log(this.mainsyntax[x])
//console.log(this.mainsyntax[x].Id)
for (let s=0; s < this.mainsyntax[x].Subject.length; s++ ){
console.log()
//console.log()
if (this.mainsyntax[x].Subject[s] == (this.subjectsControl.value.slice(0, this.subjectsControl.value.indexOf(':'))).replace(/\s/g, "")){
//console.log("okk")
for (let v=0; v < this.mainsyntax[x].Verbs.length; v++ ){
......@@ -174,8 +175,9 @@ export class MainDetailsComponent implements OnInit {
this.numunitControlisDivVisible = true;
//add the numunit data
}
if (this.mainsyntax[x].Attributes.length > 1){
this.stsysconsetControlisDivVisible = true;
if (this.mainsyntax[x].Attributes.includes('StateValue') || this.mainsyntax[x].Attributes.includes('System')|| this.mainsyntax[x].Attributes.includes('Connection')|| this.mainsyntax[x].Attributes.includes('StateSet')) {
if(!this.mainsyntax[x].Id.includes('M14') && !this.mainsyntax[x].Id.includes('M16')){
this.stsysconsetControlisDivVisible = true;}
//add the connection data
}
this.main = this.mainsyntax[x].Id
......@@ -254,15 +256,17 @@ export class MainDetailsComponent implements OnInit {
updateMain(): void {
this.currentmain.sys_fun_inter = this.subjectsControl.value;
if( this.stateitemControlisDivVisible){this.currentmain.state_item_before_verb = this.stateitemControl.value;}
if (this.statevalueControlisDivVisible){this.currentmain.statevalue_before_verb = this.statevalueControl.value;}
if( this.stateitemControlisDivVisible){this.currentmain.state_item_before_verb = this.stateitemControl.value;}else{this.currentmain.state_item_before_verb =''}
if (this.statevalueControlisDivVisible){this.currentmain.statevalue_before_verb = this.statevalueControl.value;}else{this.currentmain.statevalue_before_verb =''}
this.currentmain.shall = this.shallControl.value;
this.currentmain.verb = this.verbControl.value;
if (this.quantifierControlisDivVisible){this.currentmain.quantifier = this.quantifierControl.value;}
if (this.quantifierControlisDivVisible){this.currentmain.quantifier = this.quantifierControl.value;}else{this.currentmain.quantifier =''}
//num
if (this.numericalisDivVisible){this.currentmain.mumerical_units = this.numunitControl.value;}
if (this.numericalisDivVisible){this.currentmain.mumerical_units = this.numunitControl.value;}else{this.currentmain.mumerical_units =''}
this.currentmain.flow_function_interface_item_system_state_stateset = this.fifuintsysstatsetControl.value;
if (this.stsysconsetControlisDivVisible){this.currentmain.statevalue_system_connection_stateset = this.stsysconsetControl.value;}
if (this.stsysconsetControlisDivVisible){this.currentmain.statevalue_system_connection_stateset = this.stsysconsetControl.value;}else{this.currentmain.statevalue_system_connection_stateset =''}
for (let i=0; i<MainDetailsComponent.id.length; i++){
this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain)
.subscribe(
......@@ -276,111 +280,116 @@ export class MainDetailsComponent implements OnInit {
}
getmainchoices(main: any): void{
this.mainService.getmain(main)
.subscribe(
data => {
//get Subject
this.getsubject(JSON.parse(data[0].system_choices));
this.getsubject(JSON.parse(data[0].function_choices));
this.getsubject(JSON.parse(data[0].inteface_choices));
//get State Item
this.getstateitem(JSON.parse(data[0].state_choices));
this.getstateitem(JSON.parse(data[0].item_choices));
//get statevalue
this.getstatevalue(JSON.parse(data[0].state_value_choices));
//get verd
this.getverb(JSON.parse(data[0].main_verb_choices));
//get quantifier
this.getquantifier(JSON.parse(data[0].quantifier_choices));
// get fifuintsysstatset
this.getfifuintsysstatset(JSON.parse(data[0].flow_choices));
this.getfifuintsysstatset(JSON.parse(data[0].function_choices));
this.getfifuintsysstatset(JSON.parse(data[0].inteface_choices));
this.getfifuintsysstatset(JSON.parse(data[0].item_choices));
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));
//stsysconset
this.getstsysconset(JSON.parse(data[0].state_set_choices));
this.getstsysconset(JSON.parse(data[0].system_choices));
this.getstsysconset(JSON.parse(data[0].connection_choices));
this.getstsysconset(JSON.parse(data[0].state_value_choices));
// number_unit_choices
this.getnumunit(JSON.parse(data[0].number_unit_choices));
},
error => {
console.log(error);
});
}
getchoices(): void{
this.mainService.getsubject()
getsubject (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.subjects.indexOf(strIntoObj[x][1]) == -1) {
this.subjects.push((strIntoObj[x][1]));}}
}
getstateitem (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.stateitem.indexOf(strIntoObj[x][1]) == -1) {
this.stateitem.push((strIntoObj[x][1]));}}
}
getstatevalue (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.statevalue.indexOf(strIntoObj[x][1]) == -1) {
this.statevalue.push((strIntoObj[x][1]));}}
}
getverb (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.verb.indexOf(strIntoObj[x][1]) == -1) {
this.verb.push((strIntoObj[x][1]));}}
}
getquantifier (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.quantifier.indexOf(strIntoObj[x][1]) == -1) {
this.quantifier.push((strIntoObj[x][1]));}}
}
getfifuintsysstatset (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.fifuintsysstatset.indexOf(strIntoObj[x][1]) == -1) {
this.fifuintsysstatset.push((strIntoObj[x][1]));}}
}
getstsysconset (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.stsysconset.indexOf(strIntoObj[x][1]) == -1) {
this.stsysconset.push((strIntoObj[x][1]));}}
}
getnumunit (strIntoObj: any): void{
for (let x=0; x < strIntoObj.length; x++ ){
if(this.numunit.indexOf(strIntoObj[x][1]) == -1) {
this.numunit.push((strIntoObj[x][1]));}}
}
getchoices(): void{
this.mainService.getmainsyntax()
.subscribe(
data => {
this.mainsyntax = data
console.log(data);
},
error => {
console.log(error);
});
this.mainService.getshall()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.subjects.indexOf(data[x][1]) == -1) {
this.subjects.push((data[x][1]));}}
if(this.shall.indexOf(data[x][1]) == -1) {
this.shall.push(data[x][1]);}}
},
error => {
console.log(error);
});
this.mainService.getstateitem()
.subscribe(
data => {
//no data from State and Item
for (let x=0; x < data.length; x++ ){
if(this.stateitem.indexOf(data[x][1]) == -1) {
this.stateitem.push(data[x][1]);}}
},
error => {
console.log(error);
});
this.mainService.getstatevalue()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.statevalue.indexOf(data[x][1]) == -1) {
this.statevalue.push(data[x][1]);}}
},
error => {
console.log(error);
});
this.mainService.getshall()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.shall.indexOf(data[x][1]) == -1) {
this.shall.push(data[x][1]);}}
},
error => {
console.log(error);
});
this.mainService.getverb()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.verb.indexOf(data[x][1]) == -1) {
this.verb.push(data[x][1]);}}
console.log(this.verb)
},
error => {
console.log(error);
});
this.mainService.getquantifier()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.quantifier.indexOf(data[x][1]) == -1) {
this.quantifier.push(data[x][1]);}}
},
error => {
console.log(error);
});
//num
this.mainService.getnumunit()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.numunit.indexOf(data[x][1]) == -1) {
this.numunit.push(data[x][1]);}}
},
error => {
console.log(error);
});
this.mainService.getfifuintsysstatset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.fifuintsysstatset.indexOf(data[x][1]) == -1) {
this.fifuintsysstatset.push(data[x][1]);}}
},
error => {
console.log(error);
});
this.mainService.getstsysconset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
if(this.stsysconset.indexOf(data[x][1]) == -1) {
this.stsysconset.push(data[x][1]);}}
},
error => {
console.log(error);
});
this.mainService.getmainsyntax()
.subscribe(
data => {
this.mainsyntax = data
},
error => {
console.log(error);
});
}
}
......
......@@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { Main } from '../models/main.model';
const baseUrl = 'http://155.207.131.19:8000/api-auth/groupboilerplates/0/boilerplates/';
const baseUrl2 = 'http://155.207.131.19:8000/api-auth/groupboilerplates/';
const Url = '/main/';
@Injectable({
......@@ -32,6 +33,9 @@ export class MainService {
delete(boilerplate: any, id: any): Observable<any> {
return this.http.delete(`${baseUrl}${boilerplate}${Url}${baseUrl}${id}`);
}
getmain(gb: any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}${Url}`+`choices/`);
}
getsubject(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/subject/`);
......@@ -153,8 +157,8 @@ export class MainService {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/state/instance`);
}
getdictionary(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/dictionary`);
getdictionary(gb : any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/dictionary/`);
}
getmainsyntax(): Observable<any> {
......
......@@ -34,15 +34,15 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1"),
#to be updated with domains from DSO
#SYSTEM
SYSTEM_CHOICES = get_instances("SAO#System") #+get_i_instances("SAO#System")
SYSTEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#System")
SYSTEM_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#System")
SYSTEM_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#System")
#SYSTEM_CHOICES = get_instances("SAO#System") #+get_i_instances("SAO#System")
#SYSTEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#System")
#SYSTEM_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#System")
#SYSTEM_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#System")
#FUNTION
FUNCTION_CHOICES = get_instances("SAO#Function")
FUNCTION_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Function")
FUNCTION_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Function")
FUNCTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Function")
#FUNCTION_CHOICES = get_instances("SAO#Function")
#FUNCTION_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Function")
#FUNCTION_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Function")
#FUNCTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Function")
#
SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not"))
QUANTIFIER_CHOICES = ( ("None","None"), ("All", "All"), ("Only", "Only"),
......@@ -51,41 +51,41 @@ QUANTIFIER_CHOICES = ( ("None","None"), ("All", "All"), ("Only", "Only"),
)
NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"), ("Number", "Number"))
#ITEM
ITEM_CHOICES = get_instances("SAO#Item")
ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item")
ITEM_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Item")
ITEM_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Item")
#ITEM_CHOICES = get_instances("SAO#Item")
#ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item")
#ITEM_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Item")
#ITEM_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Item")
#
#Interface
INTERFACE_CHOICES = get_instances("SAO#Interface")
INTERFACE_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Interface")
INTERFACE_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Interface")
INTERFACE_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Interface")
#INTERFACE_CHOICES = get_instances("SAO#Interface")
#INTERFACE_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Interface")
#INTERFACE_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Interface")
#INTERFACE_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Interface")
#
#Connection
CONNECTION_CHOICES = get_instances("SAO#Connection")
CONNECTION_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Connection")
CONNECTION_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Connection")
CONNECTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Connection")
#CONNECTION_CHOICES = get_instances("SAO#Connection")
#CONNECTION_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Connection")
#CONNECTION_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Connection")
#CONNECTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Connection")
#
#Flow
FLOW_CHOICES = get_instances("SAO#Flow")
FLOW_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Flow")
FLOW_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Flow")
FLOW_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Flow")
#FLOW_CHOICES = get_instances("SAO#Flow")
#FLOW_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Flow")
#FLOW_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Flow")
#FLOW_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Flow")
#
#State
STATE_CHOICES = get_instances("SAO#State")
STATE_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#State")
STATE_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#State")
STATE_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#State")
#STATE_CHOICES = get_instances("SAO#State")
#STATE_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#State")
#STATE_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#State")
#STATE_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#State")
#State Choices
STATE_SET_CHOICES = get_instances("SAO#StateSet")
STATECHOICES_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#StateSet")
#STATE_SET_CHOICES = get_instances("SAO#StateSet")
#STATECHOICES_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#StateSet")
#
#State Values
STATE_VALUE_CHOICES =get_instances("SAO#StateValue")
STATEVALUES_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#StateValue")
#STATE_VALUE_CHOICES =get_instances("SAO#StateValue")
#STATEVALUES_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#StateValue")
#
#VERB_CHOICES = get_verb_instances("LO#Verb")
......@@ -116,23 +116,23 @@ class Main(models.Model):
boilerplate_of_main = models.ForeignKey('reqtool.Boilerplate', related_name='main_boilerplate', on_delete=models.CASCADE)
main_owner = models.ForeignKey(User, related_name='main_owner', on_delete=models.CASCADE)
#Subject
sys_fun_inter = models.CharField(choices=SYSTEM_CHOICES + FUNCTION_CHOICES + INTERFACE_CHOICES, max_length=100)
sys_fun_inter = models.CharField(max_length=100)
#Between Subject - Verb
state_item_before_verb = models.CharField(choices=STATE_CHOICES + ITEM_CHOICES, max_length=100, blank=True)
statevalue_before_verb = models.CharField(choices=STATE_VALUE_CHOICES, max_length=100, blank=True)
state_item_before_verb = models.CharField(max_length=100, blank=True)
statevalue_before_verb = models.CharField(max_length=100, blank=True)
#Verb
shall = models.CharField(choices=SHALL_CHOICES, max_length=100)
verb = models.CharField(choices=VERB_CHOICES, max_length=100)
shall = models.CharField(max_length=100)
verb = models.CharField(max_length=100)
#Between Verb - Object
quantifier = models.CharField(choices=QUANTIFIER_CHOICES, max_length=100, blank=True)
quantifier = models.CharField(max_length=100, blank=True)
numerical = models.CharField(blank=True, null=True, max_length=10)
mumerical_units = models.CharField(choices=NUMBER_UNITS_CHOICES, max_length=100, blank=True)
mumerical_units = models.CharField(max_length=100, blank=True)
#Οbject
flow_function_interface_item_system_state_stateset = models.CharField(choices=FLOW_CHOICES + FUNCTION_CHOICES + INTERFACE_CHOICES + ITEM_CHOICES + SYSTEM_CHOICES +STATE_CHOICES + STATE_SET_CHOICES, max_length=100)
flow_function_interface_item_system_state_stateset = models.CharField( max_length=100)
#last definitions
statevalue_system_connection_stateset = models.CharField(choices=STATE_VALUE_CHOICES + SYSTEM_CHOICES + CONNECTION_CHOICES + STATE_SET_CHOICES, max_length=100, blank=True)
statevalue_system_connection_stateset = models.CharField(max_length=100, blank=True)
#ID [M1-M16]
main_choices = models.CharField(choices=MAIN_CHOICES, max_length=100)
main_choices = models.CharField(max_length=100, blank=True)
class Meta:
ordering = ['boilerplate_of_main']
......
......@@ -13,7 +13,7 @@ from pygments import highlight
#get prefix syntax from the Onotlogy#
#print(get_prefix_new_syntax())
PREFIX_SYNTAX = get_prefix_syntax()
#PREFIX_SYNTAX = get_prefix_syntax()
SIMPLE_PREFIX_CHOICES = ( ("",""),
......@@ -32,8 +32,9 @@ LOGICAL_EXPRESSION = ( ("",""),
("occuring functionality", "occuring functionality")
)
#Need fixing
#VERB_CHOICES_PREFIX = ( ("",""))
VERB_CHOICES_PREFIX = get_prefix_verbs()
#Must read this info from the Ontology
......@@ -73,23 +74,33 @@ def create_extra_prefix(instance, now_prefix):
def create_infer_result(instance):
infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance)
infer = InferenceResults(owner_infer= instance.boilerplate_owner, infer_group_of_boilerplate = instance, ontology_file=instance.ontology_file)
infer.save()
#Here we have to give and the ontology file of the Boilerplate Group to get the current instances
def initialize_instances(instance):
classes_inctances = BoilerplateGroupClassesInstances ( classes_instances_owner= instance.boilerplate_owner, classes_instances_group_of_boilerplate = instance,
prefix_choices = json.dumps(PREFIX_CHOICES), prefix_logcon_choices =json.dumps(LOGIC_CONNECTIVE), prefix_verb_choices =json.dumps(STATE_CHOICES + VERB_CHOICES_PREFIX),
main_class_choices =json.dumps(MAIN_CHOICES), system_choices = json.dumps(SYSTEM_CHOICES), function_choices =json.dumps(FUNCTION_CHOICES),
quantifier_choices=json.dumps(QUANTIFIER_CHOICES), number_unit_choices=json.dumps(NUMBER_UNITS_CHOICES), item_choices=json.dumps(ITEM_CHOICES),
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) )
ontology_file=instance.ontology_file )
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 )
dict.save()
'''Update instaces of the ontology after the inferencing'''
def update_instances(instance):
g = Graph()
g.load(instance.ontology_file, format="turtle")
#PREFIX_SYNTAX = get_prefix_syntax(g)
VERB_CHOICES_PREFIX = get_prefix_verbs(g)
SYSTEM_CHOICES = get_instances_g("SAO#System",g)
FUNCTION_CHOICES = get_instances_g("SAO#Function",g)
ITEM_CHOICES = get_instances_g("SAO#Item",g)
INTERFACE_CHOICES = get_instances_g("SAO#Interface",g)
CONNECTION_CHOICES = get_instances_g("SAO#Connection",g)
FLOW_CHOICES = get_instances_g("SAO#Flow",g)
STATE_CHOICES = get_instances_g("SAO#State",g)
STATE_SET_CHOICES = get_instances_g("SAO#StateSet",g)
STATE_VALUE_CHOICES =get_instances_g("SAO#StateValue",g)
BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= instance.owner_infer, classes_instances_group_of_boilerplate = instance.infer_group_of_boilerplate).update(
prefix_choices = json.dumps(PREFIX_CHOICES), prefix_logcon_choices =json.dumps(LOGIC_CONNECTIVE), prefix_verb_choices =json.dumps(STATE_CHOICES + VERB_CHOICES_PREFIX),
main_class_choices =json.dumps(MAIN_CHOICES), system_choices = json.dumps(SYSTEM_CHOICES), function_choices =json.dumps(FUNCTION_CHOICES),
......@@ -98,6 +109,12 @@ def update_instances(instance):
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) )
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)
......@@ -105,6 +122,7 @@ 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)
title_bgroup = models.CharField(max_length=100, unique=True)
description = models.CharField(max_length=500)
......@@ -173,18 +191,18 @@ class PrefixGroup(models.Model):
class Prefix(models.Model):
prefixgroup = models.ForeignKey(PrefixGroup, related_name='prefix', on_delete=models.CASCADE)
prefix_boilerplate = models.ForeignKey(Boilerplate, related_name='prefix_boilerplate', on_delete=models.CASCADE)
prefix = models.CharField(choices=PREFIX_CHOICES, max_length=100)
prefix = models.CharField(max_length=100)
#state value constraint
system_fun_item = models.CharField(choices= (ITEM_CHOICES + SYSTEM_CHOICES + FUNCTION_CHOICES), max_length=100)
state_or_verb = models.CharField(choices=STATE_CHOICES + VERB_CHOICES_PREFIX, max_length=100)
system_fun_item = models.CharField(max_length=100)
state_or_verb = models.CharField(max_length=100)
#occuring functionality
item_function_flow_statevalue = models.CharField(choices=ITEM_CHOICES + FLOW_CHOICES + FUNCTION_CHOICES + STATE_VALUE_CHOICES, max_length=100)
item_function_flow_statevalue = models.CharField(max_length=100)
#state value constraint OR occuring functionality
logical_expression = models.CharField(choices=LOGICAL_EXPRESSION, max_length=100, blank=True)
logical_expression = models.CharField(max_length=100, blank=True)
#Logic connectivity Prefix1 (and/or/xor) Prefix2
logic_connective = models.CharField(choices=LOGIC_CONNECTIVE, default='', max_length=100, blank=True)
logic_connective = models.CharField(max_length=100, blank=True)
#Prefix value P1/P2/P3
simple_prefix = models.CharField(choices=SIMPLE_PREFIX_CHOICES, max_length=100)
simple_prefix = models.CharField(max_length=100, blank=True)
def __init__(self, *args, **kwargs):
......@@ -226,6 +244,7 @@ class BoilerplateData(models.Model):
class InferenceResults(models.Model):
owner_infer = models.ForeignKey(User, related_name='owner_infer', on_delete=models.CASCADE)
infer_group_of_boilerplate = models.ForeignKey(BoilerplateGroup, related_name='infer_owner_of_boilerplate', on_delete=models.CASCADE)
ontology_file = models.CharField(max_length=100, blank=True)
inference_data = models.CharField(default="", max_length=1000000, blank=True)
def save(self, **kwargs):
......@@ -263,4 +282,8 @@ class BoilerplateGroupClassesInstances(models.Model):
suffix_choices = JSONField()
class BoilerplateGroupDictionary(models.Model):
classes_instances_group_of_boilerplate_dic = models.ForeignKey(BoilerplateGroup, related_name='classes_instances_owner_of_boilerplate_dic', on_delete=models.CASCADE)
classes_instances_owner_dic = models.ForeignKey(User, related_name='classes_instances_owner_dic', on_delete=models.CASCADE)
ontology_file_dic = models.CharField(default="", max_length=100, blank=True)
Dictionary_Data = JSONField()
from rest_framework import serializers
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, BoilerplateData, BoilerplateGroup, InferenceResults, BoilerplateGroupClassesInstances
from reqman.apps.reqtool.models.requirements import BoilerplateGroupDictionary, Prefix, Boilerplate, BoilerplateData, BoilerplateGroup, InferenceResults, BoilerplateGroupClassesInstances
class BoilerplateSerializer(serializers.ModelSerializer):
......@@ -43,4 +43,9 @@ class BoilerplateGroupClassesInstancesSerializer(serializers.ModelSerializer):
class Meta:
model = BoilerplateGroupClassesInstances
fields = '__all__'
class BoilerplateGroupDictionarySerializer(serializers.ModelSerializer):
classes_instances_owner_dic = serializers.ReadOnlyField(source='owner.username')
class Meta:
model = BoilerplateGroupDictionary
fields = '__all__'
......@@ -3,16 +3,15 @@ from rdflib import Graph, BNode
from rdflib.namespace import RDFS
from rdflib import ConjunctiveGraph, URIRef, RDFS, RDF, Namespace
from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
from reqman.apps.reqtool.models.main_req import SYSTEM_CHOICES, FUNCTION_CHOICES, INTERFACE_CHOICES, FLOW_CHOICES, ITEM_CHOICES, STATE_CHOICES, STATE_SET_CHOICES
#HERE
#Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
Ontology_file = "../../Ontologies/2022_AOCS.ttl"
Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
list_of_inference_metrics = ["IncompleteRequirement", "AmbiguousRequirement",
"InconsistentRequirement","NoisyRequirement","OpaqueRequirement","RedundantRequirement"]
prefix_syntax = get_prefix_syntax()
prefix_syntax = get_prefix_syntax(g)
main_syntax = get_main_sytax_inference()
......@@ -23,6 +22,8 @@ def getclassofmain(main):
return(findclassofmain(main))
def getinstancefile(data):
datam = data.split(":")
out_list = get_file_and_instances('SAO#'+ datam[0].strip())
for j in range(0,(len(out_list)-1),2):
if out_list[j]==data:
splitter = out_list[j].split(" : ")
......@@ -31,7 +32,7 @@ def getinstancefile(data):
return instance_file, splitter
def inferencing(project, boilerlate, prefix, main, suffix):
def inferencing(ontfile, project, boilerlate, prefix, main, suffix):
metrics = {}
listofboil = []
listofprefix = []
......@@ -48,8 +49,9 @@ def inferencing(project, boilerlate, prefix, main, suffix):
for i in suffix:
listofsuffix.append(list(i.values()))
#findclassofmain(listofmain)
ontology_with_new_req = exportboiltottl(project, listofprefix, listofboil, listofmain, listofsuffix)
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"
#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:
......@@ -57,24 +59,29 @@ def inferencing(project, boilerlate, prefix, main, suffix):
if title in infer_result[met]:
metrics[title].append(met)
metrics.update(infer_result)
return (metrics, ontology_with_new_req)
return (metrics, ontology_with_new_req_and_infer)
def exportboiltottl(project, prefix, boilerplate, main, suffix):
def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
''' Export boilerplate to ttl file and return the file path'''
#print(out_list) #A list with the values and the file that is the instance
file_name = project.replace('/', '')
if (os.path.exists("../../Ontologies/"+file_name+"/") == False):
os.mkdir("../../Ontologies/"+file_name)
save_path = "../../Ontologies/"+file_name+"/"
completeName = os.path.join(save_path, file_name)
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#")
g = Graph()
g.load(Ontology_file, format="turtle")
#find the ontology to load
file_name = project.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('../../Ontologies/'+ontfile, format="turtle")
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")
g.remove((previous_req, None, None))
for i in range(len(boilerplate)):
title = boilerplate[i][0]['title']
g.add((per_instances + title, RDF.type, rdo + 'Requirement'))
......@@ -134,6 +141,7 @@ def exportboiltottl(project, prefix, boilerplate, main, suffix):
#Need S3
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)
......@@ -202,65 +210,20 @@ def findclassofmain(listofmain):
attrsmain = main_syntax[('M'+str(i+1))]['Attributes']
#for currentmain in range(len(listofmain)):
currentverb = listofmain['verb'].rsplit(' : ', 1)
currentsubject = listofmain['sys_fun_inter']
currentattr = listofmain['flow_function_interface_item_system_state_stateset']
currentsubject = listofmain['sys_fun_inter'].rsplit(' : ')
currentattr = listofmain['flow_function_interface_item_system_state_stateset'].rsplit(' : ')
for verbmain in verbsmain:
flag = 0
if (verbmain.upper() == currentverb[len(currentverb)-1].upper() ):
for submain in subsmain:
flag = 0
if submain == "System":
for sys in SYSTEM_CHOICES:
if sys[0] == currentsubject:
flag = 1
break
if submain == "Function":
for sys in FUNCTION_CHOICES:
if sys[0] == currentsubject:
flag = 1
break
if submain == "Interface":
for sys in INTERFACE_CHOICES:
if sys[0] == currentsubject:
flag = 1
break
if submain == currentsubject[0].strip():
flag = 1
if flag == 1 :
for attrmain in attrsmain:
if attrmain == "Flow":
for sys in FLOW_CHOICES:
if sys[0] == currentattr:
classlist.append('M'+str(i+1))
return(classlist)
if attrmain == "Item":
for sys in ITEM_CHOICES:
if sys[0] == currentattr:
classlist.append('M'+str(i+1))
return(classlist)
if attrmain == "Function":
for sys in FUNCTION_CHOICES:
if sys[0] == currentattr:
classlist.append('M'+str(i+1))
return(classlist)
if attrmain == "System":
for sys in SYSTEM_CHOICES:
if sys[0] == currentattr:
classlist.append('M'+str(i+1))
return(classlist)
if attrmain == "Interface":
for sys in INTERFACE_CHOICES:
if sys[0] == currentattr:
classlist.append('M'+str(i+1))
return(classlist)
if attrmain == "State":
for sys in (STATE_CHOICES):
if sys[0] == currentattr:
classlist.append('M'+str(i+1))
return(classlist)
if attrmain == "StateSet":
for sys in (STATE_SET_CHOICES):
if sys[0] == currentattr:
classlist.append('M'+str(i+1))
return(classlist)
if attrmain == currentattr[0].strip():
classlist.append('M'+str(i+1))
return(classlist)
classlist.append("ERROR")
return classlist
......
......@@ -8,7 +8,7 @@ from rdflib import ConjunctiveGraph, URIRef, RDFS, RDF, Namespace
#Ontology_file = "../../Ontologies/Mokos_18_1_7_47.ttl"
#Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
Ontology_file = "../../Ontologies/2022_AOCS.ttl"
Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
subClass_instances = "../../Ontologies/instances_subclass.txt"
......@@ -39,11 +39,11 @@ def find_subclass_domain_range():
def findsubclass():
file2 = open(subClass_instances, "w+")
subclasslist = []
for subj, obj in g.subject_objects(predicate=RDFS.subClassOf):
subClass = subj + "$"+ obj + "\n"
file2.write(subClass)
subclasslist.append(subClass)
return subclasslist
def get_i_instances(keyword):
......@@ -96,16 +96,52 @@ def get_verb_file_and_instances(keyword):
'''Get Instaces - return tuple'''
def get_instances(keyword):
get_file_and_instances(keyword)
#get_file_and_instances(keyword)
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-1]]
out_list = []
with open('../../Ontologies/instances.txt') as f:
for data in f:
if (data.strip()).endswith(keyword):
spliter_1 = data.split('$')
spliter_2 = spliter_1[0].split("#")
in_list.append(spliter_2[len(spliter_2) - 1])
#with open('../../Ontologies/instances.txt') as f:
# for data in f:
# if (data.strip()).endswith(keyword):
# spliter_1 = data.split('$')
# spliter_2 = spliter_1[0].split("#")
# in_list.append(spliter_2[len(spliter_2) - 1])
for extra in in_list:
for uri in list_of_DSO:
per = URIRef(uri +extra)
for s, p, o in g.triples((None, RDFS.subClassOf, per)): #subClassOf
spl = s.split("#")
in_list.append(spl[len(spl) - 1])
for extra in in_list:
for uri in list_of_DSO:
p = URIRef(uri +extra)
for s, p, o in g.triples((None, RDF.type, p)):
spl = s.split("#")
uri = spl[len(spl) - 2].split("/")
out_list.append(spl[len(spl) - 1])
#new code
out_list.append(extra)
return tuple((str(keywordspl[len(keywordspl)-1]+" : "+out_list[n+1]+" : "+out_list[n]), str(keywordspl[len(keywordspl)-1]+" : "+out_list[n+1]+" : "+out_list[n]) ) for n in range(0, len(out_list), 2))
# A list with the values and the file that is the instance
out_list = []
# A dict with all the info of classes, subclasses and instances
info_dict = {}
'''Get Instaces - return tuple'''
def get_instances_g(keyword, g):
#get_file_and_instances(keyword)
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-1]]
out_list = []
#with open('../../Ontologies/instances.txt') as f:
# for data in f:
# if (data.strip()).endswith(keyword):
# spliter_1 = data.split('$')
# spliter_2 = spliter_1[0].split("#")
# in_list.append(spliter_2[len(spliter_2) - 1])
for extra in in_list:
for uri in list_of_DSO:
per = URIRef(uri +extra)
......@@ -130,20 +166,17 @@ out_list = []
info_dict = {}
def get_file_and_instances(keyword):
out_list = []
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-1]]
with open('../../Ontologies/instances.txt') as f:
for data in f:
if (data.strip()).endswith(keyword):
spliter_1 = data.split('$')
spliter_2 = spliter_1[0].split("#")
in_list.append(spliter_2[len(spliter_2) - 1])
#find one layer down System: Subclass
for extra in in_list:
for uri in list_of_DSO:
per = URIRef(uri +extra)
for s, p, o in g.triples((None, RDFS.subClassOf, per)): #subClassOf
spl = s.split("#")
in_list.append(spl[len(spl) - 1])
#find two layer down System: Subclass : Instance
for extra in in_list:
for uri in list_of_DSO:
per = URIRef(uri +extra)
......@@ -152,7 +185,8 @@ def get_file_and_instances(keyword):
uri = spl[len(spl) - 2].split("/")
out_list.append(keywordspl[len(keywordspl)-1]+" : "+extra+" : " +spl[len(spl) - 1])
out_list.append(str(spl[len(spl) - 2]))
#return out_list#tuple((out_list[i+1], out_list[i]) for i in range(0, (len(out_list) - 1), 2) )
return out_list
#Instances and Comments
def get_dmo_instance_and_comment(keyword):
......@@ -193,7 +227,7 @@ def get_dmo_instance_and_comment(keyword):
#Classes and Comments
def get_dmo_classes_and_comment(keyword):
def get_dmo_classes_and_comment(keyword, g):
dmo_dic = {}
dic_list = []
dmo_dic_in = {}
......@@ -281,19 +315,19 @@ def get_dmo_classes_and_comment(keyword):
dic_list.append(dmo_dic)
if out_list_com:
Dictionary_Data = { "Name":section, "TheClasses" : dic_list, "GeneralInstances": dic_list_in}
Dictionary_Data_list.append(Dictionary_Data)
return dic_list
return Dictionary_Data
#return dic_list
else:
if dic_list_backup:
Dictionary_Data = { "Name":section, "TheClasses" : dic_list_backup, "GeneralInstances": dic_list_in}
Dictionary_Data_list.append(Dictionary_Data)
return dic_list_backup
return Dictionary_Data
#return dic_list_backup
else:
dmo_dic_backup = {"Class": " ", "Comment":" "}
dic_list_backup.append(dmo_dic_backup)
Dictionary_Data = { "Name":section, "TheClasses" : dic_list_backup, "GeneralInstances": dic_list_in}
Dictionary_Data_list.append(Dictionary_Data)
return dic_list_backup
return Dictionary_Data
#return dic_list_backup
#Classes of classes and Comments
def get_dmo_classes_of_classes_and_comment(keyword):
......@@ -330,14 +364,13 @@ def get_dmo_classes_of_classes_and_comment(keyword):
'''Get Instaces - return list'''
def get_instances_list(keyword):
findsubclass()
f = findsubclass()
an_list=[]
with open(subClass_instances) as f:
for data in f:
if (data.strip()).endswith(keyword):
spliter_1 = data.split('$')
spliter_2 = spliter_1[0].split("#")
an_list.append(spliter_2[len(spliter_2) - 1])
for data in f:
if (data.strip()).endswith(keyword):
spliter_1 = data.split('$')
spliter_2 = spliter_1[0].split("#")
an_list.append(spliter_2[len(spliter_2) - 1])
return an_list
......@@ -502,7 +535,7 @@ def get_main_sytax_inference():
main_dict[main]["Quantifier"] = check_quantifier(bnodes_uriref)
main_dict[main]["Attributes"] = get_attribute(bnodes_uriref, main_dict[main]["Subject"], main_dict[main]["Related_to_Subject"], main_dict[main]["Verbs"])
print( main_dict[main]["Subject"])
#print( main_dict[main]["Subject"])
return main_dict
......@@ -546,7 +579,7 @@ def get_main_sytax():
'''Find Prefix syntax - return a dict with the syntax'''
def get_prefix_syntax():
def get_prefix_syntax(g):
prefix_dict={}
prefix_list = []
get_prefix = get_instances_list("RBO#Prefix")
......@@ -621,7 +654,7 @@ def get_prefix_syntax():
'''Return Verb list Of Prefixes'''
def get_prefix_verbs():
def get_prefix_verbs(g):
prefix_dict={}
prefix_list = []
verblist =[]
......
......@@ -34,58 +34,15 @@ urlpatterns = [
#MAIN CHOICES DATA
path('groupboilerplates/<int:groupboil>/main/choices/', main_req_views.MainChoicesViewSet.as_view(), name='mainchoices'),
path('main/choices/subject/', main_req_views.SysFunIntChoicesViewSet.as_view(), name='mainsubject'),
path('main/choices/stateitem/', main_req_views.StatItemChoicesViewSet.as_view(), name='mainstateitem'),
path('main/choices/statevalue/', main_req_views.StatevalueChoicesViewSet.as_view(), name='mainstatevalue'),
path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
path('main/choices/verb/', main_req_views.VerbChoicesViewSet.as_view(), name='mainverb'),
path('main/choices/quantifier/', main_req_views.QuantChoicesViewSet.as_view(), name='mainquantifier'),
path('main/choices/numunit/', main_req_views.NumUnitChoicesViewSet.as_view(), name='mainnumunit'),
path('main/choices/fifuintsysstatset/', main_req_views.FlFuIntItSysStatSetChoicesViewSet.as_view(), name='mainfifuintsysstatset'),
path('main/choices/stsysconset/', main_req_views.StaSysConSetChoicesViewSet.as_view(), name='mainstsysconset'),
#SUFFIX CHOICES DATA
path('suffix/choices/suffix/', suffix_req_views.SuffixChoicesViewSet.as_view(), name='suffixsuffix'),
path('suffix/choices/numunits/', suffix_req_views.NumChoicesViewSet.as_view(), name='suffixnum'),
path('suffix/choices/flow/', suffix_req_views.FlowChoicesViewSet.as_view(), name='suffixflow'),
#CLASSES System
path('class/system', main_req_views.SystemClassViewSet.as_view(), name='class_system'),
path('class/system/subclasses', main_req_views.SystemSubclasesViewSet.as_view(), name='subclass_system'),
path('class/system/instance', main_req_views.SystemInstancesViewSet.as_view(), name='instances_of_system'),
#CLASSES Function
path('class/function', main_req_views.FunctionClassViewSet.as_view(), name='class_function'),
path('class/function/subclasses', main_req_views.FunctionSubclasesViewSet.as_view(), name='subclass_function'),
path('class/function/instance', main_req_views.FunctionInstancesViewSet.as_view(), name='instances_of_function'),
#CLASSES Item
path('class/item', main_req_views.ItemClassViewSet.as_view(), name='class_item'),
path('class/item/subclasses', main_req_views.ItemSubclasesViewSet.as_view(), name='subclass_item'),
path('class/item/instance', main_req_views.ItemInstancesViewSet.as_view(), name='instances_of_item'),
#CLASSES Interface
path('class/interface', main_req_views.InterfaceClassViewSet.as_view(), name='class_interface'),
path('class/interface/subclasses', main_req_views.InterfaceSubclasesViewSet.as_view(), name='subclass_interface'),
path('class/interface/instance', main_req_views.InterfaceInstancesViewSet.as_view(), name='instances_of_interface'),
#CLASSES Connection
path('class/connection', main_req_views.ConnectionClassViewSet.as_view(), name='class_connection'),
path('class/connection/subclasses', main_req_views.ConnectionSubclasesViewSet.as_view(), name='subclass_connection'),
path('class/connection/instance', main_req_views.ConnectionInstancesViewSet.as_view(), name='instances_of_connection'),
#CLASSES Flow
path('class/flow', main_req_views.FlowClassViewSet.as_view(), name='class_flow'),
path('class/flow/subclasses', main_req_views.FlowSubclasesViewSet.as_view(), name='subclass_flow'),
path('class/flow/instance', main_req_views.FlowInstancesViewSet.as_view(), name='instances_of_flow'),
#CLASSES State
path('class/state', main_req_views.StateClassViewSet.as_view(), name='class_state'),
path('class/state/subclasses', main_req_views.StateSubclasesViewSet.as_view(), name='subclass_state'),
path('class/state/instance', main_req_views.StateInstancesViewSet.as_view(), name='instances_of_state'),
#Dictionary
path('dictionary/', main_req_views.DictionaryViewSet.as_view(), name='dictionary'),
path('groupboilerplates/<int:groupboil>/dictionary/', main_req_views.DictionaryViewSet.as_view(), name='dictionary'),
path('mainsyntax/', main_req_views.MainSyntaxViewSet.as_view(), name='mainsyntax'),
]
\ No newline at end of file
......@@ -4,7 +4,7 @@ from rest_framework import permissions
from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from reqman.apps.reqtool.rest_api.serializers.requirements import BoilerplateGroupClassesInstancesSerializer
from reqman.apps.reqtool.rest_api.serializers.requirements import BoilerplateGroupClassesInstancesSerializer, BoilerplateGroupDictionarySerializer
from reqman.apps.reqtool.models.main_req import Main
from reqman.apps.reqtool.rest_api.serializers.main_req import MainSerializer
......@@ -16,19 +16,9 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import Dictionary_Da
from rest_framework.response import Response
from rest_framework.views import APIView
from reqman.apps.reqtool.models.main_req import SYSTEM_CHOICES, FUNCTION_CHOICES, INTERFACE_CHOICES, STATE_CHOICES, ITEM_CHOICES
from reqman.apps.reqtool.models.main_req import STATE_VALUE_CHOICES, SHALL_CHOICES, VERB_CHOICES, QUANTIFIER_CHOICES, NUMBER_UNITS_CHOICES
from reqman.apps.reqtool.models.main_req import FLOW_CHOICES, CONNECTION_CHOICES, STATE_SET_CHOICES
from reqman.apps.reqtool.models.main_req import SHALL_CHOICES, MAIN_SYNTAX
from reqman.apps.reqtool.models.main_req import SYSTEM_CLASSES_COMMENTS, SYSTEM_SUBCLASSES_COMMENTS, SYSTEM_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import FUNCTION_CLASSES_COMMENTS, FUNCTION_SUBCLASSES_COMMENTS, FUNCTION_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import ITEM_CLASSES_COMMENTS, ITEM_SUBCLASSES_COMMENTS, ITEM_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import INTERFACE_CLASSES_COMMENTS, INTERFACE_SUBCLASSES_COMMENTS, INTERFACE_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import CONNECTION_CLASSES_COMMENTS, CONNECTION_SUBCLASSES_COMMENTS, CONNECTION_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import FLOW_CLASSES_COMMENTS, FLOW_SUBCLASSES_COMMENTS, FLOW_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import STATE_CLASSES_COMMENTS, STATE_SUBCLASSES_COMMENTS, STATE_INSTANCES_COMMENTS, MAIN_SYNTAX
from reqman.apps.reqtool.models.requirements import BoilerplateData, BoilerplateGroupClassesInstances
from reqman.apps.reqtool.models.requirements import BoilerplateData, BoilerplateGroupClassesInstances, BoilerplateGroupDictionary
from rest_framework.exceptions import APIException
......@@ -77,12 +67,38 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
ev_instance =instance['verb'].rsplit(' : ', 1)
eo_instance = instance['flow_function_interface_item_system_state_stateset'].rsplit(':', 1)
mn = (es_instance[len(es_instance)-1] + ' ' + instance['shall'] + ' ' + ev_instance[len(ev_instance)-1] + ' ' + eo_instance[len(eo_instance)-1])
boildata = BoilerplateData.objects.filter(owner_data=instance['boilerplate_of_main'].owner, boilerplate_data_id = instance['boilerplate_of_main'])
boildata.update(main_data = mn )
#get instances of the ontology that this boilerplate belongs
data = BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= instance['boilerplate_of_main'].owner, classes_instances_group_of_boilerplate = boildata.values('group_of_boilerplate_data')[0]['group_of_boilerplate_data'])
sub_data = data.values('system_choices')[0]['system_choices'] + data.values('function_choices')[0]['function_choices'] + data.values('inteface_choices')[0]['inteface_choices']
if( instance['sys_fun_inter'] not in sub_data):
raise APIException("MAIN : Instance of Subject does not exist")
stateitem_data = data.values('state_choices')[0]['state_choices'] + data.values('item_choices')[0]['item_choices']
if( instance['state_item_before_verb'] not in stateitem_data):
raise APIException("MAIN : Instance of State or Item before Verb does not exist")
statevalue_data = data.values('state_value_choices')[0]['state_value_choices']
if( instance['statevalue_before_verb'] not in statevalue_data):
raise APIException("MAIN : Instance of StateValue before Verb does not exist")
verb_data = data.values('main_verb_choices')[0]['main_verb_choices']
if( instance['verb'] not in verb_data):
raise APIException("MAIN : Instance of Verb does not exist")
quantifier_data = data.values('quantifier_choices')[0]['quantifier_choices']
if( instance['quantifier'] not in quantifier_data):
raise APIException("MAIN : Instance of Quantifier does not exist")
fifuintsysstatset_data = data.values('system_choices')[0]['system_choices'] + data.values('function_choices')[0]['function_choices'] + data.values('flow_choices')[0]['flow_choices'] + data.values('inteface_choices')[0]['inteface_choices'] + data.values('item_choices')[0]['item_choices'] + data.values('state_choices')[0]['state_choices'] + data.values('state_set_choices')[0]['state_set_choices']
if( instance['flow_function_interface_item_system_state_stateset'] not in fifuintsysstatset_data):
raise APIException("MAIN : Instance of Object does not exist")
stsysconset_data = data.values('system_choices')[0]['system_choices'] + data.values('state_set_choices')[0]['state_set_choices'] + data.values('connection_choices')[0]['connection_choices'] + data.values('state_value_choices')[0]['state_value_choices']
if( instance['statevalue_system_connection_stateset'] not in stsysconset_data):
raise APIException("MAIN : Instance of after Object does not exist")
numunit_data = data.values('number_unit_choices')[0]['number_unit_choices']
if( instance['mumerical_units'] not in numunit_data):
raise APIException("MAIN : Instance of Number Unit does not exist")
curmain_choices = inference.getclassofmain(instance)
#instance['main_choices'] = curmain_choices[0]
if curmain_choices[0] == 'ERROR':
raise APIException("Main choices not in [M1-M16]")
else:
BoilerplateData.objects.filter(owner_data=instance['boilerplate_of_main'].owner, boilerplate_data_id = instance['boilerplate_of_main']).update(main_data = mn )
instance = serializer.save(main_choices = curmain_choices[0])
#instance = serializer.save()
......@@ -105,28 +121,7 @@ class MainChoicesViewSet(ListAPIView):
queryset_cl= BoilerplateGroupClassesInstances.objects.filter(classes_instances_group_of_boilerplate = group_pk)
return queryset_cl
class SysFunIntChoicesViewSet(APIView):
def get(self, request):
response = Response(SYSTEM_CHOICES + FUNCTION_CHOICES + INTERFACE_CHOICES)
return response
class StatItemChoicesViewSet(APIView):
def get(self, request):
response = Response(STATE_CHOICES + ITEM_CHOICES)
return response
class StatevalueChoicesViewSet(APIView):
def get(self, request):
response = Response(STATE_VALUE_CHOICES)
return response
class ShallChoicesViewSet(APIView):
def get(self, request):
......@@ -134,171 +129,23 @@ class ShallChoicesViewSet(APIView):
return response
class VerbChoicesViewSet(APIView):
def get(self, request):
response = Response(VERB_CHOICES)
return response
class QuantChoicesViewSet(APIView):
def get(self, request):
response = Response(QUANTIFIER_CHOICES)
return response
class NumUnitChoicesViewSet(APIView):
def get(self, request):
response = Response(NUMBER_UNITS_CHOICES)
return response
class FlFuIntItSysStatSetChoicesViewSet(APIView):
def get(self, request):
response = Response(FLOW_CHOICES + FUNCTION_CHOICES + INTERFACE_CHOICES + ITEM_CHOICES + SYSTEM_CHOICES +STATE_CHOICES + STATE_SET_CHOICES)
return response
class StaSysConSetChoicesViewSet(APIView):
def get(self, request):
response = Response(STATE_VALUE_CHOICES + SYSTEM_CHOICES + CONNECTION_CHOICES + STATE_SET_CHOICES)
return response
class SystemClassViewSet(APIView):
def get(self, request):
response = Response(SYSTEM_CLASSES_COMMENTS)
return response
class SystemSubclasesViewSet(APIView):
def get(self, request):
response = Response(SYSTEM_SUBCLASSES_COMMENTS)
return response
class SystemInstancesViewSet(APIView):
def get(self, request):
response = Response(SYSTEM_INSTANCES_COMMENTS)
return response
class FunctionClassViewSet(APIView):
def get(self, request):
response = Response(FUNCTION_CLASSES_COMMENTS)
return response
class FunctionSubclasesViewSet(APIView):
def get(self, request):
response = Response(FUNCTION_SUBCLASSES_COMMENTS)
return response
class FunctionInstancesViewSet(APIView):
def get(self, request):
response = Response(FUNCTION_INSTANCES_COMMENTS)
return response
class ItemClassViewSet(APIView):
def get(self, request):
response = Response(ITEM_CLASSES_COMMENTS)
return response
class ItemSubclasesViewSet(APIView):
def get(self, request):
response = Response(ITEM_SUBCLASSES_COMMENTS)
return response
class ItemInstancesViewSet(APIView):
def get(self, request):
response = Response(ITEM_INSTANCES_COMMENTS)
return response
class InterfaceClassViewSet(APIView):
def get(self, request):
response = Response(INTERFACE_CLASSES_COMMENTS)
return response
class InterfaceSubclasesViewSet(APIView):
def get(self, request):
response = Response(INTERFACE_SUBCLASSES_COMMENTS)
return response
class InterfaceInstancesViewSet(APIView):
def get(self, request):
response = Response(INTERFACE_INSTANCES_COMMENTS)
return response
class ConnectionClassViewSet(APIView):
def get(self, request):
response = Response(CONNECTION_CLASSES_COMMENTS)
return response
class ConnectionSubclasesViewSet(APIView):
def get(self, request):
response = Response(CONNECTION_SUBCLASSES_COMMENTS)
return response
class ConnectionInstancesViewSet(APIView):
def get(self, request):
response = Response(CONNECTION_INSTANCES_COMMENTS)
return response
class FlowClassViewSet(APIView):
def get(self, request):
response = Response(FLOW_CLASSES_COMMENTS)
return response
class FlowSubclasesViewSet(APIView):
def get(self, request):
response = Response(FLOW_SUBCLASSES_COMMENTS)
return response
class FlowInstancesViewSet(APIView):
def get(self, request):
response = Response(FLOW_INSTANCES_COMMENTS)
return response
class StateClassViewSet(APIView):
def get(self, request):
response = Response(STATE_CLASSES_COMMENTS)
return response
#class DictionaryViewSet(APIView):
class StateSubclasesViewSet(APIView):
#def get(self, request):
# response = Response(Dictionary_Data_list)
# return response
def get(self, request):
response = Response(STATE_SUBCLASSES_COMMENTS)
return response
class StateInstancesViewSet(APIView):
def get(self, request):
response = Response(STATE_INSTANCES_COMMENTS)
return response
class DictionaryViewSet(APIView):
class DictionaryViewSet(ListAPIView):
"""
API view to retrieve, update or delete
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateGroupDictionarySerializer
def get(self, request):
response = Response(Dictionary_Data_list)
return response
def get_queryset(self):
group_pk = self.kwargs['groupboil']
queryset_cl= BoilerplateGroupDictionary.objects.filter(classes_instances_group_of_boilerplate_dic = group_pk)
return queryset_cl
class MainSyntaxViewSet(APIView):
......
......@@ -6,8 +6,6 @@ from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, BoilerplateGroup, PREFIX_CHOICES, LOGIC_CONNECTIVE
from reqman.apps.reqtool.models.requirements import VERB_CHOICES_PREFIX, ITEM_CHOICES, SYSTEM_CHOICES, FUNCTION_CHOICES, STATE_CHOICES
from reqman.apps.reqtool.models.requirements import ITEM_CHOICES, FLOW_CHOICES, FUNCTION_CHOICES, STATE_VALUE_CHOICES
from reqman.apps.reqtool.models.requirements import BoilerplateData, InferenceResults, BoilerplateGroupClassesInstances
from reqman.apps.reqtool.rest_api.serializers.requirements import BoilerplateSerializer, PrefixSerializer, BoilerplateDataSerializer, BoilerplateGroupSerializer, InferSerializer, BoilerplateGroupClassesInstancesSerializer
......@@ -153,9 +151,21 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
ev_instance =instance['state_or_verb'].rsplit(':', 1)
ei_instance = instance['item_function_flow_statevalue'].rsplit(':', 1)
pr = (instance['prefix'] + ' ' + es_instance[len(es_instance)-1] + ' ' + ev_instance[len(ev_instance)-1] + ' ' + ei_instance[len(ei_instance)-1])
BoilerplateData.objects.filter(owner_data=instance['prefix_boilerplate'].owner, boilerplate_data_id = instance['prefix_boilerplate']).update(prefix_data = pr )
boildata = BoilerplateData.objects.filter(owner_data=instance['prefix_boilerplate'].owner, boilerplate_data_id = instance['prefix_boilerplate'])
boildata.update(prefix_data = pr )
#get instances of the ontology that this boilerplate belongs
data = BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= instance['prefix_boilerplate'].owner, classes_instances_group_of_boilerplate = boildata.values('group_of_boilerplate_data')[0]['group_of_boilerplate_data'])
es_data = data.values('system_choices')[0]['system_choices'] + data.values('function_choices')[0]['function_choices'] + data.values('item_choices')[0]['item_choices']
if( instance['system_fun_item'] not in es_data):
raise APIException("PREFIX : Instance of Subject does not exist")
ev_data = data.values('state_choices')[0]['state_choices'] + data.values('prefix_verb_choices')[0]['prefix_verb_choices']
if( instance['state_or_verb'] not in ev_data):
raise APIException("PREFIX : Instance of State or Verb does not exist")
ei_data = data.values('function_choices')[0]['function_choices'] + data.values('item_choices')[0]['item_choices']+ data.values('flow_choices')[0]['flow_choices']+ data.values('state_value_choices')[0]['state_value_choices']
if( instance['item_function_flow_statevalue'] not in ei_data):
raise APIException("PREFIX : Instance of Object does not exist")
#find the class of the prefix
prefix_choices = inference.getclassofprefix(instance)
if prefix_choices[0] == 'ERROR':
raise APIException("Prefix choices not in [P1-P3]")
else:
......@@ -222,8 +232,11 @@ 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))
metrics, onto_file = inference.inferencing(project_title, boildata, prefixdata, maindata, suffixdata)
instance.update(inference_data = metrics)
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()
def getboildata(self, pr):
......
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