예제 #1
1
  public static final void current(IData pipeline) throws ServiceException {
    // --- <<IS-START(current)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [o] field:0:required $thread
    IDataCursor cursor = pipeline.getCursor();

    try {
      Thread thread = Thread.currentThread();
      String description =
          thread.getClass().getName() + " ID#" + thread.getId() + " " + thread.getName();
      IDataUtil.put(cursor, "$thread", description);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #2
0
  public static final void validate(IData pipeline) throws ServiceException {
    // --- <<IS-START(validate)>> ---
    // @sigtype java 3.5
    // [i] field:0:required $datetime
    // [i] field:0:optional $pattern
    // {&quot;date.jdbc&quot;,&quot;date.xml&quot;,&quot;datetime.jdbc&quot;,&quot;datetime.xml&quot;,&quot;datetime.xcbl&quot;,&quot;datetime.sapiens&quot;,&quot;datetime.epoch.milliseconds&quot;,&quot;time.jdbc&quot;,&quot;time.xml&quot;}
    // [i] field:0:optional $raise? {&quot;false&quot;,&quot;true&quot;}
    // [o] field:0:required $valid?
    IDataCursor cursor = pipeline.getCursor();

    boolean valid = true, raise = false;
    try {
      String datetime = IDataUtil.getString(cursor, "$datetime");
      String pattern = IDataUtil.getString(cursor, "$pattern");
      raise = Boolean.parseBoolean(IDataUtil.getString(cursor, "$raise?"));

      // attempt to parse the datetime string, if no exception is thrown then the string is valid
      parse(datetime, pattern);
    } catch (IllegalArgumentException ex) {
      if (raise) tundra.exception.raise(ex);
      valid = false;
    } finally {
      IDataUtil.put(cursor, "$valid?", "" + valid);
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #3
0
  public static final void write(IData pipeline) throws ServiceException {
    // --- <<IS-START(write)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $file
    // [i] field:0:optional $mode {&quot;append&quot;,&quot;write&quot;}
    // [i] object:0:optional $content
    // [i] field:0:optional $encoding
    // [o] field:0:optional $file
    IDataCursor cursor = pipeline.getCursor();

    try {
      String file = IDataUtil.getString(cursor, "$file");
      String mode = IDataUtil.getString(cursor, "$mode");
      Object content = IDataUtil.get(cursor, "$content");
      String encoding = IDataUtil.getString(cursor, "$encoding");

      file = write(file, mode, content, encoding);

      IDataUtil.put(cursor, "$file", file);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #4
0
  public static final void process(IData pipeline) throws ServiceException {
    // --- <<IS-START(process)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:required $file
    // [i] field:0:optional $mode {&quot;read&quot;,&quot;append&quot;,&quot;write&quot;}
    // [i] field:0:required $service
    // [i] record:0:optional $pipeline
    // [i] field:0:optional $service.input
    // [o] record:0:optional $pipeline
    IDataCursor cursor = pipeline.getCursor();

    try {
      String file = IDataUtil.getString(cursor, "$file");
      String mode = IDataUtil.getString(cursor, "$mode");
      String service = IDataUtil.getString(cursor, "$service");
      String input = IDataUtil.getString(cursor, "$service.input");
      IData scope = IDataUtil.getIData(cursor, "$pipeline");
      boolean scoped = scope != null;

      scope = process(file, mode, service, input, scoped ? scope : pipeline);

      if (scoped) IDataUtil.put(cursor, "$pipeline", scope);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #5
0
  public static final void getTimeZoneOffsetFromGMT(IData pipeline) throws ServiceException {
    // --- <<IS-START(getTimeZoneOffsetFromGMT)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:required inTimeZone
    // [o] field:0:required outOffset

    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String inTimeZone = IDataUtil.getString(pipelineCursor, "inTimeZone");
    pipelineCursor.destroy();

    java.util.TimeZone inTZ = java.util.TimeZone.getTimeZone(inTimeZone);
    java.util.Calendar inCalendar = new java.util.GregorianCalendar(inTZ);
    int offset =
        inCalendar.get(java.util.Calendar.ZONE_OFFSET)
            + inCalendar.get(java.util.Calendar.DST_OFFSET);

    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    IDataUtil.put(pipelineCursor_1, "outOffset", String.valueOf(offset));
    pipelineCursor_1.destroy();
    // --- <<IS-END>> ---

  }
예제 #6
0
  public static final void get(IData pipeline) throws ServiceException {
    // --- <<IS-START(get)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] record:0:optional $bizdoc
    // [i] - field:0:required InternalID
    // [i] field:0:optional $part
    // [o] object:0:optional $content
    // [o] field:0:optional $content.type
    IDataCursor cursor = pipeline.getCursor();

    try {
      IData bizdoc = IDataUtil.getIData(cursor, "$bizdoc");
      String partName = IDataUtil.getString(cursor, "$part");

      if (bizdoc != null) {
        ContentPart part = new ContentPart(bizdoc, partName);
        java.io.InputStream content = part.getContent();

        if (content != null) {
          IDataUtil.put(cursor, "$content", content);
          IDataUtil.put(cursor, "$content.type", part.getMimeType());
        }
      }
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #7
0
  public static final void compare(IData pipeline) throws ServiceException {
    // --- <<IS-START(compare)>> ---
    // @sigtype java 3.5
    // [i] field:0:optional $datetime.x
    // [i] field:0:optional $datetime.y
    // [o] field:0:required $before?
    // [o] field:0:required $equal?
    // [o] field:0:required $after?
    IDataCursor cursor = pipeline.getCursor();

    try {
      String dx = IDataUtil.getString(cursor, "$datetime.x");
      String dy = IDataUtil.getString(cursor, "$datetime.y");

      int comparison = compare(dx, dy);

      IDataUtil.put(cursor, "$before?", "" + (comparison < 0));
      IDataUtil.put(cursor, "$equal?", "" + (comparison == 0));
      IDataUtil.put(cursor, "$after?", "" + (comparison > 0));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #8
0
  public static final void format(IData pipeline) throws ServiceException {
    // --- <<IS-START(format)>> ---
    // @sigtype java 3.5
    // [i] field:0:optional $datetime
    // [i] field:0:optional $pattern.input
    // {&quot;datetime&quot;,&quot;date&quot;,&quot;time&quot;,&quot;milliseconds&quot;}
    // [i] field:0:optional $pattern.output
    // {&quot;datetime&quot;,&quot;date&quot;,&quot;time&quot;,&quot;milliseconds&quot;}
    // [o] field:0:optional $datetime
    IDataCursor cursor = pipeline.getCursor();

    try {
      String datetime = IDataUtil.getString(cursor, "$datetime");
      String inPattern = IDataUtil.getString(cursor, "$pattern.input");
      String outPattern = IDataUtil.getString(cursor, "$pattern.output");

      datetime = format(datetime, inPattern, outPattern);

      if (datetime != null) IDataUtil.put(cursor, "$datetime", datetime);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #9
0
파일: gzip.java 프로젝트: Permafrost/Tundra
  public static final void decompress(IData pipeline) throws ServiceException {
    // --- <<IS-START(decompress)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] object:0:optional $content.gzip
    // [i] field:0:optional $encoding
    // [i] field:0:optional $mode
    // {&quot;stream&quot;,&quot;bytes&quot;,&quot;string&quot;,&quot;base64&quot;}
    // [o] object:0:optional $content
    IDataCursor cursor = pipeline.getCursor();

    try {
      Object input = IDataUtil.get(cursor, "$content.gzip");
      Charset charset = CharsetHelper.normalize(IDataUtil.getString(cursor, "$encoding"));
      ObjectConvertMode mode = ObjectConvertMode.normalize(IDataUtil.getString(cursor, "$mode"));

      Object output =
          ObjectHelper.convert(
              GzipHelper.decompress(InputStreamHelper.normalize(input, charset)), charset, mode);

      if (output != null) IDataUtil.put(cursor, "$content", output);
    } catch (IOException ex) {
      ExceptionHelper.raise(ex);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #10
0
  public static final void clear(IData pipeline) throws ServiceException {
    // --- <<IS-START(clear)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    IDataCursor cursor = pipeline.getCursor();

    try {
      String[] keys = IDataUtil.getStringArray(cursor, "$preserve");
      tundra.document.clear(pipeline, keys);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #11
0
  public static final void capture(IData pipeline) throws ServiceException {
    // --- <<IS-START(capture)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [o] record:0:required $pipeline
    IDataCursor cursor = pipeline.getCursor();

    try {
      IDataUtil.put(cursor, "$pipeline", IDataUtil.clone(pipeline));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #12
0
  public static final void merge(IData pipeline) throws ServiceException {
    // --- <<IS-START(merge)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] record:0:optional $document
    IDataCursor cursor = pipeline.getCursor();

    try {
      merge(pipeline, IDataUtil.getIData(cursor, "$document"));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #13
0
  public static final void length(IData pipeline) throws ServiceException {
    // --- <<IS-START(length)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [o] field:0:required $length
    IDataCursor cursor = pipeline.getCursor();

    try {
      IDataUtil.put(cursor, "$length", "" + tundra.document.size(pipeline));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #14
0
파일: step.java 프로젝트: Permafrost/Tundra
  public static final void unreached(IData pipeline) throws ServiceException {
    // --- <<IS-START(unreached)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $message
    IDataCursor cursor = pipeline.getCursor();
    try {
      String message = IDataUtil.getString(cursor, "$message");
      unreached(message);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #15
0
  public static final void create(IData pipeline) throws ServiceException {
    // --- <<IS-START(create)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:required $file
    IDataCursor cursor = pipeline.getCursor();

    try {
      create(IDataUtil.getString(cursor, "$file"));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #16
0
  public static final void now(IData pipeline) throws ServiceException {
    // --- <<IS-START(now)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [o] field:0:required $datetime
    IDataCursor cursor = pipeline.getCursor();

    try {
      IDataUtil.put(cursor, "$datetime", now());
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #17
0
  public static final void drop(IData pipeline) throws ServiceException {
    // --- <<IS-START(drop)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $key
    IDataCursor cursor = pipeline.getCursor();

    try {
      String key = IDataUtil.getString(cursor, "$key");
      tundra.document.drop(pipeline, key);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #18
0
 protected IData extractIData(IData data, String key, boolean mandatory, IData defaultValue)
     throws ServiceOutputException {
   IDataCursor cur = data.getCursor();
   try {
     IData result = IDataUtil.getIData(cur, key);
     if (result == null) {
       result = defaultValue;
     }
     if (mandatory && result == null) {
       throw new ServiceOutputException(this, String.format("missing required IData in %s", key));
     }
     return result;
   } finally {
     cur.destroy();
   }
 }
예제 #19
0
  public static final void substitute(IData pipeline) throws ServiceException {
    // --- <<IS-START(substitute)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    IDataCursor cursor = pipeline.getCursor();

    try {
      IData dup = tundra.document.substitute(pipeline, pipeline, true);
      tundra.document.clear(pipeline, null);
      IDataUtil.merge(dup, pipeline);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #20
0
  public static final void length(IData pipeline) throws ServiceException {
    // --- <<IS-START(length)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:required $file
    // [o] field:0:required $length
    IDataCursor cursor = pipeline.getCursor();

    try {
      String file = IDataUtil.getString(cursor, "$file");
      IDataUtil.put(cursor, "$length", "" + length(file));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #21
0
  public static final void get(IData pipeline) throws ServiceException {
    // --- <<IS-START(get)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $key
    // [o] object:0:optional $value
    IDataCursor cursor = pipeline.getCursor();

    try {
      String key = IDataUtil.getString(cursor, "$key");
      IDataUtil.put(cursor, "$value", tundra.support.document.get(pipeline, key));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #22
0
  public static final void normalize(IData pipeline) throws ServiceException {
    // --- <<IS-START(normalize)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:required $file
    // [o] field:0:required $file
    IDataCursor cursor = pipeline.getCursor();

    try {
      IDataUtil.put(
          cursor, "$file", tundra.support.file.normalize(IDataUtil.getString(cursor, "$file")));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #23
0
  public static final void copy(IData pipeline) throws ServiceException {
    // --- <<IS-START(copy)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:required $key.source
    // [i] field:0:required $key.target
    IDataCursor cursor = pipeline.getCursor();

    try {
      String source = IDataUtil.getString(cursor, "$key.source");
      String target = IDataUtil.getString(cursor, "$key.target");
      tundra.document.copy(pipeline, source, target);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #24
0
  public static final void add(IData pipeline) throws ServiceException {
    // --- <<IS-START(add)>> ---
    // @sigtype java 3.5
    // [i] field:0:optional $datetime
    // [i] field:0:optional $duration
    // [o] field:0:optional $datetime
    IDataCursor cursor = pipeline.getCursor();

    try {
      String datetime = IDataUtil.getString(cursor, "$datetime");
      String duration = IDataUtil.getString(cursor, "$duration");
      IDataUtil.put(cursor, "$datetime", add(datetime, duration));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #25
0
  public static final void rename(IData pipeline) throws ServiceException {
    // --- <<IS-START(rename)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:required $file.source
    // [i] field:0:required $file.target
    IDataCursor cursor = pipeline.getCursor();

    try {
      String source = IDataUtil.getString(cursor, "$file.source");
      String target = IDataUtil.getString(cursor, "$file.target");
      rename(source, target);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #26
0
  public static final void epochToDateString(IData pipeline) throws ServiceException {
    // --- <<IS-START(epochToDateString)>> ---
    // @sigtype java 3.5
    // [i] object:0:required epochTime
    // [o] field:0:required dateString
    IDataCursor pipelineCursor = pipeline.getCursor();
    Long myTimeAsLong = (Long) IDataUtil.get(pipelineCursor, "epochTime");

    Date date = new Date(myTimeAsLong);
    DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
    String dateString = format.format(date);

    IDataUtil.put(pipelineCursor, "dateString", dateString);

    pipelineCursor.destroy();
    // --- <<IS-END>> ---

  }
예제 #27
0
  public static final void remove(IData pipeline) throws ServiceException {
    // --- <<IS-START(remove)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] record:0:optional $bizdoc
    // [i] - field:0:required InternalID
    // [i] field:0:optional $part
    IDataCursor cursor = pipeline.getCursor();

    try {
      IData bizdoc = IDataUtil.getIData(cursor, "$bizdoc");
      String partName = IDataUtil.getString(cursor, "$part");

      remove(bizdoc, partName);
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #28
0
  public static final void concatenate(IData pipeline) throws ServiceException {
    // --- <<IS-START(concatenate)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $date
    // [i] field:0:optional $time
    // [o] field:0:optional $datetime
    IDataCursor cursor = pipeline.getCursor();

    try {
      String date = IDataUtil.getString(cursor, "$date");
      String time = IDataUtil.getString(cursor, "$time");

      if (date != null && time != null) IDataUtil.put(cursor, "$datetime", concatenate(date, time));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #29
0
  public static final void first(IData pipeline) throws ServiceException {
    // --- <<IS-START(first)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [o] field:0:optional $key
    // [o] object:0:optional $value
    IDataCursor cursor = pipeline.getCursor();
    try {
      if (cursor.first()) {
        String key = cursor.getKey();
        Object value = cursor.getValue();
        IDataUtil.put(cursor, "$key", key);
        IDataUtil.put(cursor, "$value", value);
      }
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }
예제 #30
0
  public static final void duration(IData pipeline) throws ServiceException {
    // --- <<IS-START(duration)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $datetime.start
    // [i] field:0:optional $datetime.end
    // [o] field:0:optional $duration
    IDataCursor cursor = pipeline.getCursor();

    try {
      String start = IDataUtil.getString(cursor, "$datetime.start");
      String end = IDataUtil.getString(cursor, "$datetime.end");

      IDataUtil.put(cursor, "$duration", duration(start, end));
    } finally {
      cursor.destroy();
    }
    // --- <<IS-END>> ---

  }