Commit a80c458d authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

5 step instances level, details about inference results

parent e52b17aa
......@@ -46,8 +46,8 @@
<!-- Name Column -->
<ng-container matColumnDef="title_data">
<th mat-header-cell *matHeaderCellDef> Title </th>
<td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}} > {{element.title_data}} <span
*ngIf="get_metrics(element.title_data).length > 0" matBadge={{get_metrics(element.title_data).length}}
<td mat-cell *matCellDef="let element" matTooltip={{get_metrics(element.title_data)}}> {{element.title_data}}
<span *ngIf="get_metrics(element.title_data).length > 0" matBadge={{get_metrics(element.title_data).length}}
matBadgeColor="warn" matBadgeSize="small" position="above"> &nbsp;&nbsp; </span>
</td>
</ng-container>
......
......@@ -156,19 +156,21 @@ export class BoilerplateListComponent implements OnInit {
this.boilerplateService.getAllInfer(this.route.snapshot.params.gb)
.subscribe(
data => {
console.log(data);
this.currentInfer = data[0];
this.infer = data;
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
var final = []
for (let i of this.list_of_inference_metrics) {
if (obj[i] != undefined) {
if (data[0]) {
const obj = JSON.parse(this.currentInfer['inference_data'].replace(/'/g, "\""))
var final = []
for (let i of this.list_of_inference_metrics) {
if (obj[i] != undefined) {
final.push({ value: obj[i].length, name: i })
}
final.push({ value: obj[i].length, name: i })
}
}
}
console.log(final);
//console.log(final);
this.chartOption.series = [{
type: 'pie',
radius: ['40%', '70%'],
......
<div fxLayoutAlign="end">
<mat-chip color="primary"> MAIN TEMPLATE : {{this.main}}</mat-chip>
<h2><span class="badge badge-secondary"> MAIN TEMPLATE : {{this.main}}</span></h2>
</div>
<div class="form-row">
<div class="col">
......@@ -91,9 +91,10 @@
<mat-label>Quantifier</mat-label>
<input placeholder="Pick one" aria-label="Number" matInput [formControl]="quantifierControl" type="text"
[matAutocomplete]="autoquantifier">
<mat-autocomplete autoActiveFirstOption #autoquantifier="matAutocomplete">
<mat-autocomplete autoActiveFirstOption #autoquantifier="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of quantifierfilteredOptions | async" [value]="option">
{{option}}
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
......@@ -116,9 +117,10 @@
<mat-label>Number Unit</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="numunitControl"
[matAutocomplete]="autonumunit">
<mat-autocomplete autoActiveFirstOption #autonumunit="matAutocomplete">
<mat-autocomplete autoActiveFirstOption #autonumunit="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of numunitfilteredOptions | async" [value]="option">
{{option}}
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
......
<div class="form-row">
<div class="col">
<form class="form-group form-inline" ngNativeValidate>
<mat-form-field class="example-full-width">
<mat-label>Suffix</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="suffixControl"
required
[matAutocomplete]="autosuffix"
>
<mat-autocomplete autoActiveFirstOption #autosuffix="matAutocomplete">
<mat-option *ngFor="let option of suffixfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col" >
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label>
<input type="text" matInput [(ngModel)]="currentsuffix.numerical" name="numerical">
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Unit</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="mumerical_unitsControl"
[matAutocomplete]="automumerical_units"
>
<mat-autocomplete autoActiveFirstOption #automumerical_units="matAutocomplete">
<mat-option *ngFor="let option of mumerical_unitsfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="flowControl.value !=null">Flow : {{flowControl.value.slice(0, flowControl.value.indexOf(':'))}}</mat-label>
<mat-label>Flow</mat-label>
<input type="text"
placeholder="Pick one"
aria-label="Number"
matInput
[formControl]="flowControl"
[matAutocomplete]="autoflow"
>
<mat-autocomplete autoActiveFirstOption #autoflow="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of flowfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline" ngNativeValidate>
<mat-form-field class="example-full-width">
<mat-label *ngIf="this.suffixControl.value !=null">Suffix :{{this.suffixControl.value.slice(0,
this.suffixControl.value.indexOf(':'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="suffixControl" required
[matAutocomplete]="autosuffix">
<mat-autocomplete autoActiveFirstOption #autosuffix="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of suffixfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Numerical Value</mat-label>
<input type="text" matInput [(ngModel)]="currentsuffix.numerical" name="numerical">
</mat-form-field>
</form>
</div>
<div class="col">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label *ngIf="this.mumerical_unitsControl.value !=null">Numerical Value
: {{this.mumerical_unitsControl.value.slice(0,
this.mumerical_unitsControl.value.indexOf(':'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="mumerical_unitsControl"
[matAutocomplete]="autonumsuffix">
<mat-autocomplete autoActiveFirstOption #autonumsuffix="matAutocomplete" showPanel="true"
[displayWith]="displayFn">
<mat-option *ngFor="let option of mumerical_unitsfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
<div class="col" *ngIf="this.mumerical_unitsControl.value !=null">
<form class="form-group form-inline"
[ngStyle]=" showflow(this.suffixControl.value) ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-form-field class="example-full-width">
<mat-label *ngIf="flowControl.value !=null">Flow or Function : {{flowControl.value.slice(0,
flowControl.value.indexOf(':'))}}</mat-label>
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="flowControl" required
[matAutocomplete]="autoflow">
<mat-autocomplete autoActiveFirstOption #autoflow="matAutocomplete" showPanel="true" [displayWith]="displayFn">
<mat-option *ngFor="let option of flowfilteredOptions | async" [value]="option">
{{option.split(" : ").pop()}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
</div>
</div>
\ No newline at end of file
......@@ -26,6 +26,7 @@ export class SuffixDetailsComponent implements OnInit {
flowControl = new FormControl();
flow: string[] = [];
flowfilteredOptions: Observable<string[]>;
flowControlisDivVisible = false
public static id: any[] = [];
private readonly notifier: NotifierService;
......@@ -61,7 +62,10 @@ export class SuffixDetailsComponent implements OnInit {
}
ngOnInit(): void {
this.getchoices();
//this.getchoices();
this.getflowchoices(this.route.snapshot.params.gb);
console.log('aaa', this.route.snapshot.params.gb);
this.getAllSuffix(this.route.snapshot.params.id);
}
......@@ -75,6 +79,16 @@ export class SuffixDetailsComponent implements OnInit {
return "";
}
showflow(option: string): boolean {
this.flowControlisDivVisible = false
if (option != null) {
let x = option.split(" : ");
if ((x[x.length - 2] == "") || (x[x.length - 1] == "")) { return false; }
if (x[x.length - 2] == 'EventRelated' || x[x.length - 2] == 'TimeRangeRelated' || x[x.length - 2] == 'ExecutionRelated') { this.flowControlisDivVisible = true; return true; }
}
return false;
}
private _filter(data: string[], value: string): string[] {
const filterValue = value.toLowerCase();
return data.filter(option => option.toLowerCase().includes(filterValue));
......@@ -119,7 +133,7 @@ export class SuffixDetailsComponent implements OnInit {
updateSuffix(): void {
this.currentsuffix.s_choices = this.suffixControl.value;
this.currentsuffix.mumerical_units = this.mumerical_unitsControl.value;
this.currentsuffix.flow = this.flowControl.value;
if (this.flowControlisDivVisible) { this.currentsuffix.flow = this.flowControl.value; } else { this.currentsuffix.flow = '' }
for (let i = 0; i < SuffixDetailsComponent.id.length; i++) {
this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix)
.subscribe(
......@@ -133,32 +147,50 @@ export class SuffixDetailsComponent implements OnInit {
}
getchoices(): void {
this.suffixService.getsuffix()
getflowchoices(prefix_group: any): void {
this.suffixService.getsuffixflow(prefix_group)
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
if (this.suffix.indexOf(data[x][1]) == -1) {
this.suffix.push(data[x][1]);
}
}
//set flow choices
this.setflow(JSON.parse(data[0].flow_choices));
this.setflow(JSON.parse(data[0].function_choices));
this.setsuffix(JSON.parse(data[0].suffix_choices));
this.setmumerical_units(JSON.parse(data[0].number_unit_choices));
},
error => {
console.log(error);
});
this.suffixService.getnumunits()
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
if (this.mumerical_units.indexOf(data[x][1]) == -1) {
this.mumerical_units.push(data[x][1]);
}
}
},
error => {
console.log(error);
});
this.suffixService.getflow()
}
setflow(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.flow.indexOf(strIntoObj[x][1]) == -1) {
this.flow.push((strIntoObj[x][1]));
}
}
}
setsuffix(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.suffix.indexOf(strIntoObj[x][1]) == -1) {
this.suffix.push((strIntoObj[x][1]));
}
}
}
setmumerical_units(strIntoObj: any): void {
for (let x = 0; x < strIntoObj.length; x++) {
if (this.mumerical_units.indexOf(strIntoObj[x][1]) == -1) {
this.mumerical_units.push((strIntoObj[x][1]));
}
}
}
}
/*this.suffixService.getflow()
.subscribe(
data => {
for (let x = 0; x < data.length; x++) {
......@@ -169,8 +201,4 @@ export class SuffixDetailsComponent implements OnInit {
},
error => {
console.log(error);
});
}
}
});*/
\ No newline at end of file
......@@ -45,6 +45,27 @@ export class SubClasses {
SubClass_name?: any;
SubclassComment?: any
InstanceOfSubclass?: Instances[];
SubSubClass?: SubSubClasses[];
}
export class SubSubClasses {
SubSubClass_name?: any;
SubSubclassComment?: any
SubInstanceOfSubclass?: Instances[];
SubSubClass?:SubSubSubClasses[];
}
export class SubSubSubClasses {
SubSubClass_name?: any;
SubSubclassComment?: any
SubInstanceOfSubclass?: Instances[];
SubSubClass?:SubSubSubSubClasses[];
}
export class SubSubSubSubClasses {
SubSubClass_name?: any;
SubSubclassComment?: any
SubInstanceOfSubclass?: Instances[];
}
export class Instances {
......
......@@ -6,6 +6,7 @@ import { environment } from '../../environments/environment';
const baseUrl = environment.apiroot + 'api-auth/groupboilerplates/0/boilerplates/';
const Url = '/suffix/';
const baseUrl2 = environment.apiroot + 'api-auth/groupboilerplates/';
@Injectable({
providedIn: 'root'
......@@ -45,5 +46,9 @@ export class SuffixService {
getflow(): Observable<any> {
return this.http.get(environment.apiroot +`api-auth/suffix/choices/flow/`);
}
getsuffixflow(gb: any): Observable<any> {
return this.http.get(`${baseUrl2}${gb}`+`/prefix/choices/simpleprefix/`);
}
}
......@@ -45,11 +45,17 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1"),
#FUNCTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Function")
#
SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not"))
QUANTIFIER_CHOICES = ( ("None","None"), ("All", "All"), ("Only", "Only"),
("More Than", "More Than"), ("Less Than", "Less Than"), ("Exactly","Exactly"),
("At Least", "At Least"), ("At Most", "At Most")
)
NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"), ("Number", "Number"))
#QUANTIFIER_CHOICES = ( ("None","None"), ("All", "All"), ("Only", "Only"),
# ("More Than", "More Than"), ("Less Than", "Less Than"), ("Exactly","Exactly"),
# ("At Least", "At Least"), ("At Most", "At Most")
# )
#NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"), ("Number", "Number"))
##g = Graph()
#g.load('../../Ontologies/2022_AOCS.ttl', format="turtle")
#PREFIX_SYNTAX = get_prefix_syntax(g)
#S_CHOICES = get_instances_g("RBO#Preposition",g) + get_instances_g("RBO#NumericalAffirmative",g)
#print(S_CHOICES)
#ITEM
#ITEM_CHOICES = get_instances("SAO#Item")
#ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item")
......@@ -91,7 +97,6 @@ NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^
#VERB_CHOICES = get_verb_instances("LO#Verb")
VERB_CHOICES = get_verb_file_and_instances("LO#Verb")
#test to add M
CLASS_CHOICES = (("SYSTEM","SYSTEM"), ("FUNCTION","FUNCTION"), ("SHALL","SHALL/SHALL NOT"),
("QUANTIFIER","QUANTIFIER"), ("NUMBER_UNITS","NUMBER_UNITS"), ("ITEM","ITEM"),
......
......@@ -36,6 +36,9 @@ LOGICAL_EXPRESSION = ( ("",""),
#Need fixing
#VERB_CHOICES_PREFIX = ( ("",""))
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/RDO-instances#"]#,
list_of_RBO = ["http://delab.csd.auth.gr/ontologies/2018/LO#","http://delab.csd.auth.gr/ontologies/2018/RBO#","http://delab.csd.auth.gr/ontologies/2018/LO-instances#"]
#list_of_LO = ["http://delab.csd.auth.gr/ontologies/2018/LO#","http://delab.csd.auth.gr/ontologies/2018/RBO#","http://delab.csd.auth.gr/ontologies/2018/LO-instances#"]
#Must read this info from the Ontology
......@@ -106,15 +109,19 @@ def update_instances(instance):
g.load(instance.ontology_file, format="turtle")
#PREFIX_SYNTAX = get_prefix_syntax(g)
VERB_CHOICES_PREFIX = get_prefix_verbs(g)
SYSTEM_CHOICES = get_instances_g("SAO#System",g)
FUNCTION_CHOICES = get_instances_g("SAO#Function",g)
ITEM_CHOICES = get_instances_g("SAO#Item",g)
INTERFACE_CHOICES = get_instances_g("SAO#Interface",g)
CONNECTION_CHOICES = get_instances_g("SAO#Connection",g)
FLOW_CHOICES = get_instances_g("SAO#Flow",g)
STATE_CHOICES = get_instances_g("SAO#State",g)
STATE_SET_CHOICES = get_instances_g("SAO#StateSet",g)
STATE_VALUE_CHOICES =get_instances_g("SAO#StateValue",g)
SYSTEM_CHOICES = get_instances_g("SAO#System",g, list_of_DSO)
FUNCTION_CHOICES = get_instances_g("SAO#Function",g, list_of_DSO)
ITEM_CHOICES = get_instances_g("SAO#Item",g, list_of_DSO)
INTERFACE_CHOICES = get_instances_g("SAO#Interface",g, list_of_DSO)
CONNECTION_CHOICES = get_instances_g("SAO#Connection",g, list_of_DSO)
FLOW_CHOICES = get_instances_g("SAO#Flow",g, list_of_DSO)
STATE_CHOICES = get_instances_g("SAO#State",g, list_of_DSO)
STATE_SET_CHOICES = get_instances_g("SAO#StateSet",g, list_of_DSO)
STATE_VALUE_CHOICES =get_instances_g("SAO#StateValue",g, list_of_DSO)
NUMBER_UNITS_CHOICES = get_instances_g("RBO#NumberUnit",g, list_of_RBO)
QUANTIFIER_CHOICES = get_instances_g("RBO#Quantifier",g, list_of_RBO)
NUMERICAL_AFFIRMATIVE_CHOICES = get_instances_g("RBO#NumericalAffirmative",g, list_of_RBO)
S_CHOICES = get_instances_g("RBO#Preposition",g, list_of_RBO) + get_instances_g("RBO#NumericalAffirmative",g, list_of_RBO)
BoilerplateGroupClassesInstances.objects.filter(classes_instances_owner= instance.owner_infer, classes_instances_group_of_boilerplate = instance.infer_group_of_boilerplate).update(
prefix_choices = json.dumps(PREFIX_CHOICES), prefix_logcon_choices =json.dumps(LOGIC_CONNECTIVE), prefix_verb_choices =json.dumps(STATE_CHOICES + VERB_CHOICES_PREFIX),
main_class_choices =json.dumps(MAIN_CHOICES), system_choices = json.dumps(SYSTEM_CHOICES), function_choices =json.dumps(FUNCTION_CHOICES),
......
......@@ -18,16 +18,26 @@ SUFFIX_CHOICES = (("",""), ('S1', 'S1: <numerical-affirmative> j <closed-interva
)
NUMERICAL_AFFIRMATIVE_CHOICES = (("MORE THAN", "MORE THAN"), ("LESS THAN", "LESS THAN"), ("EXACTLY","EXACTLY"),
("AT LEAST", "AT LEAST"), ("AT MOST", "AT MOST"))
NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"))
TIME_UNITS_CHOICES = (("SECONDS","SECONDS"), ("MINUTES","MINUTES"), ("MILLISECONDS","MILLISECONDS"), ("CYCLES","CYCLES"))
FLOW_CHOICES = get_instances("SAO#Flow")
#NUMBER_UNITS_CHOICES = (("",""),("m/s","m/s"), ("m/s^2","m/s^2"), ("m/s^3","m/s^3"), ("rad","rad"), ("rad/s","rad/s"), ("Hz","Hz"), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"))
#TIME_UNITS_CHOICES = (("SECONDS","SECONDS"), ("MINUTES","MINUTES"), ("MILLISECONDS","MILLISECONDS"), ("CYCLES","CYCLES"))
#FLOW_CHOICES = get_instances("SAO#Flow")
# FLOW returns ()
S2_CHOICES = (("BEFORE","BEFORE"), ("AFTER","AFTER"))
S3_CHOICES = (("EVERY","EVERY"), ("FOR A PERIOD OF","FOR A PERIOD OF"), ("WITHIN", "WITHIN"), ("FOR AT LEAST", "FOR AT LEAST"))
S4_CHOICES = (("AT THE BEGINNING","AT THE BEGINNING"), ("AT THE END","AT THE END"))
S5_6_CHOICES = (("AT EVEN INTERVALS","AT EVEN INTERVALS"), ("SEQUENTIALLY","SEQUENTIALLY"))
S5_6_CHOICES = (("AT EVEN INTERVALS","AT EVEN INTERVALS"), ("SEQUENTIALLY","SEQUENTIALLY"))
#S_CHOICES = NUMERICAL_AFFIRMATIVE_CHOICES + S2_CHOICES + S3_CHOICES + S4_CHOICES + S5_6_CHOICES
S_CHOICES = NUMERICAL_AFFIRMATIVE_CHOICES + S2_CHOICES + S3_CHOICES + S4_CHOICES + S5_6_CHOICES
'''g = Graph()
g.load('../../Ontologies/2022_AOCS.ttl', format="turtle")
S_CHOICES = get_instances_g("RBO#Preposition",g) + get_instances_g("RBO#NumericalAffirmative",g)
FLOW_CHOICES=(("SECONDS","SECONDS"), ("MINUTES","MINUTES"), ("MILLISECONDS","MILLISECONDS"), ("CYCLES","CYCLES"))
NUMBER_UNITS_CHOICES=get_instances_g("LO#NumberUnit",g)
SYSTEM_CHOICES = get_instances_g("SAO#System",g)
print(SYSTEM_CHOICES)'''
def create_suffix(instance):
......@@ -49,13 +59,16 @@ class Suffix(models.Model):
boilerplate_of_suffix = models.ForeignKey('reqtool.Boilerplate', related_name='suffix_boilerplate', on_delete=models.CASCADE)
suffix_owner = models.ForeignKey(User, related_name='suffix_owner', on_delete=models.CASCADE)
#prefix templates
s_choices = models.CharField(choices=S_CHOICES, max_length=100, blank=True)
#s_choices = models.CharField(choices=S_CHOICES, max_length=100, blank=True)
s_choices = models.CharField(max_length=100, blank=True)
#if S1
numerical = models.CharField(blank=True, null=True, max_length=10)
mumerical_units = models.CharField(choices=NUMBER_UNITS_CHOICES + TIME_UNITS_CHOICES, max_length=100, blank=True)
#mumerical_units = models.CharField(choices=NUMBER_UNITS_CHOICES, max_length=100, blank=True)
mumerical_units = models.CharField(max_length=100, blank=True)
#time_units = models.CharField(choices=TIME_UNITS_CHOICES, max_length=100, blank=True)
#if S2/S3
flow = models.CharField(choices=FLOW_CHOICES, max_length=100, blank=True)
#flow = models.CharField(choices=FLOW_CHOICES, max_length=100, blank=True)
flow = models.CharField(max_length=100, blank=True)
#find suffix
suffix_choices = models.CharField(choices=SUFFIX_CHOICES, max_length=100, blank=True)
#custom suffix
......
......@@ -38,9 +38,9 @@ urlpatterns = [
path('main/choices/shall/', main_req_views.ShallChoicesViewSet.as_view(), name='mainshall'),
#SUFFIX CHOICES DATA
path('suffix/choices/suffix/', suffix_req_views.SuffixChoicesViewSet.as_view(), name='suffixsuffix'),
path('suffix/choices/numunits/', suffix_req_views.NumChoicesViewSet.as_view(), name='suffixnum'),
path('suffix/choices/flow/', suffix_req_views.FlowChoicesViewSet.as_view(), name='suffixflow'),
##path('suffix/choices/suffix/', suffix_req_views.SuffixChoicesViewSet.as_view(), name='suffixsuffix'),
#path('suffix/choices/numunits/', suffix_req_views.NumChoicesViewSet.as_view(), name='suffixnum'),
#path('suffix/choices/flow/', suffix_req_views.FlowChoicesViewSet.as_view(), name='suffixflow'),
#Dictionary
path('groupboilerplates/<int:groupboil>/dictionary/', main_req_views.DictionaryViewSet.as_view(), name='dictionary'),
......
......@@ -97,7 +97,9 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
if( instance['mumerical_units'] not in numunit_data):
raise APIException("MAIN : Instance of Number Unit does not exist")
curmain_choices = inference.getclassofmain(instance)
if curmain_choices[0] == 'ERROR':
if(curmain_choices==None):
raise APIException("Main choices not in [M1-M16]")
if (curmain_choices[0] == 'ERROR'):
raise APIException("Main choices not in [M1-M16]")
else:
instance = serializer.save(main_choices = curmain_choices[0])
......@@ -136,7 +138,7 @@ class MainChoicesAPIView(APIView):
#print(Dictdata.values('Dictionary_Data')[0]['Dictionary_Data'])
class_prefix = self.getClassontologyfile(g,es_instance)
for s, p, o in g.triples((URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , RDF.type, URIRef(class_prefix))):
for s, p, o in g.triples((URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#") + es_instance[len(es_instance)-1].strip() , RDF.type, URIRef(class_prefix))):
raise APIException("This instance already exist")
try:
g.add(( URIRef( "http://delab.csd.auth.gr/ontologies/2018/RDO-instances#" + es_instance[len(es_instance)-1].strip() ) , RDF.type, URIRef(class_prefix) ))
......@@ -146,6 +148,7 @@ class MainChoicesAPIView(APIView):
raise APIException("Cannot Add instance")
tempDict = []
flag = 0
#PROBLEMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
for sao in Dictdata.values('Dictionary_Data')[0]['Dictionary_Data']:
if sao['Name'] == es_instance[0].strip():
for sao2 in sao['TheClasses']:
......@@ -154,22 +157,54 @@ class MainChoicesAPIView(APIView):
for sao3 in sao2['Subclass']:
if sao3['SubClass_name'] == es_instance[2].strip():
flag = 2
if(sao3 ['InstanceOfSubclass'] == ''):
sao3 ['InstanceOfSubclass'] = []
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
else:
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
print(sao3)
for sao4 in sao3['SubSubClass']:
if es_instance[3] and sao4['SubSubClass_name'] == es_instance[3].strip():
flag =3
for sao5 in sao4['SubSubClass']:
if es_instance[4] and sao5['SubSubClass_name'] == es_instance[4].strip():
flag =4
for sao6 in sao5['SubSubClass']:
if es_instance[5] and sao6['SubSubClass_name'] == es_instance[5].strip():
flag = 5
if(flag == 5):
if(sao6 ['SubInstanceOfSubclass'] == ''):
sao6 ['SubInstanceOfSubclass'] = []
sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment })
else:
sao6['SubInstanceOfSubclass'].append({"Instance": es_instance[6].strip(), "Comment": comment })
if(flag == 4):
if(sao5 ['SubInstanceOfSubclass'] == ''):
sao5 ['SubInstanceOfSubclass'] = []
sao5['SubInstanceOfSubclass'].append({"Instance": es_instance[5].strip(), "Comment": comment })
else:
sao5['SubInstanceOfSubclass'].append({"Instance": es_instance[5].strip(), "Comment": comment })
if(flag == 3):
if(sao4 ['SubInstanceOfSubclass'] == ''):
sao4 ['SubInstanceOfSubclass'] = []
sao4['SubInstanceOfSubclass'].append({"Instance": es_instance[4].strip(), "Comment": comment })
else:
sao4['InstanceOfSubclass'].append({"Instance": es_instance[4].strip(), "Comment": comment })
# SubSubClass_name
if(flag == 2):
if(sao3 ['InstanceOfSubclass'] == ''):
sao3 ['InstanceOfSubclass'] = []
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
else:
sao3['InstanceOfSubclass'].append({"Instance": es_instance[3].strip(), "Comment": comment })
if (flag == 1):
if(sao2 ['Instance_of_Class'] == ''):
print('sao2')
sao2 ['Instance_of_Class'] = []
sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment })
else:
sao2 ['Instance_of_Class'].append({"Instance": es_instance[2].strip(), "Comment": comment })
if(flag==0):
sao['GeneralInstances'].append({"Instance": es_instance[1].strip(), "Comment": comment })
print('aaaaaaaaaaaaaaaaa', flag)
tempDict.append(sao)
Dictdata.update(Dictionary_Data= tempDict)
if(len(es_instance) == 2):
instance=es_instance[0] +': ' + instance
if (es_instance[0].strip() == 'System'):
m = data.values('system_choices')[0]['system_choices'][:-1]
if (len(m) ==1 ):
......@@ -204,13 +239,12 @@ class MainChoicesAPIView(APIView):
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Flow'):
m = data.values('flow_choices')[0]['flow_choices'][:-1]
print('data',m)
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(flow_choices = str(m))
print(m)
data.update(flow_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'State'):
m = data.values('state_choices')[0]['state_choices'][:-1]
......@@ -236,6 +270,14 @@ class MainChoicesAPIView(APIView):
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(state_value_choices = str(m))
return HttpResponse('Update Instance')
if (es_instance[0].strip() == 'Connection'):
m = data.values('connection_choices')[0]['connection_choices'][:-1]
if (len(m) ==1 ):
m+= '["'+instance+'","'+instance+'"]'+']'
else :
m+= ',["'+instance+'","'+instance+'"]'+']'
data.update(connection_choices = str(m))
return HttpResponse('Update Instance')
......@@ -248,10 +290,18 @@ class MainChoicesAPIView(APIView):
raise APIException("There is no file for instances")
def getClassontologyfile(self, g, es_instance):
for ns_prefix, namespace in g.namespaces():
for s, p, o in g.triples((URIRef( namespace+ es_instance[len(es_instance)-2].strip() ) ,None, None)):
return URIRef( namespace+ es_instance[len(es_instance)-2].strip() )
raise APIException("There is no Class in the Ontology ")
if(len(es_instance) == 2 ):
for ns_prefix, namespace in g.namespaces():
for s, p, o in g.triples((URIRef( 'http://delab.csd.auth.gr/ontologies/2018/SAO#'+ es_instance[len(es_instance)-2].strip() ) ,None, None)):
print(p,s)
return URIRef( 'http://delab.csd.auth.gr/ontologies/2018/SAO#'+ es_instance[len(es_instance)-2].strip() )
raise APIException("There is no Class in the Ontology ")
else:
for ns_prefix, namespace in g.namespaces():
for s, p, o in g.triples((URIRef( namespace+ es_instance[len(es_instance)-2].strip() ) ,None, None)):
return URIRef( namespace+ es_instance[len(es_instance)-2].strip() )
raise APIException("There is no Class in the Ontology ")
......
......@@ -14,8 +14,8 @@ from reqman.apps.reqtool.rest_api.services import fuseki
from rest_framework.response import Response
from rest_framework.views import APIView
from reqman.apps.reqtool.models.suffix_req import S_CHOICES, NUMBER_UNITS_CHOICES, TIME_UNITS_CHOICES, FLOW_CHOICES
from reqman.apps.reqtool.models.suffix_req import NUMERICAL_AFFIRMATIVE_CHOICES, S2_CHOICES, S3_CHOICES, S4_CHOICES, S5_6_CHOICES
#from reqman.apps.reqtool.models.suffix_req import S_CHOICES, NUMBER_UNITS_CHOICES, TIME_UNITS_CHOICES, FLOW_CHOICES
#from reqman.apps.reqtool.models.suffix_req import NUMERICAL_AFFIRMATIVE_CHOICES, S2_CHOICES, S3_CHOICES, S4_CHOICES, S5_6_CHOICES
from reqman.apps.reqtool.models.requirements import BoilerplateData
......@@ -77,42 +77,6 @@ class SuffixDetailsAPIView(RetrieveUpdateDestroyAPIView):
instance.delete()
def getclassofsuffix(self, suffix):
for sys in NUMERICAL_AFFIRMATIVE_CHOICES:
if sys[0] == suffix:
return ("S1")
for sys in S2_CHOICES:
if sys[0] == suffix:
return ("S2")
for sys in S3_CHOICES:
if sys[0] == suffix:
return ("S3")
for sys in S4_CHOICES:
if sys[0] == suffix:
return ("S4")
#special case only one option for S5, S6
if S5_6_CHOICES[0][0] == suffix:
return ("S5")
if S5_6_CHOICES[1][0] == suffix:
return ("S6")
return ("S1")
class SuffixChoicesViewSet(APIView):
def get(self, request):
response = Response(S_CHOICES)
return response
class NumChoicesViewSet(APIView):
def get(self, request):
response = Response(NUMBER_UNITS_CHOICES+TIME_UNITS_CHOICES)
return response
class FlowChoicesViewSet(APIView):
def get(self, request):
response = Response(FLOW_CHOICES)
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