mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 06:00:44 +00:00
Updating to pass tests
This commit is contained in:
@ -259,24 +259,27 @@ public class PollingAutomationPerTableRunner implements Runnable
|
||||
/////////////////////////////////////////////////
|
||||
// next add any tableTriggers, defined in data //
|
||||
/////////////////////////////////////////////////
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TableTrigger.TABLE_NAME);
|
||||
queryInput.setFilter(new QQueryFilter(
|
||||
new QFilterCriteria("tableName", QCriteriaOperator.EQUALS, table.getName()),
|
||||
new QFilterCriteria(triggerEvent.equals(TriggerEvent.POST_INSERT) ? "postInsert" : "postUpdate", QCriteriaOperator.EQUALS, true)
|
||||
));
|
||||
QueryOutput queryOutput = new QueryAction().execute(queryInput);
|
||||
for(QRecord record : queryOutput.getRecords())
|
||||
if(QContext.getQInstance().getTable(TableTrigger.TABLE_NAME) != null)
|
||||
{
|
||||
// todo - get filter if there is/was one
|
||||
rs.add(new TableAutomationAction()
|
||||
.withName("Script:" + record.getValue("scriptId"))
|
||||
.withFilter(null)
|
||||
.withTriggerEvent(triggerEvent)
|
||||
.withPriority(record.getValueInteger("priority"))
|
||||
.withCodeReference(new QCodeReference(RunRecordScriptAutomationHandler.class))
|
||||
.withValues(MapBuilder.of("scriptId", record.getValue("scriptId")))
|
||||
);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TableTrigger.TABLE_NAME);
|
||||
queryInput.setFilter(new QQueryFilter(
|
||||
new QFilterCriteria("tableName", QCriteriaOperator.EQUALS, table.getName()),
|
||||
new QFilterCriteria(triggerEvent.equals(TriggerEvent.POST_INSERT) ? "postInsert" : "postUpdate", QCriteriaOperator.EQUALS, true)
|
||||
));
|
||||
QueryOutput queryOutput = new QueryAction().execute(queryInput);
|
||||
for(QRecord record : queryOutput.getRecords())
|
||||
{
|
||||
// todo - get filter if there is/was one
|
||||
rs.add(new TableAutomationAction()
|
||||
.withName("Script:" + record.getValue("scriptId"))
|
||||
.withFilter(null)
|
||||
.withTriggerEvent(triggerEvent)
|
||||
.withPriority(record.getValueInteger("priority"))
|
||||
.withCodeReference(new QCodeReference(RunRecordScriptAutomationHandler.class))
|
||||
.withValues(MapBuilder.of("scriptId", record.getValue("scriptId")))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
rs.sort(Comparator.comparing(taa -> Objects.requireNonNullElse(taa.getPriority(), Integer.MAX_VALUE)));
|
||||
|
@ -22,7 +22,6 @@
|
||||
package com.kingsrook.qqq.backend.core.actions.scripts;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -208,53 +207,4 @@ public class RunAdHocRecordScriptAction
|
||||
throw (new QException("Code reference did not contain a scriptRevision, scriptRevisionId, or scriptId"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private ScriptRevision getCurrentScriptRevision(RunAdHocRecordScriptInput input, Serializable scriptRevisionId) throws QException
|
||||
{
|
||||
GetInput getInput = new GetInput();
|
||||
getInput.setTableName("scriptRevision");
|
||||
getInput.setPrimaryKey(scriptRevisionId);
|
||||
GetOutput getOutput = new GetAction().execute(getInput);
|
||||
if(getOutput.getRecord() == null)
|
||||
{
|
||||
/* todo
|
||||
throw (new QNotFoundException("The current revision of the script for record [" + input.getCodeReference().getRecordTable() + "][" + input.getCodeReference().getRecordPrimaryKey() + "]["
|
||||
+ input.getCodeReference().getFieldName() + "] (scriptRevisionId=" + scriptRevisionId + ") was not found."));
|
||||
|
||||
*/
|
||||
throw (new IllegalStateException("todo"));
|
||||
}
|
||||
|
||||
return (new ScriptRevision(getOutput.getRecord()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private Script getScript(RunAdHocRecordScriptInput input, Serializable scriptId) throws QException
|
||||
{
|
||||
GetInput getInput = new GetInput();
|
||||
getInput.setTableName("script");
|
||||
getInput.setPrimaryKey(scriptId);
|
||||
GetOutput getOutput = new GetAction().execute(getInput);
|
||||
|
||||
if(getOutput.getRecord() == null)
|
||||
{
|
||||
/*
|
||||
throw (new QNotFoundException("The script for record [" + input.getCodeReference().getRecordTable() + "][" + input.getCodeReference().getRecordPrimaryKey() + "]["
|
||||
+ input.getCodeReference().getFieldName() + "] (script id=" + scriptId + ") was not found."));
|
||||
|
||||
*/
|
||||
throw (new IllegalStateException("todo"));
|
||||
}
|
||||
|
||||
return (new Script(getOutput.getRecord()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user