class ViewModel::SapWrapper

Attributes

schema_type[R]
view_model[R]

Public Class Methods

new(xml_doc, schema_type, report_type = "3", additional_data = {}) click to toggle source
# File lib/view_model/sap_wrapper.rb, line 5
def initialize(xml_doc, schema_type, report_type = "3", additional_data = {})
  @schema_type = schema_type
  @view_model = build_view_model(xml_doc, schema_type, report_type)
  @summary = Presenter::Sap::Summary.new(view_model)
  @report = Presenter::Sap::Report.new(view_model, schema_type, additional_data)
  @recommendation_report = Presenter::Sap::RecommendationReport.new(view_model)
end

Public Instance Methods

get_view_model() click to toggle source
# File lib/view_model/sap_wrapper.rb, line 33
def get_view_model
  view_model
end
to_hash() click to toggle source
# File lib/view_model/sap_wrapper.rb, line 17
def to_hash
  @summary.to_hash
end
to_hash_ni() click to toggle source
# File lib/view_model/sap_wrapper.rb, line 21
def to_hash_ni
  @report.to_hash_ni
end
to_recommendation_report() click to toggle source
# File lib/view_model/sap_wrapper.rb, line 29
def to_recommendation_report
  @recommendation_report.to_hash
end
to_report() click to toggle source
# File lib/view_model/sap_wrapper.rb, line 25
def to_report
  @report.to_hash
end
type() click to toggle source
# File lib/view_model/sap_wrapper.rb, line 13
def type
  view_model.type_of_assessment.to_sym
end

Private Instance Methods

build_view_model(xml_doc, schema_type, report_type) click to toggle source
# File lib/view_model/sap_wrapper.rb, line 39
def build_view_model(xml_doc, schema_type, report_type)
  case schema_type
  when :"SAP-Schema-18.0.0"
    return ViewModel::SapSchema1800::CommonSchema.new xml_doc
  when :"SAP-Schema-17.1"
    return ViewModel::SapSchema171::CommonSchema.new xml_doc
  when :"SAP-Schema-17.0"
    return ViewModel::SapSchema170::CommonSchema.new xml_doc
  when :"SAP-Schema-16.3"
    case report_type
    when "2"
      return ViewModel::SapSchema163::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema163::Sap.new(xml_doc)
    end
  when :"SAP-Schema-16.2"
    case report_type
    when "2"
      return ViewModel::SapSchema162::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema162::Sap.new(xml_doc)
    end
  when :"SAP-Schema-16.1"
    case report_type
    when "2"
      return ViewModel::SapSchema161::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema161::Sap.new(xml_doc)
    end
  when :"SAP-Schema-16.0"
    case report_type
    when "2"
      return ViewModel::SapSchema160::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema160::Sap.new(xml_doc)
    end
  when :"SAP-Schema-15.0"
    case report_type
    when "2"
      return ViewModel::SapSchema150::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema150::Sap.new(xml_doc)
    end
  when :"SAP-Schema-14.2"
    case report_type
    when "2"
      return ViewModel::SapSchema142::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema142::Sap.new(xml_doc)
    end
  when :"SAP-Schema-14.1"
    case report_type
    when "2"
      return ViewModel::SapSchema141::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema141::Sap.new(xml_doc)
    end
  when :"SAP-Schema-14.0"
    case report_type
    when "2"
      return ViewModel::SapSchema140::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema140::Sap.new(xml_doc)
    end
  when :"SAP-Schema-13.0"
    case report_type
    when "2"
      return ViewModel::SapSchema130::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema130::Sap.new(xml_doc)
    end
  when :"SAP-Schema-12.0"
    case report_type
    when "2"
      return ViewModel::SapSchema120::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema120::Sap.new(xml_doc)
    end
  when :"SAP-Schema-11.2"
    case report_type
    when "2"
      return ViewModel::SapSchema112::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema112::Sap.new(xml_doc)
    end
  when :"SAP-Schema-11.0"
    case report_type
    when "2"
      return ViewModel::SapSchema110::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchema110::Sap.new(xml_doc)
    end
  when :"SAP-Schema-10.2"
    return ViewModel::SapSchema102::Rdsap.new(xml_doc) if report_type == "2"
  when :"SAP-Schema-NI-18.0.0"
    return ViewModel::SapSchemaNi1800::CommonSchema.new xml_doc
  when :"SAP-Schema-NI-17.4"
    return ViewModel::SapSchemaNi174::CommonSchema.new xml_doc
  when :"SAP-Schema-NI-17.3"
    return ViewModel::SapSchemaNi173::CommonSchema.new xml_doc
  when :"SAP-Schema-NI-17.2"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi172::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi172::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-17.1"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi171::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi171::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-17.0"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi170::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi170::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-16.1"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi161::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi161::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-16.0"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi160::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi160::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-15.0"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi150::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi150::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-14.2"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi142::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi142::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-14.1"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi141::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi141::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-14.0"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi140::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi140::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-13.0"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi130::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi130::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-12.0"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi120::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi120::Sap.new(xml_doc)
    end
  when :"SAP-Schema-NI-11.2"
    case report_type
    when "2"
      return ViewModel::SapSchemaNi112::Rdsap.new(xml_doc)
    when "3"
      return ViewModel::SapSchemaNi112::Sap.new(xml_doc)
    end
  end

  raise ArgumentError, "Unsupported schema type"
end