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
a12c5411
Commit
a12c5411
authored
Jan 18, 2021
by
Thodoris Nestoridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add p3
parent
a354e0ff
Pipeline
#37
failed with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
5 deletions
+95
-5
requirements.py
...ool/reqman/api/reqman/apps/reqtool/models/requirements.py
+35
-1
requirements.py
.../reqman/apps/reqtool/rest_api/serializers/requirements.py
+11
-1
urls.py
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
+4
-1
requirements_views.py
.../reqman/apps/reqtool/rest_api/views/requirements_views.py
+45
-2
No files found.
reqtool/reqman/api/reqman/apps/reqtool/models/requirements.py
View file @
a12c5411
...
...
@@ -65,6 +65,22 @@ def create_p2(instance, now_prefix, prev_prefix, series_of_prefix):
prefix
.
save
()
def
create_p3
(
instance
,
now_prefix
,
prev_prefix
,
series_of_prefix
):
try
:
prefix
=
OccuringFunctionalityP3
.
objects
.
get
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
if
now_prefix
==
prev_prefix
:
return
prefix
=
OccuringFunctionalityP3
.
objects
.
get
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
prefix
.
delete
()
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
3
][
0
]:
prefix
=
OccuringFunctionalityP3
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
prefix
.
save
()
except
OccuringFunctionalityP3
.
DoesNotExist
:
if
now_prefix
==
SIMPLE_PREFIX_CHOICES
[
3
][
0
]:
prefix
=
OccuringFunctionalityP3
(
prefix_of_occuring_functionality_p3
=
instance
,
prefix_boilerplate_of_occuring_functionality_p3
=
instance
.
boilerplate
,
prefix_series_of_occuring_functionality_p3
=
series_of_prefix
)
prefix
.
save
()
def
create_state_value_constraint_from_logical_expression
(
instance
,
logical_expression
,
prev_logical_expression
,
series_of_log_expr
):
try
:
log_expr
=
StateValueConstraint
.
objects
.
get
(
logical_expression
=
instance
,
prefix_of_logical_expression
=
instance
.
prefix
,
log_expr_series
=
series_of_log_expr
)
...
...
@@ -149,7 +165,11 @@ class Prefix(models.Model):
create_p2
(
self
,
self
.
simple_prefix_1
,
prev_prefix_list
[
0
],
'1'
)
create_p2
(
self
,
self
.
simple_prefix_2
,
prev_prefix_list
[
1
],
'2'
)
create_p2
(
self
,
self
.
simple_prefix_3
,
prev_prefix_list
[
2
],
'3'
)
'''Create P3 '''
create_p3
(
self
,
self
.
simple_prefix_1
,
prev_prefix_list
[
0
],
'1'
)
create_p3
(
self
,
self
.
simple_prefix_2
,
prev_prefix_list
[
1
],
'2'
)
create_p3
(
self
,
self
.
simple_prefix_3
,
prev_prefix_list
[
2
],
'3'
)
class
Meta
:
ordering
=
[
'boilerplate'
]
...
...
@@ -208,6 +228,20 @@ class OccuringFunctionalityP2(models.Model):
ordering
=
[
'prefix_boilerplate_of_occuring_functionality_p2'
]
class
OccuringFunctionalityP3
(
models
.
Model
):
prefix_of_occuring_functionality_p3
=
models
.
ForeignKey
(
Prefix
,
related_name
=
'occuring_functionality_p3'
,
on_delete
=
models
.
CASCADE
)
prefix_boilerplate_of_occuring_functionality_p3
=
models
.
ForeignKey
(
Boilerplate
,
related_name
=
'occuring_functionality_b_p3'
,
on_delete
=
models
.
CASCADE
)
prefix_series_of_occuring_functionality_p3
=
models
.
TextField
(
default
=
'0'
)
system_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
perform_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
function_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
item_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
flow_for_occuring_functionality_p3
=
models
.
TextField
(
max_length
=
100
,
blank
=
True
,)
class
Meta
:
ordering
=
[
'prefix_boilerplate_of_occuring_functionality_p3'
]
class
StateValueConstraint
(
models
.
Model
):
prefix_of_logical_expression
=
models
.
ForeignKey
(
Prefix
,
related_name
=
'prefix_of_log_expr'
,
on_delete
=
models
.
CASCADE
)
logical_expression
=
models
.
ForeignKey
(
LogicalExpression
,
related_name
=
'own_log_expr'
,
on_delete
=
models
.
CASCADE
)
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/serializers/requirements.py
View file @
a12c5411
from
rest_framework
import
serializers
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
,
LogicalExpression
,
OccuringFunctionalityP2
,
StateValueConstraint
,
OccuringFunctionalityForLogicalExpression
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
,
LogicalExpression
,
OccuringFunctionalityP2
,
StateValueConstraint
,
OccuringFunctionalityForLogicalExpression
,
OccuringFunctionalityP3
class
BoilerplateSerializer
(
serializers
.
ModelSerializer
):
owner
=
serializers
.
ReadOnlyField
(
source
=
'owner.username'
)
...
...
@@ -35,6 +35,16 @@ class OccuringFunctionalityP2Serializer(serializers.ModelSerializer):
class
OccuringFunctionalityP3Serializer
(
serializers
.
ModelSerializer
):
prefix_of_occuring_functionality_p3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_boilerplate_of_occuring_functionality_p3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
prefix_series_of_occuring_functionality_p3
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
class
Meta
:
model
=
OccuringFunctionalityP3
fields
=
(
'id'
,
'prefix_of_occuring_functionality_p3'
,
'prefix_boilerplate_of_occuring_functionality_p3'
,
'prefix_series_of_occuring_functionality_p3'
,
'system_for_occuring_functionality_p3'
,
'perform_for_occuring_functionality_p3'
,
'function_for_occuring_functionality_p3'
,
'item_for_occuring_functionality_p3'
,
'flow_for_occuring_functionality_p3'
)
class
StateValueConstraintSerializer
(
serializers
.
ModelSerializer
):
prefix_of_logical_expression
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
logical_expression
=
serializers
.
PrimaryKeyRelatedField
(
read_only
=
True
)
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/urls.py
View file @
a12c5411
...
...
@@ -15,9 +15,12 @@ urlpatterns = [
#'''P1'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/'
,
requirements_views
.
LogicalExpressionListCreateAPIView
.
as_view
(),
name
=
'api-log_expr-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:pk>/'
,
requirements_views
.
LogicalExpressionDetailsAPIView
.
as_view
(),
name
=
'api-log_expr-details'
),
#'''P2
or P3
'''
#'''P2'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p2/'
,
requirements_views
.
OccuringFunctionalityP2ListCreateAPIView
.
as_view
(),
name
=
'api-occur_func-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p2/<int:pk>/'
,
requirements_views
.
OccuringFunctionalityP2DetailsAPIView
.
as_view
(),
name
=
'api-occur_func-details'
),
#'''P3'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p3/'
,
requirements_views
.
OccuringFunctionalityP3ListCreateAPIView
.
as_view
(),
name
=
'api-occur_func_p3-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p3/<int:pk>/'
,
requirements_views
.
OccuringFunctionalityP3DetailsAPIView
.
as_view
(),
name
=
'api-occur_func_p3-details'
),
#'''Logical expression of P1'''
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/constraint/'
,
requirements_views
.
StateValueConstraintListCreateAPIView
.
as_view
(),
name
=
'api-constraint-list'
),
path
(
'requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/constraint/<int:pk>/'
,
requirements_views
.
StateValueConstraintDetailsAPIView
.
as_view
(),
name
=
'api-constraint-details'
),
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/requirements_views.py
View file @
a12c5411
...
...
@@ -5,8 +5,8 @@ from django.http import HttpResponse, JsonResponse
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework.parsers
import
JSONParser
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
,
LogicalExpression
,
OccuringFunctionalityP2
,
StateValueConstraint
,
OccuringFunctionalityForLogicalExpression
from
reqman.apps.reqtool.rest_api.serializers.requirements
import
PrefixSerializer
,
BoilerplateSerializer
,
LogicalExpressionSerializer
,
OccuringFunctionalityP2Serializer
,
StateValueConstraintSerializer
,
OccuringFunctionalityForLogicalExpressionSerializer
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
,
LogicalExpression
,
OccuringFunctionalityP2
,
OccuringFunctionalityP3
,
StateValueConstraint
,
OccuringFunctionalityForLogicalExpression
from
reqman.apps.reqtool.rest_api.serializers.requirements
import
PrefixSerializer
,
BoilerplateSerializer
,
LogicalExpressionSerializer
,
OccuringFunctionalityP2Serializer
,
OccuringFunctionalityP3Serializer
,
StateValueConstraintSerializer
,
OccuringFunctionalityForLogicalExpressionSerializer
from
reqman.apps.permissions
import
IsOwnerOrReadOnly
from
reqman.apps.reqtool.rest_api.services
import
fuseki
...
...
@@ -189,6 +189,49 @@ class OccuringFunctionalityP2DetailsAPIView(RetrieveUpdateDestroyAPIView):
class
OccuringFunctionalityP3ListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityP3Serializer
#queryset = LogicalExpression.objects.all()
def
get_queryset
(
self
):
bp
=
self
.
kwargs
[
'boilerplate'
]
pr
=
self
.
kwargs
[
'prefixs'
]
queryset_prefix
=
OccuringFunctionalityP3
.
objects
.
filter
(
prefix_boilerplate_of_occuring_functionality_p3
=
bp
,
prefix_of_occuring_functionality_p3
=
pr
)
return
queryset_prefix
#Custom actions when POST
def
perform_create
(
self
,
serializer
):
serializer
.
save
()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class
OccuringFunctionalityP3DetailsAPIView
(
RetrieveUpdateDestroyAPIView
):
"""
API view to retrieve, update or delete post
"""
permission_classes
=
[
permissions
.
IsAuthenticatedOrReadOnly
]
serializer_class
=
OccuringFunctionalityP3Serializer
queryset
=
OccuringFunctionalityP3
.
objects
.
all
()
#Custom actions when PUT
def
perform_update
(
self
,
serializer
):
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
()
class
StateValueConstraintListCreateAPIView
(
ListCreateAPIView
):
"""
API view to retrieve list of posts or create new
...
...
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