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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@

#Other
/releases/
/packages/
/oqlmodule.mpr.bak
/oqlmodule.mpr.lock
/modeler-merge-marker
/nativemobile/builds/
/vendorlib/temp/
.DS_Store
/.svn/
/mprcontents/mprjournal*
Binary file modified OQLModule.mpr
Binary file not shown.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

apply from: 'environment.gradle'

sourceCompatibility = '11'
sourceCompatibility = '21'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

repositories {
Expand All @@ -27,7 +27,7 @@ mxMarketplace {
filterRequiredLibs = true
appDirectory = "."
includeFiles = List.of(licenseFile, CsvAsTableWidgetFile)
versionPathPrefix = "__Version " // the path prefix within the module to the version folder
versionPathPrefix = "__Version " // the path prefix within the module to the version folder
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion environment.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def mxPathDefault = (System.getProperty('os.name').startsWith('Windows'))
? "${System.getenv('PROGRAMFILES')}/Mendix"
: "${System.getenv('HOME')}/.mendix"
def mxPath = System.getenv('MX_INSTALL_PATH') ?: System.getProperty('MX_INSTALL_PATH') ?: mxPathDefault
def mxInstallVersion = System.getenv('MODELER_VERSION') ?: System.getenv('MX_INSTALL_VERSION') ?: System.getProperty('MX_INSTALL_VERSION') ?: '10.21.0.64362'
def mxInstallVersion = System.getenv('MODELER_VERSION') ?: System.getenv('MX_INSTALL_VERSION') ?: System.getProperty('MX_INSTALL_VERSION') ?: '11.6.0'

project.ext.mxInstallPath = "${mxPath}/${mxInstallVersion}"
project.ext.mxRuntimeBundles = new File("${mxInstallPath}/runtime/bundles")
Expand Down
2 changes: 1 addition & 1 deletion javascriptsource/datawidgets/actions/Set_Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Big } from "big.js";
* @param {string} targetName - Name of the filter to set. Valid targets are: Number filter, Date filter, Text filter, Drop-down filter. You can find filter name in widget settings in the "Common" group (Properties>Common>Name).
* @param {boolean} useDefaultValue - Determine the use of default value provided by the filter component itself.
If true, "Value" section will be ignored
* @param {"DataWidgets.Filter_Operators.contains"|"DataWidgets.Filter_Operators.startsWith"|"DataWidgets.Filter_Operators.endsWith"|"DataWidgets.Filter_Operators.between"|"DataWidgets.Filter_Operators.greater"|"DataWidgets.Filter_Operators.greaterEqual"|"DataWidgets.Filter_Operators.equal"|"DataWidgets.Filter_Operators.notEqual"|"DataWidgets.Filter_Operators.smaller"|"DataWidgets.Filter_Operators.smallerEqual"|"DataWidgets.Filter_Operators.empty"|"DataWidgets.Filter_Operators.notEmpty"} operators - Selected operators value. If filter has operators, this value will be applied.
* @param {undefined|"contains"|"startsWith"|"endsWith"|"between"|"greater"|"greaterEqual"|"equal"|"notEqual"|"smaller"|"smallerEqual"|"empty"|"notEmpty"} operators - Selected operators value. If filter has operators, this value will be applied.
* @param {string} stringValue - Value set for dropdown filter or text filter. Choose empty if not use.
* @param {Big} numberValue - Number value for number filter. Choose empty if not use.
* @param {Date} dateTimeValue - Date time value for date filter, can also be use as "start date". Choose empty if not use.
Expand Down
2 changes: 1 addition & 1 deletion javasource/oql/actions/CountRowsOQLStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
package oql.actions;

import com.mendix.systemwideinterfaces.core.IContext;
import oql.implementation.OQL;
import com.mendix.systemwideinterfaces.core.UserAction;
import oql.implementation.OQL;

/**
* This action executes an OQL query and returns the amount of results
Expand Down
65 changes: 65 additions & 0 deletions javasource/oql/actions/ExecuteDMLStatement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.

package oql.actions;

import com.mendix.systemwideinterfaces.MendixRuntimeException;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.systemwideinterfaces.core.UserAction;
import oql.implementation.OQL;

/**
* This action executes a DML statement and returns number of affected rows
*
* For further documentation please refer to https://docs.mendix.com/appstore/modules/oql-module#executedmlstatement
*/
public class ExecuteDMLStatement extends UserAction<java.lang.Long>
{
private final java.lang.String statement;

public ExecuteDMLStatement(
IContext context,
java.lang.String _statement
)
{
super(context);
this.statement = _statement;
}

@java.lang.Override
public java.lang.Long executeAction() throws Exception
{
// BEGIN USER CODE
if (statement == null) {
throw new MendixRuntimeException("DML statement cannot be null");
}

IContext context = getContext().createSudoClone();

java.lang.Long result = OQL.executeDML(context, statement);

OQL.resetParameters();

return result;
// END USER CODE
}

/**
* Returns a string representation of this action
* @return a string representation of this action
*/
@java.lang.Override
public java.lang.String toString()
{
return "ExecuteDMLStatement";
}

// BEGIN EXTRA CODE
// END EXTRA CODE
}
10 changes: 5 additions & 5 deletions javasource/oql/actions/ExecuteOQLStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

package oql.actions;

import java.util.List;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import oql.implementation.OQL;
import com.mendix.systemwideinterfaces.core.UserAction;
import oql.implementation.OQL;
import java.util.List;

/**
* This action executes an OQL query and returns a list of Mendix objects
Expand Down Expand Up @@ -52,10 +52,10 @@ public java.util.List<IMendixObject> executeAction() throws Exception
IContext context = getContext().createSudoClone();

List<IMendixObject> result = OQL.executeOQL(context, statement, returnEntity, amount, offset);
if (!this.preserveParameters)

if (!this.preserveParameters)
OQL.resetParameters();

return result;
// END USER CODE
}
Expand Down
95 changes: 45 additions & 50 deletions javasource/oql/actions/ExportOQLToCSV.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@

package oql.actions;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.mendix.core.Core;
import com.mendix.logging.ILogNode;
import com.mendix.systemwideinterfaces.connectionbus.data.IDataColumnSchema;
Expand All @@ -35,10 +20,20 @@
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.systemwideinterfaces.core.IMendixIdentifier;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import com.mendix.systemwideinterfaces.core.UserAction;
import oql.implementation.MxCSVWriter;
import oql.implementation.OQL;
import system.proxies.FileDocument;
import com.mendix.systemwideinterfaces.core.UserAction;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
* Java action that executes an OQL query and saves the result in a CSV file stored in an object of the specified FileDocument entity, which is then returned
Expand Down Expand Up @@ -84,7 +79,7 @@ public IMendixObject executeAction() throws Exception
{
// BEGIN USER CODE
final int PAGE_SIZE = 10000;

ILogNode logger = Core.getLogger(this.getClass().getSimpleName());
String suffix = ".csv";
if (this.zipResult) {
Expand All @@ -102,35 +97,35 @@ public IMendixObject executeAction() throws Exception
os = fos;
}

MxCSVWriter writer = new MxCSVWriter(new OutputStreamWriter(os),
this.separatorChar.charAt(0),
this.quoteChar != null ? Optional.of(this.quoteChar.charAt(0)) : Optional.empty(),
this.escapeChar != null ? Optional.of(this.escapeChar.charAt(0)) : Optional.empty());
MxCSVWriter writer = new MxCSVWriter(new OutputStreamWriter(os),
this.separatorChar.charAt(0),
this.quoteChar != null ? Optional.of(this.quoteChar.charAt(0)) : Optional.empty(),
this.escapeChar != null ? Optional.of(this.escapeChar.charAt(0)) : Optional.empty());

IMendixObject result = Core.instantiate(getContext(), this.returnEntity);

logger.debug("Executing query");

int offset = 0;
while(true) {
while (true) {
if (logger.isDebugEnabled()) {
logger.debug("Executing query offset " + offset);
}

IContext context = getContext().createSudoClone();
IDataTable results = Core.retrieveOQLDataTable(context, buildRequest(statement, offset, PAGE_SIZE));

if (this.exportHeaders && offset == 0) {
List<String> headers = results.getSchema()
.getColumnSchemas()
.stream()
.map(IDataColumnSchema::getName)
.collect(Collectors.toCollection(ArrayList::new));
.getColumnSchemas()
.stream()
.map(IDataColumnSchema::getName)
.collect(Collectors.toCollection(ArrayList::new));
writer.writeRow(headers);
}

writeResults(results, writer);

if (results.getRowCount() != PAGE_SIZE) {
break;
}
Expand Down Expand Up @@ -159,12 +154,12 @@ public java.lang.String toString()
private IOQLTextGetRequest buildRequest(String statement, int offset, int pagesize) {
IOQLTextGetRequest request;
try {
request = Core.createOQLTextGetRequestFromDataSet(statement);
request = Core.createOQLTextGetRequestFromDataSet(statement);
} catch (IllegalArgumentException e) {
request = Core.createOQLTextGetRequest();
request.setQuery(statement);
}

IParameterMap parameterMap = request.createParameterMap();
IRetrievalSchema schema = Core.createRetrievalSchema();
schema.setAmount(pagesize);
Expand All @@ -176,30 +171,30 @@ private IOQLTextGetRequest buildRequest(String statement, int offset, int pagesi
request.setParameters(parameterMap);
return request;
}

private void writeResults(IDataTable results, MxCSVWriter writer) throws IOException {
for (IDataRow row : results.getRows()) {
List<String> values = IntStream
.range(0, results.getSchema().getColumnCount())
.mapToObj(index -> row.getValue(getContext(), index))
.map(value -> {
if (value == null) return "";
else {
if (value instanceof Date) {
return Long.toString(((Date) value).getTime()); // use timestamp to export for more precision than just seconds.
} else if (value instanceof IMendixIdentifier) {
return Long.toString(((IMendixIdentifier) value).toLong());
} else {
return value.toString();
}
.range(0, results.getSchema().getColumnCount())
.mapToObj(index -> row.getValue(getContext(), index))
.map(value -> {
if (value == null) return "";
else {
if (value instanceof Date) {
return Long.toString(((Date) value).getTime()); // use timestamp to export for more precision than just seconds.
} else if (value instanceof IMendixIdentifier) {
return Long.toString(((IMendixIdentifier) value).toLong());
} else {
return value.toString();
}
})
.map(value -> this.removeNewLinesFromValues ? value.replaceAll("(\r\n|\n|\r)", " ") : value)
.collect(Collectors.toCollection(ArrayList::new));
}
})
.map(value -> this.removeNewLinesFromValues ? value.replaceAll("(\r\n|\n|\r)", " ") : value)
.collect(Collectors.toCollection(ArrayList::new));
writer.writeRow(values);
}
}


// END EXTRA CODE
}
Loading