@Override public List<ProcessReference> pendingTasks() { final List<ProcessReference> result = new ArrayList<>(); create() .select(PROCESS_INSTANCE.ID, PROCESS_INSTANCE.PROCESS_NAME, PROCESS_INSTANCE.RESOURCE_TYPE, PROCESS_INSTANCE.RESOURCE_ID, PROCESS_INSTANCE.ACCOUNT_ID, PROCESS_INSTANCE.CLUSTER_ID) .from(PROCESS_INSTANCE) .where(PROCESS_INSTANCE.END_TIME.isNull() .and(PROCESS_INSTANCE.RUN_AFTER.isNull().or(PROCESS_INSTANCE.RUN_AFTER.le(new Date())))) .limit(BATCH.get()) .fetchInto((RecordHandler<Record6<Long, String, String, String, Long, Long>>) record -> { ProcessReference ref = new ProcessReference( record.getValue(PROCESS_INSTANCE.ID), record.getValue(PROCESS_INSTANCE.PROCESS_NAME), record.getValue(PROCESS_INSTANCE.RESOURCE_TYPE), record.getValue(PROCESS_INSTANCE.RESOURCE_ID), record.getValue(PROCESS_INSTANCE.ACCOUNT_ID), record.getValue(PROCESS_INSTANCE.CLUSTER_ID)); result.add(ref); }); return result; }
@Override public Map<Long, Collection<MountEntry>> getMountsForInstances(List<Long> ids, final IdFormatter idF) { ListValuedMap<Long, MountEntry> result = new ArrayListValuedHashMap<>(); create().select(INSTANCE.NAME, VOLUME.NAME, VOLUME.ID, MOUNT.PERMISSIONS, MOUNT.PATH, MOUNT.INSTANCE_ID) .from(MOUNT) .join(VOLUME) .on(VOLUME.ID.eq(MOUNT.VOLUME_ID)) .join(INSTANCE) .on(INSTANCE.ID.eq(MOUNT.INSTANCE_ID)) .where(MOUNT.REMOVED.isNull() .and(VOLUME.REMOVED.isNull()) .and(MOUNT.INSTANCE_ID.in(ids))) .fetchInto((RecordHandler<Record6<String, String, Long, String, String, Long>>) record -> { Long instanceId = record.getValue(MOUNT.INSTANCE_ID); MountEntry mount = new MountEntry(); mount.setInstanceName(record.getValue(INSTANCE.NAME)); mount.setInstanceId(idF.formatId(InstanceConstants.TYPE, instanceId)); mount.setPath(record.getValue(MOUNT.PATH)); mount.setPermission(record.getValue(MOUNT.PERMISSIONS)); mount.setVolumeId(idF.formatId(VolumeConstants.TYPE, record.getValue(VOLUME.ID))); mount.setVolumeName(record.getValue(VOLUME.NAME)); result.put(instanceId, mount); }); return result.asMap(); }
@Override public Map<Long, Collection<MountEntry>> getMountsForVolumes(List<Long> ids, final IdFormatter idF) { ListValuedMap<Long, MountEntry> result = new ArrayListValuedHashMap<>(); create().select(VOLUME.NAME, MOUNT.PERMISSIONS, MOUNT.PATH, MOUNT.INSTANCE_ID, MOUNT.VOLUME_ID, INSTANCE.NAME) .from(MOUNT) .join(INSTANCE) .on(INSTANCE.ID.eq(MOUNT.INSTANCE_ID)) .join(VOLUME) .on(VOLUME.ID.eq(MOUNT.VOLUME_ID)) .where(INSTANCE.REMOVED.isNull() .and(VOLUME.REMOVED.isNull()) .and(MOUNT.VOLUME_ID.in(ids))) .fetchInto((RecordHandler<Record6<String, String, String, Long, Long, String>>) record -> { Long volumeId = record.getValue(MOUNT.VOLUME_ID); MountEntry mount = new MountEntry(); mount.setInstanceName(record.getValue(INSTANCE.NAME)); mount.setInstanceId(idF.formatId(InstanceConstants.TYPE, record.getValue(MOUNT.INSTANCE_ID))); mount.setPath(record.getValue(MOUNT.PATH)); mount.setPermission(record.getValue(MOUNT.PERMISSIONS)); mount.setVolumeId(idF.formatId(VolumeConstants.TYPE, volumeId)); mount.setVolumeName(record.getValue(VOLUME.NAME)); result.put(volumeId, mount); }); return result.asMap(); }