SVG icon validation

  • 16 October 2020
  • 2 replies
  • 38 views

Userlevel 2
Badge +2

Goal

The following validation can be used to check whether the icons in the model comply with the desired file type. 

Solution

;with cte as (

select 'col/form_next_grp_icon' as tab_col, form_next_grp_icon as icon from col t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.form_next_grp_icon not like '%.svg'
union all select 'col/next_tab_icon', next_tab_icon from col t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.next_tab_icon not like '%.svg'
union all select 'tile_grp/icon', icon from tile_grp t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'task_variant_form/form_next_grp_icon', form_next_grp_icon from task_variant_form t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.form_next_grp_icon not like '%.svg'
union all select 'task_variant_form/next_tab_icon', next_tab_icon from task_variant_form t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.next_tab_icon not like '%.svg'
union all select 'report/icon', icon from report t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'module_grp/icon', icon from module_grp t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'report_parmtr/form_next_grp_icon', form_next_grp_icon from report_parmtr t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.form_next_grp_icon not like '%.svg'
union all select 'report_parmtr/next_tab_icon', next_tab_icon from report_parmtr t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.next_tab_icon not like '%.svg'
union all select 'msg_option/icon', icon from msg_option t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'tab/icon', icon from tab t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'report_variant/icon', icon from report_variant t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'cube_view/cube_view_icon', cube_view_icon from cube_view t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.cube_view_icon not like '%.svg'
union all select 'process/icon', icon from process t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'report_variant_form/form_next_grp_icon', form_next_grp_icon from report_variant_form t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.form_next_grp_icon not like '%.svg'
union all select 'report_variant_form/next_tab_icon', next_tab_icon from report_variant_form t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.next_tab_icon not like '%.svg'
union all select 'screen_component/tab_page_icon', tab_page_icon from screen_component t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.tab_page_icon not like '%.svg'
union all select 'tab_variant_form/form_next_grp_icon', form_next_grp_icon from tab_variant_form t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.form_next_grp_icon not like '%.svg'
union all select 'tab_variant_form/next_tab_icon', next_tab_icon from tab_variant_form t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.next_tab_icon not like '%.svg'
union all select 'task/icon', icon from task t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'tab_prefilter_grp/icon', icon from tab_prefilter_grp t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'tab_prefilter/icon', icon from tab_prefilter t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'tab_variant/icon', icon from tab_variant t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'task_parmtr/form_next_grp_icon', form_next_grp_icon from task_parmtr t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.form_next_grp_icon not like '%.svg'
union all select 'task_parmtr/next_tab_icon', next_tab_icon from task_parmtr t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.next_tab_icon not like '%.svg'
union all select 'list_bar_grp/icon', icon from list_bar_grp t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'menu/icon', icon from menu t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
union all select 'task_variant/icon', icon from task_variant t1 where t1.project_id = @project_id and t1.project_vrs_id = @project_vrs_id and t1.icon not like '%.svg'
)
insert validation_msg
select
@project_id,
@project_vrs_id,
@validation_id,
@project_id,
@project_vrs_id,
t.tab_col,
null,
null,
null,
null,
1,
dbo.tsf_user(),
getdate(),
dbo.tsf_user(),
getdate()
from cte t

 


2 replies

Userlevel 5
Badge +7

Hi Luuk Schouten,

it's also possible to use the ‘icon_used’ view from the SF.

insert validation_msg
select @project_id as project_id
, @project_vrs_id as project_vrs_id
, @validation_id as validation_id
, @project_id as pk_col_1
, @project_vrs_id as pk_col_2
, d.icon_path as pk_col_3
, null as pk_col_4
, null as pk_col_5
, null as pk_col_6
, null as pk_col_7
, 1 as generated
, dbo.tsf_user() as insert_user
, getdate() as insert_date_time
, dbo.tsf_user() as update_user
, getdate() as update_date_time
from icon_used as d
where d.project_id = @project_id
and d.project_vrs_id = @project_vrs_id
and d.icon_path is not null
and right(d.icon_path, 4) <> '.svg'

Kind regards,

Kevin

Userlevel 4
Badge +4

Hey Luuk,

 

This checks if you use a .svg name, but not if the content is an SVG.

 

You could also check on:

CAST(i.icon_data as varchar(max)) not like '%<svg%'

to make sure it is really an SVG and not just a PNG with the wrong name.

 

Gr. Ester

Reply