@Override protected void scripts() { // in case 'recover api' called for an incomplete image sql(ImageBackupStorageRefVO.class).eq(ImageBackupStorageRefVO_.imageUuid, self.getUuid()).hardDelete(); sql(ImageVO.class).eq(ImageVO_.uuid, self.getUuid()).hardDelete(); } }.execute();
private void handle(APIRemovePolicyStatementsFromRoleMsg msg) { SQL.New(RolePolicyStatementVO.class).eq(RolePolicyStatementVO_.roleUuid, self.getUuid()) .in(RolePolicyStatementVO_.uuid, msg.getPolicyStatementUuids()).hardDelete(); bus.publish(new APIRemovePolicyStatementsFromRoleEvent(msg.getId())); }
@Override public void success() { List<Tuple> eips = findEipTuplesOnVmNic(nic);; if (eips == null || eips.isEmpty()) { completion.success(); } else { for (Tuple eipTuple : eips) { VirtualRouterEipRefVO ref = Q.New(VirtualRouterEipRefVO.class) .eq(VirtualRouterEipRefVO_.eipUuid, eipTuple.get(5, String.class)) .eq(VirtualRouterEipRefVO_.virtualRouterVmUuid, nic.getVmInstanceUuid()) .find(); if (ref != null) { dbf.remove(ref); UpdateQuery q = UpdateQuery.New(EipVO.class); q.condAnd(EipVO_.uuid, Op.EQ, eipTuple.get(5, String.class)); q.set(EipVO_.vmNicUuid, null); q.set(EipVO_.guestIp, null); q.update(); } } completion.success(); } }
@Override protected void scripts() { List<DiskOfferingInventory> diskOfferingInventories = action.getParentIssuerContext(); sql(VolumeVO.class).set(VolumeVO_.diskOfferingUuid, null) .in(VolumeVO_.uuid, diskOfferingInventories.stream().map(DiskOfferingInventory::getUuid).collect(Collectors.toList())) .update(); } }.execute();
private void eliminateErrors() { String time = ElaborateGlobalConfig.ELIMILATE_TIME.value(); long count = Q.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).lt(ElaborationVO_.lastOpDate, new Timestamp(new Date().getTime() - TimeUtils.parseTimeInMillis(time))).count(); if (count > 0) { logger.debug(String.format("clean [%s] records which are not matched error code in db", count)); UpdateQuery.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).lt(ElaborationVO_.lastOpDate, new Timestamp(new Date().getTime() - TimeUtils.parseTimeInMillis(time))).delete(); } }
@Override protected void scripts() { if (!q(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).isExists()) { return; } List<String> treeUuids = q(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.treeUuid).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).listValues(); sql(VolumeSnapshotTreeVO.class).in(VolumeSnapshotTreeVO_.uuid, treeUuids).delete(); sql(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).delete(); } }.execute();
@Override public void run() { Long finalExtendPeriod = CaptchaGlobalConfig.CAPTCHA_VALID_PERIOD.value(Long.class); Timestamp expiredDate = new Timestamp(getCurrentSqlDate().getTime() - TimeUnit.SECONDS.toMillis(finalExtendPeriod)); SQL.New(CaptchaVO.class).lt(CaptchaVO_.createDate, expiredDate).delete(); }
public static UpdateQuery New(Class entityClass) { return UpdateQuery.New(entityClass); }
@Override protected void scripts() { List<String> huuids = Q.New(HostVO.class).select(HostVO_.uuid) .eq(HostVO_.clusterUuid, clusterUuid) .listValues(); SQL.New(PrimaryStorageHostRefVO.class) .eq(PrimaryStorageHostRefVO_.primaryStorageUuid, inventory.getUuid()) .in(PrimaryStorageHostRefVO_.hostUuid, huuids) .hardDelete(); } }.execute();
if (inv.getType().equals(VolumeType.Root.toString())) { spec.setDestRootVolume(inv); UpdateQuery.New(VmInstanceVO.class) .isNull(VmInstanceVO_.rootVolumeUuid) .set(VmInstanceVO_.rootVolumeUuid, inv.getUuid()) .condAnd(VmInstanceVO_.uuid, Op.EQ, spec.getVmInventory().getUuid()) .update(); } else { spec.getDestDataVolumes().add(inv);
private void handle(APIUpdateNotificationsStatusMsg msg) { APIUpdateNotificationsStatusEvent evt = new APIUpdateNotificationsStatusEvent(msg.getId()); SQL.New(NotificationVO.class).set(NotificationVO_.status, NotificationStatus.valueOf(msg.getStatus())) .in(NotificationVO_.uuid, msg.getUuids()).update(); bus.publish(evt); }