public static List < Dashboard > findSharedDashboardsMeta ( EntityManager em , PrincipalUser owner , Integer limit , String version ) { requireArgument ( em != null , "Entity manager can not be null." ) ; try { CriteriaBuilder cb = em . getCriteriaBuilder ( ) ; CriteriaQuery < Tuple > cq = cb . createTupleQuery ( ) ; Root < Dashboard > e = cq . from ( Dashboard . class ) ; List < Selection < ? > > fieldsToSelect = new ArrayList <> ( ) ; for ( Field field : FieldUtils . getFieldsListWithAnnotation ( Dashboard . class , Metadata . class ) ) { fieldsToSelect . add ( e . get ( field . getName ( ) ) . alias ( field . getName ( ) ) ) ; } cq . multiselect ( fieldsToSelect ) ; if ( owner != null ) { cq . where ( cb . equal ( e . get ( "shared" ) , true ) , cb . equal ( e . get ( "owner" ) , owner ) , version == null ? cb . isNull ( e . get ( "version" ) ) : cb . equal ( e . get ( "version" ) , version ) ) ; } else { cq . where ( cb . equal ( e . get ( "shared" ) , true ) , version == null ? cb . isNull ( e . get ( "version" ) ) : cb . equal ( e . get ( "version" ) , version ) ) ; } return _readDashboards ( em , cq , limit ) ; } catch ( NoResultException ex ) { return new ArrayList <> ( 0 ) ; } }
Gets all meta information of shared dashboards with filtering .