public virtual void CheckDeleteHistoricBatch(HistoricBatchEntity batch) { if (batch != null && !TenantManager.IsAuthenticatedTenant(batch.TenantId)) { throw Log.ExceptionCommandWithUnauthorizedTenant("delete historic batch '" + batch.Id + "'"); } }
public virtual DateTime calculateRemovalTime(HistoricBatchEntity historicBatch) { string batchOperation = historicBatch.Type; if (!string.ReferenceEquals(batchOperation, null)) { int? historyTimeToLive = getTTLByBatchOperation(batchOperation); if (historyTimeToLive != null) { if (isBatchRunning(historicBatch)) { DateTime startTime = historicBatch.StartTime; return determineRemovalTime(startTime, historyTimeToLive); } else if (isBatchEnded(historicBatch)) { DateTime endTime = historicBatch.EndTime; return determineRemovalTime(endTime, historyTimeToLive); } } } return null; }
protected internal virtual HistoryEvent CreateBatchEvent(BatchEntity batch, HistoryEventTypes eventType) { HistoricBatchEntity @event = new HistoricBatchEntity(); @event.Id = batch.Id; @event.Type = batch.Type; @event.TotalJobs = batch.TotalJobs; @event.BatchJobsPerSeed = batch.BatchJobsPerSeed; @event.InvocationsPerBatchJob = batch.InvocationsPerBatchJob; @event.SeedJobDefinitionId = batch.SeedJobDefinitionId; @event.MonitorJobDefinitionId = batch.MonitorJobDefinitionId; @event.BatchJobDefinitionId = batch.BatchJobDefinitionId; @event.TenantId = batch.TenantId; @event.EventType = eventType.EventName; if (HistoryEventTypes.BatchStart.Equals(eventType)) { @event.StartTime = ClockUtil.CurrentTime; } if (HistoryEventTypes.BatchEnd.Equals(eventType)) { @event.EndTime = ClockUtil.CurrentTime; } return(@event); }
public Void execute(CommandContext commandContext) { HistoricBatchEntity historicBatchEntity = (HistoricBatchEntity)outerInstance.historyService.createHistoricBatchQuery().singleResult(); commandContext.DbEntityManager.delete(historicBatchEntity); return(null); }
protected internal override HistoricBatchEntity loadBatchEntity(BatchEntity batch) { string batchId = batch.Id; HistoricBatchEntity cachedEntity = findInCache(typeof(HistoricBatchEntity), batchId); if (cachedEntity != null) { return(cachedEntity); } else { return(newBatchEventEntity(batch)); } }
public Void execute(CommandContext commandContext) { HistoricBatchManager historicBatchManager = commandContext.HistoricBatchManager; IList <string> ids = historicBatchManager.findHistoricBatchIdsForCleanup(7, batchOperationsMap, 0, 59); assertEquals(3, ids.Count); HistoricBatchEntity instance0 = historicBatchManager.findHistoricBatchById(ids[0]); HistoricBatchEntity instance1 = historicBatchManager.findHistoricBatchById(ids[1]); HistoricBatchEntity instance2 = historicBatchManager.findHistoricBatchById(ids[2]); assertTrue(instance0.EndTime < instance1.EndTime); assertTrue(instance1.EndTime < instance2.EndTime); return(null); }
public virtual void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { string byteArrayId = configuration.ConfigurationByteArrayId; sbyte[] configurationByteArray = findByteArrayById(byteArrayId, commandContext).Bytes; SetRemovalTimeBatchConfiguration batchConfiguration = readConfiguration(configurationByteArray); foreach (string instanceId in batchConfiguration.Ids) { HistoricBatchEntity instance = findBatchById(instanceId, commandContext); if (instance != null) { DateTime removalTime = getOrCalculateRemovalTime(batchConfiguration, instance, commandContext); if (removalTime != instance.RemovalTime) { addRemovalTime(instanceId, removalTime, commandContext); } } } }
protected internal virtual bool isEnded(HistoricBatchEntity instance) { return(instance.EndTime != null); }
protected internal virtual bool hasBaseTime(HistoricBatchEntity instance, CommandContext commandContext) { return(isStrategyStart(commandContext) || (isStrategyEnd(commandContext) && isEnded(instance))); }
protected internal virtual DateTime getOrCalculateRemovalTime(SetRemovalTimeBatchConfiguration batchConfiguration, HistoricBatchEntity instance, CommandContext commandContext) { if (batchConfiguration.hasRemovalTime()) { return(batchConfiguration.RemovalTime); } else if (hasBaseTime(instance, commandContext)) { return(calculateRemovalTime(instance, commandContext)); } else { return(null); } }
protected internal virtual DateTime calculateRemovalTime(HistoricBatchEntity batch, CommandContext commandContext) { return(commandContext.ProcessEngineConfiguration.HistoryRemovalTimeProvider.calculateRemovalTime(batch)); }
public virtual void CheckDeleteHistoricBatch(HistoricBatchEntity batch) { AuthorizationManager.CheckAuthorization(Permissions.DeleteHistory, Resources.Batch, batch.Id); }
protected internal virtual bool isBatchRunning(HistoricBatchEntity historicBatch) { return historicBatch.EndTime == null; }
protected internal virtual bool isBatchEnded(HistoricBatchEntity historicBatch) { return historicBatch.EndTime != null; }