mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
CTLE-433: updates to support extensiv integration
This commit is contained in:
@ -35,7 +35,6 @@ import com.kingsrook.qqq.backend.core.actions.dashboard.widgets.NoCodeWidgetRend
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.UpdateAction;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.ProcessState;
|
||||
@ -66,7 +65,6 @@ import com.kingsrook.qqq.backend.core.state.UUIDAndTypeStateKey;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
|
||||
|
||||
@ -114,17 +112,6 @@ public class RunProcessAction
|
||||
}
|
||||
runProcessOutput.setProcessUUID(runProcessInput.getProcessUUID());
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// if this process has defined backend variant data, put that into the session //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
if(runProcessInput.getProcessMetaData() != null && runProcessInput.getProcessMetaData().getBackendVariant() != null)
|
||||
{
|
||||
String backendVariant = runProcessInput.getProcessMetaData().getBackendVariant();
|
||||
Serializable backendVariantValue = runProcessInput.getProcessMetaData().getBackendVariantValue();
|
||||
LOG.trace("Found Backend Variant [" + backendVariant + "] with a value of [" + backendVariantValue + "], putting into QSession.");
|
||||
QContext.getQSession().setBackendVariants(MapBuilder.of(backendVariant, backendVariantValue));
|
||||
}
|
||||
|
||||
UUIDAndTypeStateKey stateKey = new UUIDAndTypeStateKey(UUID.fromString(runProcessInput.getProcessUUID()), StateType.PROCESS_STATUS);
|
||||
ProcessState processState = primeProcessState(runProcessInput, stateKey, process);
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
package com.kingsrook.qqq.backend.core.model.metadata.processes;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -55,9 +54,6 @@ public class QProcessMetaData implements QAppChildMetaData, MetaDataWithPermissi
|
||||
private BasepullConfiguration basepullConfiguration;
|
||||
private QPermissionRules permissionRules;
|
||||
|
||||
private String backendVariant;
|
||||
private Serializable backendVariantValue;
|
||||
|
||||
private List<QStepMetaData> stepList; // these are the steps that are ran, by-default, in the order they are ran in
|
||||
private Map<String, QStepMetaData> steps; // this is the full map of possible steps
|
||||
|
||||
@ -548,66 +544,4 @@ public class QProcessMetaData implements QAppChildMetaData, MetaDataWithPermissi
|
||||
qInstance.addProcess(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for backendVariant
|
||||
*******************************************************************************/
|
||||
public String getBackendVariant()
|
||||
{
|
||||
return (this.backendVariant);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for backendVariant
|
||||
*******************************************************************************/
|
||||
public void setBackendVariant(String backendVariant)
|
||||
{
|
||||
this.backendVariant = backendVariant;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for backendVariant
|
||||
*******************************************************************************/
|
||||
public QProcessMetaData withBackendVariant(String backendVariant)
|
||||
{
|
||||
this.backendVariant = backendVariant;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for backendVariantValue
|
||||
*******************************************************************************/
|
||||
public Serializable getBackendVariantValue()
|
||||
{
|
||||
return (this.backendVariantValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for backendVariantValue
|
||||
*******************************************************************************/
|
||||
public void setBackendVariantValue(Serializable backendVariantValue)
|
||||
{
|
||||
this.backendVariantValue = backendVariantValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for backendVariantValue
|
||||
*******************************************************************************/
|
||||
public QProcessMetaData withBackendVariantValue(Serializable backendVariantValue)
|
||||
{
|
||||
this.backendVariantValue = backendVariantValue;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -232,25 +232,7 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// query to see if we already have those records in the destination (to determine insert/update) //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Map<Serializable, QRecord> existingRecordsByForeignKey = Collections.emptyMap();
|
||||
if(!sourceKeyList.isEmpty())
|
||||
{
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(destinationTableName);
|
||||
getTransaction().ifPresent(queryInput::setTransaction);
|
||||
QQueryFilter filter = getExistingRecordQueryFilter(runBackendStepInput, sourceKeyList);
|
||||
queryInput.setFilter(filter);
|
||||
|
||||
Collection<String> associationNamesToInclude = getAssociationNamesToInclude();
|
||||
if(CollectionUtils.nullSafeHasContents(associationNamesToInclude))
|
||||
{
|
||||
queryInput.setIncludeAssociations(true);
|
||||
queryInput.setAssociationNamesToInclude(associationNamesToInclude);
|
||||
}
|
||||
|
||||
QueryOutput queryOutput = new QueryAction().execute(queryInput);
|
||||
existingRecordsByForeignKey = CollectionUtils.recordsToMap(queryOutput.getRecords(), destinationTableForeignKeyField);
|
||||
}
|
||||
Map<Serializable, QRecord> existingRecordsByForeignKey = getExistingRecordsByForeignKey(runBackendStepInput, destinationTableForeignKeyField, destinationTableName, sourceKeyList);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// foreach source record, build the record we'll insert/update //
|
||||
@ -348,6 +330,35 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
protected Map<Serializable, QRecord> getExistingRecordsByForeignKey(RunBackendStepInput runBackendStepInput, String destinationTableForeignKeyField, String destinationTableName, List<Serializable> sourceKeyList) throws QException
|
||||
{
|
||||
Map<Serializable, QRecord> existingRecordsByForeignKey = Collections.emptyMap();
|
||||
if(!sourceKeyList.isEmpty())
|
||||
{
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(destinationTableName);
|
||||
getTransaction().ifPresent(queryInput::setTransaction);
|
||||
QQueryFilter filter = getExistingRecordQueryFilter(runBackendStepInput, sourceKeyList);
|
||||
queryInput.setFilter(filter);
|
||||
|
||||
Collection<String> associationNamesToInclude = getAssociationNamesToInclude();
|
||||
if(CollectionUtils.nullSafeHasContents(associationNamesToInclude))
|
||||
{
|
||||
queryInput.setIncludeAssociations(true);
|
||||
queryInput.setAssociationNamesToInclude(associationNamesToInclude);
|
||||
}
|
||||
|
||||
QueryOutput queryOutput = new QueryAction().execute(queryInput);
|
||||
existingRecordsByForeignKey = CollectionUtils.recordsToMap(queryOutput.getRecords(), destinationTableForeignKeyField);
|
||||
}
|
||||
return (existingRecordsByForeignKey);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
@ -73,6 +73,7 @@ import org.apache.http.HttpEntityEnclosingRequest;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
@ -103,6 +104,11 @@ public class BaseAPIActionUtil
|
||||
|
||||
|
||||
|
||||
public enum UpdateHttpMethod
|
||||
{PUT, POST}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -321,8 +327,9 @@ public class BaseAPIActionUtil
|
||||
{
|
||||
try
|
||||
{
|
||||
String url = buildTableUrl(table);
|
||||
HttpPut request = new HttpPut(url);
|
||||
String paramString = buildQueryStringForUpdate(table, recordList);
|
||||
String url = buildTableUrl(table) + paramString;
|
||||
HttpEntityEnclosingRequestBase request = getUpdateMethod().equals(UpdateHttpMethod.PUT) ? new HttpPut(url) : new HttpPost(url);
|
||||
request.setEntity(recordsToEntity(table, recordList));
|
||||
|
||||
QHttpResponse response = makeRequest(table, request);
|
||||
@ -537,13 +544,23 @@ public class BaseAPIActionUtil
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** method to build up a query string for updates based on a given QFilter object
|
||||
**
|
||||
*******************************************************************************/
|
||||
protected String buildQueryStringForUpdate(QTableMetaData table, List<QRecord> recordList) throws QException
|
||||
{
|
||||
return ("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** method to build up a query string based on a given QFilter object
|
||||
**
|
||||
*******************************************************************************/
|
||||
protected String buildQueryStringForGet(QQueryFilter filter, Integer limit, Integer skip, Map<String, QFieldMetaData> fields) throws QException
|
||||
{
|
||||
// todo: reasonable default action
|
||||
return ("");
|
||||
}
|
||||
|
||||
@ -1148,4 +1165,14 @@ public class BaseAPIActionUtil
|
||||
{
|
||||
return (20);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
protected UpdateHttpMethod getUpdateMethod()
|
||||
{
|
||||
return (UpdateHttpMethod.PUT);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user