@Override public void afterCompletion(int status) { super.afterCompletion(status); if (TransactionSynchronization.STATUS_ROLLED_BACK == status) { document.getGlobalErrors().stream() .filter(errorMessage -> "materialFlow.error.position.quantity.notEnoughResources" .equals(errorMessage.getMessage())) .forEach(errorMessage -> logService.add(LogService.Builder .error("document", translationService.translate("materialFlowResources.document.accept", LocaleContextHolder.getLocale())) .withMessage(translationService.translate("materialFlow.error.position.quantity.notEnough", LocaleContextHolder.getLocale())) .withItem1(document.getStringField(DocumentFields.NUMBER)) .withItem2(errorMessage.getVars()[0]).withItem3(errorMessage.getVars()[1]))); } } });
private void logActivities(final Entity productionTracking, Entity stateChangeEntity, final String state) { // TODO get user from state change/current user, not create user Entity user = userService.find(stateChangeEntity.getStringField(ProductionTrackingStateChangeFields.WORKER)); String worker = StringUtils.EMPTY; if (user != null) { worker = user.getStringField(UserFields.FIRST_NAME) + " " + user.getStringField(UserFields.LAST_NAME); } String number = productionTracking.getStringField(ProductionTrackingFields.NUMBER); Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER); String orderNumber = order.getStringField(OrderFields.NUMBER); logService.add(LogService.Builder.activity( "productionTracking", translationService.translate("productionCounting.productionTracking.activity." + state + ".action", LocaleContextHolder.getLocale())).withMessage( translationService.translate("productionCounting.productionTracking.activity." + state + ".message", LocaleContextHolder.getLocale(), worker, generateDetailsUrl(number, productionTracking.getId()), generateOrderDetailsUrl(orderNumber, order.getId())))); }
private void logPerformDelete(final Entity productionTracking) { String username = securityService.getCurrentUserName(); LOGGER.info(String.format("Delete production tracking. Number : %S id : %d. User : %S", productionTracking.getStringField(ProductionTrackingFields.NUMBER), productionTracking.getId(), username)); logService.add(LogService.Builder .info("productionTracking", translationService.translate("productionCounting.productionTracking.delete", LocaleContextHolder.getLocale())).withItem1("ID: " + productionTracking.getId().toString()) .withItem2("Number: " + productionTracking.getStringField(ProductionTrackingFields.NUMBER)) .withItem3("User: " + username)); }
public void onSave(final DataDefinition productionTrackingDD, final Entity productionTracking) { Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER); willOrderAcceptOneMore(productionTrackingDD, productionTracking, order); generateNumberIfNeeded(productionTracking); setTimesToZeroIfEmpty(productionTracking); copyProducts(productionTracking); generateSetTrackingOperationProductsComponents(productionTracking); generateSetTechnologyInComponents(productionTracking); if (productionTracking.getId() == null) { Entity user = userService.find(productionTracking.getStringField("createUser")); String worker = StringUtils.EMPTY; if (user != null) { worker = user.getStringField(UserFields.FIRST_NAME) + " " + user.getStringField(UserFields.LAST_NAME); } String number = productionTracking.getStringField(ProductionTrackingFields.NUMBER); String orderNumber = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER).getStringField( OrderFields.NUMBER); Date createDate = productionTracking.getDateField("createDate"); logService.add(LogService.Builder .activity( "productionTracking", translationService.translate("productionCounting.productionTracking.activity.created.action", LocaleContextHolder.getLocale())) .withMessage( translationService.translate("productionCounting.productionTracking.activity.created.message", LocaleContextHolder.getLocale(), worker, number, generateOrderDetailsUrl(orderNumber, order.getId()))).withCreateTime(createDate)); } }
public static Builder info(String type, String action) { return new Builder().withLogLevel(LogLevel.INFO).withType(type).withAction(action); }
public static Builder debug(String type, String action) { return new Builder().withLogLevel(LogLevel.DEBUG).withType(type).withAction(action); }
public static Builder error(String type, String action) { return new Builder().withLogLevel(LogLevel.ERROR).withType(type).withAction(action); }
public static Builder newBuilder(LogLevel logLevel, String type, String action) { return new Builder().withLogLevel(logLevel).withType(type).withAction(action); }
public static Builder activity(String type, String action) { return new Builder().withLogLevel(LogLevel.ACTIVITY).withType(type).withAction(action); }