content: /*
   * Copyright 2017-2025 Hyland Software, Inc. and its affiliates.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.activiti.cloud.services.events.converter;
  
  import org.activiti.api.task.runtime.events.TaskActivatedEvent;
  import org.activiti.api.task.runtime.events.TaskAssignedEvent;
  import org.activiti.api.task.runtime.events.TaskCancelledEvent;
  import org.activiti.api.task.runtime.events.TaskCandidateGroupAddedEvent;
  import org.activiti.api.task.runtime.events.TaskCandidateGroupRemovedEvent;
  import org.activiti.api.task.runtime.events.TaskCandidateUserAddedEvent;
  import org.activiti.api.task.runtime.events.TaskCandidateUserRemovedEvent;
  import org.activiti.api.task.runtime.events.TaskCompletedEvent;
  import org.activiti.api.task.runtime.events.TaskCreatedEvent;
  import org.activiti.api.task.runtime.events.TaskSuspendedEvent;
  import org.activiti.api.task.runtime.events.TaskUpdatedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskActivatedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskAssignedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskCancelledEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskCandidateGroupAddedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskCandidateGroupRemovedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskCandidateUserAddedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskCandidateUserRemovedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskCompletedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskCreatedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskSuspendedEvent;
  import org.activiti.cloud.api.task.model.events.CloudTaskUpdatedEvent;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskActivatedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskAssignedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskCancelledEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateGroupAddedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateGroupRemovedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserAddedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserRemovedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskCompletedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskSuspendedEventImpl;
  import org.activiti.cloud.api.task.model.impl.events.CloudTaskUpdatedEventImpl;
  
  public class ToCloudTaskRuntimeEventConverter {
  
      private final RuntimeBundleInfoAppender runtimeBundleInfoAppender;
  
      private final TaskAuditServiceInfoAppender auditServiceInfoAppender;
  
      public ToCloudTaskRuntimeEventConverter(
          RuntimeBundleInfoAppender runtimeBundleInfoAppender,
          TaskAuditServiceInfoAppender auditServiceInfoAppender
      ) {
          this.runtimeBundleInfoAppender = runtimeBundleInfoAppender;
          this.auditServiceInfoAppender = auditServiceInfoAppender;
      }
  
      public CloudTaskCreatedEvent from(TaskCreatedEvent event) {
          CloudTaskCreatedEventImpl cloudEvent = new CloudTaskCreatedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskUpdatedEvent from(TaskUpdatedEvent event) {
          CloudTaskUpdatedEventImpl cloudEvent = new CloudTaskUpdatedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskAssignedEvent from(TaskAssignedEvent event) {
          CloudTaskAssignedEventImpl cloudEvent = new CloudTaskAssignedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskCompletedEvent from(TaskCompletedEvent event) {
          CloudTaskCompletedEventImpl cloudEvent = new CloudTaskCompletedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          this.auditServiceInfoAppender.appendAuditServiceInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskCancelledEvent from(TaskCancelledEvent event) {
          CloudTaskCancelledEventImpl cloudEvent = new CloudTaskCancelledEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskSuspendedEvent from(TaskSuspendedEvent event) {
          CloudTaskSuspendedEventImpl cloudEvent = new CloudTaskSuspendedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskActivatedEvent from(TaskActivatedEvent event) {
          CloudTaskActivatedEventImpl cloudEvent = new CloudTaskActivatedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskCandidateUserAddedEvent from(TaskCandidateUserAddedEvent event) {
          CloudTaskCandidateUserAddedEventImpl cloudEvent = new CloudTaskCandidateUserAddedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskCandidateUserRemovedEvent from(TaskCandidateUserRemovedEvent event) {
          CloudTaskCandidateUserRemovedEventImpl cloudEvent = new CloudTaskCandidateUserRemovedEventImpl(
              event.getEntity()
          );
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskCandidateGroupAddedEvent from(TaskCandidateGroupAddedEvent event) {
          CloudTaskCandidateGroupAddedEventImpl cloudEvent = new CloudTaskCandidateGroupAddedEventImpl(event.getEntity());
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  
      public CloudTaskCandidateGroupRemovedEvent from(TaskCandidateGroupRemovedEvent event) {
          CloudTaskCandidateGroupRemovedEventImpl cloudEvent = new CloudTaskCandidateGroupRemovedEventImpl(
              event.getEntity()
          );
          runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
          return cloudEvent;
      }
  }
  