Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -776,7 +776,7 @@ public class CommonRules extends QueryRules {
|
||||
if (f != null) {
|
||||
SqlField sql;
|
||||
if ((sql = f.getAnnotation(SqlField.class)) != null) {
|
||||
value = UtilityString.stringToObject(sql.defaultObjectValue(), f.getType());
|
||||
value = SqlFieldHolder.applyConvert(sql.defaultObjectValue(), f.getType());
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
||||
@@ -1181,7 +1181,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDefault(String fieldName) throws IllegalAccessException, IOException {
|
||||
public void applyDefault(String fieldName) throws IllegalAccessException, IOException, SQLException, ConverterNotConfiguredException {
|
||||
List<EntityHierarchy.Field> fields = getEntityHolder().getEntityFields(this.getClass(),
|
||||
x -> (fieldName == null || x.getFieldName().equalsIgnoreCase(fieldName)) && x.isSqlField());
|
||||
|
||||
@@ -1202,14 +1202,14 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
}
|
||||
|
||||
if (object == null && !defaultValue.isEmpty()) {
|
||||
object = UtilityString.stringToObject(defaultValue, field.getType());
|
||||
object = SqlFieldHolder.applyConvert(defaultValue, field.getType());
|
||||
field.set(this, object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDefault() throws IllegalAccessException, IOException {
|
||||
public void applyDefault() throws IllegalAccessException, IOException, SQLException, ConverterNotConfiguredException {
|
||||
applyDefault(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@ package it.integry.ems_model.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.exception.ConverterNotConfiguredException;
|
||||
import it.integry.ems_model.exception.EntityException;
|
||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public interface EntityInterface {
|
||||
@@ -23,9 +25,9 @@ public interface EntityInterface {
|
||||
|
||||
void execStoredProcedure() throws Exception;
|
||||
|
||||
void applyDefault(String fieldName) throws IllegalAccessException, IOException;
|
||||
void applyDefault(String fieldName) throws IllegalAccessException, IOException, SQLException, ConverterNotConfiguredException;
|
||||
|
||||
void applyDefault() throws IllegalAccessException, IOException;
|
||||
void applyDefault() throws IllegalAccessException, IOException, SQLException, ConverterNotConfiguredException;
|
||||
|
||||
List<? extends EntityBase> select(Connection connection) throws Exception;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
@@ -43,6 +44,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -78,6 +80,28 @@ public class SqlFieldHolder {
|
||||
|
||||
public static Object applyConvert(Object columnValue, Type classType) throws ConverterNotConfiguredException, SQLException {
|
||||
if (columnValue == null) return null;
|
||||
|
||||
if (CommonConstants.SYSDATE.equals(columnValue)) {
|
||||
|
||||
if (classType.equals(Date.class)) {
|
||||
columnValue = DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);
|
||||
} else if (classType.equals(LocalDate.class)) {
|
||||
columnValue = UtilityLocalDate.getNow();
|
||||
} else if (classType.equals(LocalDateTime.class)) {
|
||||
columnValue = UtilityLocalDate.getNowTime().toLocalDate();
|
||||
}
|
||||
|
||||
} else if (CommonConstants.TIMESTAMP.equals(columnValue)) {
|
||||
|
||||
if (classType.equals(Date.class)) {
|
||||
columnValue = new Date();
|
||||
} else if (classType.equals(LocalDate.class)) {
|
||||
columnValue = UtilityLocalDate.getNow();
|
||||
} else if (classType.equals(LocalDateTime.class)) {
|
||||
columnValue = UtilityLocalDate.getNowTime();
|
||||
}
|
||||
}
|
||||
|
||||
final RunnableArgsWithReturn<Object, Object> converter = getConverter(columnValue.getClass(), classType);
|
||||
|
||||
if (converter == null) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems_model.base.EntityInterface;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.exception.ConverterNotConfiguredException;
|
||||
import it.integry.ems_model.exception.RulesNotCompiledException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -28,6 +29,7 @@ import java.io.ObjectOutputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Service
|
||||
public class DroolsDataCompleting {
|
||||
@@ -162,7 +164,7 @@ public class DroolsDataCompleting {
|
||||
}
|
||||
|
||||
|
||||
public void complete(EntityInterface entity, Connection connect, String username) throws RulesNotCompiledException, IOException, IllegalAccessException {
|
||||
public void complete(EntityInterface entity, Connection connect, String username) throws RulesNotCompiledException, IOException, IllegalAccessException, SQLException, ConverterNotConfiguredException {
|
||||
if (kieBase == null) {
|
||||
throw new RulesNotCompiledException();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.google.common.base.CaseFormat;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.io.File;
|
||||
@@ -12,7 +11,6 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -385,30 +383,6 @@ public class UtilityString {
|
||||
return formatter.format(ai_int);
|
||||
}
|
||||
|
||||
public static Object stringToObject(String value, Class<?> clazz) throws IOException {
|
||||
if (clazz.equals(Integer.class)) {
|
||||
return new Integer(value);
|
||||
} else if (clazz.equals(BigDecimal.class)) {
|
||||
return new BigDecimal(value);
|
||||
} else if (clazz.equals(Double.class)) {
|
||||
return new Double(value);
|
||||
} else if (clazz.equals(String.class)) {
|
||||
return value;
|
||||
} else if (clazz.equals(Date.class) || clazz.equals(Timestamp.class)) {
|
||||
if (CommonConstants.SYSDATE.equals(value))
|
||||
return DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);
|
||||
else if (CommonConstants.TIMESTAMP.equals(value))
|
||||
return new Date();
|
||||
else
|
||||
return UtilityString.parseDate(value);
|
||||
} else if(clazz.equals(LocalDate.class)) {
|
||||
return UtilityLocalDate.getNow();
|
||||
} else if(clazz.equals(LocalDateTime.class)) {
|
||||
return UtilityLocalDate.getNowTime();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String substring(String s, int beginIndex, int endIndex) {
|
||||
if (s != null) {
|
||||
int strLen = s.length();
|
||||
|
||||
Reference in New Issue
Block a user