Initial version of scripts, javascript

This commit is contained in:
2022-10-31 11:35:48 -05:00
parent 0ada444fd4
commit 165583cd98
57 changed files with 7409 additions and 376 deletions

View File

@ -42,6 +42,8 @@ import com.kingsrook.qqq.backend.core.actions.metadata.MetaDataAction;
import com.kingsrook.qqq.backend.core.actions.metadata.ProcessMetaDataAction;
import com.kingsrook.qqq.backend.core.actions.metadata.TableMetaDataAction;
import com.kingsrook.qqq.backend.core.actions.reporting.ExportAction;
import com.kingsrook.qqq.backend.core.actions.scripts.StoreAssociatedScriptAction;
import com.kingsrook.qqq.backend.core.actions.scripts.TestScriptAction;
import com.kingsrook.qqq.backend.core.actions.tables.CountAction;
import com.kingsrook.qqq.backend.core.actions.tables.DeleteAction;
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
@ -66,6 +68,10 @@ import com.kingsrook.qqq.backend.core.model.actions.metadata.TableMetaDataInput;
import com.kingsrook.qqq.backend.core.model.actions.metadata.TableMetaDataOutput;
import com.kingsrook.qqq.backend.core.model.actions.reporting.ExportInput;
import com.kingsrook.qqq.backend.core.model.actions.reporting.ReportFormat;
import com.kingsrook.qqq.backend.core.model.actions.scripts.StoreAssociatedScriptInput;
import com.kingsrook.qqq.backend.core.model.actions.scripts.StoreAssociatedScriptOutput;
import com.kingsrook.qqq.backend.core.model.actions.scripts.TestScriptInput;
import com.kingsrook.qqq.backend.core.model.actions.scripts.TestScriptOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.delete.DeleteInput;
@ -74,6 +80,9 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QCriteriaOperator;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterOrderBy;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
@ -86,11 +95,13 @@ import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetOutput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.tables.AssociatedScript;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.model.session.QSession;
import com.kingsrook.qqq.backend.core.modules.authentication.Auth0AuthenticationModule;
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleDispatcher;
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleInterface;
import com.kingsrook.qqq.backend.core.processes.utils.GeneralProcessUtils;
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
import com.kingsrook.qqq.backend.core.utils.ExceptionUtils;
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
@ -271,6 +282,7 @@ public class QJavalinImplementation
{
get("", QJavalinImplementation::processMetaData);
});
get("/authentication", QJavalinImplementation::authenticationMetaData);
});
/////////////////////////
@ -294,6 +306,11 @@ public class QJavalinImplementation
patch("", QJavalinImplementation::dataUpdate);
put("", QJavalinImplementation::dataUpdate); // todo - want different semantics??
delete("", QJavalinImplementation::dataDelete);
get("/developer", QJavalinImplementation::getRecordDeveloperMode);
post("/developer/associatedScript/{fieldName}", QJavalinImplementation::storeRecordAssociatedScript);
get("/developer/associatedScript/{fieldName}/{scriptRevisionId}/logs", QJavalinImplementation::getAssociatedScriptLogs);
post("/developer/associatedScript/{fieldName}/test", QJavalinImplementation::testAssociatedScript);
});
});
@ -308,6 +325,16 @@ public class QJavalinImplementation
/*******************************************************************************
**
*******************************************************************************/
private static void authenticationMetaData(Context context)
{
context.result(JsonUtils.toJson(qInstance.getAuthentication()));
}
/*******************************************************************************
**
*******************************************************************************/
@ -932,6 +959,211 @@ public class QJavalinImplementation
/*******************************************************************************
**
*******************************************************************************/
private static void getRecordDeveloperMode(Context context)
{
try
{
String tableName = context.pathParam("table");
QTableMetaData table = qInstance.getTable(tableName);
String primaryKey = context.pathParam("primaryKey");
GetInput getInput = new GetInput(qInstance);
setupSession(context, getInput);
getInput.setTableName(tableName);
getInput.setShouldGenerateDisplayValues(true);
getInput.setShouldTranslatePossibleValues(true);
// todo - validate that the primary key is of the proper type (e.g,. not a string for an id field)
// and throw a 400-series error (tell the user bad-request), rather than, we're doing a 500 (server error)
getInput.setPrimaryKey(primaryKey);
GetAction getAction = new GetAction();
GetOutput getOutput = getAction.execute(getInput);
///////////////////////////////////////////////////////
// throw a not found error if the record isn't found //
///////////////////////////////////////////////////////
QRecord record = getOutput.getRecord();
if(record == null)
{
throw (new QNotFoundException("Could not find " + table.getLabel() + " with "
+ table.getFields().get(table.getPrimaryKeyField()).getLabel() + " of " + primaryKey));
}
Map<String, Serializable> rs = new HashMap<>();
rs.put("record", record);
ArrayList<HashMap<String, Serializable>> associatedScripts = new ArrayList<>();
rs.put("associatedScripts", associatedScripts);
///////////////////////////////////////////////////////
// process each associated script type for the table //
///////////////////////////////////////////////////////
for(AssociatedScript associatedScript : CollectionUtils.nonNullList(table.getAssociatedScripts()))
{
HashMap<String, Serializable> thisScriptData = new HashMap<>();
associatedScripts.add(thisScriptData);
thisScriptData.put("associatedScript", associatedScript);
String fieldName = associatedScript.getFieldName();
Serializable scriptId = record.getValue(fieldName);
if(scriptId != null)
{
GetInput getScriptInput = new GetInput(qInstance);
setupSession(context, getScriptInput);
getScriptInput.setTableName("script");
getScriptInput.setPrimaryKey(scriptId);
GetOutput getScriptOutput = new GetAction().execute(getScriptInput);
if(getScriptOutput.getRecord() != null)
{
thisScriptData.put("script", getScriptOutput.getRecord());
QueryInput queryInput = new QueryInput(qInstance);
setupSession(context, queryInput);
queryInput.setTableName("scriptRevision");
queryInput.setFilter(new QQueryFilter()
.withCriteria(new QFilterCriteria("scriptId", QCriteriaOperator.EQUALS, List.of(getScriptOutput.getRecord().getValue("id"))))
.withOrderBy(new QFilterOrderBy("id", false))
);
QueryOutput queryOutput = new QueryAction().execute(queryInput);
thisScriptData.put("scriptRevisions", new ArrayList<>(queryOutput.getRecords()));
}
}
}
context.result(JsonUtils.toJson(rs));
}
catch(Exception e)
{
handleException(context, e);
}
}
/*******************************************************************************
**
*******************************************************************************/
public static void getAssociatedScriptLogs(Context context)
{
try
{
String scriptRevisionId = context.pathParam("scriptRevisionId");
QueryInput queryInput = new QueryInput(qInstance);
setupSession(context, queryInput);
queryInput.setTableName("scriptLog");
queryInput.setFilter(new QQueryFilter()
.withCriteria(new QFilterCriteria("scriptRevisionId", QCriteriaOperator.EQUALS, List.of(scriptRevisionId)))
.withOrderBy(new QFilterOrderBy("id", false))
);
queryInput.setLimit(100);
QueryOutput queryOutput = new QueryAction().execute(queryInput);
if(CollectionUtils.nullSafeHasContents(queryOutput.getRecords()))
{
GeneralProcessUtils.addForeignRecordsListToRecordList(queryInput, queryOutput.getRecords(), "id", "scriptLogLine", "scriptLogId");
}
Map<String, Serializable> rs = new HashMap<>();
rs.put("scriptLogRecords", new ArrayList<>(queryOutput.getRecords()));
context.result(JsonUtils.toJson(rs));
}
catch(Exception e)
{
handleException(context, e);
}
}
/*******************************************************************************
**
*******************************************************************************/
private static void storeRecordAssociatedScript(Context context)
{
try
{
StoreAssociatedScriptInput input = new StoreAssociatedScriptInput(qInstance);
setupSession(context, input);
input.setCode(context.formParam("contents"));
input.setCommitMessage(context.formParam("commitMessage"));
input.setFieldName(context.pathParam("fieldName"));
input.setTableName(context.pathParam("table"));
input.setRecordPrimaryKey(context.pathParam("primaryKey"));
StoreAssociatedScriptOutput output = new StoreAssociatedScriptOutput();
StoreAssociatedScriptAction storeAssociatedScriptAction = new StoreAssociatedScriptAction();
storeAssociatedScriptAction.run(input, output);
context.result(JsonUtils.toJson("OK"));
}
catch(Exception e)
{
handleException(context, e);
}
}
/*******************************************************************************
**
*******************************************************************************/
private static void testAssociatedScript(Context context)
{
try
{
TestScriptInput input = new TestScriptInput(qInstance);
setupSession(context, input);
input.setTableName(context.pathParam("table"));
input.setRecordPrimaryKey(context.pathParam("primaryKey"));
// context.pathParam("fieldName");
Map<String, String> inputValues = new HashMap<>();
input.setInputValues(inputValues);
for(Map.Entry<String, List<String>> entry : context.formParamMap().entrySet())
{
String key = entry.getKey();
String value = entry.getValue().get(0);
if(key.equals("code"))
{
input.setCode(value);
}
else if(key.equals("scriptTypeId"))
{
input.setScriptTypeId(ValueUtils.getValueAsInteger(value));
}
else
{
inputValues.put(key, value);
}
}
TestScriptOutput output = new TestScriptOutput();
new TestScriptAction().run(input, output);
//////////////////////////////////////////////////////////////
// todo - output to frontend - then add assertions in test. //
//////////////////////////////////////////////////////////////
context.result(JsonUtils.toJson("OK"));
}
catch(Exception e)
{
handleException(context, e);
}
}
/*******************************************************************************
**
*******************************************************************************/

