• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / b6e4a7c7-d411-4822-a760-84eba5096a52

01 Dec 2025 03:02PM UTC coverage: 74.875% (-12.7%) from 87.594%
b6e4a7c7-d411-4822-a760-84eba5096a52

Pull #2251

circleci

carolyncole
Updating the department select to utilize LuxInputMultiSelect
The component only allows an item to be selected once (only for non asynch results which departments are).
fiexs #2134
Pull Request #2251: Updating the department select to utilize LuxInputMultiSelect

2390 of 3192 relevant lines covered (74.87%)

215.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/app/models/mediaflux/project_create_service_request.rb
1
# frozen_string_literal: true
2
module Mediaflux
2✔
3
  class ProjectCreateServiceRequest < Request
2✔
4
    attr_reader :token, :service_name, :document
2✔
5

6
    # Constructor
7
    # @param session_token [String] the API token for the authenticated session
8
    # @param token         [String] Optional User token for the person executing the command
9
    # @param project       [Project] A project object
10
    def initialize(session_token:, project:, token: nil)
2✔
11
      super(session_token: session_token)
115✔
12
      @token = token
115✔
13
      @project = project
115✔
14
      @data_manager = @project.metadata_model.data_manager
115✔
15
      @data_sponsor = @project.metadata_model.data_sponsor
115✔
16
      @title = @project.metadata_model.title
115✔
17
      @description = @project.metadata_model.description
115✔
18
      @directory = @project.metadata_model.project_directory
115✔
19
      @project_id = @project.metadata_model.project_id
115✔
20
      @department = departments_string(@project.metadata_model.departments)
115✔
21
      @quota = "#{@project.metadata_model.storage_capacity['size']['approved']} #{@project.metadata_model.storage_capacity['unit']['approved']}"
115✔
22
      @number_of_files = @project.metadata_model.number_of_files
115✔
23
      @hpc = @project.metadata_model.hpc
115✔
24
      @smb = @project.metadata_model.smb_request
115✔
25
      @globus = @project.metadata_model.globus_request
115✔
26
      @project_purpose = @project.metadata_model.project_purpose
115✔
27
    end
28

29
    # Specifies the Mediaflux service to use when creating project
30
    # @return [String]
31
    def self.service
2✔
32
      "tigerdata.project.create"
230✔
33
    end
34

35
    # Returns the entire response returned by the project create service.
36
    # This includes debug information that is useful to troubleshoot issues
37
    # if the request fails.
38
    def debug_output
2✔
39
      response_xml.xpath("response/reply/result/result").to_s
230✔
40
    end
41

42
    # Returns the id of the collection created in Mediaflux
43
    def mediaflux_id
2✔
44
      # Extract the <id>nnnn</id> value from the output and then extract the
45
      # numeric value inside of it.
46
      decoded_string = CGI.unescapeHTML(debug_output)
115✔
47
      xml_doc  = Nokogiri::XML(decoded_string)
115✔
48
      (xml_doc.xpath("result/result/id/text()").to_s).to_i
115✔
49
    end
50

51
    private
2✔
52

53
      # rubocop:disable Metrics/MethodLength
54
      #
55
      # This is what the call would look like from aterm:
56
      # tigerdata.project.create \
57
      #   :data-manager md1908 \
58
      #   :data-sponsor hc8719 \
59
      #   :department "Physics" \
60
      #   :description "Our fake project" \
61
      #   :directory tigerdata/RC/td-testing/md1908/HectorProject2 \
62
      #   :project-id "fake.id" \
63
      #   :quota "10 TB" \
64
      #   :title "Fake Study"
65
      #
66
      def build_http_request_body(name:)
2✔
67
        super do |xml|
230✔
68
          xml.args do
230✔
69
            xml.send("data-manager") do
230✔
70
              xml.text(@data_manager)
230✔
71
            end
72
            xml.send("data-sponsor") do
230✔
73
              xml.text(@data_sponsor)
230✔
74
            end
75
            xml.department @department
230✔
76
            xml.description @description
230✔
77
            xml.directory @directory
230✔
78
            xml.send("project-id") do
230✔
79
              xml.text(@project_id)
230✔
80
            end
81
            xml.quota @quota
230✔
82
            xml.title @title
230✔
83
            xml.send("number-of-files") do
230✔
84
              xml.text(@number_of_files)
230✔
85
            end
86
            xml.hpc @hpc
230✔
87
            xml.smb @smb
230✔
88
            xml.globus @globus
230✔
89
            if @project_purpose.present?
230✔
90
              xml.send("project-purpose") do
230✔
91
                xml.text(@project_purpose)
230✔
92
              end
93
            end
94
          end
95
        end
96
      end
97
    # rubocop:enable Metrics/MethodLength
98

99
    # Returns the names of the departments as a comma separated string
100
    def departments_string(departments)
2✔
101
      names = departments.map { |code| Affiliation.where(code:).first&.name || code }
337✔
102
      names.compact.join(", ")
115✔
103
    end
104
  end
105
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc