mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Merge pull request #49 from Kingsrook/feature/misc-updates-20231115
Feature/misc updates 20231115
This commit is contained in:
@ -270,6 +270,32 @@ public class QMetaDataVariableInterpreter
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** First look for a string in the specified system property -
|
||||||
|
** Next look for a string in the specified env var name -
|
||||||
|
** Finally return the default.
|
||||||
|
*******************************************************************************/
|
||||||
|
public String getStringFromPropertyOrEnvironment(String systemPropertyName, String environmentVariableName, String defaultIfNotSet)
|
||||||
|
{
|
||||||
|
String propertyValue = System.getProperty(systemPropertyName);
|
||||||
|
if(StringUtils.hasContent(propertyValue))
|
||||||
|
{
|
||||||
|
LOG.info("Read system property [" + systemPropertyName + "] as [" + propertyValue + "].");
|
||||||
|
return (propertyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
String envValue = interpret("${env." + environmentVariableName + "}");
|
||||||
|
if(StringUtils.hasContent(envValue))
|
||||||
|
{
|
||||||
|
LOG.info("Read env var [" + environmentVariableName + "] as [" + envValue + "].");
|
||||||
|
return (envValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultIfNotSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** First look for a boolean ("true" or "false") in the specified system property -
|
** First look for a boolean ("true" or "false") in the specified system property -
|
||||||
** Next look for a boolean in the specified env var name -
|
** Next look for a boolean in the specified env var name -
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.QMetaDataVariableInterpreter;
|
||||||
import com.kingsrook.qqq.backend.core.utils.lambdas.UnsafeSupplier;
|
import com.kingsrook.qqq.backend.core.utils.lambdas.UnsafeSupplier;
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +35,17 @@ import com.kingsrook.qqq.backend.core.utils.lambdas.UnsafeSupplier;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public class LogUtils
|
public class LogUtils
|
||||||
{
|
{
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// This string will be used in regex, inside ()'s, so you can supply pipe-delimited packages //
|
||||||
|
// as in, com.kingsrook|com.yourdomain|org.some.other.package //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
private static String packagesToKeep = ".";
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
packagesToKeep = new QMetaDataVariableInterpreter().getStringFromPropertyOrEnvironment("qqq.logger.packagesToKeep", "QQQ_LOGGER_PACKAGES_TO_KEEP", ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
@ -118,9 +130,8 @@ public class LogUtils
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String packagesToKeep = "com.kingsrook|com.coldtrack"; // todo - parameterize!!
|
StringBuilder rs = new StringBuilder();
|
||||||
StringBuilder rs = new StringBuilder();
|
String[] lines = stackTrace.split("\n");
|
||||||
String[] lines = stackTrace.split("\n");
|
|
||||||
|
|
||||||
int indexWithinSubStack = 0;
|
int indexWithinSubStack = 0;
|
||||||
int skipsInThisPackage = 0;
|
int skipsInThisPackage = 0;
|
||||||
@ -134,7 +145,13 @@ public class LogUtils
|
|||||||
{
|
{
|
||||||
keepLine = false;
|
keepLine = false;
|
||||||
indexWithinSubStack++;
|
indexWithinSubStack++;
|
||||||
if(line.matches("^\\s+at (" + packagesToKeep + ").*"))
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// avoid NPE on packages to keep (and keep all packages) //
|
||||||
|
// also, avoid the regex call if it's the default of "." (e.g., match all) //
|
||||||
|
// otherwise, check if the line matches "at (packagesToKeep).*" //
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
if(packagesToKeep == null || ".".equals(packagesToKeep) || line.matches("^\\s+at (" + packagesToKeep + ").*"))
|
||||||
{
|
{
|
||||||
keepLine = true;
|
keepLine = true;
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,14 @@ 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.QueryInput;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin;
|
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin;
|
||||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.DisplayFormat;
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.DisplayFormat;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType;
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.permissions.PermissionLevel;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.permissions.QPermissionRules;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QBackendStepMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.ExposedJoin;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.ExposedJoin;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||||
@ -80,6 +85,21 @@ public class ColumnStatsStep implements BackendStep
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public static QProcessMetaData getProcessMetaData()
|
||||||
|
{
|
||||||
|
return (new QProcessMetaData()
|
||||||
|
.withName("columnStats")
|
||||||
|
.withPermissionRules(new QPermissionRules().withLevel(PermissionLevel.NOT_PROTECTED))
|
||||||
|
.withStepList(List.of(new QBackendStepMetaData()
|
||||||
|
.withName("step")
|
||||||
|
.withCode(new QCodeReference(ColumnStatsStep.class)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -93,7 +93,7 @@ public class BaseStreamedETLStep
|
|||||||
qValueFormatter.setDisplayValuesInRecords(table, list);
|
qValueFormatter.setDisplayValuesInRecords(table, list);
|
||||||
|
|
||||||
QPossibleValueTranslator qPossibleValueTranslator = new QPossibleValueTranslator(input.getInstance(), input.getSession());
|
QPossibleValueTranslator qPossibleValueTranslator = new QPossibleValueTranslator(input.getInstance(), input.getSession());
|
||||||
qPossibleValueTranslator.translatePossibleValuesInRecords(input.getTable(), list);
|
qPossibleValueTranslator.translatePossibleValuesInRecords(table, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +226,43 @@ class QMetaDataVariableInterpreterTest extends BaseTest
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testGetStringFromPropertyOrEnvironment()
|
||||||
|
{
|
||||||
|
QMetaDataVariableInterpreter interpreter = new QMetaDataVariableInterpreter();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
// if neither prop nor env is set, get back the default //
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
assertEquals("default", interpreter.getStringFromPropertyOrEnvironment("notSet", "NOT_SET", "default"));
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// if only prop is set, get it //
|
||||||
|
/////////////////////////////////
|
||||||
|
assertEquals("default", interpreter.getStringFromPropertyOrEnvironment("foo.value", "FOO_VALUE", "default"));
|
||||||
|
System.setProperty("foo.value", "fooPropertyValue");
|
||||||
|
assertEquals("fooPropertyValue", interpreter.getStringFromPropertyOrEnvironment("foo.value", "FOO_VALUE", "default"));
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// if only env is set, get it //
|
||||||
|
////////////////////////////////
|
||||||
|
assertEquals("default", interpreter.getStringFromPropertyOrEnvironment("bar.value", "BAR_VALUE", "default"));
|
||||||
|
interpreter.setEnvironmentOverrides(Map.of("BAR_VALUE", "barEnvValue"));
|
||||||
|
assertEquals("barEnvValue", interpreter.getStringFromPropertyOrEnvironment("bar.value", "BAR_VALUE", "default"));
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// if both are set, get the prop //
|
||||||
|
///////////////////////////////////
|
||||||
|
System.setProperty("baz.value", "bazPropertyValue");
|
||||||
|
interpreter.setEnvironmentOverrides(Map.of("BAZ_VALUE", "bazEnvValue"));
|
||||||
|
assertEquals("bazPropertyValue", interpreter.getStringFromPropertyOrEnvironment("baz.value", "BAZ_VALUE", "default"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
Reference in New Issue
Block a user