}
CommandContext commandContext = Context.getCommandContext();
ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();
DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
DbEntityManager dbEntityManager = commandContext.getDbEntityManager();
for (ProcessDefinitionEntity processDefinition : processDefinitions) {
if (deployment.isNew()) {
ProcessDefinitionEntity latestProcessDefinition = processDefinitionManager.findLatestProcessDefinitionByKey(processDefinition.getKey());
processDefinition.setDeploymentId(deployment.getId());
processDefinition.setVersion(getVersionForNewProcessDefinition(deployment, processDefinition, latestProcessDefinition));
processDefinition.setId(getProcessDefinitionId(deployment, processDefinition));
List<JobDeclaration<?>> declarations = jobDeclarations.get(processDefinition.getKey());
updateJobDeclarations(declarations, processDefinition, deployment.isNew());
adjustStartEventSubscriptions(processDefinition, latestProcessDefinition);
dbEntityManager.insert(processDefinition);
deploymentCache.addProcessDefinition(processDefinition);
addAuthorizations(processDefinition);
} else {