contentstorage/castorage/conf/castoragedb_templates/castoragedb_variant.sql
changeset 121 0b3699f6c654
parent 109 e0aa398e6810
child 124 e36b2f4799c0
equal deleted inserted replaced
115:3ab5c078b490 121:0b3699f6c654
     1 SELECT "------------------------------------" AS " ";
     1 SELECT "------------------------------------" AS " ";
     2 SELECT "castoragedb_variant - BEGIN" AS " ";
     2 SELECT "castoragedb_variant - BEGIN" AS " ";
     3 
     3 
     4 {% for col in range(feat_tree.CaStorageDbSetting.OperatorCollections._value|length) -%}
     4 {%- macro stripPath(IconPath) %}
     5     {%- set Name = feat_tree.CaStorageDbSetting.OperatorCollections.Name._value[col] or '' -%}
     5     {%- set cont = true -%}
     6     {%- set ShortName = feat_tree.CaStorageDbSetting.OperatorCollections.ShortName._value[col] or '' -%}
     6     {%- set Icon = '' -%}
     7     {%- set TitleName = feat_tree.CaStorageDbSetting.OperatorCollections.TitleName._value[col] or '' -%}
     7     {%- for c in IconPath|reverse|list -%}
     8     {%- set GroupName = feat_tree.CaStorageDbSetting.OperatorCollections.GroupName._value[col] or '' -%}
     8         {%- if c == '\\' or c == '/' -%}
     9     {%- set Locked = feat_tree.CaStorageDbSetting.OperatorCollections.Locked._value[col] or false -%}
     9             {%- set cont = false -%}
    10     {%- set IconFileName = ( feat_tree.CaStorageDbSetting.OperatorCollections.Icon.localPath._value[col] or '' ) -%}
    10         {%- endif %}
    11     {%- set IconSkinId = feat_tree.CaStorageDbSetting.OperatorCollections.IconSkinId._value[col] or '' -%}
    11         {%- if cont %}
    12     {% if IconSkinId == "" and IconFileName != "" and IconFileName != "dummy" -%}
    12             {%- set Icon = c ~ Icon %}
    13         {% set IconFileName = "z:\\private\\20022F35\\customsvg\\" + IconFileName %}
    13         {%- endif %}
    14     {% endif %}
    14         {%- if loop.last -%}
    15 INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME, FLAGS {% if TitleName -%},  COL_TITLE_NAME{%- endif %} {% if ShortName -%}, COL_SHORT_NAME{%- endif %}, ICON_FILENAME, ICON_SKIN_ID) 
    15             {{ "z:\\private\\20022F35\\customsvg\\" ~ Icon }}
    16 VALUES ( '{{Name}}', '{{GroupName}}', {% if Locked -%} 12 {% else %} 8 {%- endif %} {% if TitleName -%}, "{{TitleName}}"{%- endif %} {% if ShortName -%}, "{{ShortName}}"{%- endif %}, "{{IconFileName}}", "{{IconSkinId}}");
    16         {%- endif %}
    17 {% endfor %}
    17     {%- endfor %}
       
    18 {%- endmacro %}
    18 
    19 
    19 {% for i in range(feat_tree.CaStorageDbSetting.OperatorURLs._value|length) -%}
    20 {%- macro processURLs(URLs) %}
    20     {% set URLTitle = feat_tree.CaStorageDbSetting.OperatorURLs.OperatorURLTitle._value[i] %}
    21     {%- for i in range(feat_tree.CaStorageDbSetting[URLs]._value|length) -%}
    21     {%- set URLShortTitle = feat_tree.CaStorageDbSetting.OperatorURLs.OperatorURLShortTitle._value[i] or '' -%}
    22         {%- set URLTitle = feat_tree.CaStorageDbSetting[URLs].URLTitle._value[i] -%}
    22     {%- set URL = feat_tree.CaStorageDbSetting.OperatorURLs.OperatorURL._value[i] or '' -%}
    23         {%- set URLShortTitle = feat_tree.CaStorageDbSetting[URLs].URLShortTitle._value[i] or '' -%}
    23     {%- set URLIcon = feat_tree.CaStorageDbSetting.OperatorURLs.OperatorURLIcon.localPath._value[i] or '' -%}
    24         {%- set URL = feat_tree.CaStorageDbSetting[URLs].URL._value[i] or '' -%}
    24     {%- set IconSkinId = feat_tree.CaStorageDbSetting.OperatorURLs.IconSkinId._value[i] or '' -%}
    25         {%- set URLIcon = feat_tree.CaStorageDbSetting[URLs].URLIcon.localPath._value[i] or '' -%}
    25     {% if IconSkinId == "" and URLIcon != "" and URLIcon != "dummy" -%}
    26         {%- set IconSkinId = feat_tree.CaStorageDbSetting[URLs].IconSkinId._value[i] or '' -%}
    26         {% set URLIcon = "z:\\private\\20022F35\\customsvg\\" + URLIcon %}
    27         {%- if IconSkinId == "" and URLIcon != "" and URLIcon != "dummy" -%}
    27     {% endif %}
    28             {%- set URLIcon = stripPath(URLIcon) -%}
    28     INSERT INTO URL ( URL_TITLE {% if URLShortTitle -%}, URL_SHORT_TITLE{%- endif %}, URL_DEST, ICON_FILENAME, ICON_SKIN_ID )
    29         {%- endif %}
    29     VALUES ('{{URLTitle}}' {% if URLShortTitle -%}, "{{URLShortTitle}}"{%- endif %}, "{{URL}}", "{{URLIcon}}", "{{IconSkinId}}" );
    30         INSERT INTO URL ( URL_TITLE, URL_SHORT_TITLE, URL_DEST, ICON_FILENAME, ICON_SKIN_ID ) 
    30 {% endfor %}
    31         VALUES ( '{{URLTitle}}', "{{URLShortTitle}}", "{{URL}}", "{{URLIcon}}", "{{IconSkinId}}" );
       
    32     {%- endfor %}
       
    33 {%- endmacro %}
    31 
    34 
    32 {% for index in range(feat_tree.CaStorageDbSetting.OperatorCollectionItems._value|length) -%}
    35 {% macro processCollections(Collections) -%}
    33     {% set Collection = feat_tree.CaStorageDbSetting.OperatorCollections.Name._value[0] %}
    36     {%- for col in range(feat_tree.CaStorageDbSetting[Collections]._value|length) -%}
    34     {%- set Type = feat_tree.CaStorageDbSetting.OperatorCollectionItems.Type._value[index] or '' -%}
    37         {%- set Name = feat_tree.CaStorageDbSetting[Collections].Name._value[col] or '' -%}
    35     {%- set Application = feat_tree.CaStorageDbSetting.OperatorCollectionItems.Application._value[index] or '' -%}
    38         {%- set ShortName = feat_tree.CaStorageDbSetting[Collections].ShortName._value[col] or '' -%}
    36     {%- set OperatorURLTitle = feat_tree.CaStorageDbSetting.OperatorCollectionItems.OperatorURL._value[index] or '' -%}
    39         {%- set TitleName = feat_tree.CaStorageDbSetting[Collections].TitleName._value[col] or '' -%}
    37     {%- set HomescreenWidget = feat_tree.CaStorageDbSetting.OperatorCollectionItems.HomescreenWidget._value[index] or '' -%}
    40         {%- set GroupName = feat_tree.CaStorageDbSetting[Collections].GroupName._value[col] or '' -%}
    38 {% if Type == "1" -%} INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) 
    41         {%- set Locked = feat_tree.CaStorageDbSetting[Collections].Locked._value[col] or false -%}
    39   VALUES ("application", '', {{Application}},  '{{Collection}}' );{%- endif %}
    42         {%- set LocalizeNames = false -%}
    40 {% if Type == "3" -%}
    43         {%- if Collections == "Collections" -%}
    41   {% for i in range(feat_tree.CaStorageDbSetting.OperatorURLs._value|length) if OperatorURLTitle == feat_tree.CaStorageDbSetting.OperatorURLs.OperatorURLTitle._value[i] -%}
    44             {%- set LocalizeNames = feat_tree.CaStorageDbSetting[Collections].LocalizeNames._value[col] or false -%}
    42     INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, COLLECTION_NAME)
    45             {%- set TranslationFile = feat_tree.CaStorageDbSetting[Collections].TranslationFile._value[col]|string|reverse|replace('_','',1)|reverse~'_' or ''-%}
    43     VALUES ( "url", '{{OperatorURLTitle}}',  '{{Collection}}' );
    46         {%- endif %}
    44   {% endfor %}
    47         {%- set IconFileName = feat_tree.CaStorageDbSetting[Collections].Icon.localPath._value[col] or '' -%}
    45 {%- endif %}
    48         {%- set IconSkinId = feat_tree.CaStorageDbSetting[Collections].IconSkinId._value[col] or '' -%}
    46 {% if Type == "2" -%} INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON_FILENAME, ICON_SKIN_ID, URI, COLLECTION_NAME ) 
    49         {%- if IconSkinId == "" and IconFileName != "" and IconFileName != "dummy" -%}
    47   VALUES ("widget", '', '', '', "{{HomescreenWidget}}", '{{Collection}}' ); {%- endif %}
    50             {%- set IconFileName = stripPath(IconFileName) -%}
    48 {% endfor %}
    51         {%- endif %}
       
    52     INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME, FLAGS,  COL_TITLE_NAME {% if LocalizeNames -%}, TRANSLATION_FILE{%- endif %}, COL_SHORT_NAME, ICON_FILENAME, ICON_SKIN_ID) 
       
    53     VALUES ( '{{Name}}', '{{GroupName}}', {% if Locked -%} 0 {% else %} 4 {%- endif %}, "{{TitleName}}"{% if LocalizeNames -%}, "{{TranslationFile}}"{%- endif %}, "{{ShortName}}", "{{IconFileName}}", "{{IconSkinId}}");
       
    54     {% endfor %}
       
    55 {%- endmacro %}
    49 
    56 
    50 {% for col in range(feat_tree.CaStorageDbSetting.Collections._value|length) -%}
    57 {% macro processItems(Items) -%}
    51     {%- set Name = feat_tree.CaStorageDbSetting.Collections.Name._value[col] or '' -%}
    58     {%- for index in range(feat_tree.CaStorageDbSetting[Items]._value|length) -%}
    52     {% set LocalizeNames = feat_tree.CaStorageDbSetting.Collections.LocalizeNames._value[col] or false -%}
    59         {%- set Type = feat_tree.CaStorageDbSetting[Items].Type._value[index] or '' -%}
    53     {%- set ShortName = feat_tree.CaStorageDbSetting.Collections.ShortName._value[col] or '' -%}
    60         {%- set Application = feat_tree.CaStorageDbSetting[Items].Application._value[index] or '' -%}
    54     {%- set TitleName = feat_tree.CaStorageDbSetting.Collections.TitleName._value[col] or '' -%}
    61         {%- set URLTitle = feat_tree.CaStorageDbSetting[Items].URL._value[index] or '' -%}
    55     {%- set GroupName = feat_tree.CaStorageDbSetting.Collections.GroupName._value[col] or '' -%}
    62         {%- set HomescreenWidget = feat_tree.CaStorageDbSetting[Items].HomescreenWidget._value[index] or '' -%}
    56     {%- set Locked = feat_tree.CaStorageDbSetting.Collections.Locked._value[col] or false -%}
    63         
    57     {%- set TranslationFile = feat_tree.CaStorageDbSetting.Collections.TranslationFile._value[col]|string|reverse|replace('_','',1)|reverse+'_' or ''-%}
    64         {%- if Items == "Items" %}
    58     {%- set IconFileName = feat_tree.CaStorageDbSetting.Collections.Icon.localPath._value[col] or '' -%}
    65             {%- set Collection = feat_tree.CaStorageDbSetting[Items].ColName._value[index] or '' -%}
    59     {%- set IconSkinId = feat_tree.CaStorageDbSetting.Collections.IconSkinId._value[col] or '' -%}
    66             {%- set URLs = 'URLs' -%}
    60     {% if IconSkinId == "" and IconFileName != "" and IconFileName != "dummy" -%}
    67         {%- else %} {# Items == "OperatorCollectionItems" #}
    61         {% set IconFileName = "z:\\private\\20022F35\\customsvg\\" + IconFileName %}
    68             {%- set Collection = feat_tree.CaStorageDbSetting.OperatorCollections.Name._value[0] %}
    62     {% endif %}
    69             {%- set URLs = 'OperatorURLs' -%}
    63 INSERT INTO COLLECTION (COLLECTION_NAME, COL_APP_GROUP_NAME, FLAGS {% if TitleName -%},  COL_TITLE_NAME{%- endif %}{% if LocalizeNames -%},  TRANSLATION_FILE{%- endif %}{% if ShortName -%}, COL_SHORT_NAME{%- endif %}, ICON_FILENAME, ICON_SKIN_ID) 
    70         {%- endif %}
    64 VALUES ( '{{Name}}', '{{GroupName}}', {% if Locked -%} 12 {% else %} 8 {%- endif %} {% if TitleName -%}, "{{TitleName}}"{%- endif %}{% if LocalizeNames -%}, "{{TranslationFile}}"{%- endif %}{% if ShortName -%}, "{{ShortName}}"{%- endif %}, "{{IconFileName}}", "{{IconSkinId}}");
    71         
    65 {% endfor %}
    72         {% if Type == "1" -%} INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) 
       
    73           VALUES ("application", '', {{Application}},  '{{Collection}}' );{%- endif %}
       
    74           
       
    75         {% if Type == "2" -%} INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, URI, COLLECTION_NAME ) 
       
    76           VALUES ("widget", '{{HomescreenWidget}}', "{{HomescreenWidget}}", '{{Collection}}' ); {%- endif %}
       
    77           
       
    78         {% if Type == "3" -%}
       
    79           {% for i in range(feat_tree.CaStorageDbSetting[URLs]._value|length) if URLTitle == feat_tree.CaStorageDbSetting[URLs].URLTitle._value[i] -%}
       
    80             INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, COLLECTION_NAME)
       
    81             VALUES ( "url", '{{URLTitle}}', '{{Collection}}' );
       
    82           {% endfor %}
       
    83         {%- endif %}
       
    84         
       
    85     {%- endfor %}
       
    86 {%- endmacro %}
    66 
    87 
    67 {% for i in range(feat_tree.CaStorageDbSetting.URLs._value|length) -%}
    88 {{ processCollections('OperatorCollections') }}
    68     {% set URLTitle = feat_tree.CaStorageDbSetting.URLs.URLTitle._value[i] %}
       
    69     {%- set URLShortTitle = feat_tree.CaStorageDbSetting.URLs.URLShortTitle._value[i] or '' -%}
       
    70     {%- set URL = feat_tree.CaStorageDbSetting.URLs.URL._value[i] or '' -%}
       
    71     {%- set URLIcon = feat_tree.CaStorageDbSetting.URLs.URLIcon.localPath._value[i] or '' -%}
       
    72     {%- set IconSkinId = feat_tree.CaStorageDbSetting.URLs.IconSkinId._value[i] or '' -%}
       
    73     {% if IconSkinId == "" and URLIcon != "" and URLIcon != "dummy" -%}
       
    74         {% set URLIcon = "z:\\private\\20022F35\\customsvg\\" + URLIcon %}
       
    75     {% endif %}
       
    76     INSERT INTO URL ( URL_TITLE {% if URLShortTitle -%}, URL_SHORT_TITLE{%- endif %}, URL_DEST, ICON_FILENAME, ICON_SKIN_ID ) 
       
    77     VALUES ( '{{URLTitle}}' {% if URLShortTitle -%}, "{{URLShortTitle}}"{%- endif %}, "{{URL}}", "{{URLIcon}}", "{{IconSkinId}}" );
       
    78 {% endfor %}
       
    79 
    89 
    80 {% for index in range(feat_tree.CaStorageDbSetting.Items._value|length) -%}
    90 {{ processURLs('OperatorURLs') }}
    81     {%- set Type = feat_tree.CaStorageDbSetting.Items.Type._value[index] or '' -%}
    91 
    82     {%- set Application = feat_tree.CaStorageDbSetting.Items.Application._value[index] or '' -%}
    92 {{ processItems('OperatorCollectionItems') }}
    83     {%- set URLTitle = feat_tree.CaStorageDbSetting.Items.URL._value[index] or '' -%}
    93 
    84     {%- set HomescreenWidget = feat_tree.CaStorageDbSetting.Items.HomescreenWidget._value[index] or '' -%}
    94 {{ processCollections('Collections') }}
    85     {%- set Collection = feat_tree.CaStorageDbSetting.Items.ColName._value[index] or '' -%}
    95 
    86 {% if Type == "1" -%} INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ITEM_DEST, COLLECTION_NAME) 
    96 {{ processURLs('URLs') }}
    87   VALUES ("application", '', {{Application}},  '{{Collection}}' );{%- endif %}
    97 
    88 {% if Type == "3" -%}
    98 {{ processItems('Items') }}
    89   {% for i in range(feat_tree.CaStorageDbSetting.URLs._value|length) if URLTitle == feat_tree.CaStorageDbSetting.URLs.URLTitle._value[i] -%}
       
    90     INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, COLLECTION_NAME)
       
    91     VALUES ( "url", '{{URLTitle}}',  '{{Collection}}' );
       
    92   {% endfor %}
       
    93 {%- endif %}
       
    94 {% if Type == "2" -%} INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE, ITEM_NAME, ICON_FILENAME, ICON_SKIN_ID, URI, COLLECTION_NAME ) 
       
    95   VALUES ("widget", '{{HomescreenWidget}}', '', '', "{{HomescreenWidget}}", '{{Collection}}' ); {%- endif %}
       
    96 {% endfor %}
       
    97 
    99 
    98 SELECT "castoragedb_variant - END" AS " ";
   100 SELECT "castoragedb_variant - END" AS " ";
    99 SELECT "------------------------------------" AS " ";
   101 SELECT "------------------------------------" AS " ";
   100 
   102