soury commited on
Commit
b23ee5a
·
1 Parent(s): 16a8ccc

change default reportId & ReportDatetime

Browse files
src/services/json_generator.py CHANGED
@@ -1,6 +1,7 @@
 
1
  import json
2
  import tempfile
3
- from datetime import datetime
4
  from assets.utils.validation import validate_boamps_schema
5
  from src.services.report_builder import ReportBuilder
6
  import os
@@ -99,13 +100,19 @@ def generate_json(
99
  # Use ReportBuilder for cleaner, more maintainable code
100
  builder = ReportBuilder()
101
 
 
 
 
 
 
 
102
  # Build header section
103
  header_data = {
104
  "licensing": licensing,
105
  "formatVersion": formatVersion,
106
  "formatVersionSpecificationUri": formatVersionSpecificationUri,
107
  "reportId": reportId,
108
- "reportDatetime": reportDatetime or datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
109
  "reportStatus": reportStatus,
110
  "publisher_name": publisher_name,
111
  "publisher_division": publisher_division,
 
1
+ import datetime
2
  import json
3
  import tempfile
4
+ import uuid
5
  from assets.utils.validation import validate_boamps_schema
6
  from src.services.report_builder import ReportBuilder
7
  import os
 
100
  # Use ReportBuilder for cleaner, more maintainable code
101
  builder = ReportBuilder()
102
 
103
+ # Create a uuid & a report datetime if not filled by the user
104
+ if not reportId:
105
+ reportId = str(uuid.uuid4())
106
+ if not reportDatetime:
107
+ reportDatetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
108
+
109
  # Build header section
110
  header_data = {
111
  "licensing": licensing,
112
  "formatVersion": formatVersion,
113
  "formatVersionSpecificationUri": formatVersionSpecificationUri,
114
  "reportId": reportId,
115
+ "reportDatetime": reportDatetime,
116
  "reportStatus": reportStatus,
117
  "publisher_name": publisher_name,
118
  "publisher_division": publisher_division,
src/ui/form_components.py CHANGED
@@ -1,6 +1,4 @@
1
- import uuid
2
  import gradio as gr
3
- import datetime
4
  from src.services.util import (
5
  REPORT_STATUS_OPTIONS, CONFIDENTIALITY_LEVELS, DATA_USAGE_OPTIONS, DATA_FORMAT,
6
  DATA_TYPES, DATA_SOURCE,
@@ -167,12 +165,11 @@ def create_header_tab():
167
  formatVersionSpecificationUri = gr.Textbox(
168
  label="Format Version Specification URI", info="(the URI of the present specification of this set of schemas)")
169
  reportId = gr.Textbox(
170
- label="Report ID", info="(the unique identifier of this report, preferably as a uuid4 string)", value=str(uuid.uuid4()))
171
  reportDatetime = gr.Textbox(
172
  label="Report Datetime",
173
  info="Required field<br>(the publishing date of this report in format YYYY-MM-DD HH:MM:SS)",
174
  elem_classes="mandatory_field",
175
- value=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
176
  )
177
  reportStatus = gr.Dropdown(value=None,
178
  label="Report Status",
 
 
1
  import gradio as gr
 
2
  from src.services.util import (
3
  REPORT_STATUS_OPTIONS, CONFIDENTIALITY_LEVELS, DATA_USAGE_OPTIONS, DATA_FORMAT,
4
  DATA_TYPES, DATA_SOURCE,
 
165
  formatVersionSpecificationUri = gr.Textbox(
166
  label="Format Version Specification URI", info="(the URI of the present specification of this set of schemas)")
167
  reportId = gr.Textbox(
168
+ label="Report ID", info="(the unique identifier of this report, preferably as a uuid4 string)")
169
  reportDatetime = gr.Textbox(
170
  label="Report Datetime",
171
  info="Required field<br>(the publishing date of this report in format YYYY-MM-DD HH:MM:SS)",
172
  elem_classes="mandatory_field",
 
173
  )
174
  reportStatus = gr.Dropdown(value=None,
175
  label="Report Status",