@@ -67,8 +67,8 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
6767 private SearchBuilder <SnapshotDataStoreVO > searchFilteringStoreIdEqStoreRoleEqStateNeqRefCntNeq ;
6868 protected SearchBuilder <SnapshotDataStoreVO > searchFilteringStoreIdEqStateEqStoreRoleEqIdEqUpdateCountEqSnapshotIdEqVolumeIdEq ;
6969 private SearchBuilder <SnapshotDataStoreVO > stateSearch ;
70- private SearchBuilder <SnapshotDataStoreVO > idStateNeqSearch ;
7170 private SearchBuilder <SnapshotDataStoreVO > idStateNinSearch ;
71+ private SearchBuilder <SnapshotDataStoreVO > idEqRoleEqStateInSearch ;
7272 protected SearchBuilder <SnapshotVO > snapshotVOSearch ;
7373 private SearchBuilder <SnapshotDataStoreVO > snapshotCreatedSearch ;
7474 private SearchBuilder <SnapshotDataStoreVO > dataStoreAndInstallPathSearch ;
@@ -147,16 +147,16 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
147147 stateSearch .done ();
148148
149149
150- idStateNeqSearch = createSearchBuilder ();
151- idStateNeqSearch .and (SNAPSHOT_ID , idStateNeqSearch .entity ().getSnapshotId (), SearchCriteria .Op .EQ );
152- idStateNeqSearch .and (STATE , idStateNeqSearch .entity ().getState (), SearchCriteria .Op .NEQ );
153- idStateNeqSearch .done ();
154-
155150 idStateNinSearch = createSearchBuilder ();
156151 idStateNinSearch .and (SNAPSHOT_ID , idStateNinSearch .entity ().getSnapshotId (), SearchCriteria .Op .EQ );
157- idStateNinSearch .and (STATE , idStateNinSearch .entity ().getState (), SearchCriteria .Op .NIN );
152+ idStateNinSearch .and (STATE , idStateNinSearch .entity ().getState (), SearchCriteria .Op .NOTIN );
158153 idStateNinSearch .done ();
159154
155+ idEqRoleEqStateInSearch = createSearchBuilder ();
156+ idEqRoleEqStateInSearch .and (SNAPSHOT_ID , idEqRoleEqStateInSearch .entity ().getSnapshotId (), SearchCriteria .Op .EQ );
157+ idEqRoleEqStateInSearch .and (STORE_ROLE , idEqRoleEqStateInSearch .entity ().getRole (), SearchCriteria .Op .EQ );
158+ idEqRoleEqStateInSearch .and (STATE , idEqRoleEqStateInSearch .entity ().getState (), SearchCriteria .Op .IN );
159+
160160 snapshotVOSearch = snapshotDao .createSearchBuilder ();
161161 snapshotVOSearch .and (VOLUME_ID , snapshotVOSearch .entity ().getVolumeId (), SearchCriteria .Op .EQ );
162162 snapshotVOSearch .done ();
@@ -393,6 +393,15 @@ public SnapshotDataStoreVO findBySnapshotIdAndDataStoreRoleAndState(long snapsho
393393 return findOneBy (sc );
394394 }
395395
396+ @ Override
397+ public List <SnapshotDataStoreVO > listBySnapshotIdAndDataStoreRoleAndStateIn (long snapshotId , DataStoreRole role , State ... state ) {
398+ SearchCriteria <SnapshotDataStoreVO > sc = idEqRoleEqStateInSearch .create ();
399+ sc .setParameters (SNAPSHOT_ID , snapshotId );
400+ sc .setParameters (STORE_ROLE , role );
401+ sc .setParameters (STATE , (Object [])state );
402+ return listBy (sc );
403+ }
404+
396405 @ Override
397406 public SnapshotDataStoreVO findOneBySnapshotId (long snapshotId , long zoneId ) {
398407 try (TransactionLegacy transactionLegacy = TransactionLegacy .currentTxn ()) {
@@ -486,7 +495,7 @@ public List<SnapshotDataStoreVO> findBySnapshotId(long snapshotId) {
486495
487496 @ Override
488497 public List <SnapshotDataStoreVO > findBySnapshotIdWithNonDestroyedState (long snapshotId ) {
489- SearchCriteria <SnapshotDataStoreVO > sc = idStateNeqSearch .create ();
498+ SearchCriteria <SnapshotDataStoreVO > sc = idStateNinSearch .create ();
490499 sc .setParameters (SNAPSHOT_ID , snapshotId );
491500 sc .setParameters (STATE , State .Destroyed .name ());
492501 return listBy (sc );
0 commit comments