Application Onboarding page changes
[portal.git] / ecomp-portal-BE-common / src / main / webapp / WEB-INF / fusion / orm / EP.hbm.xml
index becfe7c..e03c976 100644 (file)
 <!-- Publishes mappings and queries specific to the ONAP Portal application. -->
 <hibernate-mapping package="org.onap.portalapp.portal.domain">
 
+       <!-- multilanguage -->
+       <class name="Language" table="fn_language">
+               <id name="languageId" column="language_id">
+                       <generator class="native">
+                               <param name="sequence"></param>
+                       </generator>
+               </id>
+               <property name="languageName" column="language_name" />
+               <property name="languageAlias" column="language_alias" />
+       </class>
+       
+       <class name="DisplayText" table="fn_display_text">
+               <id name="id" column="id">
+                       <generator class="native">
+                               <param name="sequence"></param>
+                       </generator>
+               </id>
+               
+               <property name="languageId" column="language_id" />
+               <property name="textId" column="text_id" />
+               <property name="label" column="text_label" />
+       </class>
+
        <!-- Widget class mapping details -->
        <class name="Widget" table="FN_WIDGET">
                <id name="id" column="WIDGET_ID">
                <property name="createdId" column="created_id" />
                <property name="modifiedId" column="modified_id" />
                <property name="timeZoneId" column="timezone" />
+               <property name="systemUser" column="is_system_user" type="yes_no"/>
+               <property name="languageId" column="language_id" />
 
                <set name="EPUserApps" table="FN_USER_ROLE" lazy="false" sort="natural"
                        inverse="true">
                        <key-many-to-one name="role"
                                class="org.onap.portalapp.portal.domain.EPRole" column="role_id" />
                </composite-id>
-               <property name="priority" type="java.lang.Short">
-                       <column name="priority" precision="4" scale="0" />
+               <property name="priority">
+                       <column name="priority" default="1" precision="4" scale="0" />
                </property>
        </class>
 
                </many-to-one>
        </class>
 
+       <!-- multilanguage -->
+       <query name="queryLanguage">
+               <![CDATA[
+                       from Language
+               ]]>
+       </query>
+       
+       <query name="displayText">
+               <![CDATA[
+                       from DisplayText where languageId = :language_id
+               ]]>
+       </query>
+       
+       <query name="queryLanguageByLanguageId">
+               <![CDATA[
+                       from Language where languageId = :language_id
+               ]]>
+       </query>
+
        <!-- show the current user plus related users -->
        <sql-query name="relatedUsers">
                <return-scalar column="org_user_id" type="java.lang.String" />
@@ -1117,7 +1161,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y
        <sql-query name="getAppsAdmins">
                <return alias="adminUserApp" class="org.onap.portalapp.portal.domain.AdminUserApp" />   
        <![CDATA[
-       SELECT apps.APP_NAME, apps.APP_ID, user.USER_ID, user.FIRST_NAME, user.LAST_NAME, user.org_user_id FROM fn_user_role userrole INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID INNER JOIN fn_app apps ON apps.APP_ID = userrole.APP_ID  WHERE user.active_yn='Y' AND userrole.ROLE_ID = :accountAdminRoleId AND (apps.ENABLED = 'Y' OR apps.APP_ID=1)      
+       SELECT apps.APP_NAME, apps.APP_ID, user.USER_ID, user.FIRST_NAME, user.LAST_NAME, user.org_user_id FROM fn_user_role userrole INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID INNER JOIN fn_app apps ON apps.APP_ID = userrole.APP_ID  WHERE user.active_yn='Y' AND userrole.ROLE_ID = :accountAdminRoleId       
        ]]>
        </sql-query>
        
@@ -1306,9 +1350,12 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y
           where a.user_id =:userId  and b.app_id = c.app_id and a.app_id = c.role_app_id and b.enabled = 'Y' and c.role_id = d.role_id and d.active_yn='Y' and a.role_id = d.role_id and e.app_id = c.app_id
                        ) A 
                left outer join
-                       (select  distinct
-                       c.AFFECTED_RECORD_ID, c.AUDIT_DATE 
-                       from FN_AUDIT_LOG c
+                       (select  FN_AUDIT_LOG.AFFECTED_RECORD_ID, max(FN_AUDIT_LOG.AUDIT_DATE) AS AUDIT_DATE 
+                       from FN_APP LEFT JOIN FN_AUDIT_LOG 
+                       on FN_APP.APP_ID = FN_AUDIT_LOG.AFFECTED_RECORD_ID  
+                       where FN_APP.ENABLED = 'Y' and FN_AUDIT_LOG.user_id=:userId
+                       and (audit_date) BETWEEN (CURDATE() - INTERVAL 90 DAY) and CURDATE() 
+                       group by  FN_AUDIT_LOG.AFFECTED_RECORD_ID
                         )B
                        on A.app_id = B.Affected_record_id
                        order by AUDIT_DATE DESC;
@@ -1349,9 +1396,12 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y
                        
                        ) A 
                left outer join
