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 Map<String, Serializable> backendDetails = new LinkedHashMap<>();
|
||||||
private List<String> errors = new ArrayList<>();
|
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)
|
public Serializable getBackendDetail(String key)
|
||||||
{
|
{
|
||||||
|
if(!this.backendDetails.containsKey(key))
|
||||||
|
{
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
return this.backendDetails.get(key);
|
return this.backendDetails.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +473,7 @@ public class QRecord implements Serializable
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public String getBackendDetailString(String key)
|
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
|
@Override
|
||||||
public void run(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
|
public void run(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
|
||||||
{
|
{
|
||||||
QTableMetaData tableMetaData = runBackendStepInput.getInstance().getTable(runBackendStepInput.getValueString(FIELD_DESTINATION_TABLE));
|
|
||||||
evaluateRecords(runBackendStepInput);
|
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))
|
if(CollectionUtils.nullSafeHasContents(recordsToInsert))
|
||||||
{
|
{
|
||||||
|
@ -231,29 +231,7 @@ public class JsonUtils
|
|||||||
** Convert a json object into a QRecord
|
** Convert a json object into a QRecord
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static QRecord parseQRecordStrict(JSONObject jsonObject, Map<String, QFieldMetaData> fields)
|
public static QRecord parseQRecord(JSONObject jsonObject, Map<String, QFieldMetaData> fields, boolean useBackendFieldNames)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
QRecord record = new QRecord();
|
QRecord record = new QRecord();
|
||||||
|
|
||||||
@ -264,7 +242,12 @@ public class JsonUtils
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
QFieldMetaData metaData = fields.get(fieldName);
|
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;
|
originalBackendName = backendName;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -326,17 +309,10 @@ public class JsonUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (record);
|
return (record);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,8 @@ public class BaseAPIActionUtil
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
protected QRecord jsonObjectToRecord(JSONObject jsonObject, Map<String, QFieldMetaData> fields) throws IOException
|
protected QRecord jsonObjectToRecord(JSONObject jsonObject, Map<String, QFieldMetaData> fields) throws IOException
|
||||||
{
|
{
|
||||||
QRecord record = JsonUtils.parseQRecordLenient(jsonObject, fields);
|
QRecord record = JsonUtils.parseQRecord(jsonObject, fields, true);
|
||||||
|
record.getBackendDetails().put(QRecord.BACKEND_DETAILS_TYPE_JSON_SOURCE_OBJECT, jsonObject.toString());
|
||||||
return (record);
|
return (record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user