/**
  * Generate a new delivery execution
  *
  * @param core_kernel_classes_Resource $assembly
  * @param string $userUri
  * @return core_kernel_classes_Resource the delivery execution
  */
 public function initDeliveryExecution(core_kernel_classes_Resource $assembly, $userUri)
 {
     $deImplementation = \taoDelivery_models_classes_execution_KVDeliveryExecution::spawn($this->getPersistence(), $userUri, $assembly);
     $deliveryExecution = new DeliveryExecution($deImplementation);
     $this->updateDeliveryExecutionStatus($deliveryExecution, null, InterfaceDeliveryExecution::STATE_ACTIVE);
     return $deliveryExecution;
 }
 /**
  * Generate a new delivery execution
  *
  * @param core_kernel_classes_Resource $assembly
  * @param string $userId
  * @return core_kernel_classes_Resource the delivery execution
  */
 public function initDeliveryExecution(core_kernel_classes_Resource $assembly, $userId)
 {
     $deImplementation = \taoDelivery_models_classes_execution_KVDeliveryExecution::spawn($this->getPersistence(), $userId, $assembly);
     $deliveryExecution = new DeliveryExecutionWrapper($deImplementation);
     $this->updateDeliveryExecutionStatus($deliveryExecution, null, DeliveryExecution::STATE_ACTIVE);
     $this->addDeliveryToUserExecutionList($userId, $assembly->getUri(), $deliveryExecution->getIdentifier());
     return $deliveryExecution;
 }
 /**
  * Update the collection of deliveries
  *
  * @param taoDelivery_models_classes_execution_KVDeliveryExecution $deliveryExecution
  * @param string $old
  * @param string $new
  */
 public function updateDeliveryExecutionStatus(taoDelivery_models_classes_execution_KVDeliveryExecution $deliveryExecution, $old, $new)
 {
     $userId = $deliveryExecution->getUserIdentifier();
     if ($old != null) {
         $oldReferences = $this->getDeliveryExecutionsByStatus($userId, $old);
         foreach (array_keys($oldReferences) as $key) {
             if ($oldReferences[$key]->getIdentifier() == $deliveryExecution->getIdentifier()) {
                 unset($oldReferences[$key]);
             }
         }
         $this->setDeliveryExecutions($userId, $old, $oldReferences);
     }
     $newReferences = $this->getDeliveryExecutionsByStatus($userId, $new);
     $newReferences[] = $deliveryExecution;
     $this->setDeliveryExecutions($userId, $new, $newReferences);
 }