Commit 6c3b314a authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

disable unused Main

parent c96ca273
......@@ -26,6 +26,6 @@
position: absolute;
top: 1%;
right: 0px;
height:80%;
height:100%;
overflow:auto;
}
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Main } from 'src/app/models/main.model';
import { Mainsyntax } from 'src/app/models/main.model';
import { MainService } from 'src/app/services/main.service';
import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs';
......@@ -13,6 +14,15 @@ import { NotifierService } from "angular-notifier";
styleUrls: ['./main-details.component.scss']
})
export class MainDetailsComponent implements OnInit {
mainsyntax = [
{Attributes: [], Id: "", Quantifier: false, Related_to_Subject: [], Subject: [], Verbs: []}];
mainsyntax11?: Mainsyntax ={
Attributes : [],
Quantifier : false,
Related_to_Subject : [],
Subject : [],
Verbs : []
};
subjectsControl = new FormControl();
subjects:string[] = [];
......@@ -78,6 +88,7 @@ export class MainDetailsComponent implements OnInit {
startWith(""),
map(value => this._filter(this.subjects, value))
);
this.stateitemControl.disable()
this.stateitemfilteredOptions = this.stateitemControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.stateitem, value))
......@@ -117,6 +128,73 @@ export class MainDetailsComponent implements OnInit {
this.getAllMain(this.route.snapshot.params.id);
}
ngDoCheck() {
this.dis();
}
dis(): void{
//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
for (let x=0; x < this.mainsyntax.length; x++ ){
//for (let x=0; x < 1; x++ ){
//console.log(this.mainsyntax[x])
//console.log(this.mainsyntax[x].Id)
for (let s=0; s < this.mainsyntax[x].Subject.length; s++ ){
if (this.mainsyntax[x].Subject[s] == (this.subjectsControl.value.slice(0, this.subjectsControl.value.indexOf(':'))).replace(/\s/g, "")){
//console.log("okk")
for (let v=0; v < this.mainsyntax[x].Verbs.length; v++ ){
if (this.mainsyntax[x].Verbs[v] == ((this.verbControl.value).replace(/\s/g, ""))){
//console.log("Verb okk")
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, "")){
console.log("Attribute okk", this.mainsyntax[x].Id)
if (this.mainsyntax[x].Related_to_Subject.length > 0 ){
this.stateitemControl.enable();
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(); }
}
}
console.log(this.mainsyntax[x].Quantifier)
if (this.mainsyntax[x].Quantifier){
this.quantifierControl.enable();
//numerical value
this.numunitControl.enable();
}
if (this.mainsyntax[x].Attributes.length > 1){this.stsysconsetControl.enable();}
}
}
}
}
}
}
/*
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();
}
displayFn(option:string): string {
if (option != null) {
let x = option.split(" : ");
......@@ -210,7 +288,6 @@ export class MainDetailsComponent implements OnInit {
.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]);}
},
......@@ -281,6 +358,15 @@ export class MainDetailsComponent implements OnInit {
error => {
console.log(error);
});
this.mainService.getmainsyntax()
.subscribe(
data => {
this.mainsyntax = data
},
error => {
console.log(error);
});
}
}
......
......@@ -14,3 +14,15 @@ export class Main {
statevalue_system_connection_stateset?: string;
main_choices?: string;
}
export class Mainsyntax {
Attributes?:In[];
Quantifier?:boolean
Related_to_Subject?:In[];
Subject?:In[];
Verbs?:In[];
}
export class In {
Instance?: any;
}
\ No newline at end of file
......@@ -156,4 +156,8 @@ export class MainService {
getdictionary(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/dictionary`);
}
getmainsyntax(): Observable<any> {
return this.http.get(`http://155.207.131.19:8000/api-auth/mainsyntax`);
}
}
......@@ -9,6 +9,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
find_subclass_domain_range()
#MAIN SYNTAX
MAIN_SYNTAX = get_main_sytax()
#import pprint
#pprint.pprint(get_main_sytax())
......@@ -78,17 +79,17 @@ STATE_CHOICES = get_instances("SAO#State")
STATE_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#State")
STATE_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#State")
STATE_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#State")
#State Choices
STATE_SET_CHOICES = get_instances("SAO#StateSet")
STATECHOICES_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#StateSet")
#
#State Values
STATE_VALUE_CHOICES =get_instances("SAO#StateValue")
#print(STATE_VALUE_CHOICES)
#nothing return get_instances
STATE_SET_CHOICES = get_i_instances("SAO#StateSet")
#print(STATE_SET_CHOICES)
STATEVALUES_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#StateValue")
#
VERB_CHOICES = get_verb_instances("LO#Verb")
#add automatic function ot get verbs
VERB_CHOICES = (("set","set"),("send","send"),("receive","receive"),("ingest","ingest"),("emit","emit"),("perform","perform"),("invoke","invoke"),
("present","present"),("transfer","transfer"),("interact with","interact with"),("have state","have state"),("have substate","have substate"),
("take values from","take values from"),("be composed","be composed"),("contain","contain"))
#test to add M
CLASS_CHOICES = (("SYSTEM","SYSTEM"), ("FUNCTION","FUNCTION"), ("SHALL","SHALL/SHALL NOT"),
......
......@@ -50,6 +50,21 @@ def get_i_instances(keyword):
return tuple((str(n), str(n)) for n in (out_list))
'''Get Verbs - return tuple'''
def get_verb_instances(keyword):
get_file_and_instances(keyword)
keywordspl = keyword.split("#")
in_list = []
out_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])
return tuple((str(n), str(n)) for n in (in_list))
'''Get Instaces - return tuple'''
def get_instances(keyword):
get_file_and_instances(keyword)
......@@ -389,6 +404,7 @@ def get_attribute(bnodes_uriref, subjects, related_subjects, verbs):
def get_main_sytax():
get_main = get_instances_list("RBO#Main")
main_dict = {}
main_dict_list = []
for main in get_main:
bnodes = []
p = URIRef("http://delab.csd.auth.gr/ontologies/2018/RBO#" + main)
......@@ -412,14 +428,15 @@ def get_main_sytax():
bnodes_uriref.append(objects)
main_dict[main] = {}
main_dict[main]["Id"] = 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"])
main_dict_list.append(main_dict[main])
return main_dict
return main_dict_list
'''Find Prefix syntax - return a dict with the syntax'''
......
......@@ -89,5 +89,6 @@ urlpatterns = [
#Dictionary
path('dictionary/', main_req_views.DictionaryViewSet.as_view(), name='dictionary'),
path('mainsyntax/', main_req_views.MainSyntaxViewSet.as_view(), name='mainsyntax'),
]
\ No newline at end of file
......@@ -25,7 +25,7 @@ from reqman.apps.reqtool.models.main_req import ITEM_CLASSES_COMMENTS, ITEM_SUBC
from reqman.apps.reqtool.models.main_req import INTERFACE_CLASSES_COMMENTS, INTERFACE_SUBCLASSES_COMMENTS, INTERFACE_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import CONNECTION_CLASSES_COMMENTS, CONNECTION_SUBCLASSES_COMMENTS, CONNECTION_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import FLOW_CLASSES_COMMENTS, FLOW_SUBCLASSES_COMMENTS, FLOW_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import STATE_CLASSES_COMMENTS, STATE_SUBCLASSES_COMMENTS, STATE_INSTANCES_COMMENTS
from reqman.apps.reqtool.models.main_req import STATE_CLASSES_COMMENTS, STATE_SUBCLASSES_COMMENTS, STATE_INSTANCES_COMMENTS, MAIN_SYNTAX
from reqman.apps.reqtool.models.requirements import BoilerplateData
from rest_framework.exceptions import APIException
......@@ -285,4 +285,10 @@ class DictionaryViewSet(APIView):
def get(self, request):
response = Response(Dictionary_Data_list)
return response
class MainSyntaxViewSet(APIView):
def get(self, request):
response = Response(MAIN_SYNTAX)
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