Skip to content

Commit

Permalink
merged #143 - Refactor: ontology_submission.rb file to isolate the pr…
Browse files Browse the repository at this point in the history
…ocessing steps
  • Loading branch information
mdorf committed Apr 24, 2024
2 parents 5f9846a + c879069 commit e2a27e4
Show file tree
Hide file tree
Showing 15 changed files with 1,466 additions and 1,200 deletions.
217 changes: 0 additions & 217 deletions Gemfile.lock

This file was deleted.

34 changes: 27 additions & 7 deletions lib/ontologies_linked_data.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "goo"
require 'goo'

# Make sure we're in the load path
lib_dir = File.dirname(__FILE__)+"/../lib"
lib_dir = "#{File.dirname(__FILE__)}/../lib"
$LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)

# Setup Goo (repo connection and namespaces)
require "ontologies_linked_data/config/config"
require 'ontologies_linked_data/config/config'

# Include other dependent code
require "ontologies_linked_data/security/authorization"
Expand All @@ -31,27 +31,47 @@
require "ontologies_linked_data/metrics/metrics"

# Require base model
require "ontologies_linked_data/models/base"
require 'ontologies_linked_data/models/base'

# Require all models



# Require all models and services
project_root = File.dirname(File.absolute_path(__FILE__))
# Require base services
require 'ontologies_linked_data/services/submission_process/submission_process'

# We need to require deterministic - that is why we have the sort.

models = Dir.glob("#{project_root}/ontologies_linked_data/services/**/*.rb").sort
models.each do |m|
require m
end

# We need to require deterministic - that is why we have the sort.
models = Dir.glob("#{project_root}/ontologies_linked_data/models/concerns//**/*.rb").sort
models.each do |m|
require m
end

models = Dir.glob("#{project_root}/ontologies_linked_data/concerns/**/*.rb").sort
models.each do |m|
require m
end
# We need to require deterministic - that is why we have the sort.
models = Dir.glob(project_root + '/ontologies_linked_data/models/**/*.rb').sort
models = Dir.glob("#{project_root}/ontologies_linked_data/models/**/*.rb").sort
models.each do |m|
require m
end



module LinkedData
def rootdir
File.dirname(File.absolute_path(__FILE__))
end

def bindir
File.expand_path(rootdir + '/../bin')
File.expand_path("#{rootdir}/../bin")
end
end
43 changes: 23 additions & 20 deletions lib/ontologies_linked_data/diff/bubastis_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class InputFileNotFoundError < Diff::DiffException
class DiffFileNotGeneratedException < Diff::DiffException
end

class BubastisDiffCommand
class BubastisDiffCommand < DiffTool

# Bubastis version 1.2
# 18th December 2014
Expand All @@ -37,15 +37,33 @@ class BubastisDiffCommand
# Loading one file locally and one from the web and outputting results to plain text:
# java -jar bubastis_1_2.jar -ontology1 "H://disease_ontology_version_1.owl" -ontology2 "http://www.disease.org/diseaseontology_latest.owl" -output "C://my_diff.txt"

def initialize(input_fileOld, input_fileNew, output_repo)
def initialize(old_file_path, new_file_path)
@bubastis_jar_path = LinkedData.bindir + "/bubastis.jar"
@input_fileOld = input_fileOld
@input_fileNew = input_fileNew
@output_repo = output_repo
@input_fileOld = old_file_path
@input_fileNew = new_file_path
@output_repo = File.expand_path(@input_fileNew).gsub(File.basename(@input_fileNew),'')
@file_diff_path = nil
@java_heap_size = LinkedData.settings.java_max_heap_size
end


def file_diff_path
@file_diff_path
end

def diff
setup_environment
call_bubastis_java_cmd
if @file_diff_path.nil?
raise DiffFileNotGeneratedException, "Diff file nil"
elsif not File.exist?(@file_diff_path)
raise DiffFileNotGeneratedException, "Diff file not found in #{@file_diff_path}"
end
return @file_diff_path
end

private

def setup_environment
if @input_fileOld.nil? or (not File.exist?(@input_fileOld))
raise InputFileNotFoundError, "#{@input_fileOld} not found."
Expand Down Expand Up @@ -105,21 +123,6 @@ def call_bubastis_java_cmd
end
return @file_diff_path
end

def file_diff_path
@file_diff_path
end

def diff
setup_environment
call_bubastis_java_cmd
if @file_diff_path.nil?
raise DiffFileNotGeneratedException, "Diff file nil"
elsif not File.exist?(@file_diff_path)
raise DiffFileNotGeneratedException, "Diff file not found in #{@file_diff_path}"
end
return @file_diff_path
end
end
end
end
14 changes: 13 additions & 1 deletion lib/ontologies_linked_data/diff/diff.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
module LinkedData
module Diff
class <<self
class << self
attr_accessor :logger
end

class DiffTool
def initialize(old_file_path, new_file_path)
@old_file_path = old_file_path
@new_file_path = new_file_path
end

# @return String generated path file
def diff
raise NotImplementedError
end
end
class DiffException < Exception
end
class MkdirException < DiffException
Expand Down
Loading

0 comments on commit e2a27e4

Please sign in to comment.