Module: PuppetX::EnterpriseModules::Oracle::JavaSourceHandling

Defined in:
lib/puppet_x/enterprisemodules/oracle/java_source_handling.rb

Overview

The JavaSourceHandling module provides methods to manage and process Java source definitions within an Oracle database. It includes functionality to retrieve, process, and describe changes to Java source definitions, as well as to check for compilation errors.

This module is designed to be used within Puppet manifests to ensure that Java source definitions are correctly managed and maintained in the Oracle database.

Instance Method Summary collapse

Instance Method Details

#change_to_s(currentvalue, _newvalue) ⇒ String

Returns a string representation of the change based on the current value.

Parameters:

  • currentvalue (String)

    The current value of the resource.

  • _newvalue (String)

    The new value to be set.

Returns:

  • (String)

    A description of the change made to the resource.



31
32
33
34
35
36
37
# File 'lib/puppet_x/enterprisemodules/oracle/java_source_handling.rb', line 31

def change_to_s(currentvalue, _newvalue)
  if currentvalue.to_s == 'absent'
    'created java source definition'
  else
    'changed to new java source definition'
  end
end

#compilation_errorsObject



52
53
54
55
# File 'lib/puppet_x/enterprisemodules/oracle/java_source_handling.rb', line 52

def compilation_errors
  results = sql template('ora_config/ora_java_source/java_source_errors.sql.erb', binding), :sid => resource.sid
  results.first['ERRORS'].to_i
end

#current_contentString

Retrieves the current content of the Java source definition from the database.

Returns:

  • (String)

    The current content of the Java source definition.



22
23
24
# File 'lib/puppet_x/enterprisemodules/oracle/java_source_handling.rb', line 22

def current_content
  @current_content ||= process_content(sql(template('ora_config/ora_java_source/java_source_definition.sql.erb', binding), :sid => resource.sid, :parse => false))
end

#process_content(content) ⇒ String

Processes the content by removing unnecessary elements and formatting it for comparison.

Parameters:

  • content (String)

    The content to be processed.

Returns:

  • (String)

    The processed content, formatted for comparison.



43
44
45
46
47
48
49
50
# File 'lib/puppet_x/enterprisemodules/oracle/java_source_handling.rb', line 43

def process_content(content)
  content.gsub(/CREATE(\s|\n)+OR(\s|\n)+REPLACE(\s|\n)+AND(\s|\n)+RESOLVE(\s|\n)+JAVA(\s|\n)+SOURCE(\s|\n)+NAMED.*AS(\s|\n)+/mi, '').
    gsub(/1\* SELECT text as content FROM all_source WHERE name.*/, '').
    gsub(/--.*\n/, '').
    gsub(%r{^/\s*$}, '').
    gsub(/\s|\s|"|'/, '').
    delete("\n").upcase
end