Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias
my-test-project-1
Commits
2481172d
Commit
2481172d
authored
May 11, 2021
by
Matthias
Browse files
Merge remote-tracking branch 'origin/master'
parents
396da0d5
5d1dcfe0
Pipeline
#32966
passed with stages
in 1 minute and 44 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
import_api_app/__init__.py
View file @
2481172d
...
@@ -101,8 +101,8 @@ def create_app(test_config=None):
...
@@ -101,8 +101,8 @@ def create_app(test_config=None):
# api.add_resource(JobReport, '/v1/job/<topic_name>/report')
# api.add_resource(JobReport, '/v1/job/<topic_name>/report')
api
.
add_resource
(
WriteJobResultToDrupal
,
'/v1/drupal/<job_drupal_uuid>/<job_log_drupal_uuid>'
)
api
.
add_resource
(
WriteJobResultToDrupal
,
'/v1/drupal/<job_drupal_uuid>/<job_log_drupal_uuid>'
)
api
.
add_resource
(
WriteTypeReportToDrupal
,
'/v1/drupal/WriteElementReport'
)
api
.
add_resource
(
WriteTypeReportToDrupal
,
'/v1/drupal/WriteElementReport'
)
api
.
add_resource
(
UpdateInstitution
,
'/v1/drupal/institution/<institution
I
d>'
)
api
.
add_resource
(
UpdateInstitution
,
'/v1/drupal/institution/<institution
_drupal_uui
d>'
)
api
.
add_resource
(
UpdateRecordSet
,
'/v1/drupal/recordset/<record_set_id>'
)
api
.
add_resource
(
UpdateRecordSet
,
'/v1/drupal/recordset/<record_set_
drupal_uu
id>'
)
api
.
add_resource
(
api
.
add_resource
(
DeleteRecord
,
DeleteRecord
,
'/v1/drupal/delete/record/<session_id>'
,
'/v1/drupal/delete/record/<session_id>'
,
...
...
import_api_app/resources/UpdateInstitution.py
View file @
2481172d
...
@@ -75,11 +75,11 @@ class UpdateInstitution(Resource):
...
@@ -75,11 +75,11 @@ class UpdateInstitution(Resource):
paragraph_url
=
f
'
{
base_url
}{
extended_address_path
}{
element
[
"id"
]
}
'
paragraph_url
=
f
'
{
base_url
}{
extended_address_path
}{
element
[
"id"
]
}
'
drupal_response_address
=
requests
.
get
(
paragraph_url
,
headers
=
headers
,
auth
=
auth
)
drupal_response_address
=
requests
.
get
(
paragraph_url
,
headers
=
headers
,
auth
=
auth
)
response_data
=
drupal_response_address
.
json
()[
'data'
]
response_data
=
drupal_response_address
.
json
()[
'data'
]
address
es
=
response_data
[
'attributes'
][
'field_address'
]
next_
address
=
response_data
[
'attributes'
][
'field_address'
]
if
address
es
is
not
None
:
if
next_
address
is
not
None
:
address
es
[
'coordinates'
]
=
\
next_
address
[
'coordinates'
]
=
\
response_data
[
'attributes'
][
'field_geographical_coordinates'
][
'value'
]
response_data
[
'attributes'
][
'field_geographical_coordinates'
][
'value'
]
addresses
.
append
(
address
es
)
addresses
.
append
(
next_
address
)
institution_types
=
[]
institution_types
=
[]
paragraph_url
=
\
paragraph_url
=
\
...
@@ -139,14 +139,14 @@ class UpdateInstitution(Resource):
...
@@ -139,14 +139,14 @@ class UpdateInstitution(Resource):
institution_data_de
[
'attributes'
][
'computed_teaser_image_url'
],
institution_data_de
[
'attributes'
][
'computed_teaser_image_url'
],
'computed_teaser_color'
:
institution_data_de
[
'attributes'
][
'computed_teaser_color'
],
'computed_teaser_color'
:
institution_data_de
[
'attributes'
][
'computed_teaser_color'
],
}
}
producer_topic
=
current_app
.
config
[
'topic-drupal-export'
]
headers
=
[
(
'recordSetId'
,
bytes
(
'none'
,
encoding
=
'utf-8'
)),
(
'sessionId'
,
bytes
(
str
(
uuid
.
uuid4
()),
encoding
=
'utf-8'
)),
(
'institutionId'
,
bytes
(
result
.
get
(
'field_memobase_id'
),
encoding
=
'utf-8'
)),
(
'isPublished'
,
bytes
(
str
(
result
[
'status'
]),
encoding
=
'utf-8'
))
]
try
:
try
:
producer_topic
=
current_app
.
config
[
'topic-drupal-export'
]
headers
=
[
(
'recordSetId'
,
bytes
(
'none'
,
encoding
=
'utf-8'
)),
(
'sessionId'
,
bytes
(
str
(
uuid
.
uuid4
()),
encoding
=
'utf-8'
)),
(
'institutionId'
,
bytes
(
result
.
get
(
'field_memobase_id'
),
encoding
=
'utf-8'
)),
(
'isPublished'
,
bytes
(
str
(
result
[
'status'
]),
encoding
=
'utf-8'
))
]
key
=
bytes
(
result
.
get
(
'field_memobase_id'
),
encoding
=
'utf-8'
)
key
=
bytes
(
result
.
get
(
'field_memobase_id'
),
encoding
=
'utf-8'
)
self
.
producer
.
send
(
producer_topic
,
result
,
key
,
headers
=
headers
)
self
.
producer
.
send
(
producer_topic
,
result
,
key
,
headers
=
headers
)
except
Exception
as
ex
:
except
Exception
as
ex
:
...
...
import_api_app/resources/UpdateRecordSet.py
View file @
2481172d
...
@@ -17,7 +17,7 @@ class UpdateRecordSet(Resource):
...
@@ -17,7 +17,7 @@ class UpdateRecordSet(Resource):
value_serializer
=
lambda
m
:
json
.
dumps
(
m
,
ensure_ascii
=
False
)
value_serializer
=
lambda
m
:
json
.
dumps
(
m
,
ensure_ascii
=
False
)
.
encode
(
'utf-8'
))
.
encode
(
'utf-8'
))
def
get
(
self
,
record_set_id
):
def
get
(
self
,
record_set_
drupal_uu
id
):
"""
"""
Update the record set with the given drupal UUID in the backend.
Update the record set with the given drupal UUID in the backend.
---
---
...
@@ -25,7 +25,7 @@ class UpdateRecordSet(Resource):
...
@@ -25,7 +25,7 @@ class UpdateRecordSet(Resource):
- Import Record Set
- Import Record Set
parameters:
parameters:
- in: path
- in: path
name: record_set_id
name: record_set_
drupal_uu
id
required: true
required: true
description: The UUID of the updated recordset
description: The UUID of the updated recordset
example: 0c4c777c-94f8-45ba-945a-bfe6967d40da
example: 0c4c777c-94f8-45ba-945a-bfe6967d40da
...
@@ -56,9 +56,9 @@ class UpdateRecordSet(Resource):
...
@@ -56,9 +56,9 @@ class UpdateRecordSet(Resource):
# Retrieve Drupal Entities for each language.
# Retrieve Drupal Entities for each language.
# Returns default entity if there is a language missing.
# Returns default entity if there is a language missing.
de_drupal_url
=
f
'
{
base_url
}
/de
{
json_api_path
}{
record_set_id
}
'
de_drupal_url
=
f
'
{
base_url
}
/de
{
json_api_path
}{
record_set_
drupal_uu
id
}
'
fr_drupal_url
=
f
'
{
base_url
}
/fr
{
json_api_path
}{
record_set_id
}
'
fr_drupal_url
=
f
'
{
base_url
}
/fr
{
json_api_path
}{
record_set_
drupal_uu
id
}
'
it_drupal_url
=
f
'
{
base_url
}
/it
{
json_api_path
}{
record_set_id
}
'
it_drupal_url
=
f
'
{
base_url
}
/it
{
json_api_path
}{
record_set_
drupal_uu
id
}
'
try
:
try
:
drupal_record_set_de
=
\
drupal_record_set_de
=
\
requests
.
get
(
de_drupal_url
,
headers
=
headers
,
auth
=
auth
).
json
()[
'data'
]
requests
.
get
(
de_drupal_url
,
headers
=
headers
,
auth
=
auth
).
json
()[
'data'
]
...
@@ -199,7 +199,7 @@ class UpdateRecordSet(Resource):
...
@@ -199,7 +199,7 @@ class UpdateRecordSet(Resource):
'field_teaser_image'
:
drupal_record_set_de
[
'relationships'
][
'field_teaser_image'
]
'field_teaser_image'
:
drupal_record_set_de
[
'relationships'
][
'field_teaser_image'
]
}
}
except
LookupError
as
ex
:
except
LookupError
as
ex
:
msg
=
'LookupError for '
+
record_set_id
+
': '
+
str
(
ex
)
+
'
\n
'
+
\
msg
=
'LookupError for '
+
record_set_
drupal_uu
id
+
': '
+
str
(
ex
)
+
'
\n
'
+
\
traceback
.
format_exc
()
+
'
\n
'
+
\
traceback
.
format_exc
()
+
'
\n
'
+
\
'baseRequest: '
+
de_drupal_url
+
'
\n
'
'baseRequest: '
+
de_drupal_url
+
'
\n
'
current_app
.
logger
.
error
(
msg
)
current_app
.
logger
.
error
(
msg
)
...
@@ -209,7 +209,7 @@ class UpdateRecordSet(Resource):
...
@@ -209,7 +209,7 @@ class UpdateRecordSet(Resource):
'result_topic_value'
:
result_topic_value
'result_topic_value'
:
result_topic_value
},
500
},
500
except
Exception
as
ex
:
except
Exception
as
ex
:
msg
=
'Exception for '
+
record_set_id
+
': '
+
str
(
ex
)
+
'
\n
'
+
\
msg
=
'Exception for '
+
record_set_
drupal_uu
id
+
': '
+
str
(
ex
)
+
'
\n
'
+
\
traceback
.
format_exc
()
+
'
\n
'
+
\
traceback
.
format_exc
()
+
'
\n
'
+
\
'baseRequest: '
+
de_drupal_url
+
'
\n
'
'baseRequest: '
+
de_drupal_url
+
'
\n
'
current_app
.
logger
.
error
(
msg
)
current_app
.
logger
.
error
(
msg
)
...
@@ -219,7 +219,7 @@ class UpdateRecordSet(Resource):
...
@@ -219,7 +219,7 @@ class UpdateRecordSet(Resource):
'result_topic_value'
:
result_topic_value
,
'result_topic_value'
:
result_topic_value
,
},
500
},
500
return
self
.
send_message
(
result_topic_value
,
record_set_id
)
return
self
.
send_message
(
result_topic_value
,
record_set_
drupal_uu
id
)
def
send_message
(
self
,
result_topic_value
,
record_set_drupal_id
):
def
send_message
(
self
,
result_topic_value
,
record_set_drupal_id
):
headers
=
[
headers
=
[
...
...
Write
Preview
Supports
Markdown
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