Skip to content

Commit

Permalink
include pid on extended metadata attribute for import via JSON #2044
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Nov 6, 2024
1 parent 1277919 commit 3bc526c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/seek/extended_metadata_type/emt_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def self.create_extended_metadata_type_from_json(data)
sample_attribute_type: sample_attribute_type,
sample_controlled_vocab: sample_controlled_vocab,
linked_extended_metadata_type: linked_extended_metadata_type,
required: attr['required'].present? ? attr['required'] : false
required: attr['required'].present? ? attr['required'] : false,
pid: attr['pid'].present? ? attr['pid'] : nil
)
end
emt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
},
"pos": {
"type": "integer"
},
"pid": {
"type": "string"
}
},
"required": ["title", "type"],
Expand Down Expand Up @@ -69,6 +72,9 @@
},
"pos": {
"type": "integer"
},
"pid": {
"type": "string"
}
},
"required": ["title", "type", "ID"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"type": "Controlled Vocabulary",
"required": true,
"pos": 1,
"pid": "http://edamontology.org/topic_0003",
"ID": "CV_TOPICS_ID"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"description": null,
"type": "Linked Extended Metadata",
"required": false,
"pid": "https://somevocab.org/father",
"ID": "PERSON_EMT_ID"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"title": "last_name",
"label": "last name",
"description": null,
"type": "String"
"type": "String",
"pid": "http://schema.org/family_name"
}
]
}
4 changes: 4 additions & 0 deletions test/unit/extended_metadatas/emt_extractor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class EmtExtractorTest < ActiveSupport::TestCase
assert_equal 'first_name', attr1.title
assert_equal SampleAttributeType.find_by(title: 'String'), attr1.sample_attribute_type
assert_equal true, attr1.required
assert_nil attr1.pid

attr2 = emt.extended_metadata_attributes.second
assert_not_nil attr2
Expand All @@ -27,6 +28,7 @@ class EmtExtractorTest < ActiveSupport::TestCase
assert_nil attr2.description
assert_equal SampleAttributeType.find_by(title: 'String'), attr2.sample_attribute_type
assert_equal false, attr2.required
assert_equal "http://schema.org/family_name", attr2.pid

end

Expand All @@ -50,6 +52,7 @@ class EmtExtractorTest < ActiveSupport::TestCase
assert_nil dad_attr.description
assert_equal SampleAttributeType.find_by(title: 'Linked Extended Metadata'), dad_attr.sample_attribute_type
refute dad_attr.required
assert_equal "https://somevocab.org/father", dad_attr.pid

mom_attr = emt.extended_metadata_attributes.second
assert_not_nil mom_attr
Expand Down Expand Up @@ -85,6 +88,7 @@ class EmtExtractorTest < ActiveSupport::TestCase
assert_equal "Topics, used for annotating. Describes the domain, field of interest, of study, application, work, data, or technology. Initially seeded from the EDAM ontology.", topics_attr.description
assert_equal SampleAttributeType.find_by(title: 'Controlled Vocabulary'), topics_attr.sample_attribute_type
assert topics_attr.required
assert_equal 'http://edamontology.org/topic_0003', topics_attr.pid

assert_equal topic_cv, topics_attr.sample_controlled_vocab
assert_equal 4, topics_attr.sample_controlled_vocab.sample_controlled_vocab_terms.count
Expand Down

0 comments on commit 3bc526c

Please sign in to comment.