-                       (select  distinct
-                       c.AFFECTED_RECORD_ID, c.AUDIT_DATE 
-                       from FN_AUDIT_LOG c
+                       (select  FN_AUDIT_LOG.AFFECTED_RECORD_ID, max(FN_AUDIT_LOG.AUDIT_DATE) AS AUDIT_DATE 
+                       from FN_APP LEFT JOIN FN_AUDIT_LOG 
+                       on FN_APP.APP_ID = FN_AUDIT_LOG.AFFECTED_RECORD_ID  
+                       where FN_APP.ENABLED = 'Y' and FN_AUDIT_LOG.user_id=:userId
+                       and (audit_date) BETWEEN (CURDATE() - INTERVAL 90 DAY) and CURDATE() 
+                       group by  FN_AUDIT_LOG.AFFECTED_RECORD_ID 
                         )B
                        on A.app_id = B.Affected_record_id
                        order by AUDIT_DATE DESC;
@@ -1941,7 +1991,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y
                        class="org.onap.portalapp.portal.transport.EPUserAppCurrentRoles" />
                        <![CDATA[
                        
-                       select distinct fu.role_id, fr.user_id, fu.role_name, fu.priority from fn_role fu left outer join fn_user_role fr ON fu.role_id = fr.role_id and fu.app_id = fr.app_id and fr.role_id != 999 where fu.app_id =:appId and fr.user_id =:userId
+                       select distinct fu.role_id, fr.user_id, fu.role_name, fu.priority from fn_role fu left outer join fn_user_role fr ON fu.role_id = fr.role_id and fu.app_id = fr.app_id and fr.role_id != 999 where fu.app_id =:appId and fr.user_id =:userId and fu.active_yn='Y' 
                        ;               
                        ]]>
        </sql-query>
@@ -2072,6 +2122,51 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y
                        ]]>
        </sql-query>
        
+       <sql-query name="getRoleFunctionsOfUserforAlltheApplications">
+                       <![CDATA[
+                       select distinct ep.function_cd from fn_user_role fu, ep_app_role_function ep, ep_app_function ea
+                       where fu.role_id = ep.role_id 
+                       and fu.app_id = ep.app_id
+                       and fu.user_id =:userId 
+                       and ea.function_cd = ep.function_cd
+                       and exists
+                       (
+                       select fa.app_id from fn_user fu, fn_user_role ur, fn_app fa where fu.user_id =:userId and fu.user_id = ur.user_id
+                       and ur.app_id = fa.app_id and fa.enabled = 'Y'
+                       );
+                       ]]>
+       </sql-query>
+       
+       <sql-query name="getApplicationsofTheUserwithAdminAndRoleAdmin">
+       <return alias="getApplicationsofTheUserwithAdminAndRoleAdmin" class="org.onap.portalapp.portal.domain.AppIdAndNameTransportModel" />
+                       <![CDATA[
+                       SELECT app.APP_ID, app.APP_NAME, app.APP_TYPE FROM FN_APP app 
+                       inner join FN_USER_ROLE userrole ON userrole.APP_ID=app.APP_ID 
+                       where userrole.USER_ID = :userId AND userrole.ROLE_ID=999 AND (app.ENABLED = 'Y' OR app.APP_ID=1)
+                       UNION
+                       SELECT DISTINCT app.APP_ID, app.app_name, app.APP_TYPE FROM fn_user user 
+                                       INNER JOIN fn_user_role user_role ON user.USER_ID = user_role.USER_ID 
+                                        INNER JOIN fn_role role ON role.ROLE_ID = user_role.ROLE_ID  
+                       INNER JOIN fn_app app ON app.app_id= user_role.app_id and (app.enabled='Y'  or app.app_id=1) 
+                       INNER JOIN ep_app_role_function appfunction ON  appfunction.app_id = app.app_id and appfunction.role_id=role.ROLE_ID and (appfunction.function_cd like '%APPROVER%')
+                       WHERE user.user_id = :userId ;
+                       ]]>
+       </sql-query>
+       
+       <sql-query name="getApplicationsofTheUserContainsApprover">
+       <return alias="getApplicationsofTheUserContainsApprover" class="org.onap.portalapp.portal.domain.AppIdAndNameTransportModel" />
+                       <![CDATA[
+                       SELECT DISTINCT app.APP_ID, app.APP_TYPE, app.app_name FROM fn_user user 
+                                       INNER JOIN fn_user_role user_role ON user.USER_ID = user_role.USER_ID 
+                                        INNER JOIN fn_role role ON role.ROLE_ID = user_role.ROLE_ID  
+                       INNER JOIN fn_app app ON app.app_id= user_role.app_id and (app.enabled='Y'  or app.app_id=1) 
+                       INNER JOIN ep_app_role_function appfunction ON  appfunction.app_id = app.app_id and appfunction.role_id=role.ROLE_ID and (appfunction.function_cd like '%APPROVER%')
+                       WHERE user.user_id = :userId ;
+                       ]]>
+       </sql-query>
+       
+       
+       
        <sql-query name="getUserRolesForLeftMenu">
                        <return alias="getUserRolesListForLeftMenu" class="org.onap.portalapp.portal.domain.UserRole" />
        
