Commit e4ff295f authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

New inference proccess 1.4.2

parent a80c458d
......@@ -10,11 +10,20 @@
</nav>
<mat-grid-list cols="2">
<div class="first">
<div *ngIf="get_metrics(currentboilerplate.title)" style="margin-right: 50px;width: 90%;"
class="alert alert-warning" role="alert">
<p [innerHTML]="getinferdata()"></p>
<div *ngIf="get_metrics(currentboilerplate.title)"
style="display:flex; flex-direction: row; align-items: center;margin-bottom: 50px;">
<mat-accordion>
<mat-expansion-panel *ngFor="let msection of mes_list" class="alert alert-warning" role="alert">
<mat-expansion-panel-header>
<mat-panel-title [innerHTML]='msection.Description'>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]=msection.Title></p>
<p [innerHTML]='msection.Info'></p>
</mat-expansion-panel>
</mat-accordion>
</div>
<div *ngIf="currentboilerplate.id" class="edit-form">
<div *ngIf=" currentboilerplate.id" class="edit-form">
<form ngNativeValidate>
<div class="form-group" style="display:flex; flex-direction: row; align-items: center">
<label for="title" style="margin-right: 50px;">Requirement title</label>
......@@ -138,7 +147,12 @@
{{instan.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{instan.Comment}}</p>
<div fxLayout="column">
<p fxFlex fxHide.xs>{{instan.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, '', '', '', '', instan.Instance, instan.Comment)" />
</div>
</mat-expansion-panel>
</li>
</div>
......@@ -205,8 +219,14 @@
<mat-panel-title>
{{ subsubsubsubinstansub.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubsubsubinstansub.Comment}}</p>
<div fxLayout="column">
<p fxFlex fxHide.xs>{{subsubsubsubinstansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , subsubsub.SubSubClass_name, subsubsubsub.SubSubClass_name, subsubsubsubinstansub.Instance, subsubsubsubinstansub.Comment)" />
</div>
</mat-expansion-panel>
</li>
</div>
......@@ -227,7 +247,12 @@
{{ subsubsubinstansub.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubsubinstansub.Comment}}</p>
<div fxLayout="column">
<p fxFlex fxHide.xs>{{subsubsubinstansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , subsubsub.SubSubClass_name, '', subsubsubinstansub.Instance, subsubsubinstansub.Comment)" />
</div>
</mat-expansion-panel>
</li>
</div>
......@@ -248,7 +273,12 @@
{{ subsubinstansub.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{subsubinstansub.Comment}}</p>
<div fxLayout="column">
<p fxFlex fxHide.xs>{{subsubinstansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, subsub.SubSubClass_name , '', '', subsubinstansub.Instance, subsubinstansub.Comment)" />
</div>
</mat-expansion-panel>
</li>
</div>
......@@ -270,7 +300,12 @@
{{ instansub.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
<p>{{instansub.Comment}}</p>
<div fxLayout="column">
<p fxFlex fxHide.xs>{{instansub.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button"
value="Delete Instance"
(click)="deleteInstance(section.Name , item.Class, sub.SubClass_name, '', '', '', instansub.Instance, instansub.Comment)" />
</div>
</mat-expansion-panel>
</li>
......@@ -297,7 +332,11 @@
{{genin.Instance}}
</mat-panel-title>
</mat-expansion-panel-header>
{{genin.Comment}}
<div fxLayout="column">
<p fxFlex fxHide.xs> {{genin.Comment}}</p>
<input fxFlex fxHide.xs fxLayoutAlign="start" class="btn btn-warning" type="button" value="Delete Instance"
(click)="deleteInstance(section.Name , '', '', '' , '', '', genin.Instance, genin.Comment)" />
</div>
</mat-expansion-panel>
</li>
</div>
......
......@@ -135,9 +135,9 @@ export class MainDetailsComponent implements OnInit {
}
ngOnInit(): void {
this.getAllMain(this.route.snapshot.params.id);
this.getchoices();
this.getmainchoices(this.route.snapshot.params.gb);
this.getAllMain(this.route.snapshot.params.id);
}
ngDoCheck() {
......
......@@ -169,4 +169,8 @@ export class MainService {
setinstances(gb : any, instance: any, comment:any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/add`+`/${instance}`+`/${comment}/`);
}
deleteinstances(gb : any, instance: any, comment:any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/main/choices/delete`+`/${instance}`+`/${comment}/`);
}
}
......@@ -121,21 +121,21 @@ 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(max_length=100)
sys_fun_inter = models.CharField(max_length=1000)
#Between Subject - Verb
state_item_before_verb = models.CharField(max_length=100, blank=True)
statevalue_before_verb = models.CharField(max_length=100, blank=True)
state_item_before_verb = models.CharField(max_length=1000, blank=True)
statevalue_before_verb = models.CharField(max_length=1000, blank=True)
#Verb
shall = models.CharField(max_length=100)
verb = models.CharField(max_length=100)
shall = models.CharField(max_length=1000)
verb = models.CharField(max_length=1000)
#Between Verb - Object
quantifier = models.CharField(max_length=100, blank=True)
numerical = models.CharField(blank=True, null=True, max_length=10)
mumerical_units = models.CharField(max_length=100, blank=True)
quantifier = models.CharField(max_length=1000, blank=True)
numerical = models.CharField(blank=True, null=True, max_length=1000)
mumerical_units = models.CharField(max_length=1000, blank=True)
#Οbject
flow_function_interface_item_system_state_stateset = models.CharField( max_length=100)
flow_function_interface_item_system_state_stateset = models.CharField( max_length=1000)
#last definitions
statevalue_system_connection_stateset = models.CharField(max_length=100, blank=True)
statevalue_system_connection_stateset = models.CharField(max_length=1000, blank=True)
#ID [M1-M16]
main_choices = models.CharField(max_length=100, blank=True)
......
......@@ -158,7 +158,7 @@ class Boilerplate(models.Model):
owner = models.ForeignKey(User, related_name='boilerplate', on_delete=models.CASCADE)
group_of_boilerplate = models.ForeignKey(BoilerplateGroup, related_name='owner_of_boilerplate', on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=30, unique=True)
title = models.CharField(max_length=300, unique=True)
has_prefix = models.BooleanField(default=False)
has_main = models.BooleanField(default=False)
has_suffix = models.BooleanField(default=False)
......@@ -212,18 +212,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(max_length=100)
prefix = models.CharField(max_length=1000)
#state value constraint
system_fun_item = models.CharField(max_length=100)
state_or_verb = models.CharField(max_length=100)
system_fun_item = models.CharField(max_length=1000)
state_or_verb = models.CharField(max_length=1000)
#occuring functionality
item_function_flow_statevalue = models.CharField(max_length=100)
item_function_flow_statevalue = models.CharField(max_length=1000)
#state value constraint OR occuring functionality
logical_expression = models.CharField(max_length=100, blank=True)
logical_expression = models.CharField(max_length=1000, blank=True)
#Logic connectivity Prefix1 (and/or/xor) Prefix2
logic_connective = models.CharField(max_length=100, blank=True)
logic_connective = models.CharField(max_length=1000, blank=True)
#Prefix value P1/P2/P3
simple_prefix = models.CharField(max_length=100, blank=True)
simple_prefix = models.CharField(max_length=1000, blank=True)
def __init__(self, *args, **kwargs):
......@@ -265,7 +265,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)
ontology_file = models.CharField(max_length=1000, blank=True)
inference_data = models.CharField(default="", max_length=1000000, blank=True)
def save(self, **kwargs):
......@@ -280,7 +280,7 @@ class InferenceResults(models.Model):
class BoilerplateGroupClassesInstances(models.Model):
classes_instances_group_of_boilerplate = models.ForeignKey(BoilerplateGroup, related_name='classes_instances_owner_of_boilerplate', on_delete=models.CASCADE)
classes_instances_owner = models.ForeignKey(User, related_name='classes_instances_owner', on_delete=models.CASCADE)
ontology_file = models.CharField(default="", max_length=100, blank=True)
ontology_file = models.CharField(default="", max_length=1000, blank=True)
prefix_choices = JSONField()
prefix_logcon_choices = JSONField()
prefix_verb_choices = JSONField()
......@@ -306,5 +306,5 @@ class BoilerplateGroupClassesInstances(models.Model):
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)
ontology_file_dic = models.CharField(default="", max_length=1000, blank=True)
Dictionary_Data = JSONField()
......@@ -82,10 +82,10 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
g.load('../../Ontologies/'+ontfile, format="turtle")
else :
g.load(ontfile, format="turtle")
print(ontfile)
#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))
#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'))
......@@ -135,7 +135,6 @@ def exportboiltottl(ontfile,project, prefix, boilerplate, main, suffix):
if(main[i][0][j] != ""):
instance_file, splitter_1 = getinstancefile(main[i][0][j], g)
if ( splitter_1[0] =='Item' or splitter_1[0] =='Flow' ):
print(main[i][0][j])
g.add((per_instances+(title+"_"+ main[i][0]['main_choices']), rbo+"isRelatedToTraversingConcept", URIRef(str(instance_file))+"#"+ str(splitter_1[len(splitter_1) -1])))
else :
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])))
......@@ -253,36 +252,62 @@ def shacl(ontotlogy_file):
open(target, 'w').close()
shutil.copyfile(file1, target)
for i in range(3):
print(i+1, 'Cycle of inferencing')
result = subprocess.check_output(["./reqman/apps/reqtool/rest_api/services/shacl-1.3.2/bin/shaclinfer.sh", "-datafile", target])
file_object = open(target, 'a')
res = str(result,'utf-8')
file_object.write(res.strip())
file_object.close()
print(i+1, 'Cycle of inferencing')
#result = subprocess.check_output(["./reqman/apps/reqtool/rest_api/services/shacl-1.3.2/bin/shaclinfer.sh", "-datafile", target])
try:
result = subprocess.check_output("./reqman/apps/reqtool/rest_api/services/shacl-1.4.2/bin/shaclinfer.sh -datafile "+target+" | grep -v -e 'WARN OntDocumentManager' -e 'at org.' -e 'org.apache.' -e '@'",shell=True)
except:
raise APIException("Problem during the Inferencing")
file_object = open(target, 'a')
res = str(result,'utf-8')
file_object.write(res.strip())
file_object.close()
#need to fiil with all the metrics
g = Graph()
gon = Graph()
g.load(target, format="turtle")
gon.load(ontotlogy_file, format="turtle")
req_list=[]
for inf_metr in list_of_inference_metrics:
metrics_dict[inf_metr] = []
p = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO#"+inf_metr)
for s, p, o in g.triples((None, RDF.type, p)):
#metrics_dict["IncompleteRequirement"] = [s]
# e.g IncompleteRequirement': ['Req1', 'Req2']
get_title = str(s).split("#")
if get_title[1] not in req_list:
req_list.append(get_title[1])
metrics_dict[inf_metr].append(get_title[1])
for inf_metr2 in info_metric:
metrics_dict[inf_metr2] = []
p = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO#"+inf_metr2)
req_dict={}
req_dict['Comment'] = ""
for scom, pcom, ocom in g.triples((p, RDFS.comment, None)):
req_dict['Comment'] = str(ocom)
req_dict[get_title[1]]=[]
for s1, p1, o1 in g.triples((s, p, None)):
get_title2 = str(o1).split("#")
req_dict[get_title[1]].append(get_title2[1])
metrics_dict[inf_metr2].append(req_dict)
print(metrics_dict)
for inf_metr2 in info_metric:
#e.g isMissingOfInstance : ['Comment' : '...', {'Req1':['Instance1']}, {'Req2':['Instance2']}]
metrics_dict[inf_metr2] = []
p = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO#"+inf_metr2)
req_dict={}
req_dict['Comment'] = ""
for scom, pcom, ocom in g.triples((p, RDFS.comment, None)):
req_dict['Comment'] = str(ocom)
for get_title in req_list:
req_dict[get_title]=[]
s = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"+get_title)
p = URIRef("http://delab.csd.auth.gr/ontologies/2018/RDO#"+inf_metr2)
for s1, p1, o1 in g.triples((s, p, None)):
get_title2 = str(o1).split("#")
req_dict[get_title].append(get_title2[1])
req_dict[get_title2[1]]=[]
for s3, p3, o3 in gon.triples((None, None, o1)):
sub=str(s3).split("#")
ver=str(p3).split("#")
obj=str(o3).split("#")
req_dict[get_title2[1]].append(sub[1]+' '+ ver[1]+' '+ obj[1])
for s3, p3, o3 in gon.triples((o1, None, None)):
sub=str(s3).split("#")
ver=str(p3).split("#")
obj=str(o3).split("#")
req_dict[get_title2[1]].append('<i>'+sub[1]+'</i> <u>'+ ver[1]+'</u> <i>'+obj[1]+'</i>')
metrics_dict[inf_metr2].append(req_dict)
#print(metrics_dict)
return(metrics_dict)
......
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
status = error
name = PropertiesConfig
filters = threshold
filter.threshold.type = ThresholdFilter
filter.threshold.level = ALL
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{HH:mm:ss} %-5p %-10c{1} :: %m%n
#appender.console.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss}] %-5p %-10c{1} :: %m%n
rootLogger.level = INFO
rootLogger.appenderRef.stdout.ref = STDOUT
logger.jena.name = org.apache.jena
logger.jena.level = WARN
logger.arq-info.name = org.apache.jena.arq.info
logger.arq-info.level = INFO
logger.riot.name = org.apache.jena.riot
logger.riot.level = INFO
......@@ -35,6 +35,7 @@ urlpatterns = [
#MAIN CHOICES DATA
path('groupboilerplates/<int:groupboil>/main/choices/', main_req_views.MainChoicesViewSet.as_view(), name='mainchoices'),
path('groupboilerplates/<int:groupboil>/main/choices/add/<str:instance>/<str:comment>/', main_req_views.MainChoicesAPIView.as_view(), name='setmainchoices'),
path('groupboilerplates/<int:groupboil>/main/choices/delete/<str:instance>/<str:comment>/', main_req_views.DeleteMainChoicesAPIView.as_view(), name='deletemainchoices'),
path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
#SUFFIX CHOICES DATA
......
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