def __init__(self, elem, quota_definition_sid, import_file, transform_only=False): Master.__init__(self, elem) self.quota_suspension_period_sid = Master.process_null( elem.find("sid")) self.quota_definition_sid = quota_definition_sid self.suspension_start_date = Master.process_date( elem.find("suspensionStartDate")) self.suspension_end_date = Master.process_date( elem.find("suspensionEndDate")) self.description = Master.process_null(elem.find("description")) operation_date = g.app.get_timestamp() if transform_only is False: sql = """ insert into quota_suspension_periods_oplog (quota_suspension_period_sid, quota_definition_sid, suspension_start_date, suspension_end_date, description, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.quota_suspension_period_sid, self.quota_definition_sid, self.suspension_start_date, self.suspension_end_date, self.description, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params)
def __init__(self, elem, additional_code_type_id, import_file, transform_only=False): Master.__init__(self, elem) self.additional_code_type_id = additional_code_type_id self.measure_type_id = Master.process_null( elem.find("measureType/measureTypeId")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() g.app.print_only( "Running operation {0} on additional code type measure type {1}.". format(self.operation, self.additional_code_type_id)) if transform_only is False: sql = """ insert into additional_code_type_measure_types_oplog (additional_code_type_id, measure_type_id, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.additional_code_type_id, self.measure_type_id, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.additional_code_sid = Master.process_null(elem.find("sid")) self.additional_code_type_id = Master.process_null( elem.find("additionalCodeType/additionalCodeTypeId")) self.additional_code = Master.process_null( elem.find("additionalCodeCode")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() g.app.print_only( "Running operation {0} on additional code {1}.".format( self.operation, str(self.additional_code_sid))) # Insert the additional code if transform_only is False: sql = """ insert into additional_codes_oplog (additional_code_sid, additional_code_type_id, additional_code, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.additional_code_sid, self.additional_code_type_id, self.additional_code, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any additional code descriptions sql = """ delete from additional_code_descriptions_oplog where additional_code_sid = %s """ params = [self.additional_code_sid] d = Database() d.run_query(sql, params) # Delete any additional code description periods sql = """ delete from additional_code_description_periods_oplog where additional_code_sid = %s """ params = [self.additional_code_sid] d = Database() d.run_query(sql, params) # Create new additional code description periods for elem in elem.findall('.//additionalCodeDescriptionPeriod'): AdditionalCodeDescriptionPeriod(elem, self.additional_code_sid, self.additional_code_type_id, self.additional_code, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.approved_flag = Master.process_null(elem.find("approvedFlag")) self.base_regulation_id = Master.process_null( elem.find("baseRegulationId")) self.community_code = Master.process_null(elem.find("communityCode")) self.effective_end_date = Master.process_null( elem.find("effectiveEndDate")) self.information_text = Master.process_null( elem.find("informationText")) self.officialjournal_number = Master.process_null( elem.find("officialjournalNumber")) self.officialjournal_page = Master.process_null( elem.find("officialjournalPage")) self.published_date = Master.process_null(elem.find("publishedDate")) self.replacement_indicator = Master.process_null( elem.find("replacementIndicator")) self.stopped_flag = Master.process_null(elem.find("stoppedFlag")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) self.regulation_group_id = Master.process_null( elem.find("regulationGroup/regulationGroupId")) self.regulation_role_type_id = Master.process_null( elem.find("regulationRoleType/regulationRoleTypeId")) operation_date = g.app.get_timestamp() g.app.print_only( "Running operation {0} on base regulation {1}.".format( self.operation, self.base_regulation_id)) if transform_only is False: # Insert the base regulation sql = """ insert into base_regulations_oplog (approved_flag, base_regulation_id, community_code, effective_end_date, information_text, officialjournal_number, officialjournal_page, published_date, replacement_indicator, stopped_flag, validity_start_date, validity_end_date, regulation_group_id, base_regulation_role, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.approved_flag, self.base_regulation_id, self.community_code, self.effective_end_date, self.information_text, self.officialjournal_number, self.officialjournal_page, self.published_date, self.replacement_indicator, self.stopped_flag, self.validity_start_date, self.validity_end_date, self.regulation_group_id, self.regulation_role_type_id, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.measure_type_id = Master.process_null(elem.find("measureTypeId")) self.measure_component_applicable_code = Master.process_null( elem.find("measureComponentApplicableCode")) self.measure_explosion_level = Master.process_null( elem.find("measureExplosionLevel")) self.order_number_capture_code = Master.process_null( elem.find("orderNumberCaptureCode")) self.origin_dest_code = Master.process_null( elem.find("originDestCode")) self.priority_code = Master.process_null(elem.find("priorityCode")) self.trade_movement_code = Master.process_null( elem.find("tradeMovementCode")) self.measure_type_series_id = Master.process_null( elem.find("measureTypeSeries/measureTypeSeriesId")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) self.application_code = Master.process_null( elem.find("applicationCode")) operation_date = g.app.get_timestamp() # Insert the measure type if transform_only is False: sql = """ insert into measure_types_oplog (measure_type_id, validity_start_date, validity_end_date, measure_component_applicable_code, measure_explosion_level, order_number_capture_code, origin_dest_code, priority_code, trade_movement_code, measure_type_series_id, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.measure_type_id, self.validity_start_date, self.validity_end_date, self.measure_component_applicable_code, self.measure_explosion_level, self.order_number_capture_code, self.origin_dest_code, self.priority_code, self.trade_movement_code, self.measure_type_series_id, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any measure descriptions sql = """ delete from measure_type_descriptions_oplog where measure_type_id = %s """ params = [self.measure_type_id] d = Database() d.run_query(sql, params) # Create new measure type descriptions for elem in elem.findall('.//measureTypeDescription'): MeasureTypeDescription(elem, self.measure_type_id, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.certificate_type_code = Master.process_null( elem.find("certificateType/certificateTypeCode")) self.certificate_code = Master.process_null( elem.find("certificateCode")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() g.app.print_only("Running operation {0} on certificate {1}.".format( self.operation, str(self.certificate_code))) # Insert the certificate if transform_only is False: sql = """ insert into certificates_oplog (certificate_type_code, certificate_code, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.certificate_type_code, self.certificate_code, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any certificate descriptions sql = """ delete from certificate_descriptions_oplog where certificate_type_code = %s and certificate_code = %s """ params = [self.certificate_type_code, self.certificate_code] d = Database() d.run_query(sql, params) # Delete any certificate description periods sql = """ delete from certificate_description_periods_oplog where certificate_type_code = %s and certificate_code = %s """ params = [self.certificate_type_code, self.certificate_code] d = Database() d.run_query(sql, params) # Create new certificate description periods for elem in elem.findall('.//certificateDescriptionPeriod'): CertificateDescriptionPeriod(elem, self.certificate_type_code, self.certificate_code, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.descriptions = [] self.footnote_type_id = Master.process_null( elem.find("footnoteType/footnoteTypeId")) self.footnote_id = Master.process_null(elem.find("footnoteId")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() # Insert the footnote if transform_only is False: sql = """ insert into footnotes_oplog (footnote_type_id, footnote_id, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.footnote_type_id, self.footnote_id, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any footnote descriptions sql = """ delete from footnote_descriptions_oplog where footnote_type_id = %s and footnote_id = %s """ params = [self.footnote_type_id, self.footnote_id] d = Database() d.run_query(sql, params) # Delete any footnote description periods sql = """ delete from footnote_description_periods_oplog where footnote_type_id = %s and footnote_id = %s """ params = [self.footnote_type_id, self.footnote_id] d = Database() d.run_query(sql, params) # Create new footnote description periods for elem in elem.findall('.//footnoteDescriptionPeriod'): FootnoteDescriptionPeriod(elem, self.footnote_type_id, self.footnote_id, import_file)
def __init__(self, elem, geographical_area_sid, geographical_area_id, import_file, transform_only=False): Master.__init__(self, elem) self.geographical_area_sid = geographical_area_sid self.geographical_area_id = geographical_area_id self.geographical_area_description_period_sid = Master.process_null( elem.find("sid")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() # Insert the geographical area description period if transform_only is False: sql = """ insert into geographical_area_description_periods_oplog (geographical_area_description_period_sid, geographical_area_sid, geographical_area_id, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s,%s, %s, %s, %s, %s, %s, %s) """ params = [ self.geographical_area_description_period_sid, self.geographical_area_sid, self.geographical_area_id, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Create new geographical area descriptions for elem in elem.findall('.//geographicalAreaDescription'): GeographicalAreaDescription( elem, self.geographical_area_description_period_sid, self.geographical_area_sid, self.geographical_area_id, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.quota_order_number_sid = Master.process_null(elem.find("sid")) self.quota_order_number_id = Master.process_null( elem.find("quotaOrderNumberId")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() # Insert the quota order number if transform_only is False: sql = """ insert into quota_order_numbers_oplog (quota_order_number_sid, quota_order_number_id, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.quota_order_number_sid, self.quota_order_number_id, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any quota order number origins sql = """ delete from quota_order_number_origins_oplog where quota_order_number_sid = %s """ params = [self.quota_order_number_sid] d = Database() d.run_query(sql, params) # Create new quota order number origins for elem in elem.findall('.//quotaOrderNumberOrigin'): QuotaOrderNumberOrigin(elem, self.quota_order_number_sid, import_file)
def __init__(self, elem, goods_nomenclature_sid, goods_nomenclature_item_id, productline_suffix, import_file, transform_only=False): Master.__init__(self, elem) self.goods_nomenclature_sid = goods_nomenclature_sid self.goods_nomenclature_item_id = goods_nomenclature_item_id self.productline_suffix = productline_suffix self.goods_nomenclature_indent_sid = Master.process_null( elem.find("sid")) self.number_indents = Master.process_null(elem.find("numberIndents")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() # Insert the footnote description period if transform_only is False: sql = """ insert into goods_nomenclature_indents_oplog (goods_nomenclature_indent_sid, goods_nomenclature_sid, validity_start_date, number_indents, goods_nomenclature_item_id, productline_suffix, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.goods_nomenclature_indent_sid, self.goods_nomenclature_sid, self.validity_start_date, self.number_indents, self.goods_nomenclature_item_id, self.productline_suffix, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params)
def __init__(self, elem, geographical_area_group_sid, import_file, transform_only=False): Master.__init__(self, elem) # the inputs are: # validityStartDate # validityEndDate # geographicalAreaGroupSid, which actually means the hjid of the child self.geographical_area_sid = None self.geographical_area_group_sid = geographical_area_group_sid self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) self.child_hjid = Master.process_null( elem.find("geographicalAreaGroupSid")) self.lookup_child_hjid() operation_date = g.app.get_timestamp() if transform_only is False: sql = """ insert into geographical_area_memberships_oplog (geographical_area_sid, geographical_area_group_sid, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.geographical_area_sid, self.geographical_area_group_sid, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params)
def __init__(self, elem, goods_nomenclature_sid, goods_nomenclature_item_id, productline_suffix, import_file, transform_only=False): Master.__init__(self, elem) self.goods_nomenclature_sid = goods_nomenclature_sid self.goods_nomenclature_item_id = goods_nomenclature_item_id self.productline_suffix = productline_suffix self.footnote_type_id = Master.process_null( elem.find("footnote/footnoteType/footnoteTypeId")) self.footnote_id = Master.process_null( elem.find("footnote/footnoteId")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) operation_date = g.app.get_timestamp() if transform_only is False: sql = """ insert into footnote_association_goods_nomenclatures_oplog (goods_nomenclature_sid, footnote_type, footnote_id, validity_start_date, validity_end_date, goods_nomenclature_item_id, productline_suffix, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.goods_nomenclature_sid, self.footnote_type_id, self.footnote_id, self.validity_start_date, self.validity_end_date, self.goods_nomenclature_item_id, self.productline_suffix, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params)
def __init__(self, elem, quota_definition_sid, import_file, transform_only=False): Master.__init__(self, elem) self.quota_definition_sid = quota_definition_sid self.imported_amount = Master.process_null(elem.find("importedAmount")) self.new_balance = Master.process_null(elem.find("newBalance")) self.occurrence_timestamp = Master.process_date( elem.find("occurrenceTimestamp")) self.old_balance = Master.process_null(elem.find("oldBalance")) self.last_import_date_in_allocation = Master.process_date( elem.find("lastImportDateInAllocation")) g.app.print_only( "Running operation {0} on quota balance event {1}.".format( self.operation, str(self.quota_definition_sid))) operation_date = g.app.get_timestamp() if transform_only is False: sql = """ insert into quota_balance_events_oplog (quota_definition_sid, imported_amount, new_balance, occurrence_timestamp, old_balance, last_import_date_in_allocation, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.quota_definition_sid, self.imported_amount, self.new_balance, self.occurrence_timestamp, self.old_balance, self.last_import_date_in_allocation, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params)
def __init__(self, elem, quota_order_number_sid, import_file, transform_only=False): Master.__init__(self, elem) self.quota_order_number_sid = quota_order_number_sid self.quota_order_number_origin_sid = Master.process_null(elem.find("sid")) self.validity_start_date = Master.process_date(elem.find("validityStartDate")) self.validity_end_date = Master.process_date(elem.find("validityEndDate")) self.geographical_area_id = Master.process_null(elem.find("geographicalArea/geographicalAreaId")) operation_date = g.app.get_timestamp() # Insert the quota order number origin if transform_only is False: sql = """ insert into quota_order_number_origins_oplog (quota_order_number_sid, quota_order_number_origin_sid, geographical_area_id, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.quota_order_number_sid, self.quota_order_number_origin_sid, self.geographical_area_id, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Create new footnote descriptions for elem in elem.findall('.//quotaOrderNumberOriginExclusions'): QuotaOrderNumberOriginExclusion(elem, self.quota_order_number_origin_sid, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.additional_code_type_id = Master.process_null( elem.find("additionalCodeTypeId")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) self.application_code = Master.process_null( elem.find("applicationCode")) self.meursing_table_plan_id = Master.process_null( elem.find("meursingTablePlan/meursingTablePlanId")) operation_date = g.app.get_timestamp() g.app.print_only( "Running operation {0} on additional code type {1}.".format( self.operation, str(self.additional_code_type_id))) # Insert the additional_code type if transform_only is False: sql = """ insert into additional_code_types_oplog (additional_code_type_id, application_code, meursing_table_plan_id, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.additional_code_type_id, self.application_code, self.meursing_table_plan_id, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any additional_code descriptions sql = """ delete from additional_code_type_descriptions_oplog where additional_code_type_id = %s """ params = [self.additional_code_type_id] d = Database() d.run_query(sql, params) # Delete any additional_code measure_types sql = """ delete from additional_code_type_measure_types_oplog where additional_code_type_id = %s """ params = [self.additional_code_type_id] d = Database() d.run_query(sql, params) # Create new additional_code type descriptions for elem2 in elem.findall('.//additionalCodeTypeDescription'): AdditionalCodeTypeDescription(elem2, self.additional_code_type_id, import_file) # Create new additional_code type measure types for elem3 in elem.findall('.//additionalCodeTypeMeasureType'): AdditionalCodeTypeMeasureType(elem3, self.additional_code_type_id, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.hjid = Master.process_null(elem.find("hjid")) self.geographical_area_sid = Master.process_null(elem.find("sid")) self.geographical_area_id = Master.process_null(elem.find("geographicalAreaId")) self.geographical_code = Master.process_null(elem.find("geographicalCode")) self.parent_geographical_area_group_sid = Master.process_null(elem.find("parentGeographicalAreaGroupSid")) self.validity_start_date = Master.process_date(elem.find("validityStartDate")) self.validity_end_date = Master.process_date(elem.find("validityEndDate")) operation_date = g.app.get_timestamp() # Insert the geographical area if transform_only is False: sql = """ insert into geographical_areas_oplog (hjid, geographical_area_sid, geographical_area_id, geographical_code, parent_geographical_area_group_sid, validity_start_date, validity_end_date, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.hjid, self.geographical_area_sid, self.geographical_area_id, self.geographical_code, self.parent_geographical_area_group_sid, self.validity_start_date, self.validity_end_date, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any geographical area descriptions sql = """ delete from geographical_area_descriptions_oplog where geographical_area_sid = %s """ params = [self.geographical_area_sid] d = Database() d.run_query(sql, params) # Delete any geographical area description periods sql = """ delete from geographical_area_description_periods_oplog where geographical_area_sid = %s """ params = [self.geographical_area_sid] d = Database() d.run_query(sql, params) # Delete any geographical area members sql = """ delete from geographical_area_memberships_oplog where geographical_area_group_sid = %s """ params = [self.geographical_area_sid] d = Database() d.run_query(sql, params) # Create new geographical area description periods for elem1 in elem.findall('.//geographicalAreaDescriptionPeriod'): GeographicalAreaDescriptionPeriod(elem1, self.geographical_area_sid, self.geographical_area_id, import_file) # Create new geographical area memberships for elem2 in elem.findall('.//geographicalAreaMembership'): GeographicalAreaMembership(elem2, self.geographical_area_sid, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.measure_sid = Master.process_null(elem.find("sid")) self.measure_type_id = Master.process_null(elem.find("measureType/measureTypeId")) self.geographical_area_id = Master.process_null(elem.find("geographicalArea/geographicalAreaId")) self.goods_nomenclature_item_id = Master.process_null(elem.find("goodsNomenclature/goodsNomenclatureItemId")) self.validity_start_date = Master.process_date(elem.find("validityStartDate")) self.validity_end_date = Master.process_date(elem.find("validityEndDate")) self.measure_generating_regulation_role = Master.process_null(elem.find("measureGeneratingRegulationRole/regulationRoleTypeId")) self.measure_generating_regulation_id = Master.process_null(elem.find("measureGeneratingRegulationId")) self.justification_regulation_id = Master.process_null(elem.find("justificationRegulationId")) self.justification_regulation_role = Master.process_null(elem.find("justificationRegulationRole/regulationRoleTypeId")) self.stopped_flag = Master.process_null(elem.find("stoppedFlag")) self.geographical_area_sid = Master.process_null(elem.find("geographicalArea/sid")) self.goods_nomenclature_sid = Master.process_null(elem.find("goodsNomenclature/sid")) self.ordernumber = Master.process_null(elem.find("ordernumber")) self.additional_code_type_id = Master.process_null(elem.find("additionalCode/additionalCodeType/additionalCodeTypeId")) self.additional_code_id = Master.process_null(elem.find("additionalCode/additionalCodeCode")) self.additional_code_sid = Master.process_null(elem.find("additionalCode/sid")) self.reduction_indicator = Master.process_null(elem.find("reductionIndicator")) self.export_refund_nomenclature_sid = Master.process_null(elem.find("exportRefundNomenclatureSid")) operation_date = g.app.get_timestamp() g.app.print_only("Running operation {0} on measure {1}.".format(self.operation, str(self.measure_sid))) change = Change(self.measure_sid, self.goods_nomenclature_item_id, "Measure") # Insert the goods nomenclature if transform_only is False: sql = """ insert into measures_oplog ( measure_sid, measure_type_id, geographical_area_id, goods_nomenclature_item_id, validity_start_date, validity_end_date, measure_generating_regulation_role, measure_generating_regulation_id, justification_regulation_role, justification_regulation_id, stopped_flag, geographical_area_sid, goods_nomenclature_sid, ordernumber, additional_code_type_id, additional_code_id, additional_code_sid, reduction_indicator, export_refund_nomenclature_sid, operation, operation_date, created_at, filename ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.measure_sid, self.measure_type_id, self.geographical_area_id, self.goods_nomenclature_item_id, self.validity_start_date, self.validity_end_date, self.measure_generating_regulation_role, self.measure_generating_regulation_id, self.justification_regulation_role, self.justification_regulation_id, self.stopped_flag, self.geographical_area_sid, self.goods_nomenclature_sid, self.ordernumber, self.additional_code_type_id, self.additional_code_id, self.additional_code_sid, self.reduction_indicator, self.export_refund_nomenclature_sid, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any measure excluded geographical areas sql = """delete from measure_excluded_geographical_areas_oplog where measure_sid = %s""" params = [self.measure_sid] d = Database() d.run_query(sql, params) # Delete any measure components sql = """delete from measure_components_oplog where measure_sid = %s""" params = [self.measure_sid] d = Database() d.run_query(sql, params) # Delete any measure conditions sql = """delete from measure_conditions_oplog where measure_sid = %s""" params = [self.measure_sid] d = Database() d.run_query(sql, params) # Delete any footnote associations sql = """delete from footnote_association_measures_oplog where measure_sid = %s""" params = [self.measure_sid] d = Database() d.run_query(sql, params) # Create new measureExcludedGeographicalArea for elem1 in elem.findall('.//measureExcludedGeographicalArea'): MeasureExcludedGeographicalArea(elem1, self.measure_sid, import_file) # Create new measure components for elem2 in elem.findall('.//measureComponent'): MeasureComponent(elem2, self.measure_sid, import_file) # Create new measure conditions for elem3 in elem.findall('.//measureCondition'): MeasureCondition(elem3, self.measure_sid, import_file) # Create new footnote associations to measures for elem4 in elem.findall('.//footnoteAssociationMeasure'): FootnoteAssociationMeasure(elem4, self.measure_sid, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.goods_nomenclature_sid = Master.process_null(elem.find("sid")) self.goods_nomenclature_item_id = Master.process_null( elem.find("goodsNomenclatureItemId")) self.producline_suffix = Master.process_null( elem.find("produclineSuffix")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) self.statistical_indicator = Master.process_null( elem.find("statisticalIndicator")) operation_date = g.app.get_timestamp() # Insert the goods nomenclature if transform_only is False: sql = """ insert into goods_nomenclatures_oplog (goods_nomenclature_sid, goods_nomenclature_item_id, producline_suffix, validity_start_date, validity_end_date, statistical_indicator, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.goods_nomenclature_sid, self.goods_nomenclature_item_id, self.producline_suffix, self.validity_start_date, self.validity_end_date, self.statistical_indicator, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any footnote Association GoodsNomenclatures sql = """ delete from footnote_association_goods_nomenclatures_oplog where goods_nomenclature_sid = %s """ params = [self.goods_nomenclature_sid] d = Database() d.run_query(sql, params) # Delete any goodsNomenclatureDescriptionPeriod sql = """ delete from goods_nomenclature_description_periods_oplog where goods_nomenclature_sid = %s """ params = [self.goods_nomenclature_sid] d = Database() d.run_query(sql, params) # Create new quota order number origins for elem1 in elem.findall( './/footnoteAssociationGoodsNomenclature'): FootnoteAssociationGoodsNomenclature( elem1, self.goods_nomenclature_sid, self.goods_nomenclature_item_id, self.producline_suffix, import_file) # Create new quota goods Nomenclature Description Periods for elem2 in elem.findall('.//goodsNomenclatureDescriptionPeriod'): GoodsNomenclatureDescriptionPeriod( elem2, self.goods_nomenclature_sid, self.goods_nomenclature_item_id, self.producline_suffix, import_file) # goodsNomenclatureIndents for elem3 in elem.findall('.//goodsNomenclatureIndents'): GoodsNomenclatureIndent(elem3, self.goods_nomenclature_sid, self.goods_nomenclature_item_id, self.producline_suffix, import_file)
def __init__(self, elem, import_file, transform_only=False): Master.__init__(self, elem) self.quota_definition_sid = Master.process_null(elem.find("sid")) self.quota_order_number_id = Master.process_null( elem.find("quotaOrderNumber/quotaOrderNumberId")) self.validity_start_date = Master.process_date( elem.find("validityStartDate")) self.validity_end_date = Master.process_date( elem.find("validityEndDate")) self.quota_order_number_sid = Master.process_null( elem.find("quotaOrderNumber/sid")) self.volume = Master.process_null(elem.find("volume")) self.initial_volume = Master.process_null(elem.find("initialVolume")) self.measurement_unit_code = Master.process_null( elem.find("measurementUnit/measurementUnitCode")) self.maximum_precision = Master.process_null( elem.find("maximumPrecision")) self.critical_state = Master.process_null(elem.find("criticalState")) self.critical_threshold = Master.process_null( elem.find("criticalThreshold")) self.monetary_unit_code = Master.process_null( elem.find("monetaryUnit/monetaryUnitCode")) self.measurement_unit_qualifier_code = Master.process_null( elem.find("measurementUnitQualifier/measurementUnitQualifierCode")) self.description = Master.process_null(elem.find("description")) operation_date = g.app.get_timestamp() g.app.print_only( "Running operation {0} on quota definition {1}.".format( self.operation, str(self.quota_definition_sid))) # Insert the quota order number if transform_only is False: sql = """ insert into quota_definitions_oplog (quota_definition_sid, quota_order_number_id, validity_start_date, validity_end_date, quota_order_number_sid, volume, initial_volume, measurement_unit_code, maximum_precision, critical_state, critical_threshold, monetary_unit_code, measurement_unit_qualifier_code, description, operation, operation_date, created_at, filename) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ params = [ self.quota_definition_sid, self.quota_order_number_id, self.validity_start_date, self.validity_end_date, self.quota_order_number_sid, self.volume, self.initial_volume, self.measurement_unit_code, self.maximum_precision, self.critical_state, self.critical_threshold, self.monetary_unit_code, self.measurement_unit_qualifier_code, self.description, self.operation, operation_date, operation_date, import_file ] d = Database() d.run_query(sql, params) # Delete any quota associations sql = "delete from quota_associations_oplog where main_quota_definition_sid = %s" params = [self.quota_definition_sid] d = Database() d.run_query(sql, params) # Delete any quota blocking periods sql = "delete from quota_blocking_periods_oplog where quota_definition_sid = %s" params = [self.quota_definition_sid] d = Database() d.run_query(sql, params) # Delete any quota suspension periods sql = "delete from quota_suspension_periods_oplog where quota_definition_sid = %s" params = [self.quota_definition_sid] d = Database() d.run_query(sql, params) # Delete any quota balance events sql = "delete from quota_balance_events_oplog where quota_definition_sid = %s" params = [self.quota_definition_sid] d = Database() d.run_query(sql, params) # Create new quota associations for elem1 in elem.findall('.//quotaAssociation'): QuotaAssociation(elem1, self.quota_definition_sid, import_file) # Create new quota blocking periods for elem2 in elem.findall('.//quotaBlockingPeriod'): QuotaBlockingPeriod(elem2, self.quota_definition_sid, import_file) # Create new quota suspension periods for elem3 in elem.findall('.//quotaSuspensionPeriod'): QuotaSuspensionPeriod(elem3, self.quota_definition_sid, import_file) # Create new quota balance events for elem4 in elem.findall('.//quotaBalanceEvent'): QuotaBalanceEvent(elem4, self.quota_definition_sid, import_file)