Cross Reference: parsing.rb
xref
: /
ontohub
/
app
/
models
/
ontology_version
/
parsing.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
parsing.rb revision 7a522a1916e13f0cdbf191f633a4fc2523444038
module
OntologyVersion
::
Parsing
extend
ActiveSupport
::
Concern
included
do
@
queue
= :
hets
after_create
:
parse_async
, :
if
=> :
raw_file
?
end
def
parse
raise
ArgumentError.new
(
'No raw_file set.'
)
unless
raw_file
?
do_or_set_failed
do
condition
= [
'checksum = ? and id != ?'
,
self.checksum
,
self.id
]
if
OntologyVersion.where
(
condition
)
.
any
?
raise
Exception.new
(
'Another file with same checksum already exists.'
)
end
end
update_state
! :
processing
do_or_set_failed
do
@
path
=
Hets.parse
(
self.raw_file.current
_path
)
self.xml
_file
=
File.open
(@
path
)
save
!
File.delete
(@
path
)
self.ontology.import
_latest_version
end
update_state
! :
done
end
def
parse_async
async
:
parse
end
end