Commit 176ab9ac authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

hide main component base on M1-M16

parent 6c3b314a
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline"> <form class="form-group form-inline" [ngStyle]="(stateitemControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="this.stateitemControl.value !=null">State or Item : {{this.stateitemControl.value.slice(0, this.stateitemControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="this.stateitemControl.value !=null">State or Item : {{this.stateitemControl.value.slice(0, this.stateitemControl.value.indexOf(':'))}}</mat-label>
<input type="text" <input type="text"
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline"> <form class="form-group form-inline" [ngStyle]="(statevalueControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label *ngIf="statevalueControl.value !=null">State Value : {{statevalueControl.value.slice(0, statevalueControl.value.indexOf(':'))}}</mat-label> <mat-label *ngIf="statevalueControl.value !=null">State Value : {{statevalueControl.value.slice(0, statevalueControl.value.indexOf(':'))}}</mat-label>
<input type="text" <input type="text"
...@@ -96,15 +96,16 @@ ...@@ -96,15 +96,16 @@
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
<div class="col"> <div class="col" >
<form class="form-group form-inline"> <form class="form-group form-inline" [ngStyle]="(quantifierControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Quantifier</mat-label> <mat-label>Quantifier</mat-label>
<input type="text" <input
placeholder="Pick one" placeholder="Pick one"
aria-label="Number" aria-label="Number"
matInput matInput
[formControl]="quantifierControl" [formControl]="quantifierControl"
type="text"
[matAutocomplete]="autoquantifier" [matAutocomplete]="autoquantifier"
> >
<mat-autocomplete autoActiveFirstOption #autoquantifier ="matAutocomplete"> <mat-autocomplete autoActiveFirstOption #autoquantifier ="matAutocomplete">
...@@ -117,7 +118,7 @@ ...@@ -117,7 +118,7 @@
</div> </div>
<!--NUmber Value--> <!--NUmber Value-->
<div class="col" > <div class="col" >
<form class="form-group form-inline"> <form class="form-group form-inline" [ngStyle]="(numericalisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label> <mat-label>Numerical Value</mat-label>
<input type="number" matInput value=0 [(ngModel)]="currentmain.numerical" name="numerical"> <input type="number" matInput value=0 [(ngModel)]="currentmain.numerical" name="numerical">
...@@ -125,7 +126,7 @@ ...@@ -125,7 +126,7 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline"> <form class="form-group form-inline" [ngStyle]="(numunitControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Number Unit</mat-label> <mat-label>Number Unit</mat-label>
<input type="text" <input type="text"
...@@ -166,12 +167,13 @@ ...@@ -166,12 +167,13 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<form class="form-group form-inline"> <form class="form-group form-inline" [ngStyle]="(stsysconsetControlisDivVisible) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width"> <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">Connection : {{stsysconsetControl.value.slice(0, stsysconsetControl.value.indexOf(':'))}}</mat-label>
<input type="text" <input
placeholder="Pick one" placeholder="Pick one"
aria-label="Number" aria-label="Number"
type="text"
matInput matInput
[formControl]="stsysconsetControl" [formControl]="stsysconsetControl"
[matAutocomplete]="autostsysconset" [matAutocomplete]="autostsysconset"
......
...@@ -31,10 +31,13 @@ export class MainDetailsComponent implements OnInit { ...@@ -31,10 +31,13 @@ export class MainDetailsComponent implements OnInit {
stateitemControl = new FormControl(); stateitemControl = new FormControl();
stateitem:string[] = []; stateitem:string[] = [];
stateitemfilteredOptions: Observable<string[]>; stateitemfilteredOptions: Observable<string[]>;
stateitemControlisDivVisible = false
statevalueControl = new FormControl(); statevalueControl = new FormControl();
statevalue:string[] = []; statevalue:string[] = [];
statevaluefilteredOptions: Observable<string[]>; statevaluefilteredOptions: Observable<string[]>;
statevalueControlisDivVisible = false
shallControl = new FormControl(); shallControl = new FormControl();
shall:string[] = []; shall:string[] = [];
...@@ -47,10 +50,12 @@ export class MainDetailsComponent implements OnInit { ...@@ -47,10 +50,12 @@ export class MainDetailsComponent implements OnInit {
quantifierControl = new FormControl(); quantifierControl = new FormControl();
quantifier:string[] = []; quantifier:string[] = [];
quantifierfilteredOptions: Observable<string[]>; quantifierfilteredOptions: Observable<string[]>;
quantifierControlisDivVisible = false
numunitControl = new FormControl(); numunitControl = new FormControl();
numunit:string[] = []; numunit:string[] = [];
numunitfilteredOptions: Observable<string[]>; numunitfilteredOptions: Observable<string[]>;
numunitControlisDivVisible = false
fifuintsysstatsetControl = new FormControl(); fifuintsysstatsetControl = new FormControl();
fifuintsysstatset:string[] = []; fifuintsysstatset:string[] = [];
...@@ -59,6 +64,10 @@ export class MainDetailsComponent implements OnInit { ...@@ -59,6 +64,10 @@ export class MainDetailsComponent implements OnInit {
stsysconsetControl = new FormControl(); stsysconsetControl = new FormControl();
stsysconset:string[] = []; stsysconset:string[] = [];
stsysconsetfilteredOptions: Observable<string[]>; stsysconsetfilteredOptions: Observable<string[]>;
stsysconsetControlisDivVisible = false
numericalisDivVisible = false
public static id: any [] = []; public static id: any [] = [];
private readonly notifier: NotifierService; private readonly notifier: NotifierService;
...@@ -88,7 +97,6 @@ export class MainDetailsComponent implements OnInit { ...@@ -88,7 +97,6 @@ export class MainDetailsComponent implements OnInit {
startWith(""), startWith(""),
map(value => this._filter(this.subjects, value)) map(value => this._filter(this.subjects, value))
); );
this.stateitemControl.disable()
this.stateitemfilteredOptions = this.stateitemControl.valueChanges.pipe( this.stateitemfilteredOptions = this.stateitemControl.valueChanges.pipe(
startWith(""), startWith(""),
map(value => this._filter(this.stateitem, value)) map(value => this._filter(this.stateitem, value))
...@@ -132,16 +140,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -132,16 +140,7 @@ export class MainDetailsComponent implements OnInit {
this.dis(); this.dis();
} }
dis(): void{ dis(): any{
//Related to System
this.stateitemControl.disable();
this.statevalueControl.disable()
//Quantifier
this.quantifierControl.disable();
//numerical value
this.numunitControl.disable();
// Extra Attribute
this.stsysconsetControl.disable();
//Check for each M1-M16 //Check for each M1-M16
for (let x=0; x < this.mainsyntax.length; x++ ){ for (let x=0; x < this.mainsyntax.length; x++ ){
//for (let x=0; x < 1; x++ ){ //for (let x=0; x < 1; x++ ){
...@@ -153,47 +152,48 @@ export class MainDetailsComponent implements OnInit { ...@@ -153,47 +152,48 @@ export class MainDetailsComponent implements OnInit {
for (let v=0; v < this.mainsyntax[x].Verbs.length; v++ ){ for (let v=0; v < this.mainsyntax[x].Verbs.length; v++ ){
if (this.mainsyntax[x].Verbs[v] == ((this.verbControl.value).replace(/\s/g, ""))){ if (this.mainsyntax[x].Verbs[v] == ((this.verbControl.value).replace(/\s/g, ""))){
//console.log("Verb okk") //console.log("Verb okk")
for (let a=0; a < this.mainsyntax[x].Attributes.length; a++ ){ for (let a=0; a < this.mainsyntax[x].Attributes.length; a++ ){
if (this.mainsyntax[x].Attributes[a] == (this.fifuintsysstatsetControl.value.slice(0, this.fifuintsysstatsetControl.value.indexOf(':'))).replace(/\s/g, "")){ if (this.mainsyntax[x].Attributes[a] == (this.fifuintsysstatsetControl.value.slice(0, this.fifuintsysstatsetControl.value.indexOf(':'))).replace(/\s/g, "")){
console.log("Attribute okk", this.mainsyntax[x].Id) console.log("Attribute okk", this.mainsyntax[x].Id)
if (this.mainsyntax[x].Related_to_Subject.length > 0 ){ if (this.mainsyntax[x].Related_to_Subject.length > 0 ){
this.stateitemControl.enable(); this.stateitemControlisDivVisible = true
for (let r=0; r < this.mainsyntax[x].Related_to_Subject.length; r++ ){ for (let r=0; r < this.mainsyntax[x].Related_to_Subject.length; r++ ){
if (this.mainsyntax[x].Related_to_Subject[r] == "StateValue"){this.statevalueControl.enable(); } if (this.mainsyntax[x].Related_to_Subject[r] == "StateValue"){this.statevalueControlisDivVisible = true; }
} }
} }
console.log(this.mainsyntax[x].Quantifier) console.log(this.mainsyntax[x].Quantifier)
if (this.mainsyntax[x].Quantifier){ if (this.mainsyntax[x].Quantifier){
this.quantifierControl.enable(); //this.quantifierControl.enable();
this.quantifierControlisDivVisible = true;
this.numericalisDivVisible = true;
//numerical value //numerical value
this.numunitControl.enable(); this.numunitControlisDivVisible = true;
//add the numunit data
} }
if (this.mainsyntax[x].Attributes.length > 1){this.stsysconsetControl.enable();} if (this.mainsyntax[x].Attributes.length > 1){
this.stsysconsetControlisDivVisible = true;
//add the connection data
return 1;
} }
} }
} }
} }
} }
} }
/*
if (this.mainsyntax[x].Quantifier){
console.log(this.mainsyntax[x].Quantifier)
}
for (let a=0; a < this.mainsyntax[x].Attributes.length; a++ ){
console.log(this.mainsyntax[x].Attributes[a])
}
for (let r=0; r < this.mainsyntax[x].Related_to_Subject.length; r++ ){
console.log(this.mainsyntax[x].Related_to_Subject[r])
}
for (let v=0; v < this.mainsyntax[x].Verbs.length; v++ ){
console.log(this.mainsyntax[x].Verbs[v])
}
//this.stateitemControl.enable();
*/
} }
this.getchoices(); //Related to System
this.stateitemControlisDivVisible = false;
this.statevalueControlisDivVisible = false;
//Quantifier
//this.quantifierControl.markAsUntouched();
this.quantifierControlisDivVisible = false;
//numerical value
this.numunitControlisDivVisible = false;
this.numericalisDivVisible = false;
// Extra Attribute
this.stsysconsetControlisDivVisible = false;
} }
}
displayFn(option:string): string { displayFn(option:string): string {
if (option != null) { if (option != null) {
...@@ -250,15 +250,15 @@ export class MainDetailsComponent implements OnInit { ...@@ -250,15 +250,15 @@ export class MainDetailsComponent implements OnInit {
updateMain(): void { updateMain(): void {
this.currentmain.sys_fun_inter = this.subjectsControl.value; this.currentmain.sys_fun_inter = this.subjectsControl.value;
this.currentmain.state_item_before_verb = this.stateitemControl.value; if( this.stateitemControlisDivVisible){this.currentmain.state_item_before_verb = this.stateitemControl.value;}
this.currentmain.statevalue_before_verb = this.statevalueControl.value; if (this.statevalueControlisDivVisible){this.currentmain.statevalue_before_verb = this.statevalueControl.value;}
this.currentmain.shall = this.shallControl.value; this.currentmain.shall = this.shallControl.value;
this.currentmain.verb = this.verbControl.value; this.currentmain.verb = this.verbControl.value;
this.currentmain.quantifier = this.quantifierControl.value; if (this.quantifierControlisDivVisible){this.currentmain.quantifier = this.quantifierControl.value;}
//num //num
this.currentmain.mumerical_units = this.numunitControl.value; if (this.numericalisDivVisible){this.currentmain.mumerical_units = this.numunitControl.value;}
this.currentmain.flow_function_interface_item_system_state_stateset = this.fifuintsysstatsetControl.value; this.currentmain.flow_function_interface_item_system_state_stateset = this.fifuintsysstatsetControl.value;
this.currentmain.statevalue_system_connection_stateset = this.stsysconsetControl.value; if (this.stsysconsetControlisDivVisible){this.currentmain.statevalue_system_connection_stateset = this.stsysconsetControl.value;}
for (let i=0; i<MainDetailsComponent.id.length; i++){ for (let i=0; i<MainDetailsComponent.id.length; i++){
this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain) this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain)
.subscribe( .subscribe(
...@@ -325,7 +325,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -325,7 +325,7 @@ export class MainDetailsComponent implements OnInit {
.subscribe( .subscribe(
data => { data => {
for (let x=0; x < data.length; x++ ){ for (let x=0; x < data.length; x++ ){
this.quantifier.push(data[x][1]);} this.quantifier.push(data[x][1]);}
}, },
error => { error => {
console.log(error); console.log(error);
......
...@@ -7,7 +7,7 @@ from reqman.apps.reqtool.models.main_req import SYSTEM_CHOICES, FUNCTION_CHOICES ...@@ -7,7 +7,7 @@ from reqman.apps.reqtool.models.main_req import SYSTEM_CHOICES, FUNCTION_CHOICES
Ontology_file = "../../Ontologies/Mokos_18_1_7_47.ttl" Ontology_file = "../../Ontologies/Mokos_18_1_7_47.ttl"
main_syntax = get_main_sytax() main_syntax = get_main_sytax_inference()
def getclassofmain(main): def getclassofmain(main):
return(findclassofmain(main)) return(findclassofmain(main))
...@@ -89,7 +89,7 @@ def findclassofmain(listofmain): ...@@ -89,7 +89,7 @@ def findclassofmain(listofmain):
#for currentmain in range(len(listofmain)): #for currentmain in range(len(listofmain)):
currentverb = listofmain['verb'] currentverb = listofmain['verb']
currentsubject = listofmain['sys_fun_inter'] currentsubject = listofmain['sys_fun_inter']
currentattr = listofmain['sys_fun_inter'] currentattr = listofmain['flow_function_interface_item_system_state_stateset']
for verbmain in verbsmain: for verbmain in verbsmain:
flag = 0 flag = 0
if (verbmain.upper() == currentverb.upper()): if (verbmain.upper() == currentverb.upper()):
......
...@@ -399,6 +399,42 @@ def get_attribute(bnodes_uriref, subjects, related_subjects, verbs): ...@@ -399,6 +399,42 @@ def get_attribute(bnodes_uriref, subjects, related_subjects, verbs):
return(res) return(res)
'''Find Main syntax - return a dict with the syntax'''
def get_main_sytax_inference():
get_main = get_instances_list("RBO#Main")
main_dict = {}
for main in get_main:
bnodes = []
p = URIRef("http://delab.csd.auth.gr/ontologies/2018/RBO#" + main)
for s, p, o in g.triples((p, None, None)):
if isinstance(o, BNode):
bnodes.append(o)
bnodes.sort()
for bn in bnodes:
for objects in g.objects(subject=BNode(bn)):
if isinstance(objects, BNode):
bnodes.append(objects)
bnodes.sort()
bnodes_uriref = []
for bn in bnodes:
for objects in g.objects(subject=BNode(bn)):
if isinstance(objects, URIRef):
bnodes_uriref.append(objects)
main_dict[main] = {}
main_dict[main]["Subject"] = get_subjects(bnodes_uriref)
main_dict[main]["Related_to_Subject"] = get_related_to_subject(bnodes_uriref)
main_dict[main]["Verbs"] = get_verb(bnodes_uriref)
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"])
return main_dict
'''Find Main syntax - return a dict with the syntax''' '''Find Main syntax - return a dict with the syntax'''
def get_main_sytax(): def get_main_sytax():
......
...@@ -109,7 +109,6 @@ class StatItemChoicesViewSet(APIView): ...@@ -109,7 +109,6 @@ class StatItemChoicesViewSet(APIView):
class StatevalueChoicesViewSet(APIView): class StatevalueChoicesViewSet(APIView):
def get(self, request): def get(self, request):
print(STATE_VALUE_CHOICES)
response = Response(STATE_VALUE_CHOICES) response = Response(STATE_VALUE_CHOICES)
return response return response
......
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