Esempio n. 1
0
 public virtual void CheckDeleteHistoricBatch(HistoricBatchEntity batch)
 {
     if (batch != null && !TenantManager.IsAuthenticatedTenant(batch.TenantId))
     {
         throw Log.ExceptionCommandWithUnauthorizedTenant("delete historic batch '" + batch.Id + "'");
     }
 }
Esempio n. 2
0
	  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);
        }
Esempio n. 4
0
            public Void execute(CommandContext commandContext)
            {
                HistoricBatchEntity historicBatchEntity = (HistoricBatchEntity)outerInstance.historyService.createHistoricBatchQuery().singleResult();

                commandContext.DbEntityManager.delete(historicBatchEntity);

                return(null);
            }
Esempio n. 5
0
        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));
            }
        }
Esempio n. 6
0
            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);
            }
Esempio n. 7
0
        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);
                    }
                }
            }
        }
Esempio n. 8
0
 protected internal virtual bool isEnded(HistoricBatchEntity instance)
 {
     return(instance.EndTime != null);
 }
Esempio n. 9
0
 protected internal virtual bool hasBaseTime(HistoricBatchEntity instance, CommandContext commandContext)
 {
     return(isStrategyStart(commandContext) || (isStrategyEnd(commandContext) && isEnded(instance)));
 }
Esempio n. 10
0
 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);
     }
 }
Esempio n. 11
0
 protected internal virtual DateTime calculateRemovalTime(HistoricBatchEntity batch, CommandContext commandContext)
 {
     return(commandContext.ProcessEngineConfiguration.HistoryRemovalTimeProvider.calculateRemovalTime(batch));
 }
Esempio n. 12
0
 public virtual void CheckDeleteHistoricBatch(HistoricBatchEntity batch)
 {
     AuthorizationManager.CheckAuthorization(Permissions.DeleteHistory, Resources.Batch, batch.Id);
 }
Esempio n. 13
0
	  protected internal virtual bool isBatchRunning(HistoricBatchEntity historicBatch)
	  {
		return historicBatch.EndTime == null;
	  }
Esempio n. 14
0
	  protected internal virtual bool isBatchEnded(HistoricBatchEntity historicBatch)
	  {
		return historicBatch.EndTime != null;
	  }