Skip to content

Commit

Permalink
Merge pull request #41 from omu/dev
Browse files Browse the repository at this point in the history
Merge dev into master
  • Loading branch information
huseyin authored Oct 2, 2018
2 parents f71e5c7 + e60dfe9 commit 108e8db
Show file tree
Hide file tree
Showing 32 changed files with 967 additions and 140 deletions.
44 changes: 37 additions & 7 deletions app/controllers/yoksis/resumes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,39 @@ class ResumesController < ApplicationController

include ActionsResource

def certifications
UNDEFINABLE_ACTIONS_IN_ITERATION = %i[
authors
citations
incentive_applications
incentive_activity_declarations
].freeze
private_constant :UNDEFINABLE_ACTIONS_IN_ITERATION

Services::Yoksis::Resumes::ARGS.each_key do |method|
next if method.in?(UNDEFINABLE_ACTIONS_IN_ITERATION)

define_method(method) do
render_as_json @resumes.send(
method, id_number: undefinable_actions_in_iteration_params.require(:id_number)
)
end
end

def authors
render_as_json @resumes.authors(
id_number: authors_params.require(:id_number), author_id: authors_params.require(:author_id)
)
end

def citations
render_as_json @resumes.send(
action_name,
username: @username,
password: @password,
id_number: secure_params.require(:id_number)
id_number: citations_params.require(:id_number), year: citations_params.require(:year)
)
end

alias projects certifications
alias articles certifications
alias incentive_applications citations
alias incentive_activity_declarations citations

private

Expand All @@ -29,8 +51,16 @@ def set_resumes
@resumes = Services::Yoksis::Resumes.new(basic_auth: [@username, @password])
end

def secure_params
def undefinable_actions_in_iteration_params
params.require(:resume).permit(:id_number)
end

def authors_params
params.require(:resume).permit(:id_number, :author_id)
end

def citations_params
params.require(:resume).permit(:id_number, :year)
end
end
end
15 changes: 12 additions & 3 deletions app/serializers/kps/queries/identities_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class IdentitiesSerializer < Serializer
fathers_id_number: personal_informations[:baba_tc_kimlik_no].safe_to_i,
mothers_id_number: personal_informations[:anne_tc_kimlik_no].safe_to_i,
real_person_id_number: personal_informations[:gercek_kisi_kimlik_no].safe_to_i,
country: personal_informations[:ulke].titleize_tr,
country: {
code: personal_informations.dig(:ulke, :kod).safe_to_i,
description: personal_informations.dig(:ulke, :aciklama).titleize_tr
},
status_informations: status_informations,
basic_informations: basic_informations
}
Expand All @@ -60,7 +63,10 @@ class IdentitiesSerializer < Serializer
code: card_informations.dig(:cinsiyet, :kod).safe_to_i,
description: card_informations.dig(:cinsiyet, :aciklama).titleize_tr
},
nationality: card_informations[:uyruk].titleize_tr,
nationality: {
code: card_informations.dig(:uyruk, :kod).safe_to_i,
description: card_informations.dig(:uyruk, :aciklama).titleize_tr
},
marital_status: {
code: card_informations.dig(:medeni_hal, :kod).safe_to_i,
description: card_informations.dig(:medeni_hal, :aciklama).titleize_tr
Expand All @@ -73,7 +79,10 @@ class IdentitiesSerializer < Serializer
number: card_informations[:no].safe_to_i,
registration_number: card_informations[:kayit_no].safe_to_i,
serial_number: card_informations[:seri],
issuing_reason: card_informations[:verilis_neden].titleize_tr,
issuing_reason: {
code: card_informations.dig(:verilis_neden, :kod).safe_to_i,
description: card_informations.dig(:verilis_neden, :aciklama).titleize_tr
},
issuing_date: build_date(*card_informations[:verilme_tarih].values_at(:yil, :ay, :gun))
}

Expand Down
32 changes: 32 additions & 0 deletions app/serializers/yoksis/resumes/academic_duties_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

