code: public static InternalEvent createActivityNotifyMessage(ActivityInstance ai,
              Integer eventType, String masterRequestId, String compCode) {
          InternalEvent event = new InternalEvent();
          event.workId = ai.getActivityId();
          event.transitionInstanceId = null;
          event.eventType = eventType;
          event.ownerType = OwnerType.PROCESS_INSTANCE;
          event.ownerId = ai.getProcessInstanceId();
          event.masterRequestId = masterRequestId;
          event.workInstanceId = ai.getId();
          event.completionCode = compCode;
          return event;
      }
docs: create activity FINISH, ABORT, RESUME, CORRECT, ERROR and any event type that can be specified in
  designer configuration for events.
  
  @param ai
  @param eventType
  @param masterRequestId
  @param compCode
  @return