View File

@ -26,9 +26,23 @@ import java.io.Serializable;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.actions.reporting.ReportFormat;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QCriteriaOperator;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.WidgetType;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.session.QSession;
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
@ -68,7 +82,7 @@ class QJavalinImplementationTest extends QJavalinTestBase
JSONObject jsonObject = JsonUtils.toJSONObject(response.getBody());
assertTrue(jsonObject.has("tables"));
JSONObject tables = jsonObject.getJSONObject("tables");
assertEquals(1, tables.length());
assertEquals(6, tables.length()); // person + 5 script tables
JSONObject personTable = tables.getJSONObject("person");
assertTrue(personTable.has("name"));
assertEquals("person", personTable.getString("name"));
@ -616,4 +630,135 @@ class QJavalinImplementationTest extends QJavalinTestBase
assertEquals(5, jsonObject.getJSONArray("options").getJSONObject(1).getInt("id"));
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testGetRecordDeveloperMode() throws QException
{
UpdateInput updateInput = new UpdateInput(TestUtils.defineInstance());
updateInput.setSession(new QSession());
updateInput.setTableName("person");
updateInput.setRecords(List.of(new QRecord().withValue("id", 1).withValue("testScriptId", 47)));
new UpdateAction().execute(updateInput);
InsertInput insertInput = new InsertInput(TestUtils.defineInstance());
insertInput.setSession(new QSession());
insertInput.setTableName("script");
insertInput.setRecords(List.of(new QRecord().withValue("id", 47).withValue("currentScriptRevisionId", 100)));
new InsertAction().execute(insertInput);
insertInput.setTableName("scriptRevision");
insertInput.setRecords(List.of(new QRecord().withValue("id", 1000).withValue("scriptId", 47).withValue("content", "var i;")));
new InsertAction().execute(insertInput);
HttpResponse<String> response = Unirest.get(BASE_URL + "/data/person/1/developer").asString();
assertEquals(200, response.getStatus());
JSONObject jsonObject = JsonUtils.toJSONObject(response.getBody());
System.out.println(jsonObject.toString(3));
assertNotNull(jsonObject);
assertNotNull(jsonObject.getJSONObject("record"));
assertEquals("Darin", jsonObject.getJSONObject("record").getJSONObject("values").getString("firstName"));
assertEquals("Darin", jsonObject.getJSONObject("record").getJSONObject("displayValues").getString("firstName"));
assertNotNull(jsonObject.getJSONArray("associatedScripts"));
assertNotNull(jsonObject.getJSONArray("associatedScripts").getJSONObject(0));
assertNotNull(jsonObject.getJSONArray("associatedScripts").getJSONObject(0).getJSONArray("scriptRevisions"));
assertEquals("var i;", jsonObject.getJSONArray("associatedScripts").getJSONObject(0).getJSONArray("scriptRevisions").getJSONObject(0).getJSONObject("values").getString("content"));
assertNotNull(jsonObject.getJSONArray("associatedScripts").getJSONObject(0).getJSONObject("script"));
assertEquals(100, jsonObject.getJSONArray("associatedScripts").getJSONObject(0).getJSONObject("script").getJSONObject("values").getInt("currentScriptRevisionId"));
assertNotNull(jsonObject.getJSONArray("associatedScripts").getJSONObject(0).getJSONObject("associatedScript"));
assertEquals("testScriptId", jsonObject.getJSONArray("associatedScripts").getJSONObject(0).getJSONObject("associatedScript").getString("fieldName"));
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testStoreRecordAssociatedScript() throws QException
{
InsertInput insertInput = new InsertInput(TestUtils.defineInstance());
insertInput.setSession(new QSession());
insertInput.setTableName("scriptType");
insertInput.setRecords(List.of(new QRecord().withValue("id", 1).withValue("name", "Test")));
new InsertAction().execute(insertInput);
HttpResponse<String> response = Unirest.post(BASE_URL + "/data/person/1/developer/associatedScript/testScriptId")
.field("contents", "var j = 0;")
.field("commitMessage", "Javalin Commit")
.asString();
QueryInput queryInput = new QueryInput(TestUtils.defineInstance());
queryInput.setSession(new QSession());
queryInput.setTableName("scriptRevision");
queryInput.setFilter(new QQueryFilter()
.withCriteria(new QFilterCriteria("contents", QCriteriaOperator.EQUALS, List.of("var j = 0;")))
.withCriteria(new QFilterCriteria("commitMessage", QCriteriaOperator.EQUALS, List.of("Javalin Commit")))
);
QueryOutput queryOutput = new QueryAction().execute(queryInput);
assertEquals(1, queryOutput.getRecords().size());
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testTestAssociatedScript() throws QException
{
InsertInput insertInput = new InsertInput(TestUtils.defineInstance());
insertInput.setSession(new QSession());
insertInput.setTableName("scriptType");
insertInput.setRecords(List.of(new QRecord().withValue("id", 1).withValue("name", "Test")));
new InsertAction().execute(insertInput);
HttpResponse<String> response = Unirest.post(BASE_URL + "/data/person/1/developer/associatedScript/testScriptId/test")
.field("code", "var j = 0;")
.field("scriptTypeId", "1")
.field("x", "47")
.asString();
/////////////////////////////////////////
// todo - assertions after implemented //
/////////////////////////////////////////
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testGetAssociatedScriptLogs() throws QException
{
InsertInput insertInput = new InsertInput(TestUtils.defineInstance());
insertInput.setSession(new QSession());
insertInput.setTableName("scriptLog");
insertInput.setRecords(List.of(new QRecord().withValue("id", 1).withValue("output", "testOutput").withValue("scriptRevisionId", 100)));
new InsertAction().execute(insertInput);
insertInput.setTableName("scriptLogLine");
insertInput.setRecords(List.of(
new QRecord().withValue("scriptLogId", 1).withValue("text", "line one"),
new QRecord().withValue("scriptLogId", 1).withValue("text", "line two")
));
new InsertAction().execute(insertInput);
HttpResponse<String> response = Unirest.get(BASE_URL + "/data/person/1/developer/associatedScript/testScriptId/100/logs").asString();
assertEquals(200, response.getStatus());
JSONObject jsonObject = JsonUtils.toJSONObject(response.getBody());
assertNotNull(jsonObject.getJSONArray("scriptLogRecords"));
assertEquals(1, jsonObject.getJSONArray("scriptLogRecords").length());
assertNotNull(jsonObject.getJSONArray("scriptLogRecords").getJSONObject(0).getJSONObject("values"));
assertEquals("testOutput", jsonObject.getJSONArray("scriptLogRecords").getJSONObject(0).getJSONObject("values").getString("output"));
assertNotNull(jsonObject.getJSONArray("scriptLogRecords").getJSONObject(0).getJSONObject("values").getJSONArray("scriptLogLine"));
assertEquals(2, jsonObject.getJSONArray("scriptLogRecords").getJSONObject(0).getJSONObject("values").getJSONArray("scriptLogLine").length());
assertEquals("line one", jsonObject.getJSONArray("scriptLogRecords").getJSONObject(0).getJSONObject("values").getJSONArray("scriptLogLine").getJSONObject(0).getJSONObject("values").getString("text"));
assertEquals("line two", jsonObject.getJSONArray("scriptLogRecords").getJSONObject(0).getJSONObject("values").getJSONArray("scriptLogLine").getJSONObject(1).getJSONObject("values").getString("text"));
}
}

View File

@ -31,6 +31,7 @@ import com.kingsrook.qqq.backend.core.exceptions.QValueException;
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepInput;
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepOutput;
import com.kingsrook.qqq.backend.core.model.metadata.QAuthenticationType;
import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeType;
@ -47,7 +48,9 @@ import com.kingsrook.qqq.backend.core.model.metadata.processes.QFunctionInputMet
import com.kingsrook.qqq.backend.core.model.metadata.processes.QFunctionOutputMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.processes.QRecordListMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.tables.AssociatedScript;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.model.scripts.ScriptsMetaDataProvider;
import com.kingsrook.qqq.backend.core.modules.authentication.metadata.QAuthenticationMetaData;
import com.kingsrook.qqq.backend.core.processes.implementations.mock.MockBackendStep;
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
@ -84,7 +87,7 @@ public class TestUtils
public static void primeTestDatabase() throws Exception
{
ConnectionManager connectionManager = new ConnectionManager();
Connection connection = connectionManager.getConnection(TestUtils.defineBackend());
Connection connection = connectionManager.getConnection(TestUtils.defineDefaultH2Backend());
InputStream primeTestDatabaseSqlStream = TestUtils.class.getResourceAsStream("/prime-test-database.sql");
assertNotNull(primeTestDatabaseSqlStream);
List<String> lines = (List<String>) IOUtils.readLines(primeTestDatabaseSqlStream);
@ -105,7 +108,7 @@ public class TestUtils
public static void runTestSql(String sql, QueryManager.ResultSetProcessor resultSetProcessor) throws Exception
{
ConnectionManager connectionManager = new ConnectionManager();
Connection connection = connectionManager.getConnection(defineBackend());
Connection connection = connectionManager.getConnection(defineDefaultH2Backend());
QueryManager.executeStatement(connection, sql, resultSetProcessor);
}
@ -119,7 +122,7 @@ public class TestUtils
{
QInstance qInstance = new QInstance();
qInstance.setAuthentication(defineAuthentication());
qInstance.addBackend(defineBackend());
qInstance.addBackend(defineDefaultH2Backend());
qInstance.addTable(defineTablePerson());
qInstance.addProcess(defineProcessGreetPeople());
qInstance.addProcess(defineProcessGreetPeopleInteractive());
@ -128,6 +131,17 @@ public class TestUtils
qInstance.addProcess(defineProcessSimpleThrow());
qInstance.addPossibleValueSource(definePossibleValueSourcePerson());
defineWidgets(qInstance);
qInstance.addBackend(defineMemoryBackend());
try
{
new ScriptsMetaDataProvider().defineStandardScriptsTables(qInstance, defineMemoryBackend().getName(), null);
}
catch(Exception e)
{
throw new IllegalStateException("Error adding script tables to instance");
}
return (qInstance);
}
@ -162,7 +176,7 @@ public class TestUtils
** Define the h2 rdbms backend
**
*******************************************************************************/
public static RDBMSBackendMetaData defineBackend()
public static RDBMSBackendMetaData defineDefaultH2Backend()
{
RDBMSBackendMetaData rdbmsBackendMetaData = new RDBMSBackendMetaData()
.withVendor("h2")
@ -176,6 +190,19 @@ public class TestUtils
/*******************************************************************************
** Define the memory-only backend
**
*******************************************************************************/
public static QBackendMetaData defineMemoryBackend()
{
return new QBackendMetaData()
.withBackendType("memory")
.withName("memory");
}
/*******************************************************************************
** Define the person table
**
@ -187,7 +214,7 @@ public class TestUtils
.withLabel("Person")
.withRecordLabelFormat("%s %s")
.withRecordLabelFields("firstName", "lastName")
.withBackendName(defineBackend().getName())
.withBackendName(defineDefaultH2Backend().getName())
.withPrimaryKeyField("id")
.withField(new QFieldMetaData("id", QFieldType.INTEGER))
.withField(new QFieldMetaData("createDate", QFieldType.DATE_TIME).withBackendName("create_date"))
@ -196,7 +223,11 @@ public class TestUtils
.withField(new QFieldMetaData("lastName", QFieldType.STRING).withBackendName("last_name"))
.withField(new QFieldMetaData("birthDate", QFieldType.DATE).withBackendName("birth_date"))
.withField(new QFieldMetaData("partnerPersonId", QFieldType.INTEGER).withBackendName("partner_person_id").withPossibleValueSourceName("person"))
.withField(new QFieldMetaData("email", QFieldType.STRING));
.withField(new QFieldMetaData("email", QFieldType.STRING))
.withField(new QFieldMetaData("testScriptId", QFieldType.INTEGER).withBackendName("test_script_id"))
.withAssociatedScript(new AssociatedScript()
.withFieldName("testScriptId")
.withScriptTypeId(1));
}

View File

@ -30,7 +30,8 @@ CREATE TABLE person
last_name VARCHAR(80) NOT NULL,
birth_date DATE,
email VARCHAR(250) NOT NULL,
partner_person_id INT
partner_person_id INT,
test_script_id INT
);
INSERT INTO person (id, first_name, last_name, birth_date, email) VALUES (1, 'Darin', 'Kelkhoff', '1980-05-31', 'darin.kelkhoff@gmail.com');