SAP Cloud Platform上Fiori launchpad tile的读取原理

版权声明:本文为博主汪子熙原创文章,未经博主允许不得转载。 https://blog.csdn.net/i042416/article/details/89741193

下图是Fiori on HANA HCP的architecture:
我们的Fiori UI不再是存在netweaver的BSP application里,而是存在HCP的cloud repository里了。
Fiori Launchpad及相关配置,按照wiki的介绍,现在tile configuration的内容最终是存放在HANA native的table里,通过XSE暴露的service给client端调用。

clipboard1

XSE的service是通过server side javascript实现的,这些javascript就是前一封邮件里在HANA studio里能找到的那些source code。和我们已经很熟悉的client side javascript相比,这些server side javascript在Chrome的F12里无法看到,也无法在client端debug,因为其是执行在server端的。
如果想要debug,需要用HCP 专门的workbench打开server端的实现,把debugger attach到client端的session上,然后trigger断点。这个debugger功能很弱,比如看不到callstack。一般情况下如果遇到HCP相关的incident,一旦能排除不是我们application的问题,我一般都直接FW到HCP的component让他们去看。

Sent: Tuesday, March 31, 2015 7:02 PM

how the Fiori tile information is retrieved from HANA HCP

Hi colleagues,

After I log on HCP via my own user, I could see many tiles:
https://jerry-xe84733bd.dispatcher.neo.ondemand.com/sap/hana/uis/clients/ushell-app/shells/fiori/FioriLaunchpad.html

clipboard2

I am very curious how and where this tile information is retrieved from HANA cloud.
Here below is my research result.
(1)The tile information is fetched via restful service observed in network tab:

clipboard3

It is a json stream, use list a small part of it here:

{
"ID": "70c4b7f1-5579-4517-bc09-e7231f5add96-1426085327112",
"packageID": "",
"objectName": "",
"type": "chips.tiles.applauncherdynamic.DynamicTile",
"templateProperties": [
{
"key": "navigation_target_url",
"value": "#flp-runApp?html5App=cuscrmopportunity&SAPUI5.Component=cus.crm.opportunity&url=/"
},
{
"key": "formFactor",
"value": "{"desktop":true,"tablet":true,"phone":true}"
},
{
"key": "service_url",
"value": "/sap/opu/odata/sap/CRM_OPPORTUNITY/Opportunities/$count"
},
{
"key": "sap.hana.uis.flp.app.intentSemanticObject",
"value": ""
},
{
"key": "sap.hana.uis.flp.app.intentAction",
"value": ""
},
{
"key": "navigation_component_url",
"value": "/"
},
{
"key": "service_refresh_interval",
"value": "300"
},
{
"key": "navigation_component_name",
"value": "cus.crm.opportunity"
},
{
"key": "allow_unknown_parameters",
"value": "true"
},
{
"key": "tile_size",
"value": "1x1"
},
{
"key": "html5_application_name",
"value": "cuscrmopportunity"
},
{
"key": "sap.hana.uis.flp.app.type",
"value": "SAP_UI5_Component"
},
{
"key": "display_icon_url",
"value": "sap-icon://Fiori2/F0012"
},
{
"key": "display_title_text",
"value": "My Opportunities"
}
]
},

(2) The restful service is implemented via consumption_service, whose source code could be found in HANA studio.

clipboard4

clipboard5

clipboard6

(3) The call will delegate to FIORI_DAO:

clipboard7

clipboard8

(4) FIORI_DAO is a subclass of WORKSPACE_DAO:

clipboard9

And workspace DAO just issue the query to HANA database via call getResultSet():

clipboard10

(5) Finally the HANA procedure GET_APPSITE will be called:

clipboard11

Inside the procedure we can know the tile information in HANA HCP is retrieved based on the union of the two HANA tables below:

clipboard12

Source code for UIS.GET_APPSITE

CREATE PROCEDURE UIS.GET_APPSITE(IN PACKAGE_ID NVARCHAR(256), IN OBJECT_NAME NVARCHAR(256), OUT APPSITE_DATA GET_APPSITE_TABLE_TYPE)
LANGUAGE SQLSCRIPT
SQL SECURITY DEFINER
DEFAULT SCHEMA UIS
READS SQL DATA AS
internal_site_id integer;
ws_count integer;
session_usr varchar(256);
locale nvarchar(256);
BEGIN
internal_site_id := -1;
SELECT count(*) into ws_count FROM "_SYS_RT"."_UIS_APPSITES" WHERE PACKAGE_ID LIKE :package_id AND OBJECT_NAME LIKE :object_name;
IF :ws_count > 0 THEN
SELECT INTERNAL_SITE_ID INTO internal_site_id FROM "_SYS_RT"."_UIS_APPSITES" WHERE PACKAGE_ID LIKE :package_id AND OBJECT_NAME LIKE :object_name;
END IF;
select session_context('LOCALE') INTO locale from SYS.dummy;
session_usr := SESSION_USER;
    APPSITE_DATA =
        SELECT
            site_name,
            site_layout,
            pg_layout_id,
            pg_id,
            pg_name,
            pg_layout,
            wg_layout_id,
            wg_id,
            wg_name,
            src,
            icon,
            type as wg_type,
            key,
            value,
            parent_page_id,
            'site' as record_type
        FROM "UIS"."sap.hana.uis.db::UIS_APPSITES_DATA_VIEW"
        WHERE INTERNAL_SITE_ID = :internal_site_id


        UNION ALL

        select
            NULL as site_name,
            NULL as site_layout,
            NULL as pg_layout_id,
            NULL as pg_id,
            NULL as pg_name,
            NULL as pg_layout,
            NULL as wg_layout_id,
            wg_id,
            NULL as wg_name,
            NULL as src,
            NULL as icon,
            NULL as wg_type,
            key,
            value,
            NULL as parent_page_id,
            'userwidgetprops' as record_type
        FROM "_SYS_RT"."_UIS_USER_WIDGET_PROPERTIES"
        WHERE INTERNAL_SITE_ID like :internal_site_id AND USER_NAME LIKE :session_usr

        UNION ALL

        select
            NULL as site_name,
            NULL as site_layout,
            NULL as pg_layout_id,
            NULL as pg_id,
            NULL as pg_name,
            NULL as pg_layout,
            NULL as wg_layout_id,
            NULL as wg_id,
            NULL as wg_name,
            NULL as src,
            NULL as icon,
            NULL as wg_type,
            text_id as key,
            content as value,
            NULL as parent_page_id,
            'translations' as record_type
            from _SYS_REPO.TEXT_ACCESSOR(:package_id, :object_name, 'xsappsite', :locale);


END;

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

猜你喜欢

转载自blog.csdn.net/i042416/article/details/89741193