2525import org .hibernate .engine .spi .SessionFactoryImplementor ;
2626import org .hibernate .type .StandardBasicTypes ;
2727import org .springframework .beans .factory .annotation .Autowired ;
28+ import org .springframework .security .acls .domain .BasePermission ;
2829import org .springframework .stereotype .Repository ;
2930import org .springframework .util .Assert ;
3031import ubic .gemma .model .common .auditAndSecurity .AuditEvent ;
4344import ubic .gemma .model .genome .sequenceAnalysis .BlatAssociation ;
4445import ubic .gemma .model .genome .sequenceAnalysis .BlatResult ;
4546import ubic .gemma .persistence .service .common .auditAndSecurity .curation .AbstractCuratableDao ;
47+ import ubic .gemma .persistence .service .maintenance .TableMaintenanceUtil ;
4648import ubic .gemma .persistence .util .*;
4749import ubic .gemma .persistence .util .Filter ;
4850
@@ -492,7 +494,7 @@ public long countExpressionExperiments( ArrayDesign arrayDesign ) {
492494 + AclQueryUtils .formAclRestrictionClause ( "ee.id" ) + " "
493495 + "and ad = :ad" )
494496 .setParameter ( "ad" , arrayDesign );
495- AclQueryUtils .addAclParameters ( query , ExpressionExperiment .class );
497+ AclQueryUtils .setAclParameters ( query , ExpressionExperiment .class );
496498 return ( Long ) query .uniqueResult ();
497499 }
498500
@@ -503,7 +505,7 @@ public Map<Taxon, Long> getPerTaxonCount() {
503505 + "join ad.primaryTaxon t "
504506 + AclQueryUtils .formAclRestrictionClause ( "ad.id" ) + " "
505507 + "group by t" );
506- AclQueryUtils .addAclParameters ( query , ArrayDesign .class );
508+ AclQueryUtils .setAclParameters ( query , ArrayDesign .class );
507509 //noinspection unchecked
508510 List <Object []> csList = query .setCacheable ( true ).list ();
509511 return csList .stream ().collect ( Collectors .toMap ( row -> ( Taxon ) row [0 ], row -> ( Long ) row [1 ] ) );
@@ -536,7 +538,7 @@ public long countSwitchedExpressionExperiments( ArrayDesign arrayDesign ) {
536538 + AclQueryUtils .formAclRestrictionClause ( "e.id" ) + " "
537539 + "and b.originalPlatform = :arrayDesign" )
538540 .setParameter ( "arrayDesign" , arrayDesign );
539- AclQueryUtils .addAclParameters ( query , ExpressionExperiment .class );
541+ AclQueryUtils .setAclParameters ( query , ExpressionExperiment .class );
540542 return ( Long ) query
541543 .setCacheable ( true )
542544 .uniqueResult ();
@@ -1059,7 +1061,7 @@ private Query finishFilteringQuery( String queryString, @Nullable Filters filter
10591061
10601062 Query query = this .getSessionFactory ().getCurrentSession ().createQuery ( queryString );
10611063
1062- AclQueryUtils .addAclParameters ( query , ArrayDesign .class );
1064+ AclQueryUtils .setAclParameters ( query , ArrayDesign .class );
10631065 FilterQueryUtils .addRestrictionParameters ( query , filters );
10641066
10651067 return query ;
@@ -1136,10 +1138,12 @@ private void populateBlacklisted( Collection<ArrayDesignValueObject> vos ) {
11361138 private void populateExpressionExperimentCount ( Collection <ArrayDesignValueObject > entities ) {
11371139 Query query = this .getSessionFactory ().getCurrentSession ()
11381140 .createSQLQuery ( "select ee2ad.ARRAY_DESIGN_FK as ID, count(distinct ee2ad.EXPRESSION_EXPERIMENT_FK) as EE_COUNT from EXPRESSION_EXPERIMENT2ARRAY_DESIGN ee2ad "
1139- + EE2CAclQueryUtils .formNativeAclJoinClause ( "ee2ad.EXPRESSION_EXPERIMENT_FK" ) + " "
1141+ + AclDenormalizedTableQueryUtils .formNativeAclJoinClause ( "ee2ad.EXPRESSION_EXPERIMENT_FK" , "IS_AUTHENTICATED_ANONYMOUSLY " ) + " "
11401142 + "where ee2ad.ARRAY_DESIGN_FK in :ids "
11411143 + "and not ee2ad.IS_ORIGINAL_PLATFORM"
1142- + EE2CAclQueryUtils .formNativeAclRestrictionClause ( ( SessionFactoryImplementor ) getSessionFactory (), "ee2ad.ACL_IS_AUTHENTICATED_ANONYMOUSLY_MASK" )
1144+ + AclDenormalizedTableQueryUtils .formNativeAclRestrictionClause ( ( SessionFactoryImplementor ) getSessionFactory (),
1145+ "IS_AUTHENTICATED_ANONYMOUSLY" , "ee2ad." + TableMaintenanceUtil .EE2AD_IS_AUTHENTICATED_ANONYMOUSLY_MASK_COLUMN ,
1146+ BasePermission .READ )
11431147 + formNativeNonTroubledClause ( "ee2ad.EXPRESSION_EXPERIMENT_FK" , ExpressionExperiment .class )
11441148 + " group by ee2ad.ARRAY_DESIGN_FK" )
11451149 .addScalar ( "ID" , StandardBasicTypes .LONG )
@@ -1150,7 +1154,7 @@ private void populateExpressionExperimentCount( Collection<ArrayDesignValueObjec
11501154 .addSynchronizedEntityClass ( ExpressionExperiment .class )
11511155 .addSynchronizedEntityClass ( ArrayDesign .class )
11521156 .setCacheable ( true );
1153- EE2CAclQueryUtils . addAclParameters ( query , ExpressionExperiment .class );
1157+ AclDenormalizedTableQueryUtils . setAclParameters ( query , "IS_AUTHENTICATED_ANONYMOUSLY" , ExpressionExperiment .class );
11541158 Map <Long , Long > countById = QueryUtils .<Long , Object []>streamByBatch ( query , "ids" , IdentifiableUtils .getIds ( entities ), 2048 )
11551159 .collect ( Collectors .toMap ( o -> ( Long ) o [0 ], o -> ( Long ) o [1 ] ) );
11561160 for ( ArrayDesignValueObject vo : entities ) {
@@ -1162,12 +1166,14 @@ private void populateExpressionExperimentCount( Collection<ArrayDesignValueObjec
11621166 private void populateSwitchedExpressionExperimentCount ( Collection <ArrayDesignValueObject > entities ) {
11631167 Query query = this .getSessionFactory ().getCurrentSession ()
11641168 .createSQLQuery ( "select ee2ad.ARRAY_DESIGN_FK as ID, count(distinct ee2ad.EXPRESSION_EXPERIMENT_FK) as EE_COUNT from EXPRESSION_EXPERIMENT2ARRAY_DESIGN ee2ad "
1165- + EE2CAclQueryUtils .formNativeAclJoinClause ( "ee2ad.EXPRESSION_EXPERIMENT_FK" ) + " "
1169+ + AclDenormalizedTableQueryUtils .formNativeAclJoinClause ( "ee2ad.EXPRESSION_EXPERIMENT_FK" , "IS_AUTHENTICATED_ANONYMOUSLY " ) + " "
11661170 + "where ee2ad.ARRAY_DESIGN_FK in :ids "
11671171 + "and ee2ad.IS_ORIGINAL_PLATFORM "
11681172 // ignore noop switches
11691173 + "and ee2ad.ARRAY_DESIGN_FK not in (select ARRAY_DESIGN_FK from EXPRESSION_EXPERIMENT2ARRAY_DESIGN where EXPRESSION_EXPERIMENT_FK = ee2ad.EXPRESSION_EXPERIMENT_FK and ARRAY_DESIGN_FK = ee2ad.ARRAY_DESIGN_FK and not IS_ORIGINAL_PLATFORM)"
1170- + EE2CAclQueryUtils .formNativeAclRestrictionClause ( ( SessionFactoryImplementor ) getSessionFactory (), "ee2ad.ACL_IS_AUTHENTICATED_ANONYMOUSLY_MASK" )
1174+ + AclDenormalizedTableQueryUtils .formNativeAclRestrictionClause ( ( SessionFactoryImplementor ) getSessionFactory (),
1175+ "IS_AUTHENTICATED_ANONYMOUSLY" , "ee2ad." + TableMaintenanceUtil .EE2AD_IS_AUTHENTICATED_ANONYMOUSLY_MASK_COLUMN ,
1176+ BasePermission .READ )
11711177 + formNativeNonTroubledClause ( "ee2ad.EXPRESSION_EXPERIMENT_FK" , ExpressionExperiment .class )
11721178 + " group by ee2ad.ARRAY_DESIGN_FK" )
11731179 .addScalar ( "ID" , StandardBasicTypes .LONG )
@@ -1178,7 +1184,7 @@ private void populateSwitchedExpressionExperimentCount( Collection<ArrayDesignVa
11781184 .addSynchronizedEntityClass ( ExpressionExperiment .class )
11791185 .addSynchronizedEntityClass ( ArrayDesign .class )
11801186 .setCacheable ( true );
1181- EE2CAclQueryUtils . addAclParameters ( query , ExpressionExperiment .class );
1187+ AclDenormalizedTableQueryUtils . setAclParameters ( query , "IS_AUTHENTICATED_ANONYMOUSLY" , ExpressionExperiment .class );
11821188 Map <Long , Long > switchedCountById = QueryUtils .<Long , Object []>streamByBatch ( query , "ids" , IdentifiableUtils .getIds ( entities ), 2048 )
11831189 .collect ( Collectors .toMap ( row -> ( Long ) row [0 ], row -> ( Long ) row [1 ] ) );
11841190 for ( ArrayDesignValueObject vo : entities ) {
0 commit comments