diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e0d9dd5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,701 @@ +[*] +charset = utf-8 +end_of_line = crlf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 180 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = true +ij_smart_tabs = false +ij_visual_guides = +ij_wrap_on_typing = false + +[*.dcl] +ij_declarative_keep_indents_on_empty_lines = false + +[*.java] +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = false +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_deconstruction_list_components = true +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = true +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = false +ij_java_align_multiline_parenthesized_expression = false +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = false +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_align_types_in_multi_catch = true +ij_java_annotation_new_line_in_record_component = false +ij_java_annotation_parameter_wrap = off +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = off +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = off +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = off +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 1 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_field_with_annotations = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_blank_lines_between_record_components = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_add_space = false +ij_java_block_comment_at_first_column = true +ij_java_builder_methods = +ij_java_call_parameters_new_line_after_left_paren = false +ij_java_call_parameters_right_paren_on_new_line = false +ij_java_call_parameters_wrap = off +ij_java_case_statement_on_separate_line = true +ij_java_catch_on_new_line = false +ij_java_class_annotation_wrap = split_into_lines +ij_java_class_brace_style = end_of_line +ij_java_class_count_to_use_import_on_demand = 5 +ij_java_class_names_in_javadoc = 1 +ij_java_deconstruction_list_wrap = normal +ij_java_delete_unused_module_imports = false +ij_java_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_not_wrap_after_single_annotation_in_parameter = false +ij_java_do_while_brace_force = never +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_enum_constants_wrap = off +ij_java_enum_field_annotation_wrap = off +ij_java_extends_keyword_wrap = off +ij_java_extends_list_wrap = off +ij_java_field_annotation_wrap = split_into_lines +ij_java_field_name_prefix = +ij_java_field_name_suffix = +ij_java_finally_on_new_line = false +ij_java_for_brace_force = never +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = off +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false +ij_java_generate_use_type_annotation_before_type = true +ij_java_if_brace_force = never +ij_java_imports_layout = *, |, javax.**, java.**, |, $* +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 2 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_builder_methods_indents = false +ij_java_keep_control_statement_in_one_line = true +ij_java_keep_first_column_comment = true +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = true +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = false +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_on_demand_import_from_same_package_first = true +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = false +ij_java_line_comment_add_space_on_reformat = false +ij_java_line_comment_at_first_column = true +ij_java_local_variable_name_prefix = +ij_java_local_variable_name_suffix = +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = off +ij_java_method_parameters_new_line_after_left_paren = false +ij_java_method_parameters_right_paren_on_new_line = false +ij_java_method_parameters_wrap = off +ij_java_modifier_list_wrap = false +ij_java_multi_catch_types_wrap = normal +ij_java_names_count_to_use_import_on_demand = 3 +ij_java_new_line_after_lparen_in_annotation = false +ij_java_new_line_after_lparen_in_deconstruction_pattern = true +ij_java_new_line_after_lparen_in_record_header = false +ij_java_new_line_when_body_is_presented = false +ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.* +ij_java_parameter_annotation_wrap = off +ij_java_parameter_name_prefix = +ij_java_parameter_name_suffix = +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = true +ij_java_prefer_parameters_wrap = false +ij_java_preserve_module_imports = true +ij_java_record_components_wrap = normal +ij_java_repeat_annotations = +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +ij_java_rparen_on_new_line_in_annotation = false +ij_java_rparen_on_new_line_in_deconstruction_pattern = true +ij_java_rparen_on_new_line_in_record_header = false +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = true +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = false +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_deconstruction_list = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_annotation_eq = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_inside_block_braces_when_body_is_present = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = false +ij_java_spaces_within_braces = false +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_deconstruction_list = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_record_header = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_static_field_name_prefix = +ij_java_static_field_name_suffix = +ij_java_subclass_name_prefix = +ij_java_subclass_name_suffix = Impl +ij_java_switch_expressions_wrap = normal +ij_java_ternary_operation_signs_on_next_line = false +ij_java_ternary_operation_wrap = off +ij_java_test_name_prefix = +ij_java_test_name_suffix = Test +ij_java_throws_keyword_wrap = off +ij_java_throws_list_wrap = off +ij_java_use_external_annotations = false +ij_java_use_fq_class_names = false +ij_java_use_relative_indents = false +ij_java_use_single_class_imports = true +ij_java_variable_annotation_wrap = off +ij_java_visibility = public +ij_java_while_brace_force = never +ij_java_while_on_new_line = false +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false +ij_java_wrap_semicolon_after_call_chain = false + +[*.properties] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = false + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.jspx,*.pom,*.rng,*.tagx,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_align_attributes = true +ij_xml_align_text = false +ij_xml_attribute_wrap = normal +ij_xml_block_comment_add_space = false +ij_xml_block_comment_at_first_column = true +ij_xml_keep_blank_lines = 2 +ij_xml_keep_indents_on_empty_lines = false +ij_xml_keep_line_breaks = true +ij_xml_keep_line_breaks_in_text = true +ij_xml_keep_whitespaces = false +ij_xml_keep_whitespaces_around_cdata = preserve +ij_xml_keep_whitespaces_inside_cdata = false +ij_xml_line_comment_at_first_column = true +ij_xml_space_after_tag_name = false +ij_xml_space_around_equals_in_attribute = false +ij_xml_space_inside_empty_tag = false +ij_xml_text_wrap = normal + +[{*.bash,*.sh,*.zsh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false +ij_shell_use_unix_line_separator = true + +[{*.gant,*.groovy,*.gy}] +ij_groovy_align_group_field_declarations = false +ij_groovy_align_multiline_array_initializer_expression = false +ij_groovy_align_multiline_assignment = false +ij_groovy_align_multiline_binary_operation = false +ij_groovy_align_multiline_chained_methods = false +ij_groovy_align_multiline_extends_list = false +ij_groovy_align_multiline_for = true +ij_groovy_align_multiline_list_or_map = true +ij_groovy_align_multiline_method_parentheses = false +ij_groovy_align_multiline_parameters = true +ij_groovy_align_multiline_parameters_in_calls = false +ij_groovy_align_multiline_resources = true +ij_groovy_align_multiline_ternary_operation = false +ij_groovy_align_multiline_throws_list = false +ij_groovy_align_named_args_in_map = true +ij_groovy_align_throws_keyword = false +ij_groovy_array_initializer_new_line_after_left_brace = false +ij_groovy_array_initializer_right_brace_on_new_line = false +ij_groovy_array_initializer_wrap = off +ij_groovy_assert_statement_wrap = off +ij_groovy_assignment_wrap = off +ij_groovy_binary_operation_wrap = off +ij_groovy_blank_lines_after_class_header = 0 +ij_groovy_blank_lines_after_imports = 1 +ij_groovy_blank_lines_after_package = 1 +ij_groovy_blank_lines_around_class = 1 +ij_groovy_blank_lines_around_field = 0 +ij_groovy_blank_lines_around_field_in_interface = 0 +ij_groovy_blank_lines_around_method = 1 +ij_groovy_blank_lines_around_method_in_interface = 1 +ij_groovy_blank_lines_before_imports = 1 +ij_groovy_blank_lines_before_method_body = 0 +ij_groovy_blank_lines_before_package = 0 +ij_groovy_block_brace_style = end_of_line +ij_groovy_block_comment_add_space = false +ij_groovy_block_comment_at_first_column = true +ij_groovy_call_parameters_new_line_after_left_paren = false +ij_groovy_call_parameters_right_paren_on_new_line = false +ij_groovy_call_parameters_wrap = off +ij_groovy_catch_on_new_line = false +ij_groovy_class_annotation_wrap = split_into_lines +ij_groovy_class_brace_style = end_of_line +ij_groovy_class_count_to_use_import_on_demand = 5 +ij_groovy_do_while_brace_force = never +ij_groovy_else_on_new_line = false +ij_groovy_enable_groovydoc_formatting = true +ij_groovy_enum_constants_wrap = off +ij_groovy_extends_keyword_wrap = off +ij_groovy_extends_list_wrap = off +ij_groovy_field_annotation_wrap = split_into_lines +ij_groovy_finally_on_new_line = false +ij_groovy_for_brace_force = never +ij_groovy_for_statement_new_line_after_left_paren = false +ij_groovy_for_statement_right_paren_on_new_line = false +ij_groovy_for_statement_wrap = off +ij_groovy_ginq_general_clause_wrap_policy = 2 +ij_groovy_ginq_having_wrap_policy = 1 +ij_groovy_ginq_indent_having_clause = true +ij_groovy_ginq_indent_on_clause = true +ij_groovy_ginq_on_wrap_policy = 1 +ij_groovy_ginq_space_after_keyword = true +ij_groovy_if_brace_force = never +ij_groovy_import_annotation_wrap = 2 +ij_groovy_imports_layout = *, |, javax.**, java.**, |, $* +ij_groovy_indent_case_from_switch = true +ij_groovy_indent_label_blocks = true +ij_groovy_insert_inner_class_imports = false +ij_groovy_keep_blank_lines_before_right_brace = 2 +ij_groovy_keep_blank_lines_in_code = 2 +ij_groovy_keep_blank_lines_in_declarations = 2 +ij_groovy_keep_control_statement_in_one_line = true +ij_groovy_keep_first_column_comment = true +ij_groovy_keep_indents_on_empty_lines = false +ij_groovy_keep_line_breaks = true +ij_groovy_keep_multiple_expressions_in_one_line = false +ij_groovy_keep_simple_blocks_in_one_line = false +ij_groovy_keep_simple_classes_in_one_line = true +ij_groovy_keep_simple_lambdas_in_one_line = true +ij_groovy_keep_simple_methods_in_one_line = true +ij_groovy_label_indent_absolute = false +ij_groovy_label_indent_size = 0 +ij_groovy_lambda_brace_style = end_of_line +ij_groovy_layout_static_imports_separately = true +ij_groovy_line_comment_add_space = false +ij_groovy_line_comment_add_space_on_reformat = false +ij_groovy_line_comment_at_first_column = true +ij_groovy_method_annotation_wrap = split_into_lines +ij_groovy_method_brace_style = end_of_line +ij_groovy_method_call_chain_wrap = off +ij_groovy_method_parameters_new_line_after_left_paren = false +ij_groovy_method_parameters_right_paren_on_new_line = false +ij_groovy_method_parameters_wrap = off +ij_groovy_modifier_list_wrap = false +ij_groovy_names_count_to_use_import_on_demand = 3 +ij_groovy_packages_to_use_import_on_demand = java.awt.*, javax.swing.* +ij_groovy_parameter_annotation_wrap = off +ij_groovy_parentheses_expression_new_line_after_left_paren = false +ij_groovy_parentheses_expression_right_paren_on_new_line = false +ij_groovy_prefer_parameters_wrap = false +ij_groovy_resource_list_new_line_after_left_paren = false +ij_groovy_resource_list_right_paren_on_new_line = false +ij_groovy_resource_list_wrap = off +ij_groovy_space_after_assert_separator = true +ij_groovy_space_after_colon = true +ij_groovy_space_after_comma = true +ij_groovy_space_after_comma_in_type_arguments = true +ij_groovy_space_after_for_semicolon = true +ij_groovy_space_after_quest = true +ij_groovy_space_after_type_cast = true +ij_groovy_space_before_annotation_parameter_list = false +ij_groovy_space_before_array_initializer_left_brace = false +ij_groovy_space_before_assert_separator = false +ij_groovy_space_before_catch_keyword = true +ij_groovy_space_before_catch_left_brace = true +ij_groovy_space_before_catch_parentheses = true +ij_groovy_space_before_class_left_brace = true +ij_groovy_space_before_closure_left_brace = true +ij_groovy_space_before_colon = true +ij_groovy_space_before_comma = false +ij_groovy_space_before_do_left_brace = true +ij_groovy_space_before_else_keyword = true +ij_groovy_space_before_else_left_brace = true +ij_groovy_space_before_finally_keyword = true +ij_groovy_space_before_finally_left_brace = true +ij_groovy_space_before_for_left_brace = true +ij_groovy_space_before_for_parentheses = true +ij_groovy_space_before_for_semicolon = false +ij_groovy_space_before_if_left_brace = true +ij_groovy_space_before_if_parentheses = true +ij_groovy_space_before_method_call_parentheses = false +ij_groovy_space_before_method_left_brace = true +ij_groovy_space_before_method_parentheses = false +ij_groovy_space_before_quest = true +ij_groovy_space_before_record_parentheses = false +ij_groovy_space_before_switch_left_brace = true +ij_groovy_space_before_switch_parentheses = true +ij_groovy_space_before_synchronized_left_brace = true +ij_groovy_space_before_synchronized_parentheses = true +ij_groovy_space_before_try_left_brace = true +ij_groovy_space_before_try_parentheses = true +ij_groovy_space_before_while_keyword = true +ij_groovy_space_before_while_left_brace = true +ij_groovy_space_before_while_parentheses = true +ij_groovy_space_in_named_argument = true +ij_groovy_space_in_named_argument_before_colon = false +ij_groovy_space_within_empty_array_initializer_braces = false +ij_groovy_space_within_empty_method_call_parentheses = false +ij_groovy_spaces_around_additive_operators = true +ij_groovy_spaces_around_assignment_operators = true +ij_groovy_spaces_around_bitwise_operators = true +ij_groovy_spaces_around_equality_operators = true +ij_groovy_spaces_around_lambda_arrow = true +ij_groovy_spaces_around_logical_operators = true +ij_groovy_spaces_around_multiplicative_operators = true +ij_groovy_spaces_around_regex_operators = true +ij_groovy_spaces_around_relational_operators = true +ij_groovy_spaces_around_shift_operators = true +ij_groovy_spaces_within_annotation_parentheses = false +ij_groovy_spaces_within_array_initializer_braces = false +ij_groovy_spaces_within_braces = true +ij_groovy_spaces_within_brackets = false +ij_groovy_spaces_within_cast_parentheses = false +ij_groovy_spaces_within_catch_parentheses = false +ij_groovy_spaces_within_for_parentheses = false +ij_groovy_spaces_within_gstring_injection_braces = false +ij_groovy_spaces_within_if_parentheses = false +ij_groovy_spaces_within_list_or_map = false +ij_groovy_spaces_within_method_call_parentheses = false +ij_groovy_spaces_within_method_parentheses = false +ij_groovy_spaces_within_parentheses = false +ij_groovy_spaces_within_switch_parentheses = false +ij_groovy_spaces_within_synchronized_parentheses = false +ij_groovy_spaces_within_try_parentheses = false +ij_groovy_spaces_within_tuple_expression = false +ij_groovy_spaces_within_while_parentheses = false +ij_groovy_special_else_if_treatment = true +ij_groovy_ternary_operation_wrap = off +ij_groovy_throws_keyword_wrap = off +ij_groovy_throws_list_wrap = off +ij_groovy_use_flying_geese_braces = false +ij_groovy_use_fq_class_names = false +ij_groovy_use_fq_class_names_in_javadoc = true +ij_groovy_use_relative_indents = false +ij_groovy_use_single_class_imports = true +ij_groovy_variable_annotation_wrap = off +ij_groovy_while_brace_force = never +ij_groovy_while_on_new_line = false +ij_groovy_wrap_chain_calls_after_dot = false +ij_groovy_wrap_long_lines = false + +[{*.har,*.json,*.jsonc}] +indent_size = 2 +ij_json_array_wrapping = split_into_lines +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_keep_trailing_comma = false +ij_json_object_wrapping = split_into_lines +ij_json_property_alignment = do_not_align +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = false +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false + +[{*.htm,*.html,*.sht,*.shtm,*.shtml}] +ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3 +ij_html_align_attributes = true +ij_html_align_text = false +ij_html_attribute_wrap = normal +ij_html_block_comment_add_space = false +ij_html_block_comment_at_first_column = true +ij_html_do_not_align_children_of_min_lines = 0 +ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p +ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot +ij_html_enforce_quotes = false +ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var +ij_html_keep_blank_lines = 2 +ij_html_keep_indents_on_empty_lines = false +ij_html_keep_line_breaks = true +ij_html_keep_line_breaks_in_text = true +ij_html_keep_whitespaces = false +ij_html_keep_whitespaces_inside = span, pre, textarea +ij_html_line_comment_at_first_column = true +ij_html_new_line_after_last_attribute = never +ij_html_new_line_before_first_attribute = never +ij_html_quote_style = double +ij_html_remove_new_line_before_tags = br +ij_html_space_after_tag_name = false +ij_html_space_around_equality_in_attribute = false +ij_html_space_inside_empty_tag = false +ij_html_text_wrap = normal + +[{*.kt,*.kts}] +ij_kotlin_align_in_columns_case_branch = false +ij_kotlin_align_multiline_binary_operation = false +ij_kotlin_align_multiline_extends_list = false +ij_kotlin_align_multiline_method_parentheses = false +ij_kotlin_align_multiline_parameters = true +ij_kotlin_align_multiline_parameters_in_calls = false +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_collection_literal_expression = false +ij_kotlin_allow_trailing_comma_context_receiver_list = true +ij_kotlin_allow_trailing_comma_destructuring_declaration = true +ij_kotlin_allow_trailing_comma_function_literal = true +ij_kotlin_allow_trailing_comma_indices = false +ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_allow_trailing_comma_type_argument_list = false +ij_kotlin_allow_trailing_comma_type_parameter_list = true +ij_kotlin_allow_trailing_comma_value_argument_list = false +ij_kotlin_allow_trailing_comma_value_parameter_list = true +ij_kotlin_allow_trailing_comma_when_entry = true +ij_kotlin_assignment_wrap = normal +ij_kotlin_blank_lines_after_class_header = 0 +ij_kotlin_blank_lines_around_block_when_branches = 0 +ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1 +ij_kotlin_block_comment_add_space = false +ij_kotlin_block_comment_at_first_column = true +ij_kotlin_call_parameters_new_line_after_left_paren = true +ij_kotlin_call_parameters_right_paren_on_new_line = true +ij_kotlin_call_parameters_wrap = on_every_item +ij_kotlin_catch_on_new_line = false +ij_kotlin_class_annotation_wrap = split_into_lines +ij_kotlin_continuation_indent_for_chained_calls = false +ij_kotlin_continuation_indent_for_expression_bodies = false +ij_kotlin_continuation_indent_in_argument_lists = false +ij_kotlin_continuation_indent_in_elvis = false +ij_kotlin_continuation_indent_in_if_conditions = false +ij_kotlin_continuation_indent_in_parameter_lists = false +ij_kotlin_continuation_indent_in_supertype_lists = false +ij_kotlin_else_on_new_line = false +ij_kotlin_enum_constants_wrap = off +ij_kotlin_extends_list_wrap = normal +ij_kotlin_field_annotation_wrap = split_into_lines +ij_kotlin_finally_on_new_line = false +ij_kotlin_if_rparen_on_new_line = true +ij_kotlin_import_nested_classes = false +ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^ +ij_kotlin_indent_before_arrow_on_new_line = true +ij_kotlin_insert_whitespaces_in_simple_one_line_method = true +ij_kotlin_keep_blank_lines_before_right_brace = 2 +ij_kotlin_keep_blank_lines_in_code = 2 +ij_kotlin_keep_blank_lines_in_declarations = 2 +ij_kotlin_keep_first_column_comment = true +ij_kotlin_keep_indents_on_empty_lines = false +ij_kotlin_keep_line_breaks = true +ij_kotlin_lbrace_on_next_line = false +ij_kotlin_line_break_after_multiline_when_entry = true +ij_kotlin_line_comment_add_space = false +ij_kotlin_line_comment_add_space_on_reformat = false +ij_kotlin_line_comment_at_first_column = true +ij_kotlin_method_annotation_wrap = split_into_lines +ij_kotlin_method_call_chain_wrap = normal +ij_kotlin_method_parameters_new_line_after_left_paren = true +ij_kotlin_method_parameters_right_paren_on_new_line = true +ij_kotlin_method_parameters_wrap = on_every_item +ij_kotlin_name_count_to_use_star_import = 5 +ij_kotlin_name_count_to_use_star_import_for_members = 3 +ij_kotlin_packages_to_use_import_on_demand = java.util.*, kotlinx.android.synthetic.**, io.ktor.** +ij_kotlin_parameter_annotation_wrap = off +ij_kotlin_space_after_comma = true +ij_kotlin_space_after_extend_colon = true +ij_kotlin_space_after_type_colon = true +ij_kotlin_space_before_catch_parentheses = true +ij_kotlin_space_before_comma = false +ij_kotlin_space_before_extend_colon = true +ij_kotlin_space_before_for_parentheses = true +ij_kotlin_space_before_if_parentheses = true +ij_kotlin_space_before_lambda_arrow = true +ij_kotlin_space_before_type_colon = false +ij_kotlin_space_before_when_parentheses = true +ij_kotlin_space_before_while_parentheses = true +ij_kotlin_spaces_around_additive_operators = true +ij_kotlin_spaces_around_assignment_operators = true +ij_kotlin_spaces_around_elvis = true +ij_kotlin_spaces_around_equality_operators = true +ij_kotlin_spaces_around_function_type_arrow = true +ij_kotlin_spaces_around_logical_operators = true +ij_kotlin_spaces_around_multiplicative_operators = true +ij_kotlin_spaces_around_range = false +ij_kotlin_spaces_around_relational_operators = true +ij_kotlin_spaces_around_unary_operator = false +ij_kotlin_spaces_around_when_arrow = true +ij_kotlin_variable_annotation_wrap = off +ij_kotlin_while_on_new_line = false +ij_kotlin_wrap_elvis_expressions = 1 +ij_kotlin_wrap_expression_body_functions = 1 +ij_kotlin_wrap_first_method_in_call_chain = false + +[{*.markdown,*.md}] +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_format_tables = true +ij_markdown_insert_quote_arrows_on_wrap = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_keep_line_breaks_inside_text_blocks = true +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 +ij_markdown_wrap_text_if_long = true +ij_markdown_wrap_text_inside_blockquotes = true + +[{*.toml,Cargo.lock,Cargo.toml.orig,Gopkg.lock,Pipfile,poetry.lock,uv.lock}] +ij_toml_keep_indents_on_empty_lines = false + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_line_comment_add_space = false +ij_yaml_line_comment_add_space_on_reformat = false +ij_yaml_line_comment_at_first_column = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true diff --git a/README.md b/README.md index 260b2f7..612b7ff 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,33 @@ To compile the CLI type `mvn package` To run the CLI and get some help message, type `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar` -To execute the CLI on some test FHIR file, type `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar html src/test/resources/example.json` or `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar embed src/test/resources/example.json` +To execute the CLI on some test FHIR file, type `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar html src/test/resources/example.json` or +`java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar embed src/test/resources/example.json` -To execute the CLI on some test FHIR file, type `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar html src/test/resources/example.json` or `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar embed src/test/resources/example.json` +To execute the CLI on some test FHIR file, type `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar html src/test/resources/example.json` or +`java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar embed src/test/resources/example.json` -To directly open the generated html preview in a browser, use: ` java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar -d html src/test/resources/example.json` +To directly open the generated html preview in a browser, use: +` java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar -d html src/test/resources/example.json` -To extract the narratives from the CLI on some test FHIR file, type `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar html src/test/resources/example.json` or `java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar extract src/test/resources/example.json` +To extract the narratives from the CLI on some test FHIR file, type +`java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar html src/test/resources/example.json` or +`java -jar target/fhir-visualization-tool-1.0-SNAPSHOT-jar-with-dependencies.jar extract src/test/resources/example.json` + +# Formating Code + +## Configuring Save action + +![saveAction.png](dev/saveActions.png) + +Install plugin : https://plugins.jetbrains.com/plugin/22113-save-actions-x + +Congifuration plugin ![configurationPlugin.png](dev/configurationSaveActions.png) + +## Code Formatting + +Configuration : + +- Setting +- Editor > Code Style > Java +- select Project for the scheme ![selectScheme.png](dev/codeStyleConfiguration.png) \ No newline at end of file diff --git a/dev/codeStyleConfiguration.png b/dev/codeStyleConfiguration.png new file mode 100644 index 0000000..7e4fcea Binary files /dev/null and b/dev/codeStyleConfiguration.png differ diff --git a/dev/configurationSaveActions.png b/dev/configurationSaveActions.png new file mode 100644 index 0000000..23b0f0b Binary files /dev/null and b/dev/configurationSaveActions.png differ diff --git a/dev/saveActions.png b/dev/saveActions.png new file mode 100644 index 0000000..93c7f75 Binary files /dev/null and b/dev/saveActions.png differ diff --git a/pom.xml b/pom.xml index f6720e2..37609e3 100644 --- a/pom.xml +++ b/pom.xml @@ -1,174 +1,170 @@ - - 4.0.0 - be.fgov.ehealth - fhir-visualization-tool - jar - 1.13 - - - github - - - - internal.repo - Temporary Staging Repository - file://${project.build.directory}/mvn-repo - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.6.0 - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - internal.repo::default::file://${project.build.directory}/mvn-repo - - - 11 - 11 - - - info.picocli - picocli-codegen - 4.6.2 - - - - -Aproject=${project.groupId}/${project.artifactId} - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - - - be.fgov.ehealth.fhir.narrative.App - - - - jar-with-dependencies - - - - - - - com.github.github - site-maven-plugin - 0.12 - - Maven artifacts for ${project.version} - true - ${project.build.directory}/mvn-repo - refs/heads/mvn-rep - **/* - laboResultVisualization - ehealthplatformstandards - - - - - - site - - deploy - - - - - - trial - http://maven.apache.org - - - junit - junit - 4.13.2 - test - - - - org.fhir - ucum - 1.0.9 - - - - ca.uhn.hapi.fhir - hapi-fhir-base - 7.6.1 - - - - ca.uhn.hapi.fhir - hapi-fhir-structures-r4 - 7.6.1 - - - - ca.uhn.hapi.fhir - hapi-fhir-validation - 7.6.1 - - - - org.apache.commons - commons-collections4 - 4.4 - - - - org.thymeleaf - thymeleaf - 3.1.1.RELEASE - - - - com.github.ben-manes.caffeine - caffeine - 3.1.8 - - - - ca.uhn.hapi.fhir - hapi-fhir-caching-caffeine - 7.6.1 - - - - info.picocli - picocli - 4.7.3 - - - - com.squareup.okhttp3 - okhttp - 4.12.0 - - - - com.fasterxml.jackson.core - jackson-core - 2.17.1 - - - - + + 4.0.0 + be.fgov.ehealth + fhir-visualization-tool + jar + 1.13 + + + github + + + + internal.repo + Temporary Staging Repository + file://${project.build.directory}/mvn-repo + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.0 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + info.picocli + picocli-codegen + 4.6.2 + + + + -Aproject=${project.groupId}/${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + package + + single + + + + + be.fgov.ehealth.fhir.narrative.App + + + + jar-with-dependencies + + + + + + + com.github.github + site-maven-plugin + 0.12 + + Maven artifacts for ${project.version} + true + ${project.build.directory}/mvn-repo + refs/heads/mvn-rep + + **/* + + laboResultVisualization + ehealthplatformstandards + + + + + + site + + deploy + + + + + + trial + http://maven.apache.org + + + junit + junit + 4.13.2 + test + + + + org.fhir + ucum + 1.0.9 + + + + ca.uhn.hapi.fhir + hapi-fhir-base + 7.6.1 + + + + ca.uhn.hapi.fhir + hapi-fhir-structures-r4 + 7.6.1 + + + + ca.uhn.hapi.fhir + hapi-fhir-validation + 7.6.1 + + + + org.apache.commons + commons-collections4 + 4.4 + + + + org.thymeleaf + thymeleaf + 3.1.1.RELEASE + + + + com.github.ben-manes.caffeine + caffeine + 3.1.8 + + + + ca.uhn.hapi.fhir + hapi-fhir-caching-caffeine + 7.6.1 + + + + info.picocli + picocli + 4.7.3 + + + + com.squareup.okhttp3 + okhttp + 4.12.0 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.1 + + diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/App.java b/src/main/java/be/fgov/ehealth/fhir/narrative/App.java index b85a4b0..864b47f 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/App.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/App.java @@ -5,14 +5,14 @@ import java.io.PrintStream; -public class App -{ - public static void main(String[] args ) { - PrintStream out = System.out; +public class App { + + public static void main(final String[] args) { + final PrintStream out = System.out; System.exit(commandLine(args, out)); } - public static int commandLine(String[] args, PrintStream out) { + public static int commandLine(final String[] args, final PrintStream out) { return new CommandLine(new Visualization(out)).execute(args); } } diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeEmbed.java b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeEmbed.java index dbbaf5c..77d1e8d 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeEmbed.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeEmbed.java @@ -7,18 +7,19 @@ import org.hl7.fhir.r4.model.Resource; public class HtmlNarrativeEmbed implements ResourceProcessor { + private final Visualization visualization; private final FhirContext ctx; - private INarrativeGenerator generator; + private final INarrativeGenerator generator; - public HtmlNarrativeEmbed(Visualization visualization, FhirContext ctx) { + public HtmlNarrativeEmbed(final Visualization visualization, final FhirContext ctx) { this.generator = new CustomThymeleafNarrativeGenerator("classpath:/narratives/diagnosticreport/narrative.properties"); this.visualization = visualization; this.ctx = ctx; } @Override - public Integer process(Resource resource) { + public Integer process(final Resource resource) { final IParser parser = ctx.newJsonParser().setPrettyPrint(true); ctx.setNarrativeGenerator(this.generator); final String output = parser diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeExtract.java b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeExtract.java index 1a0117c..5acf5a5 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeExtract.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlNarrativeExtract.java @@ -4,14 +4,15 @@ import org.hl7.fhir.r4.model.Resource; public class HtmlNarrativeExtract implements ResourceProcessor { + private final Visualization visualization; - public HtmlNarrativeExtract(Visualization visualization) { + public HtmlNarrativeExtract(final Visualization visualization) { this.visualization = visualization; } @Override - public Integer process(Resource resource) { + public Integer process(final Resource resource) { FhirNarrativeUtils.collectNarratives(resource).forEach(x -> { visualization.getOutput().println(x.getLeft()); visualization.getOutput().println(x.getRight()); diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlPreview.java b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlPreview.java index 8d96b2b..e14bb47 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlPreview.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/HtmlPreview.java @@ -5,32 +5,29 @@ import org.apache.commons.io.IOUtils; import org.hl7.fhir.r4.model.Resource; -import java.awt.Desktop; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; +import java.awt.*; +import java.io.*; import java.nio.charset.StandardCharsets; public class HtmlPreview implements ResourceProcessor { + private final Visualization visualization; private final FhirContext ctx; private final ResourceHtmlGenerator htmlGenerator = new ResourceHtmlGenerator(); - public HtmlPreview(Visualization visualization, FhirContext ctx) { + public HtmlPreview(final Visualization visualization, final FhirContext ctx) { this.visualization = visualization; this.ctx = ctx; } - public Integer process(Resource resource) { - byte[] html; + @Override + public Integer process(final Resource resource) { + final byte[] html; try { html = htmlGenerator.generateHtmlRepresentation(ctx, resource, visualization.css != null ? new String(IOUtils.toByteArray(new FileInputStream(visualization.css)), StandardCharsets.UTF_8) : null); - } catch (IOException e) { + } catch (final IOException e) { throw new IllegalArgumentException("Invalid css"); } @@ -38,12 +35,12 @@ public Integer process(Resource resource) { if (visualization.display) { try { - File tmpFile = File.createTempFile("be.fgov.ehealth.fhir.report", ".html"); - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile))) { + final File tmpFile = File.createTempFile("be.fgov.ehealth.fhir.report", ".html"); + try (final OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile))) { os.write(html); } Desktop.getDesktop().browse(tmpFile.toURI()); - } catch (IOException e) { + } catch (final IOException e) { //Ignore } } diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/ResourceProcessor.java b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/ResourceProcessor.java index ccca37d..135236c 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/ResourceProcessor.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/ResourceProcessor.java @@ -3,5 +3,6 @@ import org.hl7.fhir.r4.model.Resource; public interface ResourceProcessor { + Integer process(Resource resource) throws Exception; } diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/Visualization.java b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/Visualization.java index 2e7fb4e..649cd9d 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/Visualization.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/cmd/Visualization.java @@ -22,31 +22,30 @@ @Command(name = "fhirpreview", mixinStandardHelpOptions = true) public class Visualization implements Callable { - @Option(names = { "-s", "--style" }, description = "Style") - protected File css; - @Option(names = { "-d", "--display" }, description = "Display generated document in visualizer") + private final PrintStream output; + @Option(names = {"-s", "--style"}, description = "Style") + protected File css; + @Option(names = {"-d", "--display"}, description = "Display generated document in visualizer") protected Boolean display = false; - //TODO rendre mandatory l'IG - @Option(names = { "-v", "--validate" }, arity = "1..1", + @Option(names = {"-v", "--validate"}, arity = "1..1", description = { "Validate the resource.", "If absent, validation is not performed.", - "Optionally specify a list of URLs, separated by a comma, to implementation guides to be used for validation. (fallback: ${FALLBACK-VALUE})." }, + "Optionally specify a list of URLs, separated by a comma, to implementation guides to be used for validation. (fallback: ${FALLBACK-VALUE})."}, split = ",") protected String[] implementationGuideUrls; - - @Parameters(description = "Action to perform on file. May be one of ${COMPLETION-CANDIDATES}", index = "0") private Action action; - @Parameters(index = "1") private File file; - - @Parameters(index = "2") private String profile; - - @Spec private CommandSpec spec; - - private final PrintStream output; - - public Visualization(PrintStream output) { + @Parameters(description = "Action to perform on file. May be one of ${COMPLETION-CANDIDATES}", index = "0") + private Action action; + @Parameters(index = "1") + private File file; + @Parameters(index = "2") + private String profile; + @Spec + private CommandSpec spec; + + public Visualization(final PrintStream output) { this.output = output; } @@ -63,7 +62,7 @@ public Integer call() throws Exception { if (display) { final String html = validated.getRight(); final File tmpFile = File.createTempFile("be.fgov.ehealth.fhir.validation", ".html"); - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile))) { + try (final OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile))) { os.write(html.getBytes()); } Desktop.getDesktop().browse(tmpFile.toURI()); @@ -76,32 +75,32 @@ public Integer call() throws Exception { IParser parser = null; if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("json")) { - parser = ctx.newJsonParser(); - } else if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("xml") ) { + parser = ctx.newJsonParser(); + } else if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("xml")) { parser = ctx.newXmlParser(); } - IBaseResource resource = parser.parseResource(new String(readAllBytes(file.toPath()), StandardCharsets.UTF_8)); + final IBaseResource resource = parser.parseResource(new String(readAllBytes(file.toPath()), StandardCharsets.UTF_8)); - switch (resource.fhirType()){ + switch (resource.fhirType()) { case "Immunization": - Immunization immunization = (Immunization) stripNarratives((Resource) resource); + final Immunization immunization = (Immunization) stripNarratives((Resource) resource); return action.execute(this, ctx, immunization); case "Bundle": - Bundle bundle = (Bundle) stripNarratives((Resource)resource); + final Bundle bundle = (Bundle) stripNarratives((Resource) resource); return action.execute(this, ctx, bundle); case "AllergyIntolerance": - AllergyIntolerance allergy = (AllergyIntolerance) stripNarratives((Resource)resource); + final AllergyIntolerance allergy = (AllergyIntolerance) stripNarratives((Resource) resource); return action.execute(this, ctx, allergy); case "ServiceRequest": - ServiceRequest serviceRequest = (ServiceRequest) stripNarratives((Resource)resource); + final ServiceRequest serviceRequest = (ServiceRequest) stripNarratives((Resource) resource); return action.execute(this, ctx, serviceRequest); case "Task": - Task task = (Task) stripNarratives((Resource)resource); + final Task task = (Task) stripNarratives((Resource) resource); return action.execute(this, ctx, task); default: @@ -120,16 +119,17 @@ public enum Action { private final ActionLambda executor; - Action(ActionLambda executor) { + Action(final ActionLambda executor) { this.executor = executor; } - public Integer execute(Visualization visualization, FhirContext ctx, Resource resource) throws Exception { + public Integer execute(final Visualization visualization, final FhirContext ctx, final Resource resource) throws Exception { return executor.execute(visualization, ctx, resource); } public interface ActionLambda { - Integer execute(Visualization visualization, FhirContext ctx, Resource resource) throws Exception; + + Integer execute(Visualization visualization, FhirContext ctx, Resource resource) throws Exception; } } } diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/gen/ResourceHtmlGenerator.java b/src/main/java/be/fgov/ehealth/fhir/narrative/gen/ResourceHtmlGenerator.java index cca6784..0ef4a46 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/gen/ResourceHtmlGenerator.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/gen/ResourceHtmlGenerator.java @@ -15,20 +15,28 @@ import java.util.Objects; public class ResourceHtmlGenerator { + private INarrativeGenerator generator; public ResourceHtmlGenerator() { //this.generator = new CustomThymeleafNarrativeGenerator("classpath:/narratives/diagnosticreport/narrative.properties"); } - public ResourceHtmlGenerator(INarrativeGenerator generator) { + public ResourceHtmlGenerator(final INarrativeGenerator generator) { this.generator = generator; } + public static StringBuilder getDiagnosticNarrative(final Bundle bundleParse, final StringBuilder narrative) { + return narrative.append(((DiagnosticReport) bundleParse.getEntry().stream() + .filter(e -> e.getResource().fhirType().equals("DiagnosticReport")).findFirst() + .orElseThrow(() -> new IllegalArgumentException("Bundle must contain a DiagnosticReport")) + .getResource()).getText().getDiv().toString()).append("
"); + } + //TODO change for other messages - public byte[] generateHtmlRepresentation(FhirContext fhirContext, Resource resource, String css) { + public byte[] generateHtmlRepresentation(final FhirContext fhirContext, final Resource resource, final String css) { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try(OutputStreamWriter sw = new OutputStreamWriter(bos, StandardCharsets.UTF_8)) { + try (final OutputStreamWriter sw = new OutputStreamWriter(bos, StandardCharsets.UTF_8)) { sw.append("\r\n"); sw.append(generateDivRepresentation(fhirContext, resource, css)); sw.append("\r\n"); - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); } return bos.toByteArray(); } - public String generateDivRepresentation(FhirContext fhirContext, Resource resource, String css) { - IParser parser; + public String generateDivRepresentation(final FhirContext fhirContext, final Resource resource, final String css) { + final IParser parser; switch (resource.getResourceType().toString()) { case "Bundle": Bundle bundle = (Bundle) resource; - List profiles = bundle.getMeta().getProfile(); - String mainProfile = profiles.isEmpty() ? "" : profiles.get(0).getValue(); + final List profiles = bundle.getMeta().getProfile(); + final String mainProfile = profiles.isEmpty() ? "" : profiles.get(0).getValue(); StringBuilder narrative = new StringBuilder(); generator = new CustomThymeleafNarrativeGenerator("classpath:/narratives/diagnosticreport/narrative.properties"); @@ -60,7 +68,7 @@ public String generateDivRepresentation(FhirContext fhirContext, Resource resour Bundle bundleParse; if ("Bundle".equals(bundle.getEntryFirstRep().getResource().getResourceType().toString())) { do { - for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) { + for (final Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) { bundleParse = parser.parseResource(Bundle.class, parser.encodeResourceToString(FhirNarrativeUtils.stripNarratives(bundleEntryComponent.getResource()))); narrative = getDiagnosticNarrative(bundleParse, narrative); } @@ -80,7 +88,7 @@ public String generateDivRepresentation(FhirContext fhirContext, Resource resour bundleParse = parser.parseResource(Bundle.class, parser.encodeResourceToString(FhirNarrativeUtils.stripNarratives(resource))); return getDiagnosticNarrative(bundleParse, narrative).toString(); } - } catch (Exception e) { + } catch (final Exception e) { System.out.println("Error while parsing Bundle: " + e); return ""; } @@ -124,13 +132,4 @@ public String generateDivRepresentation(FhirContext fhirContext, Resource resour } - public StringBuilder getDiagnosticNarrative(Bundle bundleParse, StringBuilder narrative) { - return narrative.append(((DiagnosticReport) bundleParse.getEntry().stream() - .filter(e -> e.getResource().fhirType().equals("DiagnosticReport")).findFirst() - .orElseThrow(() -> new IllegalArgumentException("Bundle must contain a DiagnosticReport")) - .getResource()).getText().getDiv().toString()).append("
"); - - - } - } diff --git a/src/main/java/be/fgov/ehealth/fhir/narrative/option/FhirValidator.java b/src/main/java/be/fgov/ehealth/fhir/narrative/option/FhirValidator.java index e3263ec..ff1edb1 100644 --- a/src/main/java/be/fgov/ehealth/fhir/narrative/option/FhirValidator.java +++ b/src/main/java/be/fgov/ehealth/fhir/narrative/option/FhirValidator.java @@ -37,13 +37,17 @@ public FhirValidator(final PrintStream ps, final List implementationGuid validator = validationService.initializeValidator(cliContext, definitions, tt); } + private static String toHml(final List records) { + return (new HTMLOutputGenerator(records)).generate(System.currentTimeMillis()); + } + public Pair validate(final String source) throws Exception { // add source cliContext.setSources(singletonList(source)); // validate final List records = new ArrayList<>(); - final Resource resource = validator.validate(cliContext.getSources(), cliContext.getProfiles(), null, records,null,false,0,false); + final Resource resource = validator.validate(cliContext.getSources(), cliContext.getProfiles(), null, records, null, false, 0, false); final int errors = validationService.displayOperationOutcome((OperationOutcome) resource, false, cliContext.isCrumbTrails()); // return hasErrors and html @@ -59,8 +63,4 @@ public Pair validate(final byte[] data) throws Exception { // return hasErrors and html return Pair.of(errors, toHml(records)); } - - private String toHml(final List records) { - return (new HTMLOutputGenerator(records)).generate(System.currentTimeMillis()); - } } diff --git a/src/main/java/org/hl7/fhir/r4/model/FhirNarrativeUtils.java b/src/main/java/org/hl7/fhir/r4/model/FhirNarrativeUtils.java index 469d75e..450bd8e 100644 --- a/src/main/java/org/hl7/fhir/r4/model/FhirNarrativeUtils.java +++ b/src/main/java/org/hl7/fhir/r4/model/FhirNarrativeUtils.java @@ -7,28 +7,30 @@ import java.util.List; public final class FhirNarrativeUtils { - private FhirNarrativeUtils() { } - public static Resource stripNarratives(Resource resource) { + private FhirNarrativeUtils() { + } + + public static Resource stripNarratives(final Resource resource) { visitAndStrip(resource); return resource; } - public static List> collectNarratives(Resource resource) { - LinkedList> acc = new LinkedList<>(); + public static List> collectNarratives(final Resource resource) { + final LinkedList> acc = new LinkedList<>(); visitAndCollect(resource, "", acc); return acc; } - private static void visitAndStrip(Base resource) { - List children = new LinkedList<>(); + private static void visitAndStrip(final Base resource) { + final List children = new LinkedList<>(); resource.listChildren(children); children.forEach(p -> { - Base[] property = resource.getProperty(p.getName().hashCode(), p.getName(), false); + final Base[] property = resource.getProperty(p.getName().hashCode(), p.getName(), false); if (property != null) { Arrays.asList(property).forEach(base -> { if (base instanceof Narrative) { - Narrative narrative = ((Narrative) base); + final Narrative narrative = ((Narrative) base); if (narrative.status == null || (narrative.status.getValue() != Narrative.NarrativeStatus.ADDITIONAL && narrative.status.getValue() != Narrative.NarrativeStatus.EXTENSIONS)) { resource.setProperty(p.getName(), new Narrative()); } @@ -40,16 +42,16 @@ private static void visitAndStrip(Base resource) { }); } - private static void visitAndCollect(Base resource, String path, List> acc) { - List children = new LinkedList<>(); + private static void visitAndCollect(final Base resource, final String path, final List> acc) { + final List children = new LinkedList<>(); resource.listChildren(children); children.forEach(p -> { - Base[] property = resource.getProperty(p.getName().hashCode(), p.getName(), false); + final Base[] property = resource.getProperty(p.getName().hashCode(), p.getName(), false); if (property != null) { - List bases = Arrays.asList(property); + final List bases = Arrays.asList(property); bases.forEach(base -> { if (base instanceof Narrative) { - Narrative narrative = ((Narrative) base); + final Narrative narrative = ((Narrative) base); acc.add(Pair.of(path, narrative.getDiv().toString())); } else { visitAndCollect(base, path + "/" + p.getName() + "[" + bases.indexOf(base) + "]:" + base.getClass().getSimpleName(), acc); diff --git a/src/main/java/org/hl7/fhir/validation/BeValidationEngine.java b/src/main/java/org/hl7/fhir/validation/BeValidationEngine.java index c064dba..576bb0f 100644 --- a/src/main/java/org/hl7/fhir/validation/BeValidationEngine.java +++ b/src/main/java/org/hl7/fhir/validation/BeValidationEngine.java @@ -18,38 +18,39 @@ import java.util.List; public class BeValidationEngine extends ValidationEngine { + private final PrintStream ps; - public BeValidationEngine(PrintStream ps, ValidationEngine ve) throws FHIRException, IOException { + public BeValidationEngine(final PrintStream ps, final ValidationEngine ve) throws FHIRException, IOException { super(ve); this.ps = ps; } - public Resource validateContent(List sources, List profiles, List record) throws FHIRException, IOException { + public Resource validateContent(final List sources, final List profiles, final List record) throws FHIRException, IOException { int idx = 0; - boolean asBundle = sources.size() > 1; - Bundle results = new Bundle(); + final boolean asBundle = sources.size() > 1; + final Bundle results = new Bundle(); results.setType(Bundle.BundleType.COLLECTION); - for (byte[] data: sources) { - List messages = new ArrayList(); + for (final byte[] data : sources) { + final List messages = new ArrayList(); - String mimeType = new String(data, 0, 1); + final String mimeType = new String(data, 0, 1); Manager.FhirFormat fhirFormat = Manager.FhirFormat.JSON; if (mimeType.equals("<")) { fhirFormat = Manager.FhirFormat.XML; } - InstanceValidator validator = getValidator(fhirFormat); + final InstanceValidator validator = getValidator(fhirFormat); validator.validate(null, messages, new ByteArrayInputStream(data), fhirFormat, asSdList(profiles)); if (record != null) { record.add(new ValidationRecord("--", messages)); } try { - OperationOutcome outcome = ValidatorUtils.messagesToOutcome(messages, getContext(), getFhirPathEngine()); - ToolingExtensions.addStringExtension(outcome, "http://hl7.org/fhir/StructureDefinition/operationoutcome-file", "data-"+idx); + final OperationOutcome outcome = ValidatorUtils.messagesToOutcome(messages, getContext(), getFhirPathEngine()); + ToolingExtensions.addStringExtension(outcome, "http://hl7.org/fhir/StructureDefinition/operationoutcome-file", "data-" + idx); results.addEntry().setResource(outcome); - } catch (EOperationOutcome eOperationOutcome) { + } catch (final EOperationOutcome eOperationOutcome) { ps.println("Validation Infrastructure fail validating element " + idx + ": " + eOperationOutcome.getMessage()); throw new FHIRException(eOperationOutcome); } @@ -59,30 +60,30 @@ public Resource validateContent(List sources, List profiles, Lis } @Override - public Resource validate(List sources, List profiles, List refs, List record, IValidationEngineLoader loader, boolean all, int delay, boolean first) throws FHIRException, IOException { + public Resource validate(final List sources, final List profiles, List refs, final List record, final IValidationEngineLoader loader, final boolean all, final int delay, final boolean first) throws FHIRException, IOException { if (!profiles.isEmpty()) { ps.println(" Profiles: " + profiles); } refs = new ArrayList<>(); - boolean asBundle = ValidatorUtils.parseSources(sources, refs, this.getContext()); - Bundle results = new Bundle(); + final boolean asBundle = ValidatorUtils.parseSources(sources, refs, this.getContext()); + final Bundle results = new Bundle(); results.setType(Bundle.BundleType.COLLECTION); - for(ValidatorUtils.SourceFile ref : refs) { - TimeTracker.Session tts = this.getContext().clock().start("validation"); + for (final ValidatorUtils.SourceFile ref : refs) { + final TimeTracker.Session tts = this.getContext().clock().start("validation"); this.getContext().clock().milestone(); ps.print(" Validate " + ref); - Content cnt = this.getIgLoader().loadContent(ref.getRef(), "validate", false, false); + final Content cnt = this.getIgLoader().loadContent(ref.getRef(), "validate", false, false); try { - OperationOutcome outcome = this.validate(ref.getRef(), cnt.getFocus(), cnt.getCntType(), profiles, record); + final OperationOutcome outcome = this.validate(ref.getRef(), cnt.getFocus(), cnt.getCntType(), profiles, record); ToolingExtensions.addStringExtension(outcome, "http://hl7.org/fhir/StructureDefinition/operationoutcome-file", ref.getRef()); ps.println(" " + this.getContext().clock().milestone()); results.addEntry().setResource(outcome); tts.end(); - } catch (Exception eOperationOutcome) { + } catch (final Exception eOperationOutcome) { ps.println("Validation Infrastructure fail validating " + ref + ": " + eOperationOutcome.getMessage()); tts.end(); throw new FHIRException(eOperationOutcome); diff --git a/src/main/java/org/hl7/fhir/validation/BeValidationService.java b/src/main/java/org/hl7/fhir/validation/BeValidationService.java index e94c963..646bc0c 100644 --- a/src/main/java/org/hl7/fhir/validation/BeValidationService.java +++ b/src/main/java/org/hl7/fhir/validation/BeValidationService.java @@ -1,10 +1,7 @@ package org.hl7.fhir.validation; -import java.io.IOException; -import java.io.PrintStream; -import java.net.URISyntaxException; -import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.model.OperationOutcome; +import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.utilities.TimeTracker; import org.hl7.fhir.utilities.Utilities; @@ -14,69 +11,102 @@ import org.hl7.fhir.validation.cli.services.ValidationService; import org.jetbrains.annotations.NotNull; +import java.io.IOException; +import java.io.PrintStream; +import java.net.URISyntaxException; + public class BeValidationService extends ValidationService { + private final PrintStream ps; - public BeValidationService(PrintStream ps) { + public BeValidationService(final PrintStream ps) { super(); this.ps = ps; } + private static String getIssueSummary(final OperationOutcome.OperationOutcomeIssueComponent issue) { + final String loc; + final int line; + final int col; + if (issue.hasExpression()) { + line = ToolingExtensions.readIntegerExtension(issue, + "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-line", -1); + col = ToolingExtensions.readIntegerExtension(issue, + "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-col", -1); + loc = (issue.getExpression().get(0)).asStringValue() + + (line >= 0 && col >= 0 ? " (line " + + line + ", col" + + col + ")" : ""); + } else if (issue.hasLocation()) { + loc = (issue.getLocation().get(0)).asStringValue(); + } else { + line = ToolingExtensions.readIntegerExtension(issue, + "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-line", -1); + col = ToolingExtensions.readIntegerExtension(issue, + "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-col", -1); + loc = line >= 0 && col >= 0 ? "line " + line + ", col" + col : "??"; + } + + return " " + issue.getSeverity().getDisplay() + " @ " + loc + " : " + + issue.getDetails().getText(); + } + @Override - public BeValidationEngine initializeValidator(CliContext cliContext, String definitions, TimeTracker tt) throws Exception { + public BeValidationEngine initializeValidator(final CliContext cliContext, final String definitions, final TimeTracker tt) throws Exception { return buildValidationEngine(cliContext, definitions, tt); } + @Override @NotNull - protected BeValidationEngine buildValidationEngine(CliContext cliContext, String definitions, TimeTracker timeTracker) throws IOException, URISyntaxException { + protected BeValidationEngine buildValidationEngine(final CliContext cliContext, final String definitions, final TimeTracker timeTracker) throws IOException, URISyntaxException { System.out.print(" Load FHIR v" + cliContext.getSv() + " from " + definitions); - ValidationEngine tmpValidationEngine = getValidationEngineBuilder().withTHO(false).withVersion(cliContext.getSv()).withTimeTracker(timeTracker).withUserAgent("fhir/validator").fromSource(definitions); - BeValidationEngine validationEngine = new BeValidationEngine(ps, tmpValidationEngine); - - System.out.println(" - " + validationEngine.getContext().countAllCaches() + " resources (" + timeTracker.milestone() + ")"); - - loadIgsAndExtensions(validationEngine, cliContext, timeTracker); - System.out.print(" Get set... "); - validationEngine.setDisplayWarnings(cliContext.isDisplayWarnings()); - validationEngine.setQuestionnaireMode(cliContext.getQuestionnaireMode()); - validationEngine.setLevel(cliContext.getLevel()); - validationEngine.setDoNative(cliContext.isDoNative()); - validationEngine.setHintAboutNonMustSupport(cliContext.isHintAboutNonMustSupport()); - for (String s : cliContext.getExtensions()) { - if ("any".equals(s)) { - validationEngine.setAnyExtensionsAllowed(true); - } else { - validationEngine.getExtensionDomains().add(s); - } - } - validationEngine.setLanguage(cliContext.getLang()); - validationEngine.setLocale(cliContext.getLocale()); - validationEngine.setSnomedExtension(cliContext.getSnomedCTCode()); - validationEngine.setAssumeValidRestReferences(cliContext.isAssumeValidRestReferences()); - validationEngine.setShowMessagesFromReferences(cliContext.isShowMessagesFromReferences()); - validationEngine.setDoImplicitFHIRPathStringConversion(cliContext.isDoImplicitFHIRPathStringConversion()); - validationEngine.setHtmlInMarkdownCheck(cliContext.getHtmlInMarkdownCheck()); - validationEngine.setNoExtensibleBindingMessages(cliContext.isNoExtensibleBindingMessages()); - validationEngine.setNoUnicodeBiDiControlChars(cliContext.isNoUnicodeBiDiControlChars()); - validationEngine.setNoInvariantChecks(cliContext.isNoInvariants()); - validationEngine.setWantInvariantInMessage(cliContext.isWantInvariantsInMessages()); - validationEngine.setSecurityChecks(cliContext.isSecurityChecks()); - validationEngine.setCrumbTrails(cliContext.isCrumbTrails()); - validationEngine.setForPublication(cliContext.isForPublication()); - validationEngine.setShowTimes(cliContext.isShowTimes()); - validationEngine.setAllowExampleUrls(cliContext.isAllowExampleUrls()); - StandAloneValidatorFetcher fetcher = new StandAloneValidatorFetcher(validationEngine.getPcm(), validationEngine.getContext(), validationEngine); - validationEngine.setFetcher(fetcher); - validationEngine.setPolicyAdvisor(fetcher.getPolicyAdvisor()); - validationEngine.getContext().setLocator(fetcher); - validationEngine.getBundleValidationRules().addAll(cliContext.getBundleValidationRules()); - validationEngine.setJurisdiction(CodeSystemUtilities.readCoding(cliContext.getJurisdiction())); - - //TerminologyCache.setNoCaching(cliContext.isNoInternalCaching()); - validationEngine.prepare(); // generate any missing snapshots - System.out.println(" go (" + timeTracker.milestone() + ")"); - return validationEngine; + final ValidationEngine tmpValidationEngine = getValidationEngineBuilder().withTHO(false).withVersion(cliContext.getSv()).withTimeTracker(timeTracker).withUserAgent("fhir/validator").fromSource(definitions); + final BeValidationEngine validationEngine = new BeValidationEngine(ps, tmpValidationEngine); + + System.out.println(" - " + validationEngine.getContext().countAllCaches() + " resources (" + timeTracker.milestone() + ")"); + + loadIgsAndExtensions(validationEngine, cliContext, timeTracker); + System.out.print(" Get set... "); + validationEngine.setDisplayWarnings(cliContext.isDisplayWarnings()); + validationEngine.setQuestionnaireMode(cliContext.getQuestionnaireMode()); + validationEngine.setLevel(cliContext.getLevel()); + validationEngine.setDoNative(cliContext.isDoNative()); + validationEngine.setHintAboutNonMustSupport(cliContext.isHintAboutNonMustSupport()); + for (final String s : cliContext.getExtensions()) { + if ("any".equals(s)) { + validationEngine.setAnyExtensionsAllowed(true); + } else { + validationEngine.getExtensionDomains().add(s); + } + } + validationEngine.setLanguage(cliContext.getLang()); + validationEngine.setLocale(cliContext.getLocale()); + validationEngine.setSnomedExtension(cliContext.getSnomedCTCode()); + validationEngine.setAssumeValidRestReferences(cliContext.isAssumeValidRestReferences()); + validationEngine.setShowMessagesFromReferences(cliContext.isShowMessagesFromReferences()); + validationEngine.setDoImplicitFHIRPathStringConversion(cliContext.isDoImplicitFHIRPathStringConversion()); + validationEngine.setHtmlInMarkdownCheck(cliContext.getHtmlInMarkdownCheck()); + validationEngine.setNoExtensibleBindingMessages(cliContext.isNoExtensibleBindingMessages()); + validationEngine.setNoUnicodeBiDiControlChars(cliContext.isNoUnicodeBiDiControlChars()); + validationEngine.setNoInvariantChecks(cliContext.isNoInvariants()); + validationEngine.setWantInvariantInMessage(cliContext.isWantInvariantsInMessages()); + validationEngine.setSecurityChecks(cliContext.isSecurityChecks()); + validationEngine.setCrumbTrails(cliContext.isCrumbTrails()); + validationEngine.setForPublication(cliContext.isForPublication()); + validationEngine.setShowTimes(cliContext.isShowTimes()); + validationEngine.setAllowExampleUrls(cliContext.isAllowExampleUrls()); + final StandAloneValidatorFetcher fetcher = new StandAloneValidatorFetcher(validationEngine.getPcm(), validationEngine.getContext(), validationEngine); + validationEngine.setFetcher(fetcher); + validationEngine.setPolicyAdvisor(fetcher.getPolicyAdvisor()); + validationEngine.getContext().setLocator(fetcher); + validationEngine.getBundleValidationRules().addAll(cliContext.getBundleValidationRules()); + validationEngine.setJurisdiction(CodeSystemUtilities.readCoding(cliContext.getJurisdiction())); + + //TerminologyCache.setNoCaching(cliContext.isNoInternalCaching()); + validationEngine.prepare(); // generate any missing snapshots + System.out.println(" go (" + timeTracker.milestone() + ")"); + return validationEngine; } /** @@ -88,17 +118,17 @@ protected BeValidationEngine buildValidationEngine(CliContext cliContext, String * @return amount of issues that have severity FATAL or ERROR */ //@Override - public int displayOperationOutcome(OperationOutcome operationOutcome, boolean hasMultiples, - boolean crumbs) { + public int displayOperationOutcome(final OperationOutcome operationOutcome, final boolean hasMultiples, + final boolean crumbs) { int error = 0; int warn = 0; int info = 0; - String file = ToolingExtensions.readStringExtension(operationOutcome, - ToolingExtensions.EXT_OO_FILE); + final String file = ToolingExtensions.readStringExtension(operationOutcome, + ToolingExtensions.EXT_OO_FILE); - for (OperationOutcome.OperationOutcomeIssueComponent issue : operationOutcome.getIssue()) { + for (final OperationOutcome.OperationOutcomeIssueComponent issue : operationOutcome.getIssue()) { if (issue.getSeverity() == OperationOutcome.IssueSeverity.FATAL || - issue.getSeverity() == OperationOutcome.IssueSeverity.ERROR) { + issue.getSeverity() == OperationOutcome.IssueSeverity.ERROR) { error++; } else if (issue.getSeverity() == OperationOutcome.IssueSeverity.WARNING) { warn++; @@ -114,13 +144,13 @@ public int displayOperationOutcome(OperationOutcome operationOutcome, boolean ha ps.println(Utilities.padLeft("", '-', Integer.max(38, file.length() + 6))); } ps.println((error == 0 ? "Success" : "*FAILURE*") + ": " + error + " " + - "errors, " + warn + " warnings, " + info + " notes"); - for (OperationOutcome.OperationOutcomeIssueComponent issue : operationOutcome.getIssue()) { + "errors, " + warn + " warnings, " + info + " notes"); + for (final OperationOutcome.OperationOutcomeIssueComponent issue : operationOutcome.getIssue()) { ps.println(getIssueSummary(issue)); if (crumbs) { - ValidationMessage vm = (ValidationMessage) issue.getUserData("source.msg"); + final ValidationMessage vm = (ValidationMessage) issue.getUserData("source.msg"); if (vm != null && vm.sliceText != null) { - for (String s : vm.sliceText) { + for (final String s : vm.sliceText) { ps.println(" slice info: " + s); } } @@ -136,31 +166,4 @@ public int displayOperationOutcome(OperationOutcome operationOutcome, boolean ha return error; } - private String getIssueSummary(OperationOutcome.OperationOutcomeIssueComponent issue) { - String loc; - int line; - int col; - if (issue.hasExpression()) { - line = ToolingExtensions.readIntegerExtension(issue, - "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-line", -1); - col = ToolingExtensions.readIntegerExtension(issue, - "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-col", -1); - loc = (issue.getExpression().get(0)).asStringValue() + - (line >= 0 && col >= 0 ? " (line " + - line + ", col" + - col + ")" : ""); - } else if (issue.hasLocation()) { - loc = (issue.getLocation().get(0)).asStringValue(); - } else { - line = ToolingExtensions.readIntegerExtension(issue, - "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-line", -1); - col = ToolingExtensions.readIntegerExtension(issue, - "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-col", -1); - loc = line >= 0 && col >= 0 ? "line " + line + ", col" + col : "??"; - } - - return " " + issue.getSeverity().getDisplay() + " @ " + loc + " : " + - issue.getDetails().getText(); - } - }