Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Requirement Formalization Tool
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thodoris Nestoridis
Requirement Formalization Tool
Commits
08bac18c
Commit
08bac18c
authored
Jan 18, 2022
by
Thodoris Nestoridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get prefix instace from one source(needed for main an suffix) + update instaces on inferencing
parent
544db976
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
175 deletions
+86
-175
prefix-details.component.ts
...app/components/prefix-details/prefix-details.component.ts
+38
-55
prefix.service.ts
reqtool/ReqmanAngular11/src/app/services/prefix.service.ts
+0
-19
main_req.py
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
+1
-1
requirements.py
...ool/reqman/api/reqman/apps/reqtool/models/requirements.py
+28
-21
urls.py
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
+2
-5
main_req_views.py
.../api/reqman/apps/reqtool/rest_api/views/main_req_views.py
+14
-1
requirements_views.py
.../reqman/apps/reqtool/rest_api/views/requirements_views.py
+3
-73
No files found.
reqtool/ReqmanAngular11/src/app/components/prefix-details/prefix-details.component.ts
View file @
08bac18c
...
...
@@ -80,12 +80,7 @@ export class PrefixDetailsComponent implements OnInit {
ngOnInit
():
void
{
this
.
getchoices
(
this
.
route
.
snapshot
.
params
.
gb
);
this
.
getsubject
();
this
.
getoobject
();
this
.
getverb
();
this
.
getlogcon
();
this
.
getAllPrefix
(
this
.
route
.
snapshot
.
params
.
id
);
}
displayFn
(
option
:
string
):
string
{
...
...
@@ -160,68 +155,56 @@ export class PrefixDetailsComponent implements OnInit {
this
.
prefixService
.
getsimpleprefix
(
prefix_group
)
.
subscribe
(
data
=>
{
//get prefix (if, as soon as) etc
let
strIntoObj
=
JSON
.
parse
(
data
[
0
].
prefix_choices
)
for
(
let
x
=
0
;
x
<
strIntoObj
.
length
;
x
++
){
if
(
this
.
simpleprefix
.
indexOf
(
strIntoObj
[
x
][
1
])
==
-
1
)
{
this
.
simpleprefix
.
push
(
strIntoObj
[
x
][
1
]);}}
//set prefix choices
this
.
setprefix
(
JSON
.
parse
(
data
[
0
].
prefix_choices
));
//set verb choices
this
.
setverb
(
JSON
.
parse
(
data
[
0
].
prefix_verb_choices
));
//set subject choices
this
.
setsubject
(
JSON
.
parse
(
data
[
0
].
item_choices
));
this
.
setsubject
(
JSON
.
parse
(
data
[
0
].
system_choices
));
this
.
setsubject
(
JSON
.
parse
(
data
[
0
].
function_choices
));
//set object choices
this
.
setobject
(
JSON
.
parse
(
data
[
0
].
item_choices
));
this
.
setobject
(
JSON
.
parse
(
data
[
0
].
flow_choices
));
this
.
setobject
(
JSON
.
parse
(
data
[
0
].
function_choices
));
this
.
setobject
(
JSON
.
parse
(
data
[
0
].
state_value_choices
));
//set logic connectivity choices
this
.
setlogcon
(
JSON
.
parse
(
data
[
0
].
prefix_logcon_choices
));
},
error
=>
{
console
.
log
(
error
);
});
}
getsubject
():
void
{
this
.
prefixService
.
getsubject
()
.
subscribe
(
data
=>
{
for
(
let
x
=
0
;
x
<
data
.
length
;
x
++
){
if
(
this
.
subjects
.
indexOf
(
data
[
x
][
1
])
==
-
1
)
{
this
.
subjects
.
push
((
data
[
x
][
1
]));}}
},
error
=>
{
console
.
log
(
error
);
});
setprefix
(
strIntoObj
:
any
):
void
{
for
(
let
x
=
0
;
x
<
strIntoObj
.
length
;
x
++
){
if
(
this
.
simpleprefix
.
indexOf
(
strIntoObj
[
x
][
1
])
==
-
1
)
{
this
.
simpleprefix
.
push
((
strIntoObj
[
x
][
1
]));}}
}
getoobject
():
void
{
this
.
prefixService
.
getoobject
()
.
subscribe
(
data
=>
{
for
(
let
x
=
0
;
x
<
data
.
length
;
x
++
){
if
(
this
.
objects
.
indexOf
(
data
[
x
][
1
])
==
-
1
)
{
this
.
objects
.
push
((
data
[
x
][
1
]));}}
},
error
=>
{
console
.
log
(
error
);
});
setverb
(
strIntoObj
:
any
):
void
{
for
(
let
x
=
0
;
x
<
strIntoObj
.
length
;
x
++
){
if
(
this
.
verbs
.
indexOf
(
strIntoObj
[
x
][
1
])
==
-
1
)
{
this
.
verbs
.
push
((
strIntoObj
[
x
][
1
]));}}
}
getverb
():
void
{
this
.
prefixService
.
getverb
()
.
subscribe
(
data
=>
{
for
(
let
x
=
0
;
x
<
data
.
length
;
x
++
){
if
(
this
.
verbs
.
indexOf
(
data
[
x
][
1
])
==
-
1
)
{
this
.
verbs
.
push
((
data
[
x
][
1
]));}}
},
error
=>
{
console
.
log
(
error
);
});
setsubject
(
strIntoObj
:
any
):
void
{
for
(
let
x
=
0
;
x
<
strIntoObj
.
length
;
x
++
){
if
(
this
.
subjects
.
indexOf
(
strIntoObj
[
x
][
1
])
==
-
1
)
{
this
.
subjects
.
push
((
strIntoObj
[
x
][
1
]));}}
}
getlogcon
():
void
{
this
.
prefixService
.
getlogcon
()
.
subscribe
(
data
=>
{
for
(
let
x
=
0
;
x
<
data
.
length
;
x
++
){
if
(
this
.
logic_con
.
indexOf
(
data
[
x
][
1
])
==
-
1
)
{
this
.
logic_con
.
push
((
data
[
x
][
1
]));}}
},
error
=>
{
console
.
log
(
error
);
});
setobject
(
strIntoObj
:
any
):
void
{
for
(
let
x
=
0
;
x
<
strIntoObj
.
length
;
x
++
){
if
(
this
.
objects
.
indexOf
(
strIntoObj
[
x
][
1
])
==
-
1
)
{
this
.
objects
.
push
((
strIntoObj
[
x
][
1
]));}}
}
}
setlogcon
(
strIntoObj
:
any
):
void
{
for
(
let
x
=
0
;
x
<
strIntoObj
.
length
;
x
++
){
if
(
this
.
logic_con
.
indexOf
(
strIntoObj
[
x
][
1
])
==
-
1
)
{
this
.
logic_con
.
push
((
strIntoObj
[
x
][
1
]));}}
}
}
\ No newline at end of file
reqtool/ReqmanAngular11/src/app/services/prefix.service.ts
View file @
08bac18c
...
...
@@ -37,23 +37,4 @@ export class PrefixService {
getsimpleprefix
(
gb
:
any
):
Observable
<
any
>
{
return
this
.
http
.
get
(
`
${
baseUrl2
}${
gb
}${
Url
}
`
+
`choices/simpleprefix/`
);
}
getlogcon
():
Observable
<
any
>
{
return
this
.
http
.
get
(
`http://155.207.131.19:8000/api-auth/prefix/choices/logicalconnectivity/`
);
}
getverb
():
Observable
<
any
>
{
return
this
.
http
.
get
(
`http://155.207.131.19:8000/api-auth/prefix/choices/verbprefix/`
);
}
getsubject
():
Observable
<
any
>
{
return
this
.
http
.
get
(
`http://155.207.131.19:8000/api-auth/prefix/choices/sysfunitem/`
);
}
getoobject
():
Observable
<
any
>
{
return
this
.
http
.
get
(
`http://155.207.131.19:8000/api-auth/prefix/choices/staflowfunitem/`
);
}
//findByTitle(title: any): Observable<Prefix[]> {
// return this.http.get<Prefix[]>(`${baseUrl}title=${title}`);
//}
}
reqtool/reqman/api/reqman/apps/reqtool/models/main_req.py
View file @
08bac18c
...
...
@@ -7,7 +7,7 @@ from pygments import highlight
from
reqman.apps.reqtool.rest_api.services.parse_ontologies
import
*
find_subclass_domain_range
()
#
find_subclass_domain_range()
#MAIN SYNTAX
MAIN_SYNTAX
=
get_main_sytax
()
import
pprint
...
...
reqtool/reqman/api/reqman/apps/reqtool/models/requirements.py
View file @
08bac18c
import
json
from
django.db
import
models
from
jsonfield
import
JSONField
#from django.contrib.postgres.fields import ArrayField
...
...
@@ -71,13 +72,14 @@ def create_extra_prefix(instance, now_prefix):
prefix
.
save
()
def
create_infer_result
_and_classes_instances
(
instance
):
def
create_infer_result
(
instance
):
infer
=
InferenceResults
(
owner_infer
=
instance
.
boilerplate_owner
,
infer_group_of_boilerplate
=
instance
)
infer
.
save
()
a
=
((
"If"
,
"If"
),
(
"Unless"
,
"Unless"
),(
"As soon as"
,
"As soon as"
),
(
"As long as"
,
"As long as"
),
(
"Once"
,
"Once"
))
jsonObj
=
json
.
dumps
(
a
)
#Here we have to give and the ontology file of the Boilerplate Group to get the current instances
def
initialize_instances
(
instance
):
classes_inctances
=
BoilerplateGroupClassesInstances
(
classes_instances_owner
=
instance
.
boilerplate_owner
,
classes_instances_group_of_boilerplate
=
instance
,
prefix_choices
=
json
Obj
,
prefix_logcon_choices
=
json
.
dumps
(
LOGIC_CONNECTIVE
),
prefix_verb_choices
=
json
.
dumps
(
STATE_CHOICES
+
VERB_CHOICES_PREFIX
),
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
),
quantifier_choices
=
json
.
dumps
(
QUANTIFIER_CHOICES
),
number_unit_choices
=
json
.
dumps
(
NUMBER_UNITS_CHOICES
),
item_choices
=
json
.
dumps
(
ITEM_CHOICES
),
inteface_choices
=
json
.
dumps
(
INTERFACE_CHOICES
),
connection_choices
=
json
.
dumps
(
CONNECTION_CHOICES
),
flow_choices
=
json
.
dumps
(
FLOW_CHOICES
),
...
...
@@ -86,18 +88,31 @@ def create_infer_result_and_classes_instances(instance):
suffix_choices
=
json
.
dumps
(
S_CHOICES
)
)
classes_inctances
.
save
()
'''Update instaces of the ontology after the inferencing'''
def
update_instances
(
instance
):
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
),
quantifier_choices
=
json
.
dumps
(
QUANTIFIER_CHOICES
),
number_unit_choices
=
json
.
dumps
(
NUMBER_UNITS_CHOICES
),
item_choices
=
json
.
dumps
(
ITEM_CHOICES
),
inteface_choices
=
json
.
dumps
(
INTERFACE_CHOICES
),
connection_choices
=
json
.
dumps
(
CONNECTION_CHOICES
),
flow_choices
=
json
.
dumps
(
FLOW_CHOICES
),
state_choices
=
json
.
dumps
(
STATE_CHOICES
),
state_set_choices
=
json
.
dumps
(
STATE_SET_CHOICES
),
state_value_choices
=
json
.
dumps
(
STATE_VALUE_CHOICES
),
main_verb_choices
=
json
.
dumps
(
VERB_CHOICES
),
numerical_affirmative_choices
=
json
.
dumps
(
NUMERICAL_AFFIRMATIVE_CHOICES
),
suffix_choices
=
json
.
dumps
(
S_CHOICES
)
)
class
BoilerplateGroup
(
models
.
Model
):
boilerplate_owner
=
models
.
ForeignKey
(
User
,
related_name
=
'boilerplate_group_owner'
,
on_delete
=
models
.
CASCADE
)
#add Boilerplate path, so each Boilerplate Group can hace it's own Ontology file
title_bgroup
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
)
description
=
models
.
CharField
(
max_length
=
500
)
def
save
(
self
,
**
kwargs
):
super
(
BoilerplateGroup
,
self
)
.
save
(
**
kwargs
)
create_infer_result_and_classes_instances
(
self
)
initialize_instances
(
self
)
create_infer_result
(
self
)
class
Boilerplate
(
models
.
Model
):
...
...
@@ -156,22 +171,19 @@ class PrefixGroup(models.Model):
class
Prefix
(
models
.
Model
):
#boilerplate = models.OneToOneField(Boilerplate, related_name='prefix', on_delete=models.CASCADE, primary_key=True)
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
(
choices
=
PREFIX_CHOICES
,
max_length
=
100
)
#state value constraint
system_fun_item
=
models
.
CharField
(
choices
=
(
ITEM_CHOICES
+
SYSTEM_CHOICES
+
FUNCTION_CHOICES
),
max_length
=
100
)
state_or_verb
=
models
.
CharField
(
choices
=
STATE_CHOICES
+
VERB_CHOICES_PREFIX
,
max_length
=
100
)
#state_value = models.CharField(choices=STATE_VALUE_CHOICES, max_length=100, blank=True)
#occuring functionality
#sys_fun = models.CharField(choices=, max_length=100, blank=True)
#verb = models.CharField(choices=VERB_CHOICES, max_length=100, blank=True)
item_function_flow_statevalue
=
models
.
CharField
(
choices
=
ITEM_CHOICES
+
FLOW_CHOICES
+
FUNCTION_CHOICES
+
STATE_VALUE_CHOICES
,
max_length
=
100
)
#
Prefix value P1/P2/P3
#
state value constraint OR occuring functionality
logical_expression
=
models
.
CharField
(
choices
=
LOGICAL_EXPRESSION
,
max_length
=
100
,
blank
=
True
)
#
Info for prefix
#
Logic connectivity Prefix1 (and/or/xor) Prefix2
logic_connective
=
models
.
CharField
(
choices
=
LOGIC_CONNECTIVE
,
default
=
''
,
max_length
=
100
,
blank
=
True
)
#Prefix value P1/P2/P3
simple_prefix
=
models
.
CharField
(
choices
=
SIMPLE_PREFIX_CHOICES
,
max_length
=
100
)
...
...
@@ -216,10 +228,14 @@ class InferenceResults(models.Model):
infer_group_of_boilerplate
=
models
.
ForeignKey
(
BoilerplateGroup
,
related_name
=
'infer_owner_of_boilerplate'
,
on_delete
=
models
.
CASCADE
)
inference_data
=
models
.
CharField
(
default
=
""
,
max_length
=
1000000
,
blank
=
True
)
def
save
(
self
,
**
kwargs
):
super
(
InferenceResults
,
self
)
.
save
(
**
kwargs
)
update_instances
(
self
)
class
Meta
:
ordering
=
[
'owner_infer'
]
import
collections
class
BoilerplateGroupClassesInstances
(
models
.
Model
):
classes_instances_group_of_boilerplate
=
models
.
ForeignKey
(
BoilerplateGroup
,
related_name
=
'classes_instances_owner_of_boilerplate'
,
on_delete
=
models
.
CASCADE
)
...
...
@@ -246,14 +262,5 @@ class BoilerplateGroupClassesInstances(models.Model):
suffix_choices
=
JSONField
()
import
json
def
get_prefix_choices
():
#Must read this info from the Ontology
a
=
((
"If"
,
"If"
),
(
"Unless"
,
"Unless"
),(
"As soon as"
,
"As soon as"
),
(
"As long as"
,
"As long as"
),
(
"Once"
,
"Once"
))
jsonObj
=
json
.
dumps
(
a
)
print
(
jsonObj
)
return
jsonObj
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
View file @
08bac18c
...
...
@@ -31,12 +31,9 @@ urlpatterns = [
#PREFIX CHOICES DATA
path
(
'groupboilerplates/<int:groupboil>/prefix/choices/simpleprefix/'
,
requirements_views
.
PrefixChoicesViewSet
.
as_view
(),
name
=
'simpleprefixchoices'
),
path
(
'prefix/choices/logicalconnectivity/'
,
requirements_views
.
LogConChoicesViewSet
.
as_view
(),
name
=
'logicalconnectivitychoices'
),
path
(
'prefix/choices/verbprefix/'
,
requirements_views
.
VerbChoicesViewSet
.
as_view
(),
name
=
'verbprefixchoices'
),
path
(
'prefix/choices/sysfunitem/'
,
requirements_views
.
FunItemSysChoicesViewSet
.
as_view
(),
name
=
'sysfunitem'
),
path
(
'prefix/choices/staflowfunitem/'
,
requirements_views
.
StaFlowFunItemChoicesViewSet
.
as_view
(),
name
=
'staflowfunitem'
),
#MAIN CHOICES DATA
path
(
'groupboilerplates/<int:groupboil>/main/choices/'
,
main_req_views
.
MainChoicesViewSet
.
as_view
(),
name
=
'mainchoices'
),
path
(
'main/choices/subject/'
,
main_req_views
.
SysFunIntChoicesViewSet
.
as_view
(),
name
=
'mainsubject'
),
path
(
'main/choices/stateitem/'
,
main_req_views
.
StatItemChoicesViewSet
.
as_view
(),
name
=
'mainstateitem'
),
path
(
'main/choices/statevalue/'
,
main_req_views
.
StatevalueChoicesViewSet
.
as_view
(),
name
=
'mainstatevalue'
),
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/main_req_views.py
View file @
08bac18c
...
...
@@ -4,6 +4,7 @@ from rest_framework import permissions
from
django.http
import
HttpResponse
,
JsonResponse
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework.parsers
import
JSONParser
from
reqman.apps.reqtool.rest_api.serializers.requirements
import
BoilerplateGroupClassesInstancesSerializer
from
reqman.apps.reqtool.models.main_req
import
Main
from
reqman.apps.reqtool.rest_api.serializers.main_req
import
MainSerializer
...
...
@@ -27,7 +28,7 @@ from reqman.apps.reqtool.models.main_req import CONNECTION_CLASSES_COMMENTS, CON
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
,
MAIN_SYNTAX
from
reqman.apps.reqtool.models.requirements
import
BoilerplateData
from
reqman.apps.reqtool.models.requirements
import
BoilerplateData
,
BoilerplateGroupClassesInstances
from
rest_framework.exceptions
import
APIException
...
...
@@ -92,6 +93,18 @@ class MainDetailsAPIView(RetrieveUpdateDestroyAPIView):
#instance = serializer.validated_data
instance
.
delete
()
class
MainChoicesViewSet
(
ListAPIView
):
"""
API view to retrieve, update or delete
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
BoilerplateGroupClassesInstancesSerializer
def
get_queryset
(
self
):
group_pk
=
self
.
kwargs
[
'groupboil'
]
queryset_cl
=
BoilerplateGroupClassesInstances
.
objects
.
filter
(
classes_instances_group_of_boilerplate
=
group_pk
)
return
queryset_cl
class
SysFunIntChoicesViewSet
(
APIView
):
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/requirements_views.py
View file @
08bac18c
...
...
@@ -72,10 +72,8 @@ class BoilerplateListCreateAPIView(ListCreateAPIView):
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
BoilerplateSerializer
#queryset =
def
get_queryset
(
self
):
#print(title)
group_gb
=
self
.
kwargs
[
'groupboil'
]
queryset_boil
=
Boilerplate
.
objects
.
filter
(
owner
=
self
.
request
.
user
,
group_of_boilerplate
=
group_gb
)
return
queryset_boil
...
...
@@ -83,9 +81,7 @@ class BoilerplateListCreateAPIView(ListCreateAPIView):
#Custom actions when POST
def
perform_create
(
self
,
serializer
):
serializer
.
save
(
owner
=
self
.
request
.
user
)
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class
BoilerplateList
(
ListAPIView
):
"""
...
...
@@ -93,13 +89,11 @@ class BoilerplateList(ListAPIView):
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
BoilerplateSerializer
#queryset = Boilerplate.objects.all()
def
get_queryset
(
self
):
group_gb
=
self
.
kwargs
[
'groupboil'
]
title
=
self
.
kwargs
[
'title_1'
]
#print(title)
queryset_title
=
Boilerplate
.
objects
.
filter
(
title
=
title
,
group_of_boilerplate
=
group_gb
)
return
queryset_title
...
...
@@ -116,20 +110,14 @@ class BoilerplateDetailsAPIView(RetrieveUpdateDestroyAPIView):
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
#print(serializer.validated_data['id'])
#if not Prefix.objects.filter(boilerplate = serializer.validated_data['id']) and (serializer.validated_data['b_prefix'] == True):
# serializer.validated_data['b_prefix'] = True
instance
=
serializer
.
validated_data
bd_title
=
instance
[
'title'
]
BoilerplateData
.
objects
.
filter
(
boilerplate_data_id
=
self
.
kwargs
[
'pk'
],
group_of_boilerplate_data
=
instance
[
'group_of_boilerplate'
])
.
update
(
title_data
=
bd_title
)
instance
=
serializer
.
save
()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
#print("deleted")
instance
.
delete
()
...
...
@@ -139,12 +127,9 @@ class PrefixListAPIView(ListAPIView):
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
PrefixSerializer
#
#queryset = Prefix.objects.all()
def
get_queryset
(
self
):
group_pk
=
self
.
kwargs
[
'boilerplate'
]
#print(group_pk)
queryset_prefix
=
Prefix
.
objects
.
filter
(
prefix_boilerplate
=
group_pk
)
return
queryset_prefix
...
...
@@ -154,26 +139,12 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
PrefixSerializer
#queryset = Prefix.objects.all()
def
get_queryset
(
self
):
group_pk
=
self
.
kwargs
[
'boilerplate'
]
queryset_prefix
=
Prefix
.
objects
.
filter
(
prefix_boilerplate
=
group_pk
)
return
queryset_prefix
def
simple_prefix
(
self
,
prefix
):
if
prefix
==
"If"
:
return
"P1"
if
prefix
==
"As soon as"
:
return
"P2"
if
prefix
==
"As long as"
:
return
"P3"
if
prefix
==
"Once"
:
return
"P1"
if
prefix
==
"Unless"
:
return
"P1"
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
instance
=
serializer
.
validated_data
...
...
@@ -191,11 +162,9 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
serializer
.
save
(
simple_prefix
=
prefix_choices
)
#Custom actions when DELETE
def
perform_destroy
(
self
,
instance
):
instance
=
serializer
.
validated_data
#print("deleted")
instance
.
delete
()
...
...
@@ -206,25 +175,22 @@ class BoilerplateDataListAPIView(ListAPIView):
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
BoilerplateDataSerializer
#queryset = Prefix.objects.all()
def
get_queryset
(
self
):
group_gb
=
self
.
kwargs
[
'groupboil'
]
queryset_boil_data
=
BoilerplateData
.
objects
.
filter
(
owner_data
=
self
.
request
.
user
,
group_of_boilerplate_data
=
group_gb
)
return
queryset_boil_data
class
InferListAPIView
(
ListAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
InferSerializer
#
#queryset = Prefix.objects.all()
def
get_queryset
(
self
):
group_pk
=
self
.
kwargs
[
'groupboil'
]
#print(group_pk)
queryset_infer
=
InferenceResults
.
objects
.
filter
(
infer_group_of_boilerplate
=
group_pk
)
return
queryset_infer
...
...
@@ -234,7 +200,6 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
InferSerializer
#queryset = Prefix.objects.all()
def
get_queryset
(
self
):
group_pk
=
self
.
kwargs
[
'groupboil'
]
...
...
@@ -250,9 +215,6 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
prefixdata
=
[]
maindata
=
[]
suffixdata
=
[]
#pr = (instance['prefix'] + ' ' + instance['system_fun_item'] + ' ' + instance['state_or_verb'] + ' ' + instance['item_function_flow_statevalue'])
#BoilerplateData.objects.filter(owner_data=instance['prefix_boilerplate'].owner, boilerplate_data_id = instance['prefix_boilerplate']).
#print(instance['infer_group_of_boilerplate'].id)
project_title
=
instance
[
'infer_group_of_boilerplate'
]
.
title_bgroup
prefix
=
BoilerplateData
.
objects
.
filter
(
group_of_boilerplate_data
=
instance
[
'infer_group_of_boilerplate'
]
.
id
)
for
id
in
prefix
:
...
...
@@ -261,10 +223,7 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
maindata
.
append
(
self
.
getmaindata
(
id
.
boilerplate_data_id
.
id
))
suffixdata
.
append
(
self
.
getsuffixdata
(
id
.
boilerplate_data_id
.
id
))
metrics
,
onto_file
=
inference
.
inferencing
(
project_title
,
boildata
,
prefixdata
,
maindata
,
suffixdata
)
#print(prefix[0].boilerplate_data_id.id)
#inference.inferencing(prefix)
instance
.
update
(
inference_data
=
metrics
)
#sprefix = self.simple_prefix(instance["prefix"])
serializer
.
save
()
def
getboildata
(
self
,
pr
):
...
...
@@ -279,14 +238,10 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
def
getsuffixdata
(
self
,
pr
):
return
(
Suffix
.
objects
.
filter
(
boilerplate_of_suffix
=
pr
))
#class PrefixChoicesViewSet(APIView):#
#def get(self, request):
# response = Response(PREFIX_CHOICES)
# return response
class
PrefixChoicesViewSet
(
ListAPIView
):
"""
API view to retrieve, update or delete
post
API view to retrieve, update or delete
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
BoilerplateGroupClassesInstancesSerializer
...
...
@@ -295,28 +250,3 @@ class PrefixChoicesViewSet(ListAPIView):
group_pk
=
self
.
kwargs
[
'groupboil'
]
queryset_cl
=
BoilerplateGroupClassesInstances
.
objects
.
filter
(
classes_instances_group_of_boilerplate
=
group_pk
)
return
queryset_cl
class
LogConChoicesViewSet
(
APIView
):
def
get
(
self
,
request
):
response
=
Response
(
LOGIC_CONNECTIVE
)
return
response
class
VerbChoicesViewSet
(
APIView
):
def
get
(
self
,
request
):
response
=
Response
(
STATE_CHOICES
+
VERB_CHOICES_PREFIX
)
return
response
class
FunItemSysChoicesViewSet
(
APIView
):
def
get
(
self
,
request
):
response
=
Response
(
ITEM_CHOICES
+
SYSTEM_CHOICES
+
FUNCTION_CHOICES
)
return
response
class
StaFlowFunItemChoicesViewSet
(
APIView
):
def
get
(
self
,
request
):
response
=
Response
(
ITEM_CHOICES
+
FLOW_CHOICES
+
FUNCTION_CHOICES
+
STATE_VALUE_CHOICES
)
return
response
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment