@Override public void updateVolumeIds(long oldVolId, long newVolId) { SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create(); sc.setParameters("volumeId", oldVolId); SnapshotVO snapshot = createForUpdate(); snapshot.setVolumeId(newVolId); UpdateBuilder ub = getUpdateBuilder(snapshot); update(ub, sc, null); }
@Override public List<SnapshotVO> listByVolumeId(long volumeId) { return listByVolumeId(null, volumeId); }
@Override public List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version) { return listByVolumeIdVersion(null, volumeId, version); }
@Override public List<SnapshotVO> listByVolumeId(Filter filter, long volumeId) { SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create(); sc.setParameters("volumeId", volumeId); return listBy(sc, filter); }
@Override public List<SnapshotVO> listByVolumeIdIncludingRemoved(long volumeId) { SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create(); sc.setParameters("volumeId", volumeId); return listIncludingRemovedBy(sc, null); }
@Override public Long countSnapshotsForAccount(long accountId) { SearchCriteria<Long> sc = CountSnapshotsByAccount.create(); sc.setParameters("account", accountId); sc.setParameters("status", State.Error, State.Destroyed); return customSearch(sc, null).get(0); }
@Override @DB public boolean remove(Long id) { TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); SnapshotVO entry = findById(id); if (entry != null) { _tagsDao.removeByIdAndType(id, ResourceObjectType.Snapshot); } boolean result = super.remove(id); txn.commit(); return result; }
@PostConstruct protected void init() { VolumeIdSearch = createSearchBuilder(); VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdSearch.done(); VolumeIdTypeSearch = createSearchBuilder(); VolumeIdTypeSearch.and("volumeId", VolumeIdTypeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdTypeSearch.and("type", VolumeIdTypeSearch.entity().getsnapshotType(), SearchCriteria.Op.EQ); VolumeIdTypeSearch.done(); VolumeIdTypeNotDestroyedSearch = createSearchBuilder(); VolumeIdTypeNotDestroyedSearch.and("volumeId", VolumeIdTypeNotDestroyedSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdTypeNotDestroyedSearch.and("type", VolumeIdTypeNotDestroyedSearch.entity().getsnapshotType(), SearchCriteria.Op.EQ); VolumeIdVersionSearch = createSearchBuilder(); VolumeIdVersionSearch.and("volumeId", VolumeIdVersionSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdVersionSearch.and("version", VolumeIdVersionSearch.entity().getVersion(), SearchCriteria.Op.EQ); VolumeIdVersionSearch.done(); AccountIdSearch = createSearchBuilder(); AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ); AccountIdSearch.done(); StatusSearch = createSearchBuilder(); StatusSearch.and("volumeId", StatusSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); StatusSearch.and("status", StatusSearch.entity().getState(), SearchCriteria.Op.IN); StatusSearch.done(); notInStatusSearch = createSearchBuilder();
@Override public List<SnapshotVO> listAllByStatus(Snapshot.State... status) { SearchCriteria<SnapshotVO> sc = StatusSearch.create(); sc.setParameters("status", (Object[])status); return listBy(sc, null); }
public List<SnapshotVO> listByVolumeIdVersion(Filter filter, long volumeId, String version) { SearchCriteria<SnapshotVO> sc = VolumeIdVersionSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("version", version); return listBy(sc, filter); }
@Override public List<SnapshotVO> listByStatus(long volumeId, Snapshot.State... status) { SearchCriteria<SnapshotVO> sc = StatusSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("status", (Object[])status); return listBy(sc, null); }
@Override public List<SnapshotVO> listByStatusNotIn(long volumeId, Snapshot.State... status) { SearchCriteria<SnapshotVO> sc = this.notInStatusSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("status", (Object[]) status); return listBy(sc, null); } }
public List<SnapshotVO> listByVolumeIdType(Filter filter, long volumeId, Type type) { SearchCriteria<SnapshotVO> sc = VolumeIdTypeSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("type", type.ordinal()); return listBy(sc, filter); }
@Override public List<SnapshotVO> listByInstanceId(long instanceId, Snapshot.State... status) { SearchCriteria<SnapshotVO> sc = InstanceIdSearch.create(); if (status != null && status.length != 0) { sc.setParameters("status", (Object[])status); } sc.setJoinParameters("instanceSnapshots", "state", Volume.State.Ready); sc.setJoinParameters("instanceVolumes", "instanceId", instanceId); return listBy(sc, null); }
@Override public List<SnapshotVO> listByVolumeIdTypeNotDestroyed(long volumeId, Type type) { SearchCriteria<SnapshotVO> sc = VolumeIdTypeNotDestroyedSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("type", type.ordinal()); sc.setParameters("status", State.Destroyed); return listBy(sc, null); }