mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
fixes for unit test where create date was being specified before insert action
This commit is contained in:
@ -26,6 +26,8 @@ import java.io.Serializable;
|
||||
import com.kingsrook.qqq.backend.core.actions.interfaces.QActionInterface;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -36,17 +38,24 @@ public abstract class AbstractMemoryAction implements QActionInterface
|
||||
|
||||
/*******************************************************************************
|
||||
** If the table has a field with the given name, then set the given value in the
|
||||
** given record.
|
||||
** given record - flag added to control overwriting value.
|
||||
*******************************************************************************/
|
||||
protected void setValueIfTableHasField(QRecord record, QTableMetaData table, String fieldName, Serializable value)
|
||||
protected void setValueIfTableHasField(QRecord record, QTableMetaData table, String fieldName, Serializable value, boolean overwriteIfSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(table.getFields().containsKey(fieldName))
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// always set value if boolean to overwrite is true, otherwise, //
|
||||
// only set the value if there is currently no content for the field //
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
if(overwriteIfSet || !StringUtils.hasContent(ValueUtils.getValueAsString(table.getField(fieldName))))
|
||||
{
|
||||
record.setValue(fieldName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
/////////////////////////////////////////////////
|
||||
|
@ -53,8 +53,8 @@ public class MemoryInsertAction extends AbstractMemoryAction implements InsertIn
|
||||
///////////////////////////////////////////
|
||||
// todo .. better (not hard-coded names) //
|
||||
///////////////////////////////////////////
|
||||
setValueIfTableHasField(record, table, "createDate", now);
|
||||
setValueIfTableHasField(record, table, "modifyDate", now);
|
||||
setValueIfTableHasField(record, table, "createDate", now, false);
|
||||
setValueIfTableHasField(record, table, "modifyDate", now, false);
|
||||
}
|
||||
|
||||
InsertOutput insertOutput = new InsertOutput();
|
||||
|
@ -53,7 +53,7 @@ public class MemoryUpdateAction extends AbstractMemoryAction implements UpdateIn
|
||||
///////////////////////////////////////////
|
||||
// todo .. better (not hard-coded names) //
|
||||
///////////////////////////////////////////
|
||||
setValueIfTableHasField(record, table, "modifyDate", now);
|
||||
setValueIfTableHasField(record, table, "modifyDate", now, false);
|
||||
}
|
||||
|
||||
UpdateOutput updateOutput = new UpdateOutput();
|
||||
|
Reference in New Issue
Block a user