public static org.quartz.JobDetail convertJobToNativeObject(Job spagobiJob) {
    org.quartz.JobDetail quartzJob;

    quartzJob = new org.quartz.JobDetail();
    quartzJob.setName(spagobiJob.getName());
    quartzJob.setGroup(spagobiJob.getGroupName());
    quartzJob.setDescription(spagobiJob.getDescription());
    quartzJob.setJobClass(spagobiJob.getJobClass());
    quartzJob.setDurability(spagobiJob.isDurable());
    quartzJob.setRequestsRecovery(spagobiJob.isRequestsRecovery());
    quartzJob.setVolatility(spagobiJob.isVolatile());

    JobDataMap parameters = convertParametersToNativeObject(spagobiJob.getParameters());
    quartzJob.setJobDataMap(parameters);

    return quartzJob;
  }
  public Object serialize(Object o, Locale locale) throws SerializationException {
    StringBuffer result = null;

    if (!(o instanceof Job)) {
      throw new SerializationException(
          "JobXMLSerializer is unable to serialize object of type: " + o.getClass().getName());
    }

    try {
      Job job = (Job) o;
      result = new StringBuffer();

      String jobName = job.getName();
      String jobGroupName = job.getGroupName();
      String jobDescription = job.getDescription();
      String jobClassName = job.getJobClass().getName();
      String jobDurability = job.isDurable() ? "true" : "false";
      String jobRequestRecovery = job.isRequestsRecovery() ? "true" : "false";
      String jobVolatility = job.isVolatile() ? "true" : "false";
      Map<String, String> parameters = job.getParameters();

      boolean isForServiceConsumer =
          "service".equalsIgnoreCase(properties.getProperty(PROPERTY_CONSUMER));

      String rootTag = "ROW";
      if (isForServiceConsumer) rootTag = "JOB_DETAIL";

      result.append("<" + rootTag + " ");
      result.append(" " + JOB_NAME + "=\"" + (jobName != null ? jobName : "") + "\"");
      result.append(" " + JOB_GROUP + "=\"" + (jobGroupName != null ? jobGroupName : "") + "\"");
      result.append(
          " " + JOB_DESCRIPTION + "=\"" + (jobDescription != null ? jobDescription : "") + "\"");
      result.append(" " + JOB_CLASS + "=\"" + (jobClassName != null ? jobClassName : "") + "\"");
      result.append(" " + JOB_DURABILITY + "=\"" + jobDurability + "\"");
      result.append(" " + JOB_REQUEST_RECOVERY + "=\"" + jobRequestRecovery + "\"");
      result.append(" " + USE_VOLATILITY + "=\"" + jobVolatility + "\"");
      if (isForServiceConsumer) {
        result.append(">");
        result.append("<JOB_PARAMETERS>");

        Set<String> keys = parameters.keySet();
        for (String key : keys) {
          result.append("<JOB_PARAMETER ");

          String value = parameters.get(key);
          if (value == null) {
            logger.warn("Job parameter [" + key + "] has no value");
            continue;
          }
          result.append(" name=\"" + key + "\"");
          result.append(" value=\"" + value + "\"");
          result.append(" />");
        }

        result.append("</JOB_PARAMETERS>");
        result.append("</JOB_DETAIL>");
      } else {
        result.append(" />");
      }

    } catch (Throwable t) {
      throw new SerializationException("An error occurred while serializing object: " + o, t);
    } finally {

    }

    return result.toString();
  }