Skip to content

Commit 06b8c11

Browse files
committed
Updated EG_DEVELOPER_METADATA to_json feature.
Updated EG_DEVELOPER_METADATA_LOCATION, to be completed. Updated EG_DEVELOPER_METATADA_VISIBILITY added feature to_json. Updated EG_SHEETS_JSON code to reflect the changes in the previous classes. Signed-off-by: jvelilla <[email protected]>
1 parent 24c61d3 commit 06b8c11

File tree

4 files changed

+45
-42
lines changed

4 files changed

+45
-42
lines changed

sheets/src/json/eg_sheets_json.e

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ feature {NONE} -- JSON To Eiffel
412412

413413
eg_developer_metadata (a_json: JSON_VALUE): EG_DEVELOPER_METADATA
414414
-- Create an object `EG_DEVELOPER_METADATA` from a json representation `a_json`.
415+
local
416+
l_vs: EG_DEVELOPER_METADATA_VISIBILITY
415417
do
416418
create Result
417419
if attached integer_value_from_json (a_json, "metadataId") as l_metadata_id then
@@ -427,11 +429,13 @@ feature {NONE} -- JSON To Eiffel
427429
Result.set_location (developer_metadata_location (l_location))
428430
end
429431
if attached string_value_from_json (a_json, "visibility") as l_visibility then
432+
create l_vs
430433
if l_visibility.is_case_insensitive_equal ("DOCUMENT") then
431-
Result.visibility.set_document
434+
l_vs.set_document
432435
elseif l_visibility.is_case_insensitive_equal ("PROJECT") then
433-
Result.visibility.set_project
436+
l_vs.set_project
434437
end
438+
Result.set_visibility (l_vs)
435439
end
436440
end
437441

sheets/src/objects/eg_developer_metadata.e

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,22 @@ note
2424
class
2525
EG_DEVELOPER_METADATA
2626

27-
inherit
28-
ANY
29-
redefine
30-
default_create
31-
end
32-
33-
create
34-
default_create
35-
36-
feature {NONE} -- Initialize
37-
38-
default_create
39-
do
40-
create metadata_key.make_empty
41-
create metadata_value.make_empty
42-
create location
43-
create visibility
44-
end
4527

4628
feature -- Access
4729

4830
metadata_id: INTEGER
4931
-- The spreadsheet-scoped unique ID that identifies the metadata. IDs may be specified when metadata is created, otherwise one will be randomly generated and assigned. Must be positive.
5032

51-
metadata_key: STRING
33+
metadata_key: detachable STRING
5234
-- The metadata key. There may be multiple metadata in a spreadsheet with the same key. Developer metadata must always have a key specified.
5335

54-
metadata_value: STRING
36+
metadata_value: detachable STRING
5537
-- Data associated with the metadata's key.
5638

57-
location: EG_DEVELOPER_METADATA_LOCATION
39+
location: detachable EG_DEVELOPER_METADATA_LOCATION
5840
-- The location where the metadata is associated.
5941

60-
visibility: EG_DEVELOPER_METADATA_VISIBILITY
42+
visibility: detachable EG_DEVELOPER_METADATA_VISIBILITY
6143
-- The metadata visibility. Developer metadata must always have a visibility specified.
6244

6345

@@ -102,9 +84,22 @@ feature -- Element Change
10284
feature -- Eiffel to JSON
10385

10486
to_json: JSON_OBJECT
87+
-- JSON representation of the current object
10588
do
10689
create Result.make_empty
107-
-- TODO
90+
Result.put (create {JSON_NUMBER}.make_integer (metadata_id), "metadataId")
91+
if attached metadata_key as l_metadata_key then
92+
Result.put (create {JSON_STRING}.make_from_string (l_metadata_key), "metadataKey")
93+
end
94+
if attached metadata_value as l_mv then
95+
Result.put (create {JSON_STRING}.make_from_string (l_mv), "metadataValue")
96+
end
97+
if attached location as l_location then
98+
Result.put (l_location.to_json, "location")
99+
end
100+
if attached visibility as l_visibility then
101+
Result.put (l_visibility.to_json, "visibility")
102+
end
108103
end
109104

110105
end

sheets/src/objects/eg_developer_metadata_location.e

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,17 @@ note
2222
class
2323
EG_DEVELOPER_METADATA_LOCATION
2424

25-
inherit
26-
27-
ANY
28-
redefine
29-
default_create
30-
end
25+
feature -- Access
3126

32-
create
33-
default_create
27+
location_type: detachable EG_DEVELOPER_METADATA_LOCATION_TYPE
3428

3529

36-
feature {NONE} -- Initialization
30+
feature -- Eiffel to JSON
3731

38-
default_create
32+
to_json: JSON_OBJECT
3933
do
40-
create location_type
34+
create Result.make_empty
35+
-- TOSO
4136
end
4237

43-
feature -- Access
44-
45-
location_type: EG_DEVELOPER_METADATA_LOCATION_TYPE
46-
47-
4838
end

sheets/src/objects/eg_developer_metadata_visibility.e

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ note
66
DEVELOPER_METADATA_VISIBILITY_UNSPECIFIED Default value.
77
DOCUMENT Document-visible metadata is accessible from any developer project with access to the document.
88
PROJECT Project-visible metadata is only visible to and accessible by the developer project that created the metadata.
9-
9+
1010
]"
1111
date: "$Date$"
1212
revision: "$Revision$"
@@ -76,4 +76,18 @@ feature -- Status Report
7676
a_value = document or else
7777
a_value = project
7878
end
79+
80+
feature -- Eiffel to JSON
81+
82+
to_json: JSON_STRING
83+
-- Json representation of the current object.
84+
do
85+
if is_document then
86+
Result := "DOCUMENT"
87+
elseif is_project then
88+
Result := "PROJECT"
89+
else
90+
Result := "DEVELOPER_METADATA_VISIBILITY_UNSPECIFIED"
91+
end
92+
end
7993
end

0 commit comments

Comments
 (0)