Commit cfc4aafc authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

dictionary for system classes, subclasses and instances

parent 2a3b6646
......@@ -8,7 +8,7 @@
<li class="breadcrumb-item" aria-current="page">Edit Boilerplate</li>
</ol>
</nav>
<div>
<div class="first">
<div *ngIf="currentboilerplate.id" class="edit-form">
<form>
<div class="form-group" style="width: 63%;">
......@@ -82,5 +82,82 @@
<div *ngIf="!currentboilerplate.id">
<mat-spinner style="margin: auto;"></mat-spinner>
</div>
</div>
<!-- Dictionary -->
<div class="second">
<mat-tab-group mat-align-tabs="center">
<mat-tab label="System">
<div *ngFor="let item of systems; let i = index">
<div *ngIf="checkeven(i)">
<mat-accordion>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ item }}
</mat-panel-title>
<mat-panel-description>
<!-- only mini description-->
</mat-panel-description>
</mat-expansion-panel-header>
{{ systems [i+1] }}
<ul> <h4><b>Instances</b></h4>
<div *ngFor="let instan of intacesystems; let y = index">
<div *ngIf="item == instan">
<li>
<mat-expansion-panel hideToggle>
<p>Description.</p>
<mat-expansion-panel-header>
<mat-panel-title>
{{ intacesystems[y+1] }}
</mat-panel-title>
</mat-expansion-panel-header>
</mat-expansion-panel>
</li>
</div>
</div>
</ul>
<ul> <h4><b>Subclasses</b></h4>
<div *ngFor="let sub of subclassystems; let y = index">
<div *ngIf="item == sub">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ subclassystems[y+1] }}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subclassystems[y+2]}}</p>
<ul> <h5>Instances</h5>
<div *ngFor="let instan of intacesystems; let y = index">
<div *ngIf="sub == instan">
<li>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title>
{{ intacesystems[y+1] }}
</mat-panel-title>
</mat-expansion-panel-header>
</mat-expansion-panel>
</li>
</div>
</div>
</ul>
</mat-expansion-panel>
</li>
</div>
</div>
</ul>
</mat-expansion-panel>
</mat-accordion>
</div>
</div>
</mat-tab>
<mat-tab label="Function">Content 2</mat-tab>
<mat-tab label="Interface">Content 3</mat-tab>
<mat-tab label="Item">Content 3</mat-tab>
<mat-tab label="State">Content 3</mat-tab>
</mat-tab-group>
</div>
\ No newline at end of file
......@@ -16,3 +16,16 @@
.form-group{
min-width: 150px;
}
.first{
width: 68%;
}
.second{
width: 32%;
position: absolute;
top: 14%;
right: 0px;
height:80%;
overflow:auto;
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Boilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { MainService } from 'src/app/services/main.service';
......@@ -13,6 +14,16 @@ import { BoilerplateService } from 'src/app/services/boilerplate.service';
})
export class BoilerplateDetailsComponent implements OnInit {
panelOpenState = false;
subjects:string[] = [];
systems:string[] = [];
subclassystems:string[] = [];
intacesystems:string[] = [];
functions:string[] = [];
items:string[] = [];
currentboilerplate: Boilerplate = {
has_prefix: false,
has_main: false,
......@@ -21,12 +32,14 @@ export class BoilerplateDetailsComponent implements OnInit {
message = '';
constructor(
private mainService: MainService,
private boilerplateService: BoilerplateService,
private route: ActivatedRoute,
private router: Router) { }
ngOnInit(): void {
this.message = '';
this.getchoices();
this.getBoilerplate(this.route.snapshot.params.gb, this.route.snapshot.params.id);
}
......@@ -68,4 +81,38 @@ export class BoilerplateDetailsComponent implements OnInit {
});
}
}
getchoices(): void{
this.mainService.getclasssystem()
.subscribe(
data => {
this.systems = data
},
error => {
console.log(error);
});
this.mainService.getinstancesystem()
.subscribe(
data => {
this.intacesystems = data
},
error => {
console.log(error);
});
this.mainService.getsubclassystem()
.subscribe(
data => {
this.subclassystems = data
},
error => {
console.log(error);
});
}
checkeven(i:any): any {
if (i%2 == 0){ return true}
return false
}
}
......@@ -43,6 +43,8 @@
</div>
</div>
<table mat-table [dataSource]="newdataSource" class="mat-elevation-z8">
<!-- Position Column -->
<ng-container matColumnDef="id">
......
......@@ -69,4 +69,16 @@ export class MainService {
return this.http.get(`http://155.207.131.19:8000/api-auth/main/choices/stsysconset/`);
}
getclasssystem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/system`);
}
getsubclassystem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/system/subclasses`);
}
getinstancesystem(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/class/system/instance`);
}
}
......@@ -33,6 +33,9 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1"),
#to be updated with domains from DSO
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")
#print(get_instances("SAO#System"))
FUNCTION_CHOICES = get_instances("SAO#Function")
SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not"))
......
......@@ -34,7 +34,7 @@ def inferencing(project, boilerlate, prefix, main, suffix):
def exportboiltottl(project, prefix, boilerplate, main, suffix):
#print(out_list) A list with the values and the file that is the instance
#print(out_list) #A list with the values and the file that is the instance
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#")
......
......@@ -11,6 +11,7 @@ subClass_instances = "../../Ontologies/instances_subclass.txt"
list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS-instances#"]
list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances", "<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"]
DSO = ["http://delab.csd.auth.gr/ontologies/2018/DSO#"]
g = Graph()
g.load(Ontology_file, format="turtle")
......@@ -72,6 +73,8 @@ def get_instances(keyword):
# 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 = {}
def get_file_and_instances(keyword):
keywordspl = keyword.split("#")
......@@ -92,6 +95,82 @@ def get_file_and_instances(keyword):
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) )
#Instances and Comments
def get_dmo_instance_and_comment(keyword):
mid_list = []
out_list_com = []
keywordspl = keyword.split("#")
in_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)
for s, p, o in g.triples((None, RDF.type, per)):
spl = s.split("#")
uri = spl[len(spl) - 2].split("/")
mid_list.append(extra)
mid_list.append(spl[len(spl) - 1])
#need to find if instances have comment with their descreption!!!!!
#for now it returns only the instances
for extra in mid_list:
for uri in list_of_DSO:
per = URIRef(uri +extra)
for s, p, o in g.triples((per, RDFS.comment, None)):
spl = s.split("#")
uri = spl[len(spl) - 2].split("/")
out_list_com.append(str(extra))
out_list_com.append((str(o).replace("\r","")).replace("\n",""))
return mid_list
#Classes and Comments
def get_dmo_classes_and_comment(keyword):
out_list_instance = []
out_list_com = []
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-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("#")
out_list_instance.append(spl[len(spl) - 1])
for comment in out_list_instance:
for uri in list_of_DSO:
per = URIRef(uri +comment)
for s, p, o in g.triples((per, RDFS.comment, None)):
out_list_com.append(str(comment))
out_list_com.append((str(o).replace("\r","")).replace("\n",""))
return(out_list_com)
#Classes of classes and Comments
def get_dmo_classes_of_classes_and_comment(keyword):
out_list_instance = []
out_list_com = []
mid_list = []
keywordspl = keyword.split("#")
in_list = [keywordspl[len(keywordspl)-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("#")
out_list_instance.append(spl[len(spl) - 1])
for comment in out_list_instance:
for uri in list_of_DSO:
per = URIRef(uri +comment)
for s, p, o in g.triples((None, RDFS.subClassOf, per)):
spl = s.split("#")
out_list_com.append(str(comment))
out_list_com.append(spl[len(spl) - 1])
kop = URIRef(uri + spl[len(spl) - 1])
for q, w,m in g.triples((kop, RDFS.comment, None)):
out_list_com.append((str(m).replace("\r","")).replace("\n",""))
return(out_list_com)
'''Get Instaces - return list'''
......
......@@ -52,5 +52,12 @@ urlpatterns = [
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
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'),
]
\ No newline at end of file
......@@ -18,6 +18,9 @@ from reqman.apps.reqtool.models.main_req import SYSTEM_CHOICES, FUNCTION_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 SYSTEM_CLASSES_COMMENTS, SYSTEM_SUBCLASSES_COMMENTS, SYSTEM_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.requirements import BoilerplateData
from rest_framework.exceptions import APIException
......@@ -145,3 +148,21 @@ 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
\ 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