mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 06:00:44 +00:00
Add field sections, record labels, display values being populated
This commit is contained in:
@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.core.actions.tables;
|
||||
|
||||
|
||||
import com.kingsrook.qqq.backend.core.actions.ActionHelper;
|
||||
import com.kingsrook.qqq.backend.core.actions.values.QValueFormatter;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
|
||||
@ -48,6 +49,10 @@ public class QueryAction
|
||||
// todo pre-customization - just get to modify the request?
|
||||
QueryOutput queryOutput = qModule.getQueryInterface().execute(queryInput);
|
||||
// todo post-customization - can do whatever w/ the result if you want
|
||||
|
||||
QValueFormatter.setDisplayValuesInRecords(queryInput.getTable(), queryOutput.getRecords());
|
||||
|
||||
return queryOutput;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,10 @@ package com.kingsrook.qqq.backend.core.actions.values;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -63,7 +66,25 @@ public class QValueFormatter
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
LOG.warn("Error formatting value [" + value + "] for field [" + field.getName() + "] with format [" + field.getDisplayFormat() + "]: " + e.getMessage());
|
||||
try
|
||||
{
|
||||
if(e.getMessage().equals("f != java.lang.Integer"))
|
||||
{
|
||||
return formatValue(field, ValueUtils.getValueAsBigDecimal(value));
|
||||
}
|
||||
else if(e.getMessage().equals("d != java.math.BigDecimal"))
|
||||
{
|
||||
return formatValue(field, ValueUtils.getValueAsInteger(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG.warn("Error formatting value [" + value + "] for field [" + field.getName() + "] with format [" + field.getDisplayFormat() + "]: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
catch(Exception e2)
|
||||
{
|
||||
LOG.warn("Caught secondary exception trying to convert type on field [" + field.getName() + "] for formatting", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,4 +93,86 @@ public class QValueFormatter
|
||||
////////////////////////////////////////
|
||||
return (ValueUtils.getValueAsString(value));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Make a string from a table's recordLabelFormat and fields, for a given record.
|
||||
*******************************************************************************/
|
||||
public static String formatRecordLabel(QTableMetaData table, QRecord record)
|
||||
{
|
||||
if(!StringUtils.hasContent(table.getRecordLabelFormat()))
|
||||
{
|
||||
return (formatRecordLabelExceptionalCases(table, record));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// get list of values, then pass them to the string formatter method //
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
try
|
||||
{
|
||||
List<Serializable> values = table.getRecordLabelFields().stream()
|
||||
.map(record::getValue)
|
||||
.map(v -> v == null ? "" : v)
|
||||
.toList();
|
||||
return (table.getRecordLabelFormat().formatted(values.toArray()));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return (formatRecordLabelExceptionalCases(table, record));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Deal with non-happy-path cases for making a record label.
|
||||
*******************************************************************************/
|
||||
private static String formatRecordLabelExceptionalCases(QTableMetaData table, QRecord record)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// if there's no record label format, then just return the primary key display value //
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
String pkeyDisplayValue = record.getDisplayValue(table.getPrimaryKeyField());
|
||||
if(StringUtils.hasContent(pkeyDisplayValue))
|
||||
{
|
||||
return (pkeyDisplayValue);
|
||||
}
|
||||
|
||||
String pkeyRawValue = ValueUtils.getValueAsString(record.getValue(table.getPrimaryKeyField()));
|
||||
if(StringUtils.hasContent(pkeyRawValue))
|
||||
{
|
||||
return (pkeyRawValue);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// worst case scenario, return empty string, but never null from this method //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
return ("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** For a list of records, set their recordLabels and display values
|
||||
*******************************************************************************/
|
||||
public static void setDisplayValuesInRecords(QTableMetaData table, List<QRecord> records)
|
||||
{
|
||||
if(records == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(QRecord record : records)
|
||||
{
|
||||
for(QFieldMetaData field : table.getFields().values())
|
||||
{
|
||||
String formattedValue = QValueFormatter.formatValue(field, record.getValue(field.getName()));
|
||||
record.setDisplayValue(field.getName(), formattedValue);
|
||||
}
|
||||
|
||||
record.setRecordLabel(QValueFormatter.formatRecordLabel(table, record));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,8 +23,10 @@ package com.kingsrook.qqq.backend.core.instances;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
@ -32,6 +34,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
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.layout.QAppMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QBackendStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QComponentType;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QFrontendComponentMetaData;
|
||||
@ -41,13 +44,16 @@ import com.kingsrook.qqq.backend.core.model.metadata.processes.QFunctionOutputMe
|
||||
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.processes.QStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.bulk.delete.BulkDeleteStoreStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.bulk.edit.BulkEditReceiveValuesStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.bulk.edit.BulkEditStoreRecordsStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.BulkInsertReceiveFileStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.BulkInsertStoreRecordsStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.general.LoadInitialRecordsStep;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
|
||||
|
||||
@ -111,6 +117,11 @@ public class QInstanceEnricher
|
||||
{
|
||||
table.getFields().values().forEach(this::enrich);
|
||||
}
|
||||
|
||||
if(CollectionUtils.nullSafeIsEmpty(table.getSections()))
|
||||
{
|
||||
generateTableFieldSections(table);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -196,12 +207,19 @@ public class QInstanceEnricher
|
||||
*******************************************************************************/
|
||||
private String nameToLabel(String name)
|
||||
{
|
||||
if(name == null)
|
||||
if(!StringUtils.hasContent(name))
|
||||
{
|
||||
return (null);
|
||||
return (name);
|
||||
}
|
||||
|
||||
return (name.substring(0, 1).toUpperCase(Locale.ROOT) + name.substring(1).replaceAll("([A-Z])", " $1"));
|
||||
if(name.length() == 1)
|
||||
{
|
||||
return (name.substring(0, 1).toUpperCase(Locale.ROOT));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (name.substring(0, 1).toUpperCase(Locale.ROOT) + name.substring(1).replaceAll("([A-Z])", " $1"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -422,4 +440,71 @@ public class QInstanceEnricher
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** If a table didn't have any sections, generate "sensible defaults"
|
||||
*******************************************************************************/
|
||||
private void generateTableFieldSections(QTableMetaData table)
|
||||
{
|
||||
if(CollectionUtils.nullSafeIsEmpty(table.getFields()))
|
||||
{
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// assume this table is invalid if it has no fields, but surely it doesn't need any sections then. //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
return;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// create an identity section for the id and any fields in the record label //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
QFieldSection identitySection = new QFieldSection("identity", "Identity", new QIcon("badge"), Tier.T1, new ArrayList<>());
|
||||
|
||||
Set<String> usedFieldNames = new HashSet<>();
|
||||
|
||||
if(StringUtils.hasContent(table.getPrimaryKeyField()))
|
||||
{
|
||||
identitySection.getFieldNames().add(table.getPrimaryKeyField());
|
||||
usedFieldNames.add(table.getPrimaryKeyField());
|
||||
}
|
||||
|
||||
if(CollectionUtils.nullSafeHasContents(table.getRecordLabelFields()))
|
||||
{
|
||||
for(String fieldName : table.getRecordLabelFields())
|
||||
{
|
||||
if(!usedFieldNames.contains(fieldName))
|
||||
{
|
||||
identitySection.getFieldNames().add(fieldName);
|
||||
usedFieldNames.add(fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!identitySection.getFieldNames().isEmpty())
|
||||
{
|
||||
table.addSection(identitySection);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// if there are more fields, then add them in a default/Other Fields section //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
QFieldSection otherSection = new QFieldSection("otherFields", "Other Fields", new QIcon("dataset"), Tier.T2, new ArrayList<>());
|
||||
if(CollectionUtils.nullSafeHasContents(table.getFields()))
|
||||
{
|
||||
for(String fieldName : table.getFields().keySet())
|
||||
{
|
||||
if(!usedFieldNames.contains(fieldName))
|
||||
{
|
||||
otherSection.getFieldNames().add(fieldName);
|
||||
usedFieldNames.add(fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!otherSection.getFieldNames().isEmpty())
|
||||
{
|
||||
table.addSection(otherSection);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppChildMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
|
||||
@ -160,12 +163,63 @@ public class QInstanceValidator
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// validate field sections in the table //
|
||||
//////////////////////////////////////////
|
||||
Set<String> fieldNamesInSections = new HashSet<>();
|
||||
QFieldSection tier1Section = null;
|
||||
if(table.getSections() != null)
|
||||
{
|
||||
for(QFieldSection section : table.getSections())
|
||||
{
|
||||
validateSection(errors, table, section, fieldNamesInSections);
|
||||
if(section.getTier().equals(Tier.T1))
|
||||
{
|
||||
assertCondition(errors, tier1Section == null, "Table " + tableName + " has more than 1 section listed as Tier 1");
|
||||
tier1Section = section;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(CollectionUtils.nullSafeHasContents(table.getFields()))
|
||||
{
|
||||
for(String fieldName : table.getFields().keySet())
|
||||
{
|
||||
assertCondition(errors, fieldNamesInSections.contains(fieldName), "Table " + tableName + " field " + fieldName + " is not listed in any field sections.");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private void validateSection(List<String> errors, QTableMetaData table, QFieldSection section, Set<String> fieldNamesInSections)
|
||||
{
|
||||
assertCondition(errors, StringUtils.hasContent(section.getName()), "Missing a name for field section in table " + table.getName() + ".");
|
||||
assertCondition(errors, StringUtils.hasContent(section.getLabel()), "Missing a label for field section in table " + table.getLabel() + ".");
|
||||
if(assertCondition(errors, CollectionUtils.nullSafeHasContents(section.getFieldNames()), "Table " + table.getName() + " section " + section.getName() + " does not have any fields."))
|
||||
{
|
||||
if(table.getFields() != null)
|
||||
{
|
||||
for(String fieldName : section.getFieldNames())
|
||||
{
|
||||
assertCondition(errors, table.getFields().containsKey(fieldName), "Table " + table.getName() + " section " + section.getName() + " specifies fieldName " + fieldName + ", which is not a field on this table.");
|
||||
assertCondition(errors, !fieldNamesInSections.contains(fieldName), "Table " + table.getName() + " has field " + fieldName + " listed more than once in its field sections.");
|
||||
|
||||
fieldNamesInSections.add(fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
@ -29,7 +29,6 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.kingsrook.qqq.backend.core.actions.values.QValueFormatter;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
@ -55,7 +54,9 @@ import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
*******************************************************************************/
|
||||
public class QRecord implements Serializable
|
||||
{
|
||||
private String tableName;
|
||||
private String tableName;
|
||||
private String recordLabel;
|
||||
|
||||
private Map<String, Serializable> values = new LinkedHashMap<>();
|
||||
private Map<String, String> displayValues = new LinkedHashMap<>();
|
||||
private Map<String, Serializable> backendDetails = new LinkedHashMap<>();
|
||||
@ -90,6 +91,7 @@ public class QRecord implements Serializable
|
||||
public QRecord(QRecord record)
|
||||
{
|
||||
this.tableName = record.tableName;
|
||||
this.recordLabel = record.recordLabel;
|
||||
this.values = record.values;
|
||||
this.displayValues = record.displayValues;
|
||||
this.backendDetails = record.backendDetails;
|
||||
@ -139,15 +141,6 @@ public class QRecord implements Serializable
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setDisplayValue(QFieldMetaData field, Serializable rawValue)
|
||||
{
|
||||
displayValues.put(field.getName(), QValueFormatter.formatValue(field, rawValue));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -160,17 +153,6 @@ public class QRecord implements Serializable
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QRecord withDisplayValue(QFieldMetaData field, Serializable rawValue)
|
||||
{
|
||||
setDisplayValue(field, rawValue);
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tableName
|
||||
**
|
||||
@ -205,6 +187,39 @@ public class QRecord implements Serializable
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for recordLabel
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getRecordLabel()
|
||||
{
|
||||
return recordLabel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for recordLabel
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setRecordLabel(String recordLabel)
|
||||
{
|
||||
this.recordLabel = recordLabel;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for recordLabel
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QRecord withRecordLabel(String recordLabel)
|
||||
{
|
||||
this.recordLabel = recordLabel;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for values
|
||||
**
|
||||
|
@ -61,10 +61,6 @@ public enum QFieldType
|
||||
{
|
||||
return (INTEGER);
|
||||
}
|
||||
if(c.equals(Boolean.class))
|
||||
{
|
||||
return (BOOLEAN);
|
||||
}
|
||||
if(c.equals(BigDecimal.class))
|
||||
{
|
||||
return (DECIMAL);
|
||||
|
@ -30,6 +30,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QFrontendStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -45,6 +46,8 @@ public class QFrontendProcessMetaData
|
||||
private String tableName;
|
||||
private boolean isHidden;
|
||||
|
||||
private String iconName;
|
||||
|
||||
private List<QFrontendStepMetaData> frontendSteps;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@ -77,6 +80,11 @@ public class QFrontendProcessMetaData
|
||||
frontendSteps = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
if(processMetaData.getIcon() != null && StringUtils.hasContent(processMetaData.getIcon().getName()))
|
||||
{
|
||||
this.iconName = processMetaData.getIcon().getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -148,12 +156,12 @@ public class QFrontendProcessMetaData
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for isHidden
|
||||
** Getter for iconName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setIsHidden(boolean isHidden)
|
||||
public String getIconName()
|
||||
{
|
||||
this.isHidden = isHidden;
|
||||
return iconName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,11 +23,14 @@ package com.kingsrook.qqq.backend.core.model.metadata.frontend;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -43,7 +46,10 @@ public class QFrontendTableMetaData
|
||||
private boolean isHidden;
|
||||
private String primaryKeyField;
|
||||
|
||||
private String iconName;
|
||||
|
||||
private Map<String, QFrontendFieldMetaData> fields;
|
||||
private List<QFieldSection> sections;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// do not add setters. take values from the source-object in the constructor!! //
|
||||
@ -68,6 +74,13 @@ public class QFrontendTableMetaData
|
||||
{
|
||||
this.fields.put(entry.getKey(), new QFrontendFieldMetaData(entry.getValue()));
|
||||
}
|
||||
|
||||
this.sections = tableMetaData.getSections();
|
||||
}
|
||||
|
||||
if(tableMetaData.getIcon() != null && StringUtils.hasContent(tableMetaData.getIcon().getName()))
|
||||
{
|
||||
this.iconName = tableMetaData.getIcon().getName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +130,17 @@ public class QFrontendTableMetaData
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for sections
|
||||
**
|
||||
*******************************************************************************/
|
||||
public List<QFieldSection> getSections()
|
||||
{
|
||||
return sections;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for isHidden
|
||||
**
|
||||
@ -129,11 +153,11 @@ public class QFrontendTableMetaData
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for isHidden
|
||||
** Getter for iconName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setIsHidden(boolean isHidden)
|
||||
public String getIconName()
|
||||
{
|
||||
this.isHidden = isHidden;
|
||||
return iconName;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppChildMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -44,6 +44,7 @@ public class QProcessMetaData implements QAppChildMetaData
|
||||
private List<QStepMetaData> stepList;
|
||||
|
||||
private String parentAppName;
|
||||
private QIcon icon;
|
||||
|
||||
|
||||
|
||||
@ -321,4 +322,38 @@ public class QProcessMetaData implements QAppChildMetaData
|
||||
this.parentAppName = parentAppName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for icon
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QIcon getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for icon
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setIcon(QIcon icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for icon
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QProcessMetaData withIcon(QIcon icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* QQQ - Low-code Application Framework for Engineers.
|
||||
* Copyright (C) 2021-2022. Kingsrook, LLC
|
||||
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||
* contact@kingsrook.com
|
||||
* https://github.com/Kingsrook/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.kingsrook.qqq.backend.core.model.metadata.tables;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** A section of fields - a logical grouping.
|
||||
*******************************************************************************/
|
||||
public class QFieldSection
|
||||
{
|
||||
private String name;
|
||||
private String label;
|
||||
private Tier tier;
|
||||
|
||||
private List<String> fieldNames;
|
||||
private QIcon icon;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QFieldSection()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QFieldSection(String name, String label, QIcon icon, Tier tier, List<String> fieldNames)
|
||||
{
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.icon = icon;
|
||||
this.tier = tier;
|
||||
this.fieldNames = fieldNames;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for name
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for name
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for name
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QFieldSection withName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for label
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for label
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for label
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QFieldSection withLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tier
|
||||
**
|
||||
*******************************************************************************/
|
||||
public Tier getTier()
|
||||
{
|
||||
return tier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for tier
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setTier(Tier tier)
|
||||
{
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tier
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QFieldSection withTier(Tier tier)
|
||||
{
|
||||
this.tier = tier;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for fieldNames
|
||||
**
|
||||
*******************************************************************************/
|
||||
public List<String> getFieldNames()
|
||||
{
|
||||
return fieldNames;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for fieldNames
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setFieldNames(List<String> fieldNames)
|
||||
{
|
||||
this.fieldNames = fieldNames;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for fieldNames
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QFieldSection withFieldNames(List<String> fieldNames)
|
||||
{
|
||||
this.fieldNames = fieldNames;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for icon
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QIcon getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for icon
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setIcon(QIcon icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for icon
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QFieldSection withIcon(QIcon icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.core.model.metadata.tables;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -64,6 +65,12 @@ public class QTableMetaData implements QAppChildMetaData, Serializable
|
||||
private String parentAppName;
|
||||
private QIcon icon;
|
||||
|
||||
private String recordLabelFormat;
|
||||
private List<String> recordLabelFields;
|
||||
|
||||
private List<QFieldSection> sections;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Default constructor.
|
||||
@ -496,6 +503,7 @@ public class QTableMetaData implements QAppChildMetaData, Serializable
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for icon
|
||||
**
|
||||
@ -506,4 +514,131 @@ public class QTableMetaData implements QAppChildMetaData, Serializable
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for recordLabelFormat
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getRecordLabelFormat()
|
||||
{
|
||||
return recordLabelFormat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for recordLabelFormat
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setRecordLabelFormat(String recordLabelFormat)
|
||||
{
|
||||
this.recordLabelFormat = recordLabelFormat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for recordLabelFormat
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QTableMetaData withRecordLabelFormat(String recordLabelFormat)
|
||||
{
|
||||
this.recordLabelFormat = recordLabelFormat;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for recordLabelFields
|
||||
**
|
||||
*******************************************************************************/
|
||||
public List<String> getRecordLabelFields()
|
||||
{
|
||||
return recordLabelFields;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for recordLabelFields
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setRecordLabelFields(List<String> recordLabelFields)
|
||||
{
|
||||
this.recordLabelFields = recordLabelFields;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for recordLabelFields
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QTableMetaData withRecordLabelFields(List<String> recordLabelFields)
|
||||
{
|
||||
this.recordLabelFields = recordLabelFields;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for sections
|
||||
**
|
||||
*******************************************************************************/
|
||||
public List<QFieldSection> getSections()
|
||||
{
|
||||
return sections;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for sections
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setSections(List<QFieldSection> sections)
|
||||
{
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for sections
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QTableMetaData withSections(List<QFieldSection> fieldSections)
|
||||
{
|
||||
this.sections = fieldSections;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void addSection(QFieldSection fieldSection)
|
||||
{
|
||||
if(this.sections == null)
|
||||
{
|
||||
this.sections = new ArrayList<>();
|
||||
}
|
||||
this.sections.add(fieldSection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QTableMetaData withSection(QFieldSection fieldSection)
|
||||
{
|
||||
addSection(fieldSection);
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* QQQ - Low-code Application Framework for Engineers.
|
||||
* Copyright (C) 2021-2022. Kingsrook, LLC
|
||||
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||
* contact@kingsrook.com
|
||||
* https://github.com/Kingsrook/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.kingsrook.qqq.backend.core.model.metadata.tables;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public enum Tier
|
||||
{
|
||||
T1,
|
||||
T2,
|
||||
T3
|
||||
}
|
@ -65,7 +65,6 @@ public class MockQueryAction implements QueryInterface
|
||||
{
|
||||
Serializable value = field.equals("id") ? (i + 1) : getValue(table, field);
|
||||
record.setValue(field, value);
|
||||
record.setDisplayValue(table.getField(field), value);
|
||||
}
|
||||
|
||||
queryOutput.addRecord(record);
|
||||
|
Reference in New Issue
Block a user