protected Date getCurrentTimestamp() { return timeSource.currentTimestamp(); }
public LockInfo(User user, String entityName, String entityId) { this.entityName = entityName; this.entityId = entityId; TimeSource timeSource = AppBeans.get(TimeSource.NAME); this.since = timeSource.currentTimestamp(); this.user = user; }
@Override public String modifySequenceSql(String sequenceName, long startWith) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); return String.format("drop table %1$s ^ " + "create table %1$s (ID bigint identity(%2$d,1), CREATE_TS datetime) ^ " + "insert into %1$s (CREATE_TS) values ({ts '%3$s'})", sequenceName.toUpperCase(), startWith, dateFormat.format(AppBeans.get(TimeSource.class).currentTimestamp())); }
/** * @return short string representation of the given time zone */ public String getDisplayNameShort(@Nullable TimeZone timeZone) { if (timeZone == null) return ""; boolean dst = timeZone.inDaylightTime(timeSource.currentTimestamp()); String name = timeZone.getDisplayName(dst, TimeZone.SHORT); if (AD_HOC_TZ_PATTERN.matcher(name).matches()) return name; else return name + " (" + getDisplayOffset(timeZone) + ")"; } }
@Override public EntitySnapshot createSnapshot(Entity entity, View view) { return createSnapshot(entity, view, timeSource.currentTimestamp()); }
@Override public EntitySnapshot createTempSnapshot(Entity entity, View view) { return createTempSnapshot(entity, view, timeSource.currentTimestamp()); }
public void log(LogLevel level, String message, Throwable throwable) { log(new LogItem(timeSource.currentTimestamp(), level, message, throwable)); }
public void info(String message) { log(new LogItem(timeSource.currentTimestamp(), LogLevel.INFO, message, null)); }
public void warning(String message) { log(new LogItem(timeSource.currentTimestamp(), LogLevel.WARNING, message, null)); }
protected FileDescriptor createFileDescriptor(@Nullable String fileName, long size) { FileDescriptor fd = metadata.create(FileDescriptor.class); if (Strings.isNullOrEmpty(fileName)) { fileName = fd.getId().toString(); } fd.setName(fileName); fd.setExtension(FilenameUtils.getExtension(fileName)); fd.setSize(size); fd.setCreateDate(timeSource.currentTimestamp()); return fd; }
@Override public final void execute() { checkState(!started, "Task is already started. Task: " + taskExecutor.getTask().toString()); this.started = true; TimeSource timeSource = AppBeans.get(TimeSource.NAME); this.startTimeStamp = timeSource.currentTimestamp().getTime(); this.watchDog.manageTask(this); log.trace("Run task: {}. User: {}", taskExecutor.getTask(), getUserSession().getId()); taskExecutor.startExecution(); }
protected boolean shouldMarkNotSent(SendingMessage sendingMessage) { Date deadline = sendingMessage.getDeadline(); if (deadline != null && deadline.before(timeSource.currentTimestamp())) { return true; } Integer messageAttemptsLimit = sendingMessage.getAttemptsCount(); int defaultLimit = config.getDefaultSendingAttemptsCount(); int attemptsLimit = messageAttemptsLimit != null ? messageAttemptsLimit : defaultLimit; //noinspection UnnecessaryLocalVariable boolean res = sendingMessage.getAttemptsMade() != null && sendingMessage.getAttemptsMade() >= attemptsLimit; return res; }
@Override public void prePersist(DescriptorEvent event) { Entity entity = (Entity) event.getObject(); Date ts = timeSource.currentTimestamp(); if (entity instanceof Creatable) { ((Creatable) entity).setCreatedBy(auditInfoProvider.getCurrentUserLogin()); ((Creatable) entity).setCreateTs(ts); } if (entity instanceof Updatable) { ((Updatable) entity).setUpdateTs(ts); } }
public void setDateFieldTime() { TimeSource timeSource = AppBeans.get(TimeSource.NAME); Date date = timeSource.currentTimestamp(); fromDateField.setValue(DateUtils.addDays(date, -1)); tillDateField.setValue(DateUtils.addMinutes(date, 1)); }
protected FileDescriptor createAttachmentFileDescriptor(SendingAttachment attachment) { FileDescriptor contentFile = metadata.create(FileDescriptor.class); contentFile.setCreateDate(timeSource.currentTimestamp()); contentFile.setName(attachment.getName()); contentFile.setExtension(FilenameUtils.getExtension(attachment.getName())); contentFile.setSize((long) attachment.getContent().length); return contentFile; }
@Override public void preUpdate(DescriptorEvent event) { Entity entity = (Entity) event.getObject(); if (!((entity instanceof SoftDelete) && justDeleted((SoftDelete) entity)) && (entity instanceof Updatable)) { Updatable updatable = (Updatable) event.getObject(); updatable.setUpdatedBy(auditInfoProvider.getCurrentUserLogin()); updatable.setUpdateTs(timeSource.currentTimestamp()); } }
protected FileDescriptor createBodyFileDescriptor(SendingMessage message, byte[] bodyBytes) { FileDescriptor contentTextFile = metadata.create(FileDescriptor.class); contentTextFile.setCreateDate(timeSource.currentTimestamp()); contentTextFile.setName("Email_" + message.getId() + "." + BODY_FILE_EXTENSION); contentTextFile.setExtension(BODY_FILE_EXTENSION); contentTextFile.setSize((long) bodyBytes.length); return contentTextFile; }
@Override public List<UserSubstitution> getSubstitutedUsers(UUID userId) { LoadContext<UserSubstitution> ctx = new LoadContext<>(UserSubstitution.class); LoadContext.Query query = ctx.setQueryString("select us from sec$UserSubstitution us " + "where us.user.id = :userId and (us.endDate is null or us.endDate >= :currentDate) " + "and (us.startDate is null or us.startDate <= :currentDate) " + "and (us.substitutedUser.active = true or us.substitutedUser.active is null) order by us.substitutedUser.name"); query.setParameter("userId", userId); query.setParameter("currentDate", timeSource.currentTimestamp()); ctx.setView("app"); return dataManager.loadList(ctx); } }
@Override public void accept(FileUploadField.FileUploadSucceedEvent e) { FileDescriptor fd = getItem(); fd.setName(uploadField.getFileName()); fd.setCreateDate(timeSource.currentTimestamp()); fd.setExtension(FilenameUtils.getExtension(uploadField.getFileName())); FileUploadingAPI fileUploading = AppBeans.get(FileUploadingAPI.NAME); File file = fileUploading.getFile(uploadField.getFileId()); fd.setSize(file.length()); okBtn.setEnabled(true); nameField.focus(); needSave = true; } }
protected void internalRegisterDelete(Entity entity, String entityName, Set<String> attributes) throws IOException { Date ts = timeSource.currentTimestamp(); EntityManager em = persistence.getEntityManager(); EntityLogItem item = metadata.create(EntityLogItem.class); item.setEventTs(ts); item.setUser(findUser(em)); item.setType(EntityLogItem.Type.DELETE); item.setEntity(entityName); item.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity)); item.setAttributes(createLogAttributes(entity, attributes, null)); enqueueItem(item); }