Skip to content

Commit

Permalink
#613 adding support for "exclude" in outputMaps
Browse files Browse the repository at this point in the history
- Also general cleanups towards truly case-insensitive column processing
  • Loading branch information
ldhasson committed Jun 3, 2021
1 parent 30ac9ce commit a082fee
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/tilda/generation/html/Docs.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ else if (O._FST == FrameworkSourcedType.CLONED)
continue;
String bgColor = i % 2 == 0 ? "#FFFFFF" : "rgba(160, 199, 234, 0.2)";
String FieldType = view != null && view.getFormula(C.getName()) != null ? "formulae" : "columns";
if (view != null && view._Realize != null && TextUtil.findStarElement(view._Realize._Exclude_DEPRECATED, C.getName(), false, 0) == -1)
if (view != null && view._Realize != null && TextUtil.findStarElement(view._Realize._Exclude_DEPRECATED, C.getName(), true, 0) == -1)
FieldType = FieldType + " realized" + FieldType;
Out.println(" <TR valign=\"top\" style=\"background-color:" + bgColor + ";\">");
Out.println(" <TD>" + i + "&nbsp;&nbsp;</TD>");
Expand All @@ -310,7 +310,7 @@ else if (O._FST == FrameworkSourcedType.CLONED)
Out.println("<TD align=\"center\">" + (C._Nullable == true ? "&#x2611;" : "&#x2610") + "&nbsp;&nbsp;</TD>");
if (view != null && view._Realize != null)
{
Out.print("<TD align=\"center\">" + (TextUtil.findStarElement(view._Realize._Exclude_DEPRECATED, C.getName(), false, 0) == -1 ? "&#x2611;<!--R-->" : "&#x2610;") + "&nbsp;&nbsp;</TD>");
Out.print("<TD align=\"center\">" + (TextUtil.findStarElement(view._Realize._Exclude_DEPRECATED, C.getName(), true, 0) == -1 ? "&#x2611;<!--R-->" : "&#x2610;") + "&nbsp;&nbsp;</TD>");
}
if (O._Mode != ObjectMode.DB_ONLY)
{
Expand Down
24 changes: 18 additions & 6 deletions src/tilda/parsing/parts/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ protected boolean ValidateOutputMappings(ParserSession PS)
* @return
*/
protected List<String> expandColumnNames(String[] vals, ParserSession PS, String constructType, String constructName)
{
return expandColumnNames(vals, PS, constructType, constructName, null);
}

/**
* "colA", "abc*"
*
* @param vals
* @return
*/
protected List<String> expandColumnNames(String[] vals, ParserSession PS, String constructType, String constructName, String[] exclude)
{
String[] colNames = getColumnNames();
Set<String> S = new HashSet<String>(); // gotta be a set in case multiple column templates resolve to the same column name(s).
Expand All @@ -228,12 +239,13 @@ protected List<String> expandColumnNames(String[] vals, ParserSession PS, String
boolean found = false;
for (String colName : colNames)
{
if (TextUtil.findStarElement(valsA, colName, false, 0) != -1)
{
if (S.add(colName) == true)
L.add(colName);
found = true;
}
if (TextUtil.findStarElement(valsA, colName, true, 0) == -1)
continue;
if (exclude != null && exclude.length > 0 && TextUtil.findStarElement(exclude, colName, true, 0) != -1)
continue;
if (S.add(colName) == true)
L.add(colName);
found = true;
}
if (found == false)
PS.AddError("Object/View " + this.getFullName() + " is defining a column template '" + val + "' for " + constructType + " '" + constructName + "' which doesn't map to any columns.");
Expand Down
4 changes: 2 additions & 2 deletions src/tilda/parsing/parts/OutputMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public OutputMapping()
/*@formatter:off*/
@SerializedName("name" ) public String _Name;
@SerializedName("columns" ) public String[] _Columns;
@SerializedName("exclude" ) public String[] _Exclude = new String[] { };
@SerializedName("sync" ) public boolean _Sync = false;
@SerializedName("outTypes" ) public String[] _OutputTypeStrs;
@SerializedName("nvpSrc" ) public String _NVPSrcStr;
Expand All @@ -58,7 +59,6 @@ public OutputMapping(OutputMapping OM)
_NVPSrcStr = OM._NVPSrcStr;
_NVPValueTypeStr = OM._NVPValueTypeStr;
}


public transient List<Column> _ColumnObjs;
public transient List<OutputFormatType> _OutputTypes;
Expand All @@ -81,7 +81,7 @@ public boolean Validate(ParserSession PS, Base ParentObject)

if (_Columns != null && _Columns.length > 0)
{
_Columns = CollectionUtil.toStringArray(_ParentObject.expandColumnNames(_Columns, PS, "outputMap", _Name));
_Columns = CollectionUtil.toStringArray(_ParentObject.expandColumnNames(_Columns, PS, "outputMap", _Name, _Exclude));
}

if (TextUtil.isNullOrEmpty(_Columns) == true)
Expand Down
16 changes: 8 additions & 8 deletions src/tilda/parsing/parts/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,12 @@ private void CopyDependentObjectFields(int i, ViewColumn VC, String Prefix, Obje
|| col._FCT != FrameworkColumnType.NONE && col._FCT != FrameworkColumnType.TS && col._FCT.isOCC() == false)
// if (col._FrameworkManaged == true)
continue;
if (TextUtil.findStarElement(VC._Exclude, col._Name, false, 0) != -1)
if (TextUtil.findStarElement(VC._Exclude, col._Name, true, 0) != -1)
continue;
if (col._Name.startsWith(startingWith) == false)
continue;
ViewColumn NewVC = new ViewColumn();
if (TextUtil.findStarElement(VC._Block, col._Name, false, 0) != -1)
if (TextUtil.findStarElement(VC._Block, col._Name, true, 0) != -1)
NewVC._FormulaOnly = true;
NewVC._SameAs = col.getFullName();
NewVC._As = VC._As;
Expand All @@ -867,7 +867,7 @@ private void CopyDependentViewFields(int i, ViewColumn VC, String Prefix, View V
if (col._FCT == FrameworkColumnType.TZ
|| col._FCT != FrameworkColumnType.NONE && col._FCT != FrameworkColumnType.TS && col._FCT.isOCC() == false)
continue;
if (TextUtil.findStarElement(VC._Exclude, col._Name, false, 0) != -1)
if (TextUtil.findStarElement(VC._Exclude, col._Name, true, 0) != -1)
continue;
if (col._JoinOnly == true || col._FormulaOnly == true)
continue;
Expand All @@ -890,7 +890,7 @@ private void CopyDependentViewFields(int i, ViewColumn VC, String Prefix, View V
NewVC._Precision = col._Precision;
}

if (TextUtil.findStarElement(VC._Block, col._Name, false, 0) != -1)
if (TextUtil.findStarElement(VC._Block, col._Name, true, 0) != -1)
NewVC._FormulaOnly = true;
_ViewColumns.add(i + j, NewVC);
_PadderColumnNames.track(NewVC.getName());
Expand All @@ -906,7 +906,7 @@ private void CopyDependentViewFields(int i, ViewColumn VC, String Prefix, View V
for (ViewPivotAggregate A : P._Aggregates)
for (Value VPV : P._Values)
{
if (TextUtil.findStarElement(VC._Exclude, TextUtil.print(VPV._Name, VPV._Value), false, 0) != -1)
if (TextUtil.findStarElement(VC._Exclude, TextUtil.print(VPV._Name, VPV._Value), true, 0) != -1)
continue;
String SrcColName = A.makeName(VPV);
if (SrcColName.startsWith(startingWith) == false)
Expand All @@ -925,7 +925,7 @@ private void CopyDependentViewFields(int i, ViewColumn VC, String Prefix, View V
for (Value VPV : P._Values)
for (ViewPivotAggregate A : P._Aggregates)
{
if (TextUtil.findStarElement(VC._Exclude, TextUtil.print(VPV._Name, VPV._Value), false, 0) != -1)
if (TextUtil.findStarElement(VC._Exclude, TextUtil.print(VPV._Name, VPV._Value), true, 0) != -1)
continue;
String SrcColName = A.makeName(VPV);
if (SrcColName.startsWith(startingWith) == false)
Expand All @@ -942,7 +942,7 @@ private void CopyDependentViewFields(int i, ViewColumn VC, String Prefix, View V
}
for (Formula F : V._Formulas)
{
if (TextUtil.findStarElement(VC._Exclude, F._Name, false, 0) != -1)
if (TextUtil.findStarElement(VC._Exclude, F._Name, true, 0) != -1)
continue;
if (F._Name.startsWith(startingWith) == false)
continue;
Expand All @@ -951,7 +951,7 @@ private void CopyDependentViewFields(int i, ViewColumn VC, String Prefix, View V
NewVC._Name = Prefix + F._Name;
NewVC._As = VC._As;
NewVC._FCT = VC._FCT;
if (TextUtil.findStarElement(VC._Block, F._Name, false, 0) != -1)
if (TextUtil.findStarElement(VC._Block, F._Name, true, 0) != -1)
NewVC._FormulaOnly = true;
_ViewColumns.add(i + j, NewVC);
_PadderColumnNames.track(NewVC.getName());
Expand Down
2 changes: 1 addition & 1 deletion src/tilda/parsing/parts/ViewRealize.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public boolean Validate(ParserSession PS, View ParentView, ViewRealizedWrapper P
// LOG.debug(ParentRealized._O.getFullName()+": "+TextUtil.print(ParentRealized._O.getColumnNames()));
for (Column C : ParentRealized._O._Columns)
{
if (TextUtil.findStarElement(_Exclude_DEPRECATED, C._Name, false, 0) == -1)
if (TextUtil.findStarElement(_Exclude_DEPRECATED, C._Name, true, 0) == -1)
{
if (C._FCT.isOCC() == true)
OCC = true;
Expand Down

0 comments on commit a082fee

Please sign in to comment.