module Yoksis
module Resumes
class AcademicDutiesSerializer < Serializer
attribute(:duty_id) { object[:gorev_id].safe_to_i }
attribute(:title_id) { object[:kadro_unvan_id].safe_to_i }
attribute(:title_name) { object[:kadro_unvan_adi].titleize_tr }
attribute(:place_id) { object[:yer_id].safe_to_i }
attribute(:place_name) { object[:yer_ad].titleize_tr }
attribute(:country_id) { object[:ulke_id].safe_to_i }
attribute(:country_name) { object[:ulke_ad].titleize_tr }
attribute(:year_of_start) { object[:bastar1].safe_to_i }
attribute(:year_of_end) { object[:bittar1].safe_to_i }
attribute(:scientific_field_name) { object[:bilimalan_adi].titleize_tr }
attribute(:university_id) { object[:univ_id].safe_to_i }
attribute(:university_name) { object[:univ_birim_adi].titleize_tr }
attribute(:faculty) { object[:fakultebilgisi].titleize_tr }
attribute(:department) { object[:bolumbilgisi].titleize_tr }
attribute(:field) { object[:alanbilgisi].titleize_tr }
attribute(:field_of_specialization_id) { object[:uzmanlik_alani].safe_to_i }
attribute(:field_of_specialization_name) { object[:uzmanlik_alani_ad].titleize_tr }
attribute(:unit_id) { object[:birim_id].safe_to_i }
attribute(:academic_status_id) { object[:akademik_durum].safe_to_i }
attribute(:academic_status_name) { object[:akademik_durum_adi].titleize_tr }
attribute(:academic_unit_name) { object[:akademik_birim_adi].titleize_tr }
attribute(:active_or_passive_id) { object[:aktif_pasif].safe_to_i }
attribute(:active_or_passive_name) { object[:aktif_pasif_ad].titleize_tr }
attribute(:date_of_update) { object[:guncelleme_tarihi] && Time.zone.parse(object[:guncelleme_tarihi]) }
end
end
end
15 changes: 15 additions & 0 deletions app/serializers/yoksis/resumes/academic_links_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Yoksis
module Resumes
class AcademicLinksSerializer < Serializer
attribute(:researcher_id) { object[:arastirmaci_id].safe_to_i }
attribute(:staff_first_name) { object[:personel_adi].titleize_tr }
attribute(:staff_last_name) { object[:personel_soyadi].titleize_tr }
attribute(:staff_title) { object[:kadro_unvan_adi].titleize_tr }
attribute(:staff_workplace) { object[:kadro_yeri].titleize_tr }
attribute(:yok_link) { object[:yokakademik_link] }
attribute(:photograph_link) { object[:resim_link] }
end
end
end
25 changes: 25 additions & 0 deletions app/serializers/yoksis/resumes/administrative_duties_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Yoksis
module Resumes
class AdministrativeDutiesSerializer < Serializer
attribute(:registry_id) { object[:idgor_id].safe_to_i }
attribute(:duty_id) { object[:gorev_id].safe_to_i }
attribute(:name) { object[:gorev_adi].titleize_tr }
attribute(:place_id) { object[:yer_id].safe_to_i }
attribute(:place_name) { object[:yer_ad].titleize_tr }
attribute(:country_id) { object[:ulke_id].safe_to_i }
attribute(:country_name) { object[:ulke_ad].titleize_tr }
attribute(:year_of_start) { object[:bas_tar].safe_to_i }
attribute(:year_of_end) { object[:bit_tar].safe_to_i }
attribute(:university_id) { object[:unv_id].safe_to_i }
attribute(:university_name) { object[:unv_birim_adi].titleize_tr }
attribute(:major) { object[:abd].titleize_tr }
attribute(:faculty) { object[:fakultemyoenst].titleize_tr }
attribute(:department) { object[:bolumbilgisi].titleize_tr }
attribute(:active_or_passive_id) { object[:aktif_pasif].safe_to_i }
attribute(:active_or_passive_name) { object[:aktif_pasif_ad].titleize_tr }
attribute(:date_of_update) { object[:guncelleme_tarihi] && Time.zone.parse(object[:guncelleme_tarihi]) }
end
end
end
78 changes: 39 additions & 39 deletions app/serializers/yoksis/resumes/articles_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
module Yoksis
module Resumes
class ArticlesSerializer < Serializer
attribute(:id) { object[:yayin_id].safe_to_i }
attribute(:name) { object[:makale_adi].titleize_tr }
attribute(:type_id) { object[:makale_turu_id].safe_to_i }
attribute(:type_name) { object[:makale_turu_ad].titleize_tr }
attribute(:scope_id) { object[:kapsam_id].safe_to_i }
attribute(:scope_name) { object[:kapsam_ad].titleize_tr }
attribute(:referee_type_id) { object[:hakem_tur].safe_to_i }
attribute(:referee_type_name) { object[:hakem_tur_ad].titleize_tr }
attribute(:index_id) { object[:endeks_id].safe_to_i }
attribute(:index) { object[:endeks].titleize_tr }
attribute(:author_id) { object[:yazar_id].safe_to_i }
attribute(:author_name) { object[:yazar_adi].upcase_tr }
attribute(:authors_number) { object[:yazar_sayisi].safe_to_i }
attribute(:country_id) { object[:ulke].safe_to_i }
attribute(:country_name) { object[:ulke_adi].titleize_tr }
attribute(:city) { object[:sehir].titleize_tr }
attribute(:journal_name) { object[:dergi_adi].titleize_tr }
attribute(:language_id) { object[:yayin_dili].safe_to_i }
attribute(:language_name) { object[:yayin_dili_adi].titleize_tr }
attribute(:month) { object[:ay].safe_to_i }
attribute(:year) { object[:yil].safe_to_i }
attribute(:volume) { object[:cilt].safe_to_i }
attribute(:issue) { object[:sayi].safe_to_i }
attribute(:first_page) { object[:ilk_sayfa].safe_to_i }
attribute(:last_page) { object[:son_sayfa].safe_to_i }
attribute(:doi) { object[:doi].safe_to_i }
attribute(:issn) { object[:issn].safe_to_i }
attribute(:access_type_id) { object[:erisim_turu].safe_to_i }
attribute(:access_type_name) { object[:erisim_turu_ad] }
attribute(:access_link) { object[:erisim_linki] }
attribute(:citation_number) { object[:atif_sayisi].safe_to_i }
attribute(:field) { object[:alan_bilgisi].titleize_tr }
attribute(:keyword) { object[:anahtar_kelime].titleize_tr }
attribute(:special_number_id) { object[:ozel_sayi].safe_to_i }
attribute(:special_number_name) { object[:ozel_sayi_ad].titleize_tr }
attribute(:date_of_update) { Time.zone.parse object[:guncelleme_tarihi] || '' }
attribute(:active_or_passive_id) { object[:aktif_pasif].safe_to_i }
attribute(:active_or_passive_name) { object[:aktif_pasif_ad].titleize_tr }
attribute(:incentive_point) { object[:tesv_puan].safe_to_f }
attribute(:publishing_id) { object[:yayin_id].safe_to_i }
attribute(:publishing_language_id) { object[:yayin_dili].safe_to_i }
attribute(:publishing_language_name) { object[:yayin_dili_adi].titleize_tr }
attribute(:name) { object[:makale_adi].titleize_tr }
attribute(:type_id) { object[:makale_turu_id].safe_to_i }
attribute(:type_name) { object[:makale_turu_ad].titleize_tr }
attribute(:scope_id) { object[:kapsam_id].safe_to_i }
attribute(:scope_name) { object[:kapsam_ad].titleize_tr }
attribute(:referee_type_id) { object[:hakem_tur].safe_to_i }
attribute(:referee_type_name) { object[:hakem_tur_ad].titleize_tr }
attribute(:index_id) { object[:endeks_id].safe_to_i }
attribute(:index) { object[:endeks].titleize_tr }
attribute(:author_id) { object[:yazar_id].safe_to_i }
attribute(:authors) { object[:yazar_adi] && object[:yazar_adi].split(',').map(&:strip).map(&:titleize_tr) }
attribute(:number_of_author) { object[:yazar_sayisi].safe_to_i }
attribute(:country_id) { object[:ulke].safe_to_i }
attribute(:country_name) { object[:ulke_adi].titleize_tr }
attribute(:city) { object[:sehir].titleize_tr }
attribute(:journal_name) { object[:dergi_adi].titleize_tr }
attribute(:month) { object[:ay].safe_to_i }
attribute(:year) { object[:yil].safe_to_i }
attribute(:volume) { object[:cilt].safe_to_i }
attribute(:issue) { object[:sayi].safe_to_i }
attribute(:first_page) { object[:ilk_sayfa].safe_to_i }
attribute(:last_page) { object[:son_sayfa].safe_to_i }
attribute(:doi) { object[:doi].safe_to_i }
attribute(:issn) { object[:issn].safe_to_i }
attribute(:access_type_id) { object[:erisim_turu].safe_to_i }
attribute(:access_type_name) { object[:erisim_turu_ad] }
attribute(:access_link) { object[:erisim_linki] }
attribute(:number_of_citation) { object[:atif_sayisi].safe_to_i }
attribute(:field) { object[:alan_bilgisi].titleize_tr }
attribute(:keywords) { object[:anahtar_kelime].titleize_tr }
attribute(:special_edition_id) { object[:ozel_sayi].safe_to_i }
attribute(:special_edition_name) { object[:ozel_sayi_ad].titleize_tr }
attribute(:date_of_update) { object[:guncelleme_tarihi] && Time.zone.parse(object[:guncelleme_tarihi]) }
attribute(:active_or_passive_id) { object[:aktif_pasif].safe_to_i }
attribute(:active_or_passive_name) { object[:aktif_pasif_ad].titleize_tr }
attribute(:incentive_points) { object[:tesv_puan].safe_to_f }
end
end
end
Loading

0 comments on commit 108e8db

Please sign in to comment.