@@ -2408,5 +2503,82 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y
                order by role_id;
                ]]>
        </sql-query>
+       <sql-query name="getAprroverRoleFunctionsOfUser">
+               <![CDATA[
+               select distinct ep.function_cd from fn_user_role fu, ep_app_role_function ep, ep_app_function ea
+               where fu.role_id = ep.role_id
+               and fu.app_id = ep.app_id
+               and fu.user_id =:userId
+               and ea.function_cd = ep.function_cd and ea.function_cd like 'approver|%'
+               and exists
+               (
+               select fa.app_id from fn_user fu, fn_user_role ur, fn_app fa where fu.user_id =:userId and fu.user_id = ur.user_id
+               and ur.app_id = fa.app_id and fa.enabled = 'Y'
+               );
+               ]]>
+</sql-query>
+<sql-query name="getUserApproverRoles">
+               <![CDATA[
+               select distinct fr.role_name from fn_user_role fu, ep_app_role_function ep, ep_app_function ea, fn_role fr
+               where fu.role_id = ep.role_id
+               and fu.app_id = ep.app_id
+               and fu.user_id = :userId
+               and fu.role_id = fr.role_id and fr.active_yn='Y'
+               and ea.function_cd = ep.function_cd and ea.function_cd like 'approver|%'
+               and exists
+               (
+               select fa.app_id from fn_user fu, fn_user_role ur, fn_app fa where fu.user_id =:userId and fu.user_id = ur.user_id
+               and ur.app_id = fa.app_id and fa.enabled = 'Y'
+               );
+               ]]>
+</sql-query>
+<sql-query name="getAdminAppsForTheUser">
+               <![CDATA[
+               select fa.app_id  from fn_user_role ur,fn_app fa where ur.user_id =:userId and ur.app_id=fa.app_id and ur.role_id= 999 and (fa.enabled = 'Y' || fa.app_id=1)
+
+       
+               ]]>
+</sql-query>
+
+
+<sql-query name="getUserRoleOnUserIdAndAppId"> 
+               <return alias="getUserRoleOnUserIdAndAppId" class="org.onap.portalapp.portal.domain.EPRole" />          
+               <![CDATA[
+               
+               select fr.role_id , fr.role_name ,fr.active_yn, fr.priority, fr.app_id, fr.app_role_id  FROM fn_role fr, fn_user_role fur WHERE fr.role_id = fur.role_id AND fur.user_id= :userId AND fur.app_id = :appId AND fr.active_yn='Y'
+               
+               ]]>
+       </sql-query>
        
+       <sql-query name="getAllAdminAppsofTheUser">
+               <![CDATA[
+               select fa.app_id  from fn_user_role ur,fn_app fa where ur.user_id =:userId and ur.app_id=fa.app_id and ur.role_id= 999
+
+               ]]>
+    </sql-query>
+       <sql-query name="getAllAppsFunctionsOfUser">
+                       <![CDATA[
+                       select distinct ep.function_cd from fn_user_role fu, ep_app_role_function ep, ep_app_function ea, fn_app fa , fn_role fr
+                       where fu.role_id = ep.role_id 
+                       and fu.app_id = ep.app_id
+                       and fu.user_id =:userId
+                       and ea.function_cd = ep.function_cd
+            and ((fu.app_id = fa.app_id  and fa.enabled = 'Y' ) or (fa.app_id = 1))
+            and fr.role_id = fu.role_id and fr.active_yn='Y' 
+                   union
+            select distinct app_r_f.function_cd from ep_app_role_function app_r_f, ep_app_function a_f
+                       where role_id = 999
+                       and app_r_f.function_cd = a_f.function_cd
+                       and exists
+                       (
+                       select fa.app_id from fn_user fu, fn_user_role ur, fn_app fa where fu.user_id =:userId and fu.user_id = ur.user_id
+                       and ur.role_id = 999 and ur.app_id = fa.app_id and fa.enabled = 'Y'
+                       );
+                       ]]>
+       </sql-query>
+       <sql-query name="updateFnUser">
+               <![CDATA[
+                       UPDATE fn_user fu SET fu.language_id=:language_id WHERE fu.login_id=:login_id
+               ]]>
+       </sql-query>
 </hibernate-mapping>