菜单权限 - 基于应用存在

应用场景

  • 判断当前环境是否存在某个应用决定是否呈现菜单

样例代码

    1. 替换样例代码中的
      • appId - 应用ID
        import java.util.ArrayList;
        import java.util.Collection;
        import java.util.List;
        import org.joget.apps.app.model.AppDefinition;
        import org.joget.apps.app.service.AppService;
        import org.joget.apps.app.service.AppUtil;
         
            private List getPublishedApps(){
                AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
                Collection appCollection = appService.getPublishedApps(null);
                
                List list = new ArrayList(appCollection);
                
                return list;
            }
            
            private boolean authenticate(List publishedAppsList,String appId){
                AppDefinition appDefinition = null;
                for(int i = 0;i < publishedAppsList.size();i++){
                    appDefinition = (AppDefinition) publishedAppsList.get(i);
                    if(appId.equals(appDefinition.getAppId())){
                        return true;
                    }
                }
                
                return false;
            }
            
            public boolean run(){
                String appId = "dashboard";//判断是否有已发布ID为dashboard的应用
                List publishedAppsList = getPublishedApps();
                boolean result = authenticate(publishedAppsList, appId);
                
                return result;
            }
            
            run();
        
        

Create by Sean Fung on 2016-05-27 14:16:50.0
Last updated by Sean Fung on 2016-05-27 14:16:50.0