Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
telecom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Roque
telecom
Commits
dd6bfa1d
Commit
dd6bfa1d
authored
Oct 26, 2017
by
Roque Porchetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin_telecom_ingestion: refactoring in data ingestion reference
parent
89478a9c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
151 deletions
+152
-151
bt5/erp5_wendelin_telecom_ingestion/SkinTemplateItem/portal_skins/erp5_wendelin_telecom/IngestionPolicy_getIngestionOperationAndParameterDict.py
.../IngestionPolicy_getIngestionOperationAndParameterDict.py
+130
-129
bt5/erp5_wendelin_telecom_ingestion/SkinTemplateItem/portal_skins/erp5_wendelin_telecom/ingestionReferenceExists.py
...l_skins/erp5_wendelin_telecom/ingestionReferenceExists.py
+22
-22
No files found.
bt5/erp5_wendelin_telecom_ingestion/SkinTemplateItem/portal_skins/erp5_wendelin_telecom/IngestionPolicy_getIngestionOperationAndParameterDict.py
View file @
dd6bfa1d
...
@@ -6,34 +6,32 @@ today_string = now.strftime('%Y%m%d')
...
@@ -6,34 +6,32 @@ today_string = now.strftime('%Y%m%d')
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
portal_catalog
=
portal
.
portal_catalog
# removing eof from reference
reference
=
'_'
.
join
(
reference
.
split
(
'.'
)[:
-
1
])
try
:
log
(
"Reference: "
+
reference
)
# remove supplier and eof from reference
context
.
logEntry
(
"Data Ingestion reference: %s"
%
reference
)
reference
=
'_'
.
join
(
reference
.
split
(
'.'
)[
1
:
-
1
])
#'_'.join(reference.split('.')[:-1])
log
(
"Reference: "
+
reference
)
data_ingestion_reference
=
reference
context
.
logEntry
(
"Data Ingestion reference: %s"
%
reference
)
data_ingestion_id
=
'%s_%s'
%
(
data_ingestion_reference
,
today_string
)
eof
=
movement_dict
.
get
(
'eof'
,
'EOF'
)
data_ingestion_reference
=
reference
resource_reference
=
movement_dict
.
get
(
'resource_reference'
,
None
)
eof
=
movement_dict
.
get
(
'eof'
,
'EOF'
)
specialise_reference
=
movement_dict
.
get
(
'specialise_reference'
,
None
)
resource_reference
=
movement_dict
.
get
(
'resource_reference'
,
None
)
dataset_reference
=
movement_dict
.
get
(
'aggregate_data_set_reference'
,
None
)
specialise_reference
=
movement_dict
.
get
(
'specialise_reference'
,
None
)
dataset_reference
=
movement_dict
.
get
(
'aggregate_data_set_reference'
,
None
)
# search for applicable data ingestion
data_ingestion_id
=
'%s_%s_%s'
%
(
specialise_reference
,
data_ingestion_reference
,
today_string
)
data_ingestion
=
portal_catalog
.
getResultValue
(
context
.
logEntry
(
"Data Ingestion ID: %s"
%
reference
)
# search for applicable data ingestion
data_ingestion
=
portal_catalog
.
getResultValue
(
portal_type
=
'Data Ingestion'
,
portal_type
=
'Data Ingestion'
,
simulation_state
=
'planned'
,
reference
=
data_ingestion_reference
)
reference
=
data_ingestion_reference
)
if
data_ingestion
is
None
:
if
data_ingestion
is
not
None
:
document
=
portal
.
data_ingestion_module
.
get
(
data_ingestion_id
)
if
data_ingestion
.
getSimulationState
()
!=
'planned'
:
if
(
document
is
not
None
):
if
document
.
getSimulationState
()
==
'planned'
:
data_ingestion
=
document
else
:
context
.
logEntry
(
"An older ingestion for reference %s was already done."
%
data_ingestion_reference
)
context
.
logEntry
(
"An older ingestion for reference %s was already done."
%
data_ingestion_reference
)
raise
ValueError
(
"An older ingestion for reference %s was already done."
%
data_ingestion_reference
)
raise
ValueError
(
"An older ingestion for reference %s was already done."
%
data_ingestion_reference
)
if
data_ingestion
is
None
:
if
data_ingestion
is
None
:
specialise_value_list
=
[
x
.
getObject
()
for
x
in
portal_catalog
.
searchResults
(
specialise_value_list
=
[
x
.
getObject
()
for
x
in
portal_catalog
.
searchResults
(
portal_type
=
'Data Supply'
,
portal_type
=
'Data Supply'
,
reference
=
'embulk'
,
reference
=
'embulk'
,
...
@@ -120,7 +118,7 @@ if data_ingestion is None:
...
@@ -120,7 +118,7 @@ if data_ingestion is None:
log
(
"Data Ingestion planned."
)
log
(
"Data Ingestion planned."
)
context
.
logEntry
(
"Data Ingestion planned."
)
context
.
logEntry
(
"Data Ingestion planned."
)
else
:
else
:
log
(
"Planned Data Ingestion found for reference: "
+
str
(
data_ingestion
))
log
(
"Planned Data Ingestion found for reference: "
+
str
(
data_ingestion
))
context
.
logEntry
(
"Planned Data Ingestion found for reference: "
+
str
(
data_ingestion
))
context
.
logEntry
(
"Planned Data Ingestion found for reference: "
+
str
(
data_ingestion
))
# find ingestion line for current resource
# find ingestion line for current resource
...
@@ -130,12 +128,15 @@ else:
...
@@ -130,12 +128,15 @@ else:
elif
line
.
getResourceValue
().
getPortalType
()
==
"Data Operation"
:
elif
line
.
getResourceValue
().
getPortalType
()
==
"Data Operation"
:
operation_line
=
line
operation_line
=
line
data_operation
=
operation_line
.
getResourceValue
()
data_operation
=
operation_line
.
getResourceValue
()
data_stream
=
input_line
.
getAggregateDataStreamValue
()
data_stream
=
input_line
.
getAggregateDataStreamValue
()
if
eof
==
"EOF"
:
if
eof
==
"EOF"
:
data_ingestion
.
start
()
data_ingestion
.
start
()
log
(
"Data Ingestion started."
)
log
(
"Data Ingestion started."
)
context
.
logEntry
(
"Data Ingestion started."
)
context
.
logEntry
(
"Data Ingestion started."
)
return
data_operation
,
{
'data_stream'
:
data_stream
}
return
data_operation
,
{
'data_stream'
:
data_stream
}
except
Exception
as
e
:
context
.
logEntry
(
"[ERROR] At script IngestionPolicy_getIngestionOperationAndParameterDict
\
n
[ERROR] "
+
str
(
e
))
raise
e
bt5/erp5_wendelin_telecom_ingestion/SkinTemplateItem/portal_skins/erp5_wendelin_telecom/ingestionReferenceExists.py
View file @
dd6bfa1d
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
Products.ERP5Type.Log
import
log
# reference parameter example: telecom.MNE.filename.fif.EOF
# reference parameter example: supplier.dataset.filename.fif.EOF
# ingestion reference example: telecom_MNE_filename_fif
# ingestion reference example: dataset_filename_fif
# ingestion id example: telecom_MNE_filename_fif_20170615
FALSE
=
"FALSE"
FALSE
=
"FALSE"
TRUE
=
"TRUE"
TRUE
=
"TRUE"
today_string
=
DateTime
().
strftime
(
'%Y%m%d'
)
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
portal_catalog
=
portal
.
portal_catalog
data_ingestion_reference
=
'_'
.
join
(
reference
.
split
(
'_'
)[:
-
1
])
#'_'.join(reference.split('.')[:-1])
try
:
data_ingestion_id
=
'%s_%s'
%
(
data_ingestion_reference
,
today_string
)
context
.
logEntry
(
"Attempt to do a new ingestion with reference: %s"
%
reference
)
# first search for applicable data ingestion
# remove supplier and eof from reference
data_ingestion
=
portal_catalog
.
getResultValue
(
data_ingestion_reference
=
'_'
.
join
(
reference
.
split
(
'_'
)[
1
:
-
1
])
data_ingestion
=
portal_catalog
.
getResultValue
(
portal_type
=
'Data Ingestion'
,
portal_type
=
'Data Ingestion'
,
simulation_state
=
'planned'
,
reference
=
data_ingestion_reference
)
reference
=
data_ingestion_reference
)
if
data_ingestion
is
None
:
if
data_ingestion
is
None
:
document
=
portal
.
data_ingestion_module
.
get
(
data_ingestion_id
)
if
(
document
is
not
None
):
if
document
.
getSimulationState
()
==
'planned'
:
return
FALSE
else
:
return
TRUE
else
:
return
FALSE
return
FALSE
else
:
if
data_ingestion
.
getSimulationState
()
==
'planned'
:
return
FALSE
return
FALSE
context
.
logEntry
(
"[ERROR] Data Ingestion reference %s already exists"
%
data_ingestion_reference
)
return
TRUE
except
Exception
as
e
:
context
.
logEntry
(
"[ERROR] At script ingestionReferenceExists
\
n
[ERROR] "
+
str
(
e
))
raise
e
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