Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added DIST/XLSReport_mx8_6.1.6.mpk
Binary file not shown.
35 changes: 30 additions & 5 deletions javasource/xlsreport/report/DataOQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.mendix.systemwideinterfaces.connectionbus.data.IDataTable;
import com.mendix.systemwideinterfaces.connectionbus.requests.types.IOQLTextGetRequest;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.systemwideinterfaces.core.IMendixIdentifier;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import mxmodelreflection.proxies.MxObjectMember;
import mxmodelreflection.proxies.MxObjectType;
Expand Down Expand Up @@ -113,14 +114,23 @@ private String createOQLQuery(MxSheet mxSheet, IMendixObject inputObject, List<C
for (ColumnPreset column : mxColumnLists)
{
MxXPath first = column.getFirstPath();
switch (first.getRetrieveType())
MxXPath last = ColumnPreset.getLastPath(first);

if (last.getMxXPath_MxObjectMember().getAttributeName().equalsIgnoreCase("ID"))
{
addAttribute(last, mainObject, column, true);
}
else
{
switch (first.getRetrieveType())
{
case Attribute:
addAttribute(first, mainObject, column);
addAttribute(first, mainObject, column, false);
break;
case Reference:
addObject(first, mainObject, column);
break;
}
}
}

Expand All @@ -140,7 +150,7 @@ private String createOQLQuery(MxSheet mxSheet, IMendixObject inputObject, List<C
for (int i = 0; i < this.attributeList.size(); i++)
{
AttributeData data = this.attributeList.get(i);
String attribute = escape(data.getObjectData().getAlias()+"."+data.getAttributeName().replace(" / ", "/"));
String attribute = escape(data.getObjectData().getAlias()+(data.isFullPath() ? "/" : ".")+data.getAttributeName().replace(" / ", "/"));
if (data.isAggregate())
{
switch (data.getFunction())
Expand Down Expand Up @@ -387,15 +397,19 @@ private String addWhereValue(MxConstraint constraint) throws CoreException
* The object structure that is the owner of the attribute
* @throws CoreException
*/
private void addAttribute(MxXPath attributePath, ObjectData objectData, ColumnPreset column) throws CoreException
private void addAttribute(MxXPath attributePath, ObjectData objectData, ColumnPreset column, boolean prefixFullPath) throws CoreException
{
MxObjectMember member = attributePath.getMxXPath_MxObjectMember();
column.setDateTimeFormat(member.getAttributeType().equalsIgnoreCase("DateTime"));
String attribute = member.getAttributeName();
// Create alias name for the attribute
String alias = createAlias(attribute, 0);
// Create new attribute data object
if (prefixFullPath) attribute = column.getFullPath();

AttributeData attributeData = new AttributeData(attribute, alias, objectData);
attributeData.setFullPath(prefixFullPath);

if (column.isDataAggregation())
{
attributeData.setAggregate(true);
Expand Down Expand Up @@ -546,7 +560,7 @@ private void addObject(MxXPath path, ObjectData fromObjectData, ColumnPreset col
addObject(childPath, toObjectData, column);
break;
case Attribute:
addAttribute(path, fromObjectData, column);
addAttribute(path, fromObjectData, column, false);
break;
}
} else
Expand Down Expand Up @@ -730,6 +744,8 @@ private Object parseValue(Object value)
{
if (value instanceof Date)
return parseDate((Date)value);
else if (value instanceof IMendixIdentifier)
return parseMendixIdentifier((IMendixIdentifier)value);

return value;
}
Expand All @@ -744,6 +760,15 @@ private Date parseDate(Date value)
return dateTime.withZone(DateTimeZone.UTC).toLocalDateTime().toDate();
}

private String parseMendixIdentifier(IMendixIdentifier value)
{
if(value == null)
return null;

// convert to long then to string (for Excel number limit purposes)
return Long.toString(value.toLong());
}

/**
* Check if the string uses reserved words, and if place brackets around it.
* @param unescaped
Expand Down
11 changes: 11 additions & 0 deletions javasource/xlsreport/report/data/AttributeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class AttributeData
private String alias;
private ObjectData objectData;
private boolean aggregate;
private boolean fullPath;
private AggregateFunction function;

public AttributeData(String attributeName, String alias, ObjectData objectData)
Expand Down Expand Up @@ -46,6 +47,16 @@ public void setAggregate(boolean aggregate)
{
this.aggregate = aggregate;
}

public boolean isFullPath()
{
return fullPath;
}

public void setFullPath(boolean fullPath)
{
this.fullPath = fullPath;
}

public AggregateFunction getFunction()
{
Expand Down
32 changes: 32 additions & 0 deletions javasource/xlsreport/report/data/ColumnPreset.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package xlsreport.report.data;

import java.util.ArrayList;

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.apache.poi.ss.usermodel.CellStyle;

import com.mendix.core.Core;
import com.mendix.core.CoreException;
import com.mendix.logging.ILogNode;

import xlsreport.proxies.AggregateFunction;
Expand Down Expand Up @@ -151,6 +154,35 @@ public MxXPath getFirstPath()
return firstPath;
}

public static MxXPath getLastPath(MxXPath path) throws CoreException
{
MxXPath nextPath = path.getMxXPath_ParentMxXPath();
if (nextPath == null) return path;
else return getLastPath(nextPath);
}

public String getFullPath() throws CoreException
{
MxXPath nPath = this.firstPath;
ArrayList<String> fullPath = new ArrayList<String>();
while (nPath != null)
{
switch (nPath.getRetrieveType())
{
case Attribute:
fullPath.add(nPath.getMxXPath_MxObjectMember().getAttributeName());
break;

case Reference:
fullPath.add(nPath.getMxXPath_MxObjectReference().getCompleteName());
fullPath.add(nPath.getMxXPath_MxObjectType().getCompleteName());
break;
}
nPath = nPath.getMxXPath_ParentMxXPath();
}
return String.join("/", fullPath);
}

public long getStyleGuid()
{
return styleGuid;
Expand Down