Search in sources :

Example 6 with DbEntityManager

use of org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager in project camunda-bpm-platform by camunda.

the class HistoricDetailVariableInstanceUpdateEntity method delete.

@Override
public void delete() {
    DbEntityManager dbEntityManger = Context.getCommandContext().getDbEntityManager();
    dbEntityManger.delete(this);
    byteArrayField.deleteByteArrayValue();
}
Also used : DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)

Example 7 with DbEntityManager

use of org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager in project camunda-bpm-platform by camunda.

the class GetAttachmentContentCmd method execute.

public InputStream execute(CommandContext commandContext) {
    DbEntityManager dbEntityManger = commandContext.getDbEntityManager();
    AttachmentEntity attachment = dbEntityManger.selectById(AttachmentEntity.class, attachmentId);
    String contentId = attachment.getContentId();
    if (contentId == null) {
        return null;
    }
    ByteArrayEntity byteArray = dbEntityManger.selectById(ByteArrayEntity.class, contentId);
    byte[] bytes = byteArray.getBytes();
    return new ByteArrayInputStream(bytes);
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) ByteArrayInputStream(java.io.ByteArrayInputStream) AttachmentEntity(org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity) DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)

Example 8 with DbEntityManager

use of org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager in project camunda-bpm-platform by camunda.

the class DbHistoryEventHandler method insertOrUpdate.

/**
 * general history event insert behavior
 */
protected void insertOrUpdate(HistoryEvent historyEvent) {
    final DbEntityManager dbEntityManager = getDbEntityManager();
    if (isInitialEvent(historyEvent)) {
        dbEntityManager.insert(historyEvent);
    } else {
        if (dbEntityManager.getCachedEntity(historyEvent.getClass(), historyEvent.getId()) == null) {
            if (historyEvent instanceof HistoricScopeInstanceEvent) {
                // if this is a scope, get start time from existing event in DB
                HistoricScopeInstanceEvent existingEvent = (HistoricScopeInstanceEvent) dbEntityManager.selectById(historyEvent.getClass(), historyEvent.getId());
                if (existingEvent != null) {
                    HistoricScopeInstanceEvent historicScopeInstanceEvent = (HistoricScopeInstanceEvent) historyEvent;
                    historicScopeInstanceEvent.setStartTime(existingEvent.getStartTime());
                }
            }
            if (historyEvent.getId() == null) {
            // dbSqlSession.insert(historyEvent);
            } else {
                dbEntityManager.merge(historyEvent);
            }
        }
    }
}
Also used : DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager) HistoricScopeInstanceEvent(org.camunda.bpm.engine.impl.history.event.HistoricScopeInstanceEvent)

Example 9 with DbEntityManager

use of org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager in project camunda-bpm-platform by camunda.

the class TaskEntity method update.

public void update() {
    ensureTenantIdNotChanged();
    registerCommandContextCloseListener();
    CommandContext commandContext = Context.getCommandContext();
    DbEntityManager dbEntityManger = commandContext.getDbEntityManager();
    dbEntityManger.merge(this);
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)

Example 10 with DbEntityManager

use of org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager in project camunda-bpm-platform by camunda.

the class AcquireJobCmdUnitTest method initCommand.

@Before
public void initCommand() {
    JobExecutor jobExecutor = mock(JobExecutor.class);
    when(jobExecutor.getMaxJobsPerAcquisition()).thenReturn(3);
    when(jobExecutor.getLockOwner()).thenReturn("test");
    when(jobExecutor.getLockTimeInMillis()).thenReturn(5 * 60 * 1000);
    acquireJobsCmd = new AcquireJobsCmd(jobExecutor);
    commandContext = mock(CommandContext.class);
    DbEntityManager dbEntityManager = mock(DbEntityManager.class);
    when(commandContext.getDbEntityManager()).thenReturn(dbEntityManager);
    jobManager = mock(JobManager.class);
    when(commandContext.getJobManager()).thenReturn(jobManager);
}
Also used : AcquireJobsCmd(org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager) Before(org.junit.Before)

Aggregations

DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)11 ByteArrayEntity (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)3 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)2 AttachmentEntity (org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashMap (java.util.HashMap)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)1 AcquireJobsCmd (org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd)1 CoreVariableInstance (org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance)1 DbEntity (org.camunda.bpm.engine.impl.db.DbEntity)1 ListQueryParameterObject (org.camunda.bpm.engine.impl.db.ListQueryParameterObject)1 DbBulkOperation (org.camunda.bpm.engine.impl.db.entitymanager.operation.DbBulkOperation)1 HistoricScopeInstanceEvent (org.camunda.bpm.engine.impl.history.event.HistoricScopeInstanceEvent)1 JobExecutor (org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)1 DatabasePurgeReport (org.camunda.bpm.engine.impl.management.DatabasePurgeReport)1 AuthorizationEntity (org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity)1 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1 HistoricVariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity)1 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)1