Class: EWorld::ServiceWriter

Inherits:
BaseWriter show all
Defined in:
lib/writers/service_writer.rb

Constant Summary collapse

PACKAGE_NAME =
'services'
AUTOWIRED =
'{{--AUTOWIRED--}}'
METHODS =
'{{--METHODS--}}'

Constants inherited from BaseWriter

BaseWriter::CLASS, BaseWriter::CLASS_LOWER, BaseWriter::IMPORTS, BaseWriter::PACKAGE

Class Method Summary collapse

Methods inherited from BaseWriter

get_java_path_for

Class Method Details

.write(api_project, ui_project, controllers) ⇒ Object

Responsible for writing all the spring boot @RestController classes.

Returns:

  • void

Raises:

  • (RuntimeError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/writers/service_writer.rb', line 11

def self.write(api_project, ui_project, controllers)
    raise RuntimeError, "Expected project type to be: #{Blufin::Projects::TYPE_API_SIMPLE}, instead got: #{api_project[Blufin::Projects::TYPE]}" unless api_project[Blufin::Projects::TYPE] == Blufin::Projects::TYPE_API_SIMPLE
    raise RuntimeError, "Expected project type to be: #{Blufin::Projects::TYPE_QUASAR}, instead got: #{ui_project[Blufin::Projects::TYPE]}" unless ui_project[Blufin::Projects::TYPE] == Blufin::Projects::TYPE_QUASAR
    @generated          = []
    @overwritten        = []
    @project_path       = Blufin::Projects::get_project_path(api_project[Blufin::Projects::PROJECT_ID])
    @project_path_api   = Blufin::Projects::get_project_path(api_project[Blufin::Projects::PROJECT_ID], true)
    @project_path_ui    = Blufin::Projects::get_project_path(ui_project[Blufin::Projects::PROJECT_ID], true)
    @transient_data_api = api_project[Blufin::Projects::TRANSIENT_DATA]
    @transient_data_ui  = ui_project[Blufin::Projects::TRANSIENT_DATA]
    @service_path       = "#{EWorld::BaseWriter::get_java_path_for(@project_path, @transient_data_api['ServicePath'])}/#{PACKAGE_NAME}"

    # Loop controllers.
    controllers.each do |clazz, data|
        write_java_service(clazz, data)
        write_axios_service(clazz, data)
    end

    return @generated, @overwritten

end