Commit bf1959c7 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

back : write basic Main in Ontology, ui: start dictionary of instances

parent be8d3c1a
......@@ -11,6 +11,7 @@ import { BoilerplateDetailsComponent } from './components/boilerplate-details/bo
import { AddBoilerplateComponent } from './components/add-boilerplate/add-boilerplate.component';
import { GroupboilComponent } from './components/groupboil/groupboil.component';
import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.component';
import { InstancesListComponent } from './components/instances-list/instances-list.component';
/*import { PrefixListComponent } from './components/prefix-list/prefix-list.component';
import { PrefixDetailsComponent } from './components/prefix-details/prefix-details.component';
......@@ -24,7 +25,8 @@ const routes: Routes = [
{ path: 'groupboilerplates/:gb/boilerplates', component: BoilerplateListComponent, canActivate: [AuthGuard] },
{ 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: 'groupboilerplates/add-groupboil', component: AddGroupboilComponent, canActivate: [AuthGuard] },
{ path: 'dictionary', component: InstancesListComponent, canActivate: [AuthGuard] }
/*{ path: '', redirectTo: 'tutorials', pathMatch: 'full' },
{ path: 'prefix', component: PrefixListComponent },
{ path: 'prefix/:id', component: PrefixDetailsComponent },
......
......@@ -32,6 +32,7 @@ import { SuffixListComponent } from './components/suffix-list/suffix-list.compon
import { SuffixDetailsComponent } from './components/suffix-details/suffix-details.component';
import { GroupboilComponent } from './components/groupboil/groupboil.component';
import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.component';
import { InstancesListComponent } from './components/instances-list/instances-list.component';
......@@ -54,6 +55,7 @@ import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.
SuffixDetailsComponent,
GroupboilComponent,
AddGroupboilComponent,
InstancesListComponent,
],
imports: [
BrowserModule,
......
......@@ -26,7 +26,7 @@
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<input class="btn btn-success" type="button" value="Add Boilepate" routerLink="add-boilerplate"/>
<input class="btn btn-success" type="button" value="Add Requirement" routerLink="add-boilerplate"/>
</div>
</ul>
</div>
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { InstancesListComponent } from './instances-list.component';
describe('InstancesListComponent', () => {
let component: InstancesListComponent;
let fixture: ComponentFixture<InstancesListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ InstancesListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(InstancesListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { MainService } from 'src/app/services/main.service';
@Component({
selector: 'app-instances-list',
templateUrl: './instances-list.component.html',
styleUrls: ['./instances-list.component.scss']
})
export class InstancesListComponent implements OnInit {
subjects:string[] = [];
stateitem:string[] = [];
statevalue:string[] = [];
shall:string[] = [];
verb:string[] = [];
quantifier:string[] = [];
numunit:string[] = [];
fifuintsysstatset:string[] = [];
stsysconset:string[] = [];
constructor(private mainService: MainService) { }
ngOnInit(): void {
this.getchoices();
}
getchoices(): void{
this.mainService.getsubject()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.subjects.push(data[x][1]);}
},
error => {
console.log(error);
});
this.mainService.getstateitem()
.subscribe(
data => {
//no data from State and Item
console.log(data);
for (let x=0; x < data.length; x++ ){
this.stateitem.push(data[x][1]);}
},
error => {
console.log(error);
});
this.mainService.getstatevalue()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.statevalue.push(data[x][1]);}
},
error => {
console.log(error);
});
this.mainService.getshall()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.shall.push(data[x][1]);}
},
error => {
console.log(error);
});
this.mainService.getverb()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.verb.push(data[x][1]);}
},
error => {
console.log(error);
});
this.mainService.getquantifier()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.quantifier.push(data[x][1]);}
},
error => {
console.log(error);
});
//num
this.mainService.getnumunit()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.numunit.push(data[x][1]);}
},
error => {
console.log(error);
});
this.mainService.getfifuintsysstatset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.fifuintsysstatset.push(data[x][1]);}
},
error => {
console.log(error);
});
this.mainService.getstsysconset()
.subscribe(
data => {
for (let x=0; x < data.length; x++ ){
this.stsysconset.push(data[x][1]);}
},
error => {
console.log(error);
});
}
}
......@@ -30,9 +30,10 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1"),
("M16", "M16"),
)
#to be updated with domains from DSO
SYSTEM_CHOICES = get_instances("SAO#System") #+get_i_instances("SAO#System")
print(get_instances("SAO#System"))
#print(get_instances("SAO#System"))
FUNCTION_CHOICES = get_instances("SAO#Function")
SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not"))
QUANTIFIER_CHOICES = ( ("none","NONE"), ("all", "ALL"), ("only", "ONLY"),
......@@ -62,7 +63,6 @@ CLASS_CHOICES = (("SYSTEM","SYSTEM"), ("FUNCTION","FUNCTION"), ("SHALL","SHALL/S
("STATE_VALUE","STATE_VALUE"), ("STATE","STATE"), ("STATE_SET","STATE_SET"),
("FLOW","FLOW"), ("INTERFACE","INTERFACE"), ("CONNECTION","CONNECTION"), ("VERB","VERB") )
def create_main(instance):
'''Create the Main Model for the Boilerplate'''
try :
......
......@@ -37,6 +37,7 @@ def exportboiltottl(project, prefix, boilerplate, main, suffix):
per_instances = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#")
rdo = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO#")
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")
#for b in boilerplate:
......@@ -44,14 +45,29 @@ def exportboiltottl(project, prefix, boilerplate, main, suffix):
title = boilerplate[i][0]['title']
#title = BNode()
g.add((per_instances + title, RDF.type, rdo + 'Requirement'))
if (boilerplate[i][0]['has_main'] == True):
g.add((per_instances + title, rdo + 'hasMain', per_instances+(title+"_"+ main[i][0]['main_choices'])))
if (boilerplate[i][0]['has_prefix'] == True):
g.add((per_instances + title, rdo + 'hasPrefix', per_instances+(title+"_"+ prefix[i][0]['simple_prefix'])))
if (boilerplate[i][0]['has_main'] == True):
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'] != "":
#need to know in which file is the SUbject, RDO instances? or RDO-AOCS instance? or somewhere else?
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToSubject", per_instances + main[i][0]['sys_fun_inter']))
for j in range(0,(len(out_list)-1),2):
if out_list[j]==main[i][0]['sys_fun_inter']:
spliter_1 = out_list[j].split(" : ")
instance_file = out_list[j+1]
break
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToSubject", URIRef(str(instance_file))+"#"+ str(spliter_1[1])))
if main[i][0]['verb'] != "":
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToAction", lo + main[i][0]['verb']))
if main[i][0]['flow_function_interface_item_system_state_stateset'] != "":
for j in range(0,(len(out_list)-1),2):
if out_list[j]==main[i][0]['flow_function_interface_item_system_state_stateset']:
spliter_1 = out_list[j].split(" : ")
instance_file = out_list[j+1]
break
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedTo"+spliter_1[0], URIRef(str(instance_file))+"#"+ str(spliter_1[1])))
if (boilerplate[i][0]['has_suffix'] == True):
g.add((per_instances + title, rdo + 'hasSuffix', per_instances+(title+"_"+ suffix[i][0]['suffix_choices'])))
......
......@@ -48,6 +48,7 @@ def get_i_instances(keyword):
'''Get Instaces - return tuple'''
def get_instances(keyword):
get_file_and_instances(keyword)
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-1]]
out_list = []
......@@ -66,6 +67,29 @@ def get_instances(keyword):
out_list.append(spl[len(spl) - 1])
return tuple((str(keywordspl[len(keywordspl)-1]+" : "+n), str(keywordspl[len(keywordspl)-1]+" : "+n) ) for n in (out_list))
# A list with the values and the file that is the instance
out_list = []
def get_file_and_instances(keyword):
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])
for extra in in_list:
for uri in list_of_DSO:
per = URIRef(uri +extra)
for s, p, o in g.triples((None, RDF.type, per)):
spl = s.split("#")
uri = spl[len(spl) - 2].split("/")
out_list.append(keywordspl[len(keywordspl)-1]+" : " +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) )
'''Get Instaces - return list'''
def get_instances_list(keyword):
......
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