mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
sprint-14: put json data into backend details
This commit is contained in:
@ -64,6 +64,8 @@ public class QRecord implements Serializable
|
||||
private Map<String, Serializable> backendDetails = new LinkedHashMap<>();
|
||||
private List<String> errors = new ArrayList<>();
|
||||
|
||||
public final static String BACKEND_DETAILS_TYPE_JSON_SOURCE_OBJECT = "jsonSourceObject";
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -455,6 +457,11 @@ public class QRecord implements Serializable
|
||||
*******************************************************************************/
|
||||
public Serializable getBackendDetail(String key)
|
||||
{
|
||||
if(!this.backendDetails.containsKey(key))
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
return this.backendDetails.get(key);
|
||||
}
|
||||
|
||||
@ -466,7 +473,7 @@ public class QRecord implements Serializable
|
||||
*******************************************************************************/
|
||||
public String getBackendDetailString(String key)
|
||||
{
|
||||
return (String) this.backendDetails.get(key);
|
||||
return (String) getBackendDetail(key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,8 +62,18 @@ public class LoadViaInsertOrUpdateStep extends AbstractLoadStep
|
||||
@Override
|
||||
public void run(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
|
||||
{
|
||||
QTableMetaData tableMetaData = runBackendStepInput.getInstance().getTable(runBackendStepInput.getValueString(FIELD_DESTINATION_TABLE));
|
||||
evaluateRecords(runBackendStepInput);
|
||||
insertAndUpdateRecords(runBackendStepInput, runBackendStepOutput);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void insertAndUpdateRecords(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
|
||||
{
|
||||
QTableMetaData tableMetaData = runBackendStepInput.getInstance().getTable(runBackendStepInput.getValueString(FIELD_DESTINATION_TABLE));
|
||||
|
||||
if(CollectionUtils.nullSafeHasContents(recordsToInsert))
|
||||
{
|
||||
|
@ -231,29 +231,7 @@ public class JsonUtils
|
||||
** Convert a json object into a QRecord
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static QRecord parseQRecordStrict(JSONObject jsonObject, Map<String, QFieldMetaData> fields)
|
||||
{
|
||||
return (parseQRecord(jsonObject, fields, true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Convert a json object into a QRecord
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static QRecord parseQRecordLenient(JSONObject jsonObject, Map<String, QFieldMetaData> fields)
|
||||
{
|
||||
return (parseQRecord(jsonObject, fields, false));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Convert a json object into a QRecord
|
||||
**
|
||||
*******************************************************************************/
|
||||
private static QRecord parseQRecord(JSONObject jsonObject, Map<String, QFieldMetaData> fields, boolean strict)
|
||||
public static QRecord parseQRecord(JSONObject jsonObject, Map<String, QFieldMetaData> fields, boolean useBackendFieldNames)
|
||||
{
|
||||
QRecord record = new QRecord();
|
||||
|
||||
@ -264,7 +242,12 @@ public class JsonUtils
|
||||
try
|
||||
{
|
||||
QFieldMetaData metaData = fields.get(fieldName);
|
||||
String backendName = metaData.getBackendName() != null ? metaData.getBackendName() : fieldName;
|
||||
String backendName = fieldName;
|
||||
if(useBackendFieldNames)
|
||||
{
|
||||
backendName = metaData.getBackendName() != null ? metaData.getBackendName() : fieldName;
|
||||
}
|
||||
|
||||
originalBackendName = backendName;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -327,14 +310,7 @@ public class JsonUtils
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
if(strict)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG.debug("Caught exception parsing field [" + fieldName + "] as [" + originalBackendName + "]", e);
|
||||
}
|
||||
LOG.debug("Caught exception parsing field [" + fieldName + "] as [" + originalBackendName + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user