Commit 4a584213 authored by Ivan Tyagov's avatar Ivan Tyagov

Add a quick input action to make ingestion policy and related object creation a bit easier.

parent f687d7e5
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_fast_input</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_fast_input</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>add_ingestion_policy</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Add Ingestion Policy</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/IngestionPolicyTool_viewAddIngestionPolicyActionDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Create all required types for proper ingestion.\n
"""\n
from DateTime import DateTime\n
\n
now = DateTime()\n
ingestion_policy = context.newContent( \\\n
portal_type =\'Ingestion Policy\',\n
reference = reference,\n
version = \'001\',\n
script_id = \'ERP5Site_handleDefaultFluentdIngestion\')\n
ingestion_policy.validate()\n
\n
# create sensor\n
sensor = context.sensor_module.newContent( \\\n
portal_type=\'Sensor\', \n
reference = reference)\n
sensor.validate()\n
\n
# create new Data Stream\n
data_stream = context.data_stream_module.newContent( \\\n
portal_type=\'Data Stream\', \\\n
version = \'001\', \\\n
reference=reference)\n
data_stream.validate()\n
\n
# create Data Supply\n
resource = context.restrictedTraverse(\'data_product_module/wendelin_4\')\n
data_supply_kw = {\'reference\': reference,\n
\'version\': \'001\',\n
\'start_date\': now,\n
\'stop_date\': now + 365}\n
data_supply_line_kw = {\'resource_value\': resource,\n
\'source_value\': sensor,\n
\'destination_value\': data_stream}\n
data_supply = ingestion_policy.PortalIngestionPolicy_addDataSupply( \\\n
data_supply_kw, \\\n
data_supply_line_kw)\n
\n
data_array = context.data_array_module.newContent(\n
portal_type=\'Data Array\',\n
reference = reference,\n
version = \'001\')\n
data_array.validate()\n
\n
if batch_mode:\n
return ingestion_policy, data_supply, data_stream, data_array\n
else:\n
# UI case\n
ingestion_policy.Base_redirect(\\\n
form_id=\'view\', \\\n
keep_items={\'portal_status_message\': \\\n
context.Base_translateString(\'Ingestion Policy added.\')})\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference=None, batch_mode=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>IngestionPolicyTool_addIngestionPolicy</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>IngestionPolicyTool_addIngestionPolicy</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_reference</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>IngestionPolicyTool_viewAddIngestionPolicyActionDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>BaseWorkflow_viewWorkflowActionDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Ingestion Policy</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>editable</string>
<string>enabled</string>
<string>required</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_reference</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>Reference of the source of the data</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Reference</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -62,52 +62,15 @@ class Test(ERP5TypeTestCase):
"""
Generic step.
"""
now = DateTime()
portal = self.portal
# create ingestion policy
ingestion_policy = portal.portal_ingestion_policies.newContent( \
portal_type ='Ingestion Policy',
reference = reference,
version = '001',
script_id = 'ERP5Site_handleDefaultFluentdIngestion')
ingestion_policy.validate()
# create sensor
sensor = portal.sensor_module.newContent( \
portal_type='Sensor',
reference = reference)
sensor.validate()
# create new Data Stream for test purposes
data_stream = portal.data_stream_module.newContent( \
portal_type='Data Stream', \
version = '001', \
reference=reference)
data_stream.validate()
# create Data Supply
resource = portal.restrictedTraverse('data_product_module/wendelin_4')
data_supply_kw = {'reference': reference,
'version': '001',
'start_date': now,
'stop_date': now + 365}
data_supply_line_kw = {'resource_value': resource,
'source_value': sensor,
'destination_value': data_stream}
data_supply = ingestion_policy.PortalIngestionPolicy_addDataSupply( \
data_supply_kw, \
data_supply_line_kw)
data_array = portal.data_array_module.newContent(
portal_type='Data Array',
reference = reference,
version = '001')
data_array.validate()
ingestion_policy, data_supply, data_stream, data_array = \
self.portal.portal_ingestion_policies.IngestionPolicyTool_addIngestionPolicy( \
reference = reference, \
batch_mode = 1)
self.tic()
return ingestion_policy, data_supply, data_stream, data_array
def test_0_import(self):
"""
Test we can import certain libraries but still failure to do so should be a
......
......@@ -47,16 +47,17 @@
<value>
<tuple>
<string>W: 39, 8: Unused variable \'n\' (unused-variable)</string>
<string>W:116, 4: Unused variable \'scipy\' (unused-variable)</string>
<string>W:118, 4: Unused variable \'pandas\' (unused-variable)</string>
<string>W:117, 4: Unused variable \'sklearn\' (unused-variable)</string>
<string>W:136, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:176, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:227, 8: Unused variable \'i\' (unused-variable)</string>
<string>W:176, 4: Unused variable \'ingestion_policy\' (unused-variable)</string>
<string>W:257, 4: Unused variable \'ingestion_policy\' (unused-variable)</string>
<string>W:257, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:257, 48: Unused variable \'data_array\' (unused-variable)</string>
<string>W: 79, 4: Unused variable \'scipy\' (unused-variable)</string>
<string>W: 81, 4: Unused variable \'pandas\' (unused-variable)</string>
<string>W: 80, 4: Unused variable \'sklearn\' (unused-variable)</string>
<string>W: 99, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:139, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:190, 8: Unused variable \'i\' (unused-variable)</string>
<string>W:139, 4: Unused variable \'ingestion_policy\' (unused-variable)</string>
<string>W:220, 4: Unused variable \'ingestion_policy\' (unused-variable)</string>
<string>W:220, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:220, 48: Unused variable \'data_array\' (unused-variable)</string>
<string>W: 31, 0: Unused DateTime imported from DateTime (unused-import)</string>
</tuple>
</value>
</item>
......
......@@ -29,6 +29,7 @@ Data Stream | view
Data Supply Line | view
Data Supply Module | view
Data Supply | view
Ingestion Policy Tool | add_ingestion_policy
Ingestion Policy Tool | view
Ingestion Policy | view
Sensor Module | view
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment