mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Change type to come from abstract getType method, rather than member field in base class (force sub-class to deal with it); Add ability to incldue supplemental table meta data in frontend table meta data requests
This commit is contained in:
@ -100,7 +100,7 @@ public class QInstanceEnricher
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// let an instance define mappings to be applied during name-to-label enrichments, //
|
// let an instance define mappings to be applied during name-to-label enrichments, //
|
||||||
// e.g., to avoid ever incorrectly camel-casing an acronym (e.g., "Tla" shoudl always be "TLA") //
|
// e.g., to avoid ever incorrectly camel-casing an acronym (e.g., "Tla" should always be "TLA") //
|
||||||
// or to expand abbreviations in code (e.g., "Addr" should always be "Address" //
|
// or to expand abbreviations in code (e.g., "Addr" should always be "Address" //
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
private static final Map<String, String> labelMappings = new LinkedHashMap<>();
|
private static final Map<String, String> labelMappings = new LinkedHashMap<>();
|
||||||
|
@ -32,38 +32,11 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public abstract class QSupplementalInstanceMetaData
|
public abstract class QSupplementalInstanceMetaData
|
||||||
{
|
{
|
||||||
protected String type;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Getter for type
|
** Getter for type
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public String getType()
|
public abstract String getType();
|
||||||
{
|
|
||||||
return (this.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Fluent setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public QSupplementalInstanceMetaData withType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
return (this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,37 +28,10 @@ package com.kingsrook.qqq.backend.core.model.metadata.fields;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public abstract class QSupplementalFieldMetaData
|
public abstract class QSupplementalFieldMetaData
|
||||||
{
|
{
|
||||||
protected String type;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Getter for type
|
** Getter for type
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public String getType()
|
public abstract String getType();
|
||||||
{
|
|
||||||
return (this.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Fluent setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public QSupplementalFieldMetaData withType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
return (this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
@ -41,6 +42,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
|||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.Capability;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.Capability;
|
||||||
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.QFieldSection;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.QSupplementalTableMetaData;
|
||||||
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;
|
||||||
|
|
||||||
@ -57,14 +59,12 @@ public class QFrontendTableMetaData
|
|||||||
private String label;
|
private String label;
|
||||||
private boolean isHidden;
|
private boolean isHidden;
|
||||||
private String primaryKeyField;
|
private String primaryKeyField;
|
||||||
|
|
||||||
private String iconName;
|
private String iconName;
|
||||||
|
|
||||||
private Map<String, QFrontendFieldMetaData> fields;
|
private Map<String, QFrontendFieldMetaData> fields;
|
||||||
private List<QFieldSection> sections;
|
private List<QFieldSection> sections;
|
||||||
|
|
||||||
private List<QFrontendExposedJoin> exposedJoins;
|
private List<QFrontendExposedJoin> exposedJoins;
|
||||||
|
private Map<String, QSupplementalTableMetaData> supplementalTableMetaData;
|
||||||
private Set<String> capabilities;
|
private Set<String> capabilities;
|
||||||
|
|
||||||
private boolean readPermission;
|
private boolean readPermission;
|
||||||
@ -81,13 +81,13 @@ public class QFrontendTableMetaData
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public QFrontendTableMetaData(AbstractActionInput actionInput, QBackendMetaData backendForTable, QTableMetaData tableMetaData, boolean includeFields, boolean includeJoins)
|
public QFrontendTableMetaData(AbstractActionInput actionInput, QBackendMetaData backendForTable, QTableMetaData tableMetaData, boolean includeFullMetaData, boolean includeJoins)
|
||||||
{
|
{
|
||||||
this.name = tableMetaData.getName();
|
this.name = tableMetaData.getName();
|
||||||
this.label = tableMetaData.getLabel();
|
this.label = tableMetaData.getLabel();
|
||||||
this.isHidden = tableMetaData.getIsHidden();
|
this.isHidden = tableMetaData.getIsHidden();
|
||||||
|
|
||||||
if(includeFields)
|
if(includeFullMetaData)
|
||||||
{
|
{
|
||||||
this.primaryKeyField = tableMetaData.getPrimaryKeyField();
|
this.primaryKeyField = tableMetaData.getPrimaryKeyField();
|
||||||
this.fields = new HashMap<>();
|
this.fields = new HashMap<>();
|
||||||
@ -116,7 +116,7 @@ public class QFrontendTableMetaData
|
|||||||
QTableMetaData joinTable = qInstance.getTable(exposedJoin.getJoinTable());
|
QTableMetaData joinTable = qInstance.getTable(exposedJoin.getJoinTable());
|
||||||
frontendExposedJoin.setLabel(exposedJoin.getLabel());
|
frontendExposedJoin.setLabel(exposedJoin.getLabel());
|
||||||
frontendExposedJoin.setIsMany(exposedJoin.getIsMany());
|
frontendExposedJoin.setIsMany(exposedJoin.getIsMany());
|
||||||
frontendExposedJoin.setJoinTable(new QFrontendTableMetaData(actionInput, backendForTable, joinTable, includeFields, false));
|
frontendExposedJoin.setJoinTable(new QFrontendTableMetaData(actionInput, backendForTable, joinTable, includeFullMetaData, false));
|
||||||
for(String joinName : exposedJoin.getJoinPath())
|
for(String joinName : exposedJoin.getJoinPath())
|
||||||
{
|
{
|
||||||
frontendExposedJoin.addJoin(qInstance.getJoin(joinName));
|
frontendExposedJoin.addJoin(qInstance.getJoin(joinName));
|
||||||
@ -124,6 +124,28 @@ public class QFrontendTableMetaData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// include supplemental meta data, based on if it's meant for full or partial frontend meta-data requests //
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
for(QSupplementalTableMetaData supplementalTableMetaData : CollectionUtils.nonNullMap(tableMetaData.getSupplementalMetaData()).values())
|
||||||
|
{
|
||||||
|
boolean include;
|
||||||
|
if(includeFullMetaData)
|
||||||
|
{
|
||||||
|
include = supplementalTableMetaData.includeInFullFrontendMetaData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
include = supplementalTableMetaData.includeInPartialFrontendMetaData();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(include)
|
||||||
|
{
|
||||||
|
this.supplementalTableMetaData = Objects.requireNonNullElseGet(this.supplementalTableMetaData, HashMap::new);
|
||||||
|
this.supplementalTableMetaData.put(supplementalTableMetaData.getType(), supplementalTableMetaData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(tableMetaData.getIcon() != null)
|
if(tableMetaData.getIcon() != null)
|
||||||
{
|
{
|
||||||
this.iconName = tableMetaData.getIcon().getName();
|
this.iconName = tableMetaData.getIcon().getName();
|
||||||
@ -302,4 +324,15 @@ public class QFrontendTableMetaData
|
|||||||
{
|
{
|
||||||
return exposedJoins;
|
return exposedJoins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Getter for supplementalTableMetaData
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public Map<String, QSupplementalTableMetaData> getSupplementalTableMetaData()
|
||||||
|
{
|
||||||
|
return supplementalTableMetaData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,38 +33,12 @@ import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public abstract class QSupplementalProcessMetaData
|
public abstract class QSupplementalProcessMetaData
|
||||||
{
|
{
|
||||||
protected String type;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Getter for type
|
** Getter for type
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public String getType()
|
public abstract String getType();
|
||||||
{
|
|
||||||
return (this.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Fluent setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public QSupplementalProcessMetaData withType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
return (this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,38 +28,32 @@ package com.kingsrook.qqq.backend.core.model.metadata.tables;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public abstract class QSupplementalTableMetaData
|
public abstract class QSupplementalTableMetaData
|
||||||
{
|
{
|
||||||
protected String type;
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public boolean includeInPartialFrontendMetaData()
|
||||||
|
{
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public boolean includeInFullFrontendMetaData()
|
||||||
|
{
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Getter for type
|
** Getter for type
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public String getType()
|
public abstract String getType();
|
||||||
{
|
|
||||||
return (this.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
** Fluent setter for type
|
|
||||||
*******************************************************************************/
|
|
||||||
public QSupplementalTableMetaData withType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
return (this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ public class ApiInstanceMetaDataContainer extends QSupplementalInstanceMetaData
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public ApiInstanceMetaDataContainer()
|
public ApiInstanceMetaDataContainer()
|
||||||
{
|
{
|
||||||
setType(ApiSupplementType.NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,6 +60,17 @@ public class ApiInstanceMetaDataContainer extends QSupplementalInstanceMetaData
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return (ApiSupplementType.NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -40,13 +40,13 @@ public class ApiFieldMetaDataContainer extends QSupplementalFieldMetaData
|
|||||||
private ApiFieldMetaData defaultApiFieldMetaData;
|
private ApiFieldMetaData defaultApiFieldMetaData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Constructor
|
** Constructor
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public ApiFieldMetaDataContainer()
|
public ApiFieldMetaDataContainer()
|
||||||
{
|
{
|
||||||
setType("api");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,4 +162,14 @@ public class ApiFieldMetaDataContainer extends QSupplementalFieldMetaData
|
|||||||
return (this);
|
return (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return (ApiSupplementType.NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ public class ApiProcessMetaDataContainer extends QSupplementalProcessMetaData
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public ApiProcessMetaDataContainer()
|
public ApiProcessMetaDataContainer()
|
||||||
{
|
{
|
||||||
setType(ApiSupplementType.NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,6 +79,17 @@ public class ApiProcessMetaDataContainer extends QSupplementalProcessMetaData
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return (ApiSupplementType.NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -40,12 +40,11 @@ public class ApiTableMetaDataContainer extends QSupplementalTableMetaData
|
|||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Constructor
|
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public ApiTableMetaDataContainer()
|
public static ApiTableMetaDataContainer of(QTableMetaData table)
|
||||||
{
|
{
|
||||||
setType("api");
|
return ((ApiTableMetaDataContainer) table.getSupplementalMetaData(ApiSupplementType.NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,9 +52,9 @@ public class ApiTableMetaDataContainer extends QSupplementalTableMetaData
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static ApiTableMetaDataContainer of(QTableMetaData table)
|
public String getType()
|
||||||
{
|
{
|
||||||
return ((ApiTableMetaDataContainer) table.getSupplementalMetaData(ApiSupplementType.NAME));
|
return (ApiSupplementType.NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user