Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
bb995377
Commit
bb995377
authored
Dec 7, 2021
by
Cornelia Michlits
Browse files
Options
Downloads
Patches
Plain Diff
#104 change respose messages
parent
16ebdf41
No related branches found
No related tags found
4 merge requests
!81
New stable release
,
!43
Merge dev to master
,
!33
Draft: merge dev to master
,
!32
Add units-service to dev
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
fda-units-service/app.py
+10
-9
10 additions, 9 deletions
fda-units-service/app.py
fda-units-service/list.py
+2
-2
2 additions, 2 deletions
fda-units-service/list.py
fda-units-service/validate.py
+3
-3
3 additions, 3 deletions
fda-units-service/validate.py
with
15 additions
and
14 deletions
fda-units-service/app.py
+
10
−
9
View file @
bb995377
...
...
@@ -40,13 +40,12 @@ def suggest():
try
:
unit
=
str
(
input_json
[
'
ustring
'
])
offset
=
int
(
input_json
[
'
offset
'
])
res
=
list_units
(
unit
,
offset
)
res
=
list_units
(
stringmapper
(
unit
)
,
offset
)
return
jsonify
(
res
),
200
except
Exception
as
e
:
print
(
e
)
#str(print_exc())
res
=
{
"
success
"
:
False
,
"
message
"
:
"
Unknown error
"
+
str
(
e
)
+
unit
}
return
jsonify
(
res
)
res
=
{
"
success
"
:
False
,
"
message
"
:
str
(
e
)}
return
jsonify
(
res
),
500
@app.route
(
'
/api/units/validate
'
,
methods
=
[
"
POST
"
],
endpoint
=
'
validate
'
)
@swag_from
(
'
validate.yml
'
)
...
...
@@ -55,9 +54,10 @@ def valitate():
try
:
unit
=
str
(
input_json
[
'
ustring
'
])
res
=
validator
(
stringmapper
(
unit
))
return
str
(
res
),
200
except
Exception
as
e
:
print
(
e
)
res
=
{
"
success
"
:
False
,
"
message
"
:
"
Unknown error
"
+
str
(
e
)
+
unit
}
res
=
{
"
success
"
:
False
,
"
message
"
:
str
(
e
)}
return
jsonify
(
res
)
@app.route
(
'
/api/units/geturi
'
,
methods
=
[
"
POST
"
],
endpoint
=
'
geturi
'
)
...
...
@@ -67,10 +67,11 @@ def geturi():
try
:
name
=
str
(
input_json
[
'
uname
'
])
res
=
get_uri
(
name
)
return
jsonify
(
res
),
200
except
Exception
as
e
:
print
(
e
)
res
=
{
"
success
"
:
False
,
"
message
"
:
"
Unknown error
"
+
str
(
e
)
+
unit
}
return
jsonify
(
res
)
res
=
{
"
success
"
:
False
,
"
message
"
:
str
(
e
)}
return
jsonify
(
res
)
,
500
rest_server_port
=
5010
eureka_client
.
init
(
eureka_server
=
os
.
getenv
(
'
EUREKA_SERVER
'
,
'
http://localhost:9090/eureka/
'
),
...
...
This diff is collapsed.
Click to expand it.
fda-units-service/list.py
+
2
−
2
View file @
bb995377
...
...
@@ -18,14 +18,14 @@ rdf_schema = rdflib.Namespace('http://www.w3.org/2000/01/rdf-schema#')
r
=
{}
def
list_units
(
string
,
offset
=
0
):
if
bool
(
re
.
match
(
'
^[a-zA-Z0-9]+$
'
,
string
)):
if
bool
(
re
.
match
(
'
^[a-zA-Z0-9
\\
s
]+$
'
,
string
)):
l_query
=
"""
SELECT ?symbol ?name ?comment
WHERE {
?unit om:symbol ?symbol .
?unit <http://www.w3.org/2000/01/rdf-schema#label> ?name .
?unit <http://www.w3.org/2000/01/rdf-schema#comment> ?comment .
FILTER regex(str(?unit),
\"
"""
+
string
+
"""
\"
,
"
i
"
)
FILTER
(
regex(str(?unit),
\"
"""
+
string
+
"""
\"
,
"
i
"
)
&& lang(?name)=
"
en
"
)
} LIMIT 10 OFFSET
"""
+
str
(
offset
)
qres
=
g
.
query
(
l_query
)
units
=
list
()
...
...
This diff is collapsed.
Click to expand it.
fda-units-service/validate.py
+
3
−
3
View file @
bb995377
...
...
@@ -16,10 +16,10 @@ def validator(value):
#input str
tmp
=
str
(
om
)
+
value
t_uri
=
rdflib
.
term
.
URIRef
(
tmp
)
if
next
(
g
.
triples
((
t_uri
,
None
,
om
.
Unit
)),
_exhausted
)
is
_exhausted
and
next
(
g
.
triples
((
t_uri
,
None
,
om
.
PrefixedUnit
)),
_exhausted
)
is
_exhausted
and
next
(
g
.
triples
((
t_uri
,
None
,
om
.
UnitDivision
)),
_exhausted
)
is
_exhausted
:
return
{
"
valid
"
:
False
}
if
next
(
g
.
triples
((
t_uri
,
None
,
om
.
Unit
)),
_exhausted
)
is
_exhausted
and
next
(
g
.
triples
((
t_uri
,
None
,
om
.
PrefixedUnit
)),
_exhausted
)
is
_exhausted
and
next
(
g
.
triples
((
t_uri
,
None
,
None
)),
_exhausted
)
is
_exhausted
:
return
False
else
:
return
{
"
valid
"
:
True
}
return
True
def
stringmapper
(
thisstring
):
if
'
'
in
thisstring
:
...
...
This diff is collapsed.
Click to expand it.
Cornelia Michlits
@cornelia.michlits
mentioned in commit
82a22b15
·
Feb 20, 2022
mentioned in commit
82a22b15
mentioned in commit 82a22b155daf205b6bca7d1f226afd520b098dc8
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment