mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 06:00:44 +00:00
Add option to retur stored records; add LocalTime
This commit is contained in:
@ -27,6 +27,7 @@ import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QValueException;
|
||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
|
||||
@ -159,6 +160,11 @@ public class QRecordEntityField
|
||||
{
|
||||
return (ValueUtils.getValueAsInstant(value));
|
||||
}
|
||||
|
||||
if(type.equals(LocalTime.class))
|
||||
{
|
||||
return (ValueUtils.getValueAsLocalTime(value));
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
@ -44,6 +44,8 @@ public class BasicETLLoadFunction implements BackendStep
|
||||
{
|
||||
private static final Logger LOG = LogManager.getLogger(BasicETLLoadFunction.class);
|
||||
|
||||
private boolean returnStoredRecords = false;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -89,7 +91,11 @@ public class BasicETLLoadFunction implements BackendStep
|
||||
|
||||
InsertAction insertAction = new InsertAction();
|
||||
InsertOutput insertOutput = insertAction.execute(insertInput);
|
||||
outputRecords.addAll(insertOutput.getRecords());
|
||||
|
||||
if(returnStoredRecords)
|
||||
{
|
||||
outputRecords.addAll(insertOutput.getRecords());
|
||||
}
|
||||
|
||||
recordsInserted += insertOutput.getRecords().size();
|
||||
}
|
||||
@ -97,4 +103,15 @@ public class BasicETLLoadFunction implements BackendStep
|
||||
runBackendStepOutput.addValue(BasicETLProcess.FIELD_RECORD_COUNT, recordsInserted);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for returnStoredRecords
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setReturnStoredRecords(boolean returnStoredRecords)
|
||||
{
|
||||
this.returnStoredRecords = returnStoredRecords;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,10 +22,12 @@
|
||||
package com.kingsrook.qqq.backend.core.utils;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
@ -415,4 +417,45 @@ public class ValueUtils
|
||||
throw (new QValueException("Value [" + value + "] could not be converted to a Instant.", e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static Object getValueAsLocalTime(Serializable value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
else if(value instanceof LocalTime lt)
|
||||
{
|
||||
return (lt);
|
||||
}
|
||||
else if(value instanceof String s)
|
||||
{
|
||||
if(!StringUtils.hasContent(s))
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
return LocalTime.parse(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw (new QValueException("Unsupported class " + value.getClass().getName() + " for converting to LocalTime."));
|
||||
}
|
||||
}
|
||||
catch(QValueException qve)
|
||||
{
|
||||
throw (qve);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw (new QValueException("Value [" + value + "] could not be converted to a LocalTime.", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user