Commit e52b17aa authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

Bug fixes

parent 30b459f4
......@@ -23,7 +23,8 @@ const routes: Routes = [
{ path: 'groupboilerplates/:gb/boilerplates/details/:id', component: BoilerplateDetailsComponent, canActivate: [AuthGuard] },
{ path: 'groupboilerplates/:gb/boilerplates/add-boilerplate', component: AddBoilerplateComponent, canActivate: [AuthGuard] },
{ path: 'groupboilerplates/add-groupboil', component: AddGroupboilComponent, canActivate: [AuthGuard] },
{ path: 'dictionary', component: InstancesListComponent, canActivate: [AuthGuard] }
{ path: '**', redirectTo: 'groupboilerplates'}
//{ path: 'dictionary', component: InstancesListComponent, canActivate: [AuthGuard] }
];
......
......@@ -41,7 +41,7 @@ export class AddGroupboilComponent implements OnInit {
console.log(error);
//error, warning, success, info, default
this.submitted = false;
this.notifier.notify("warning", (JSON.stringify(error["error"]["title"][0])));
this.notifier.notify("warning", (JSON.stringify(error["error"]["title_bgroup"][0])));
});
}
newBoilerplate(): void {
......
......@@ -77,6 +77,36 @@
</div>
<mat-tab-group mat-align-tabs="center">
<div *ngFor="let section of systems| filter:searchText">
<div *ngIf= "section.Name == 'System' ">
<mat-tab label=Syntax>
<div *ngFor="let items of syntax| filter:searchText">
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
{{ items.pos }}
</mat-panel-title>
</mat-expansion-panel-header>
<div *ngFor="let item of items.data| filter:searchText">
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
{{ item.name }}
</mat-panel-title>
<mat-panel-description >
<h5>{{ item.details }}</h5>
</mat-panel-description>
</mat-expansion-panel-header>
<p>Details : {{item.explanation}}</p>
</mat-expansion-panel>
</mat-accordion>
</div>
</mat-expansion-panel>
</mat-accordion>
</div>
</mat-tab>
</div>
<mat-tab label={{section.Name}}>
<div *ngFor="let item of section.TheClasses| filter:searchText">
<div *ngIf="item.Class">
......@@ -110,7 +140,9 @@
</div>
</ul>
<ul>
<h4><b>Subclasses</b></h4>
<div *ngIf=checklen(item.Subclass)>
<h4><b>Subclasses</b></h4>
</div>
<div *ngFor="let sub of item.Subclass| filter:searchText">
<li>
<mat-expansion-panel hideToggle>
......
......@@ -214,4 +214,39 @@ export class BoilerplateDetailsComponent 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'},
];
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.'},
];
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: ''},
];
syntax = [{pos:"Prefix", data: this.prefixs}, {pos:"Main", data: this.mains}, {pos:"Suffix", data: this.suffixs}]
}
......@@ -46,9 +46,9 @@
<!-- 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
<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>
matBadgeColor="warn" matBadgeSize="small" position="above"> &nbsp;&nbsp; </span>
</td>
</ng-container>
......@@ -73,7 +73,7 @@
<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>
<mat-paginator #paginator [pageSizeOptions]="[20, 50]" showFirstLastButtons></mat-paginator>
</div>
<div echarts [options]="chartOption" class="demo-chart"></div>
......
......@@ -266,7 +266,7 @@ export class MainDetailsComponent implements OnInit {
this.message = response.message;
},
error => {
this.notifier.notify("warning", ("MAIN " + JSON.stringify(error["error"])));
this.notifier.notify("warning", ("MAIN " + JSON.stringify(error["error"]["detail"])));
});
}
......
......@@ -147,7 +147,7 @@ export class PrefixDetailsComponent implements OnInit {
this.message = response.message;
},
error => {
this.notifier.notify("warning", ("PREFIX " + JSON.stringify(error["error"])));
this.notifier.notify("warning", ("PREFIX " + JSON.stringify(error["error"]['detail'])));
});
}
}
......
......@@ -16,7 +16,7 @@ import { environment } from '../../environments/environment';
export class AuthService {
private apiRoot = 'http://155.207.131.19:8000/auth/';
private apiRoot = environment.apiroot +'auth/';
constructor(private http: HttpClient, private router:Router) { }
......
......@@ -5,10 +5,10 @@ import { Observable } from 'rxjs';
import { Boilerplate } from '../models/boilerplate.model';
import { GroupBoilerplate } from '../models/boilerplate.model';
import { InferenceResults } from '../models/boilerplate.model';
import { environment } from '../../environments/environment';
const baseUrl = '/boilerplates/';
const inferUrl = '/infer/';
const baseUrlgb = 'http://155.207.131.19:8000/api-auth/groupboilerplates/';
const baseUrlgb = environment.apiroot+'api-auth/groupboilerplates/';
@Injectable({
providedIn: 'root'
......
......@@ -2,9 +2,10 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Main } from '../models/main.model';
import { environment } from '../../environments/environment';
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 baseUrl = environment.apiroot + 'api-auth/groupboilerplates/0/boilerplates/';
const baseUrl2 = environment.apiroot + 'api-auth/groupboilerplates/';
const Url = '/main/';
@Injectable({
......@@ -38,123 +39,123 @@ export class MainService {
}
getsubject(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/subject/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/subject/`);
}
getstateitem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/stateitem/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/stateitem/`);
}
getstatevalue(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/statevalue/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/statevalue/`);
}
getshall(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/shall/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/shall/`);
}
getverb(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/verb/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/verb/`);
}
getquantifier(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/quantifier/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/quantifier/`);
}
getnumunit(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/numunit/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/numunit/`);
}
getfifuintsysstatset(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/fifuintsysstatset/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/fifuintsysstatset/`);
}
getstsysconset(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/stsysconset/`);
return this.http.get(environment.apiroot +`api-auth/main/choices/stsysconset/`);
}
getclasssystem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/system`);
return this.http.get(environment.apiroot +`api-auth/class/system`);
}
getsubclassystem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/system/subclasses`);
return this.http.get(environment.apiroot +`api-auth/class/system/subclasses`);
}
getinstancesystem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/system/instance`);
return this.http.get(environment.apiroot +`api-auth/class/system/instance`);
}
getclassfunction(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/function`);
return this.http.get(environment.apiroot +`api-auth/class/function`);
}
getsubclasfunction(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/function/subclasses`);
return this.http.get(environment.apiroot +`api-auth/class/function/subclasses`);
}
getinstancefunction(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/function/instance`);
return this.http.get(environment.apiroot +`api-auth/class/function/instance`);
}
getclassitem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/item`);
return this.http.get(environment.apiroot +`api-auth/class/item`);
}
getsubclasitem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/item/subclasses`);
return this.http.get(environment.apiroot +`api-auth/class/item/subclasses`);
}
getinstanceitem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/item/instance`);
return this.http.get(environment.apiroot +`api-auth/class/item/instance`);
}
getclassinterface(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/interface`);
return this.http.get(environment.apiroot +`api-auth/class/interface`);
}
getsubclasinterface(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/interface/subclasses`);
return this.http.get(environment.apiroot +`api-auth/class/interface/subclasses`);
}
getinstanceinterface(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/interface/instance`);
return this.http.get(environment.apiroot +`api-auth/class/interface/instance`);
}
getclassconnection(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/connection`);
return this.http.get(environment.apiroot +`api-auth/class/connection`);
}
getsubclasconnection(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/connection/subclasses`);
return this.http.get(environment.apiroot +`api-auth/class/connection/subclasses`);
}
getinstanceconnection(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/connection/instance`);
return this.http.get(environment.apiroot +`api-auth/class/connection/instance`);
}
getclassflow(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/flow`);
return this.http.get(environment.apiroot +`api-auth/class/flow`);
}
getsubclasflow(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/flow/subclasses`);
return this.http.get(environment.apiroot +`api-auth/class/flow/subclasses`);
}
getinstanceflow(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/flow/instance`);
return this.http.get(environment.apiroot +`api-auth/class/flow/instance`);
}
getclassstate(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/state`);
return this.http.get(environment.apiroot +`api-auth/class/state`);
}
getsubclasstate(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/state/subclasses`);
return this.http.get(environment.apiroot +`api-auth/class/state/subclasses`);
}
getinstancestate(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/state/instance`);
return this.http.get(environment.apiroot +`api-auth/class/state/instance`);
}
getdictionary(gb : any): Observable<any> {
......@@ -162,7 +163,7 @@ export class MainService {
}
getmainsyntax(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/mainsyntax`);
return this.http.get(environment.apiroot +`api-auth/mainsyntax`);
}
setinstances(gb : any, instance: any, comment:any): Observable<any> {
......
......@@ -2,9 +2,10 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Prefix } from '../models/prefix.model';
import { environment } from '../../environments/environment';
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 baseUrl = environment.apiroot + 'api-auth/groupboilerplates/0/boilerplates/';
const baseUrl2 = environment.apiroot + 'api-auth/groupboilerplates/';
const Url = '/prefix/';
@Injectable({
......
......@@ -2,8 +2,9 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Suffix } from '../models/suffix.model';
import { environment } from '../../environments/environment';
const baseUrl = 'http://155.207.131.19:8000/api-auth/groupboilerplates/0/boilerplates/';
const baseUrl = environment.apiroot + 'api-auth/groupboilerplates/0/boilerplates/';
const Url = '/suffix/';
@Injectable({
......@@ -34,15 +35,15 @@ export class SuffixService {
}
getsuffix(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/suffix/choices/suffix/`);
return this.http.get(environment.apiroot +`api-auth/suffix/choices/suffix/`);
}
getnumunits(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/suffix/choices/numunits/`);
return this.http.get(environment.apiroot +`api-auth/suffix/choices/numunits/`);
}
getflow(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/suffix/choices/flow/`);
return this.http.get(environment.apiroot +`api-auth/suffix/choices/flow/`);
}
}
......@@ -3,6 +3,7 @@
// The list of file replacements can be found in `angular.json`.
export const environment = {
apiroot : "http://155.207.131.19:8000/",
production: false
};
......
......@@ -79,69 +79,87 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.load('../../Ontologies/'+ontfile, format="turtle")
else :
g.load(ontfile, format="turtle")
#print(ontfile)
#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'))
if (boilerplate[i][0]['has_prefix'] == True): #If the requirement has Prefix
prefixmodel=["system_fun_item", "item_function_flow_statevalue"]
g.add((per_instances + title, rdo + 'hasPrefix', per_instances+(title+"_"+ prefix[i][0]['simple_prefix'])))
g.add((per_instances+(title+"_"+ prefix[i][0]['simple_prefix']), RDF.type, rbo + prefix[i][0]['simple_prefix']))
prefix_attr_splitter = prefix[i][0]['item_function_flow_statevalue'].split(" : ")
if (prefix_attr_splitter[0] == 'StateValue'):
g.add( (per_instances+(title+"_"+ prefix[i][0]['simple_prefix']), rbo+"isRelatedToLogicalExpression", (per_instances+("SystemStateValueContraint_"+title))))
g.add((per_instances+("SystemStateValueContraint_"+title), RDF.type, (per_instances+("SystemStateValueContraint"))))
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], 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(" : ")
g.add((per_instances+(title+"_"+ prefix[i][0]['simple_prefix']), rbo+"isRelatedToOccuringFunctionality", per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title)))
g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), RDF.type, (per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"))))
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], 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'] != "":
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(':')
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToAction", lo + mainverb[1].strip()))
mainmodel=["flow_function_interface_item_system_state_stateset", "state_item_before_verb", "statevalue_before_verb", "statevalue_system_connection_stateset"]
for j in mainmodel:
try:
if (boilerplate[i][0]['has_prefix'] == True): #If the requirement has Prefix
prefixmodel=["system_fun_item", "item_function_flow_statevalue"]
g.add((per_instances + title, rdo + 'hasPrefix', per_instances+(title+"_"+ prefix[i][0]['simple_prefix'])))
g.add((per_instances+(title+"_"+ prefix[i][0]['simple_prefix']), RDF.type, rbo + prefix[i][0]['simple_prefix']))
prefix_attr_splitter = prefix[i][0]['item_function_flow_statevalue'].split(" : ")
if (prefix_attr_splitter[0] == 'StateValue'):
g.add( (per_instances+(title+"_"+ prefix[i][0]['simple_prefix']), rbo+"isRelatedToLogicalExpression", (per_instances+("SystemStateValueContraint_"+title))))
g.add((per_instances+("SystemStateValueContraint_"+title), RDF.type, (per_instances+("SystemStateValueContraint"))))
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], 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(" : ")
g.add((per_instances+(title+"_"+ prefix[i][0]['simple_prefix']), rbo+"isRelatedToOccuringFunctionality", per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title)))
g.add((per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"+title), RDF.type, (per_instances+(prefix_verb_splitter[0]+"OccuringFunctionality"))))
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], 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])))
except:
raise APIException("The instances in Prefix of Boilerplate "+title+" are not exist in the Ontology")
try:
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'] != "":
#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(':')
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToAction", lo + mainverb[1].strip()))
#mainmodel=["flow_function_interface_item_system_state_stateset", "state_item_before_verb", "statevalue_before_verb", "statevalue_system_connection_stateset"]
mainmodel=["flow_function_interface_item_system_state_stateset", "statevalue_system_connection_stateset"]
for j in mainmodel:
if ( main[i][0]['main_choices'] == 'M10'):
instance_file, splitter_1 = getinstancefile(main[i][0][j], g)
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToTraversingConcept", URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1])))
elif 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])))
mainbeforeverbmodel=["state_item_before_verb", "statevalue_before_verb"]
for j in mainbeforeverbmodel:
if 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(" ", "")))))
per = URIRef('http://delab.csd.auth.gr/ontologies/2018/LO#'+ (main[i][0]['quantifier']).replace(" ", ""))
quant = URIRef(rbo + "Quantifier") # Initial Value if not any
for s, p, o in g.triples((per, RDFS.subClassOf, None)): #subClassOf
print(o)
if ('RBO' in o):
quant=o
g.add((per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")), RDF.type, quant))
g.add((per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")), rbo+"hasAdverb", lo + (main[i][0]['quantifier']).replace(" ", "")))
if main[i][0]['numerical'] != "":
g.add((per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")), rbo+"hasNumerical", URIRef(per_instances+(main[i][0]['quantifier']).replace(" ", "")+"_"+str(main[i][0]['numerical']))))
g.add((URIRef(per_instances+(main[i][0]['quantifier']).replace(" ", "")+"_"+str(main[i][0]['numerical'])), RDF.type, URIRef(rbo+"Numerical")))
if (boilerplate[i][0]['has_suffix'] == True):
g.add((per_instances + title, rdo + 'hasSuffix', per_instances+(title+"_"+ suffix[i][0]['suffix_choices'])))
#Need S1
#Need S2
#Need S3
g.add((per_instances+(title+"_"+ suffix[i][0]['suffix_choices']), RDF.type, URIRef(rbo+ suffix[i][0]['suffix_choices'])))
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToSubject"+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']), rbo+"isRelatedToQuantifier", (per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")))))
per = URIRef('http://delab.csd.auth.gr/ontologies/2018/LO#'+ (main[i][0]['quantifier']).replace(" ", ""))
quant = URIRef(rbo + "Quantifier") # Initial Value if not any
for s, p, o in g.triples((per, RDFS.subClassOf, None)): #subClassOf
#print(o)
if ('RBO' in o):
quant=o
g.add((per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")), RDF.type, quant))
g.add((per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")), rbo+"hasAdverb", lo + (main[i][0]['quantifier']).replace(" ", "")))
if main[i][0]['numerical'] != "":
g.add((per_instances+(title+"_"+ (main[i][0]['quantifier']).replace(" ", "")), rbo+"hasNumerical", URIRef(per_instances+(main[i][0]['quantifier']).replace(" ", "")+"_"+str(main[i][0]['numerical']))))
g.add((URIRef(per_instances+(main[i][0]['quantifier']).replace(" ", "")+"_"+str(main[i][0]['numerical'])), RDF.type, URIRef(rbo+"Numerical")))
except:
raise APIException("The instances in MAIN of Boilerplate "+title+" are not exist in the Ontology")
try:
if (boilerplate[i][0]['has_suffix'] == True):
g.add((per_instances + title, rdo + 'hasSuffix', per_instances+(title+"_"+ suffix[i][0]['suffix_choices'])))
#Need S1
#Need S2
#Need S3
g.add((per_instances+(title+"_"+ suffix[i][0]['suffix_choices']), RDF.type, URIRef(rbo+ suffix[i][0]['suffix_choices'])))
except:
raise APIException("The instances in SUFFIX of Boilerplate "+title+" are not exist in the Ontology")
#g.remove((per_instances + title, None, None))
try :
g.serialize(destination=ontfile+'.ttl', format='turtle')
......@@ -178,15 +196,28 @@ def shacl(ontotlogy_file):
print(metrics_dict)
return(metrics_dict)
from rest_framework.exceptions import APIException
'''Find if the Prefix exists in syntax'''
def findclassofprefix(listofprefix):
classlist=[]
currentverb = listofprefix['state_or_verb'].rsplit(' : ', 1)
currentstate = listofprefix['state_or_verb'].rsplit(' : ')
currentsubject = listofprefix['system_fun_item']
currentsubjectspl = listofprefix['system_fun_item'].rsplit(' : ')
currentattr = listofprefix['item_function_flow_statevalue']
#Need to be automated
if (currentstate[0] == "State"):
if (currentsubjectspl[0] != "System"):
raise APIException("The Subject must be a System")
print(currentverb)
if (currentverb[1] == "is"):
if (currentsubjectspl[0] == "System"):
raise APIException("The Subject must be an Item")
#
for prefix in prefix_syntax:
for inprefix in prefix_syntax[prefix]:
if currentverb[1] in prefix_syntax[prefix][inprefix]:
if (currentverb[1] in prefix_syntax[prefix][inprefix]) or (currentstate[0] in prefix_syntax[prefix][inprefix]):
if currentsubject.split(":")[0].strip() in prefix_syntax[prefix][inprefix.split("_")[0]+"_Subject"]:
if currentattr.split(":")[0].strip() in prefix_syntax[prefix][inprefix.split("_")[0]+"_Attribute"]:
if listofprefix['prefix'] == "If":
......@@ -216,6 +247,31 @@ def findclassofmain(listofmain):
currentverb = listofmain['verb'].rsplit(' : ', 1)
currentsubject = listofmain['sys_fun_inter'].rsplit(' : ')
currentattr = listofmain['flow_function_interface_item_system_state_stateset'].rsplit(' : ')
currenSubState = listofmain['state_item_before_verb'].rsplit(' : ')
currenSubStateValue = listofmain['statevalue_before_verb'].rsplit(' : ')
currenLast = listofmain['statevalue_system_connection_stateset'].rsplit(' : ')
#need to automatically catch this restrictions
if (currenSubState[0] == 'State'):
if (currenSubStateValue[0] != 'StateValue'):
classlist.append("ERROR")
return classlist
if (currenLast[0] == 'StateSet'):
if(currentattr[0] != 'State'):
classlist.append("ERROR")
return classlist
if (currenLast[0] == 'Connection'):
if(currentattr[0] != 'System'):
classlist.append("ERROR")
return classlist
if (currenLast[0] == 'StateValue'):
if(currentattr[0] != 'Item'):
classlist.append("ERROR")
return classlist
if (currenLast[0] == 'System'):
if(currentattr[0] != 'Interface'):
classlist.append("ERROR")
return classlist
#
for verbmain in verbsmain:
flag = 0
if (verbmain.upper() == currentverb[len(currentverb)-1].upper() ):
......@@ -228,8 +284,5 @@ def findclassofmain(listofmain):
if attrmain == currentattr[0].strip():
classlist.append('M'+str(i+1))
return(classlist)
classlist.append("ERROR")
return classlist
......@@ -96,18 +96,6 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
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")
#remove requirement if exists in the ontology
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))
main = Main.objects.filter(boilerplate_of_main = instance['boilerplate_of_main'])
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')
#
curmain_choices = inference.getclassofmain(instance)
if curmain_choices[0] == 'ERROR':
raise APIException("Main choices not in [M1-M16]")
......@@ -295,3 +283,17 @@ class MainSyntaxViewSet(APIView):
return response
''' #remove requirement if exists in the ontology
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))
main = Main.objects.filter(boilerplate_of_main = instance['boilerplate_of_main'])
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')
#'''
\ No newline at end of file
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