Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GO-168 Make MessageDraft metadata POSP params optional #530

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/concerns/pdf_visualization_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def form
return unless xml?

xml_document = xml_unsigned_content
# TODO forms without posp_id, posp_versions
posp_id, posp_version = xml_document&.root&.namespace&.href&.match(UPVS_FORM_IDENTIFIER_PATTERN)&.captures

::Upvs::Form.find_by(
Expand Down
18 changes: 13 additions & 5 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,20 @@ def any_objects_with_requested_signature?

# TODO remove UPVS, FS stuff from core domain
def form
return ::Fs::Form.find(metadata['fs_form_id']) if metadata['fs_form_id'].present?
if metadata['fs_form_id'].present?
::Fs::Form.find(metadata['fs_form_id'])
elsif all_metadata['posp_id'].present? && all_metadata['posp_version'].present?
::Upvs::Form.find_by(
identifier: all_metadata['posp_id'],
version: all_metadata['posp_version']
)
else
# TODO forms without posp_id, posp_versions
::Upvs::Form.find_by(
identifier: all_metadata['message_type']
)
Comment on lines +115 to +117
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementacia je funkcna kompletne - HTML vizualizacia, PDF vizualizacie, XSD validacie a vsetko ostatne. ALE s formularom to je iba docasny hotfix, nie stabilne riesenie.
Tieto ORSR formulare nie su v MEF a celkovo su o dost ine ako bezne UPVS formulare. Z beznych UPVS formularov vieme z XML obsahu podania jednoducho vyparsovat posp_id, posp_version a na zaklade toho jednoznacne vieme identifikovat o aky formular sa jedna a dotiahnut spravne XSD, XSLT.
Pri tychto ORSR to tak nie je, takze hotfix je:

  • XSD, XSLT hodime teraz jednorazovo do DB,
  • Upvs::Form a teda jeho XSD, XSLT budeme s draftom matchovat iba na zaklade message_type -> co znamena, ze neberieme vobec do uvahy verziu formulara.

Myslim, ze docasne takto prezijeme a potom doladime, nakolko treba vyriesit:

  • Ako identifikovat z XML obsahu o aky typ formulara sa jedna (s know how by mohol pomoct autogram kod),
  • Odkial dotahovat XSD, XSLT - chceli by sme to idealne vsetko tahat z nasho S3 uloziska.

end

::Upvs::Form.find_by(
identifier: all_metadata['posp_id'],
version: all_metadata['posp_version']
)
end

def update_html_visualization
Expand Down
2 changes: 0 additions & 2 deletions app/models/upvs/message_draft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ def validate_data

def validate_metadata
errors.add(:metadata, "No recipient URI") unless all_metadata&.dig("recipient_uri")
errors.add(:metadata, "No posp ID") unless all_metadata&.dig("posp_id")
errors.add(:metadata, "No posp version") unless all_metadata&.dig("posp_version")
errors.add(:metadata, "No message type") unless all_metadata&.dig("message_type")

errors.add(:metadata, "Reference ID must be UUID") if all_metadata&.dig("reference_id") && !all_metadata&.dig("reference_id")&.match?(Utils::UUID_PATTERN)
Expand Down
8 changes: 7 additions & 1 deletion app/models/upvs/service_with_form_allow_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
#

class Upvs::ServiceWithFormAllowRule < ApplicationRecord
scope :matching_metadata, ->(metadata) { where("schema_url LIKE ?", "%#{metadata['posp_id']}/#{metadata['posp_version']}").or(where("schema_url LIKE ?", "%#{metadata['posp_id']}/*")) }
scope :matching_metadata, -> (metadata) do
if metadata['posp_id'].present? && metadata['posp_version'].present?
where("schema_url LIKE ?", "%#{metadata['posp_id']}/#{metadata['posp_version']}").or(where("schema_url LIKE ?", "%#{metadata['posp_id']}/*"))
else
where("schema_url LIKE ?", "%#{metadata['message_type']}%")
end
end

def self.all_institutions_with_template_support(template)
::Upvs::ServiceWithFormAllowRule.matching_metadata(template.metadata)
Expand Down
Loading
Loading