public DateWrapper date(Date date) { return new DateWrapper(date); }
public DateWrapper days(int days) { return dateWrapper(Calendar.DAY_OF_MONTH, days); }
public int getMonth() { return getCalendar().get(Calendar.MONTH); }
public String toQueryString() { return new SimpleDateFormat("'TIMESTAMP' ''yyyy-MM-dd HH:mm:ss.SSS''").format(getDate()); } }
@Override public String toString() { return toQueryString(); }
protected Date evaluateDueDate() throws DocumentRouteException { String taskDueDateExpr = getTaskDueDateExpr(); if (StringUtils.isEmpty(taskDueDateExpr)) { return new Date(); } try (OperationContext context = getExecutionContext(getSession())) { Expression expr = Scripting.newExpression(taskDueDateExpr); Object res = expr.eval(context); if (res instanceof DateWrapper) { return ((DateWrapper) res).getDate(); } else if (res instanceof Date) { return (Date) res; } else if (res instanceof Calendar) { return ((Calendar) res).getTime(); } else if (res instanceof String) { return DateParser.parseW3CDateTime((String) res); } else { throw new DocumentRouteException( "The following expression can not be evaluated to a date: " + taskDueDateExpr); } } catch (DocumentRouteException e) { throw e; } catch (RuntimeException e) { throw new DocumentRouteException("Error evaluating task due date: " + taskDueDateExpr, e); } }
public DateWrapper calendar(Calendar date) { return new DateWrapper(date); }
public int getSecond() { return getCalendar().get(Calendar.SECOND); }
public DateWrapper seconds(int seconds) { return dateWrapper(Calendar.SECOND, seconds); }
/** * @since 5.7 */ protected DateWrapper dateWrapper(int unit, int value) { Calendar calendar = (Calendar) date.clone(); calendar.add(unit, value); return new DateWrapper(calendar); }
public int getMinute() { return getCalendar().get(Calendar.MINUTE); }
public DateWrapper months(int months) { return dateWrapper(Calendar.MONTH, months); }
public AutomationMapper(OperationContext ctx) { this.ctx = ctx; automatic.put("Session", () -> ctx.getCoreSession()); automatic.put(AutomationScriptingConstants.AUTOMATION_CTX_KEY, () -> ctx.getVars()); automatic.put(AutomationScriptingConstants.AUTOMATION_MAPPER_KEY, () -> this); automatic.put("CurrentUser", () -> new PrincipalWrapper(ctx.getPrincipal())); automatic.put("currentUser", () -> new PrincipalWrapper(ctx.getPrincipal())); automatic.put("Env", () -> Framework.getProperties()); automatic.put("CurrentDate", () -> new DateWrapper()); // Helpers injection ContextService contextService = Framework.getService(ContextService.class); Map<String, ContextHelper> helperFunctions = contextService.getHelperFunctions(); for (String helperFunctionsId : helperFunctions.keySet()) { automatic.put(helperFunctionsId, () -> helperFunctions.get(helperFunctionsId)); } }
public int getDay() { return getCalendar().get(Calendar.DAY_OF_MONTH); }
public DateWrapper years(int years) { return dateWrapper(Calendar.YEAR, years); }
public static Map<String, Object> initBindings(OperationContext ctx) { map.put("CurrentDate", new DateWrapper()); map.put("Context", ctx); if (ctx.get(Constants.VAR_WORKFLOW) != null) {
public int getWeek() { return getCalendar().get(Calendar.WEEK_OF_YEAR); }
public DateWrapper weeks(int weeks) { return dateWrapper(Calendar.WEEK_OF_MONTH, weeks); }
public int getYear() { return getCalendar().get(Calendar.YEAR); }
public int getHour() { return getCalendar().get(Calendar.HOUR); }