@@ -68,6 +68,9 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
6868 protected SearchBuilder <SnapshotDataStoreVO > searchFilteringStoreIdEqStateEqStoreRoleEqIdEqUpdateCountEqSnapshotIdEqVolumeIdEq ;
6969 private SearchBuilder <SnapshotDataStoreVO > stateSearch ;
7070 private SearchBuilder <SnapshotDataStoreVO > idStateNeqSearch ;
71+
72+ private SearchBuilder <SnapshotDataStoreVO > idStateNinSearch ;
73+ private SearchBuilder <SnapshotDataStoreVO > idEqRoleEqStateInSearch ;
7174 protected SearchBuilder <SnapshotVO > snapshotVOSearch ;
7275 private SearchBuilder <SnapshotDataStoreVO > snapshotCreatedSearch ;
7376 private SearchBuilder <SnapshotDataStoreVO > dataStoreAndInstallPathSearch ;
@@ -151,6 +154,16 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
151154 idStateNeqSearch .and (STATE , idStateNeqSearch .entity ().getState (), SearchCriteria .Op .NEQ );
152155 idStateNeqSearch .done ();
153156
157+ idStateNinSearch = createSearchBuilder ();
158+ idStateNinSearch .and (SNAPSHOT_ID , idStateNinSearch .entity ().getSnapshotId (), SearchCriteria .Op .EQ );
159+ idStateNinSearch .and (STATE , idStateNinSearch .entity ().getState (), SearchCriteria .Op .NOTIN );
160+ idStateNinSearch .done ();
161+
162+ idEqRoleEqStateInSearch = createSearchBuilder ();
163+ idEqRoleEqStateInSearch .and (SNAPSHOT_ID , idEqRoleEqStateInSearch .entity ().getSnapshotId (), SearchCriteria .Op .EQ );
164+ idEqRoleEqStateInSearch .and (STORE_ROLE , idEqRoleEqStateInSearch .entity ().getRole (), SearchCriteria .Op .EQ );
165+ idEqRoleEqStateInSearch .and (STATE , idEqRoleEqStateInSearch .entity ().getState (), SearchCriteria .Op .IN );
166+
154167 snapshotVOSearch = snapshotDao .createSearchBuilder ();
155168 snapshotVOSearch .and (VOLUME_ID , snapshotVOSearch .entity ().getVolumeId (), SearchCriteria .Op .EQ );
156169 snapshotVOSearch .done ();
@@ -387,6 +400,15 @@ public SnapshotDataStoreVO findBySnapshotIdAndDataStoreRoleAndState(long snapsho
387400 return findOneBy (sc );
388401 }
389402
403+ @ Override
404+ public List <SnapshotDataStoreVO > findBySnapshotIdAndDataStoreRoleAndStateIn (long snapshotId , DataStoreRole role , State ... state ) {
405+ SearchCriteria <SnapshotDataStoreVO > sc = idEqRoleEqStateInSearch .create ();
406+ sc .setParameters (SNAPSHOT_ID , snapshotId );
407+ sc .setParameters (STORE_ROLE , role );
408+ sc .setParameters (STATE , (Object [])state );
409+ return listBy (sc );
410+ }
411+
390412 @ Override
391413 public SnapshotDataStoreVO findOneBySnapshotId (long snapshotId , long zoneId ) {
392414 try (TransactionLegacy transactionLegacy = TransactionLegacy .currentTxn ()) {
@@ -488,7 +510,7 @@ public List<SnapshotDataStoreVO> findBySnapshotIdWithNonDestroyedState(long snap
488510
489511 @ Override
490512 public List <SnapshotDataStoreVO > findBySnapshotIdAndNotInDestroyedHiddenState (long snapshotId ) {
491- SearchCriteria <SnapshotDataStoreVO > sc = idStateNeqSearch .create ();
513+ SearchCriteria <SnapshotDataStoreVO > sc = idStateNinSearch .create ();
492514 sc .setParameters (SNAPSHOT_ID , snapshotId );
493515 sc .setParameters (STATE , State .Destroyed .name (), State .Hidden .name ());
494516 return listBy (sc );
0 commit comments