Automated merge with ssh://hg.services.openoffice.org/cws/dba34c
This commit is contained in:
commit
fa7f16afbf
8 changed files with 604 additions and 665 deletions
File diff suppressed because it is too large
Load diff
|
@ -205,9 +205,7 @@ public class CommandName
|
|||
{
|
||||
sName = "";
|
||||
}
|
||||
String ReturnQuote = "";
|
||||
ReturnQuote = _sIdentifierQuote + sName + _sIdentifierQuote;
|
||||
return ReturnQuote;
|
||||
return new StringBuilder(_sIdentifierQuote).append(sName).append(_sIdentifierQuote).toString();
|
||||
}
|
||||
|
||||
public void setAliasName(String _AliasName)
|
||||
|
|
|
@ -101,9 +101,10 @@ public class QueryMetaData extends CommandMetaData
|
|||
// FieldColumns = LocFieldColumns;
|
||||
// }
|
||||
// }
|
||||
|
||||
public void addSeveralFieldColumns(String[] _FieldNames, String _sCommandName)
|
||||
{
|
||||
Vector oToBeAddedFieldColumns = new Vector();
|
||||
ArrayList<FieldColumn> oToBeAddedFieldColumns = new ArrayList<FieldColumn>();
|
||||
for (int i = 0; i < _FieldNames.length; i++)
|
||||
{
|
||||
FieldColumn oFieldColumn = getFieldColumn(_FieldNames[i], _sCommandName);
|
||||
|
@ -119,7 +120,7 @@ public class QueryMetaData extends CommandMetaData
|
|||
System.arraycopy(FieldColumns, 0, LocFieldColumns, 0, nOldFieldCount);
|
||||
for (int i = 0; i < oToBeAddedFieldColumns.size(); i++)
|
||||
{
|
||||
LocFieldColumns[nOldFieldCount + i] = (FieldColumn) oToBeAddedFieldColumns.elementAt(i);
|
||||
LocFieldColumns[nOldFieldCount + i] = oToBeAddedFieldColumns.get(i);
|
||||
}
|
||||
FieldColumns = LocFieldColumns;
|
||||
}
|
||||
|
@ -138,7 +139,7 @@ public class QueryMetaData extends CommandMetaData
|
|||
|
||||
public void removeSeveralFieldColumnsByDisplayFieldName(String[] _DisplayFieldNames)
|
||||
{
|
||||
Vector oRemainingFieldColumns = new Vector();
|
||||
ArrayList<FieldColumn> oRemainingFieldColumns = new ArrayList<FieldColumn>();
|
||||
int a = 0;
|
||||
for (int n = 0; n < FieldColumns.length; n++)
|
||||
{
|
||||
|
@ -161,13 +162,10 @@ public class QueryMetaData extends CommandMetaData
|
|||
FieldColumn[] LocFieldColumns = new FieldColumn[FieldColumns.length - 1];
|
||||
for (int i = 0; i < FieldColumns.length; i++)
|
||||
{
|
||||
if (!FieldColumns[i].getFieldName().equals(_sFieldName))
|
||||
if (!FieldColumns[i].getFieldName().equals(_sFieldName) && !FieldColumns[i].getCommandName().equals(_sCommandName))
|
||||
{
|
||||
if (!FieldColumns[i].getCommandName().equals(_sCommandName))
|
||||
{
|
||||
LocFieldColumns[a] = FieldColumns[i];
|
||||
a++;
|
||||
}
|
||||
LocFieldColumns[a] = FieldColumns[i];
|
||||
a++;
|
||||
}
|
||||
}
|
||||
FieldColumns = LocFieldColumns;
|
||||
|
@ -177,7 +175,7 @@ public class QueryMetaData extends CommandMetaData
|
|||
public String[] getIncludedCommandNames()
|
||||
{
|
||||
// FieldColumn CurQueryField;
|
||||
Vector CommandNamesV = new Vector(1);
|
||||
ArrayList<String> CommandNamesV = new ArrayList<String>(1);
|
||||
// String CurCommandName;
|
||||
for (int i = 0; i < FieldColumns.length; i++)
|
||||
{
|
||||
|
@ -185,7 +183,7 @@ public class QueryMetaData extends CommandMetaData
|
|||
final String CurCommandName = CurQueryField.getCommandName();
|
||||
if (!CommandNamesV.contains(CurCommandName))
|
||||
{
|
||||
CommandNamesV.addElement(CurCommandName);
|
||||
CommandNamesV.add(CurCommandName);
|
||||
}
|
||||
}
|
||||
String[] sIncludedCommandNames = new String[CommandNamesV.size()];
|
||||
|
@ -195,7 +193,7 @@ public class QueryMetaData extends CommandMetaData
|
|||
|
||||
public static String[] getIncludedCommandNames(String[] _FieldNames)
|
||||
{
|
||||
Vector CommandNames = new Vector(1);
|
||||
ArrayList<String> CommandNames = new ArrayList<String>(1);
|
||||
for (int i = 0; i < _FieldNames.length; i++)
|
||||
{
|
||||
String CurCommandName = "";
|
||||
|
@ -208,7 +206,7 @@ public class QueryMetaData extends CommandMetaData
|
|||
}
|
||||
if (!CommandNames.contains(CurCommandName))
|
||||
{
|
||||
CommandNames.addElement(CurCommandName);
|
||||
CommandNames.add(CurCommandName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +255,7 @@ public class QueryMetaData extends CommandMetaData
|
|||
|
||||
public String[] getUniqueAggregateFieldNames()
|
||||
{
|
||||
Vector UniqueAggregateFieldVector = new Vector(0);
|
||||
ArrayList<String> UniqueAggregateFieldVector = new ArrayList<String>();
|
||||
for (int i = 0; i < AggregateFieldNames.length; i++)
|
||||
{
|
||||
if (!UniqueAggregateFieldVector.contains(AggregateFieldNames[i][0]))
|
||||
|
@ -291,10 +289,13 @@ public class QueryMetaData extends CommandMetaData
|
|||
}
|
||||
return iAggregate;
|
||||
}
|
||||
|
||||
public SQLQueryComposer getSQLQueryComposer()
|
||||
{
|
||||
if ( oSQLQueryComposer == null )
|
||||
if (oSQLQueryComposer == null)
|
||||
{
|
||||
oSQLQueryComposer = new SQLQueryComposer(this);
|
||||
}
|
||||
return oSQLQueryComposer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
************************************************************************/
|
||||
package com.sun.star.wizards.db;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
// import com.sun.star.lang.IllegalArgumentException;
|
||||
// import com.sun.star.lang.WrappedTargetException;
|
||||
|
@ -37,7 +36,6 @@ import com.sun.star.container.XIndexAccess;
|
|||
// import com.sun.star.container.XNameAccess;
|
||||
import com.sun.star.sdbcx.XColumnsSupplier;
|
||||
// import com.sun.star.sdb.XColumn;
|
||||
import com.sun.star.sdb.XSQLQueryComposerFactory;
|
||||
import com.sun.star.sdb.XSingleSelectQueryComposer;
|
||||
import com.sun.star.sdb.XSingleSelectQueryAnalyzer;
|
||||
import com.sun.star.ui.dialogs.XExecutableDialog;
|
||||
|
@ -50,6 +48,7 @@ import com.sun.star.awt.XWindow;
|
|||
import com.sun.star.sdb.SQLFilterOperator;
|
||||
|
||||
import com.sun.star.wizards.common.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SQLQueryComposer
|
||||
{
|
||||
|
@ -60,7 +59,7 @@ public class SQLQueryComposer
|
|||
// String m_sSelectClause;
|
||||
// String m_sFromClause;
|
||||
public XSingleSelectQueryAnalyzer m_xQueryAnalyzer;
|
||||
Vector composedCommandNames = new Vector(1);
|
||||
ArrayList<CommandName> composedCommandNames = new ArrayList<CommandName>(1);
|
||||
private XSingleSelectQueryComposer m_queryComposer;
|
||||
XMultiServiceFactory xMSF;
|
||||
boolean bincludeGrouping = true;
|
||||
|
@ -74,9 +73,6 @@ public class SQLQueryComposer
|
|||
final Object oQueryComposer = xMSF.createInstance("com.sun.star.sdb.SingleSelectQueryComposer");
|
||||
m_xQueryAnalyzer = (XSingleSelectQueryAnalyzer) UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class, oQueryComposer);
|
||||
m_queryComposer = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, m_xQueryAnalyzer);
|
||||
XSQLQueryComposerFactory xSQLComposerFactory;
|
||||
xSQLComposerFactory = (XSQLQueryComposerFactory) UnoRuntime.queryInterface(XSQLQueryComposerFactory.class, CurDBMetaData.DBConnection);
|
||||
// /* XSQLQueryComposer */ xSQLQueryComposer = xSQLComposerFactory.createQueryComposer();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -86,18 +82,9 @@ public class SQLQueryComposer
|
|||
|
||||
private boolean addtoSelectClause(String DisplayFieldName) throws SQLException
|
||||
{
|
||||
if (bincludeGrouping)
|
||||
if (bincludeGrouping && CurDBMetaData.xDBMetaData.supportsGroupByUnrelated() && CurDBMetaData.GroupFieldNames != null && JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, DisplayFieldName) > -1)
|
||||
{
|
||||
if (CurDBMetaData.xDBMetaData.supportsGroupByUnrelated())
|
||||
{
|
||||
if (CurDBMetaData.GroupFieldNames != null)
|
||||
{
|
||||
if (JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, DisplayFieldName) > -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -234,7 +221,6 @@ public class SQLQueryComposer
|
|||
}
|
||||
// just for debug!
|
||||
sOrder = m_queryComposer.getOrder();
|
||||
int dummy = 0;
|
||||
}
|
||||
|
||||
public void appendGroupByColumns(boolean _baddAliasFieldNames) throws SQLException
|
||||
|
@ -244,7 +230,6 @@ public class SQLQueryComposer
|
|||
XPropertySet xColumn = CurDBMetaData.getColumnObjectByFieldName(CurDBMetaData.GroupFieldNames[i], _baddAliasFieldNames);
|
||||
m_queryComposer.appendGroupByColumn(xColumn);
|
||||
}
|
||||
String s = m_xQueryAnalyzer.getQuery();
|
||||
}
|
||||
|
||||
public void setDBMetaData(QueryMetaData _oDBMetaData)
|
||||
|
@ -269,19 +254,19 @@ public class SQLQueryComposer
|
|||
return m_xQueryAnalyzer.getQuery();
|
||||
}
|
||||
|
||||
public String getFromClause()
|
||||
public StringBuilder getFromClause()
|
||||
{
|
||||
String sFromClause = "FROM";
|
||||
StringBuilder sFromClause = new StringBuilder("FROM");
|
||||
composedCommandNames.clear();
|
||||
String[] sCommandNames = CurDBMetaData.getIncludedCommandNames();
|
||||
for (int i = 0; i < sCommandNames.length; i++)
|
||||
{
|
||||
CommandName curCommandName = new CommandName(CurDBMetaData, sCommandNames[i]); //(setComposedCommandName)
|
||||
curCommandName.setAliasName(getuniqueAliasName(curCommandName.getTableName()));
|
||||
sFromClause += " " + curCommandName.getComposedName() + " " + quoteName(curCommandName.getAliasName());
|
||||
sFromClause.append(" ").append(curCommandName.getComposedName()).append(" ").append(quoteName(curCommandName.getAliasName()));
|
||||
if (i < sCommandNames.length - 1)
|
||||
{
|
||||
sFromClause += ", ";
|
||||
sFromClause.append(", ");
|
||||
}
|
||||
// fill composedCommandNames
|
||||
composedCommandNames.add(curCommandName);
|
||||
|
@ -291,30 +276,25 @@ public class SQLQueryComposer
|
|||
|
||||
public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames)
|
||||
{
|
||||
return setQueryCommand(_xParentWindow,_bincludeGrouping, _baddAliasFieldNames,true);
|
||||
return setQueryCommand(_xParentWindow, _bincludeGrouping, _baddAliasFieldNames, true);
|
||||
}
|
||||
|
||||
public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery)
|
||||
{
|
||||
try
|
||||
{
|
||||
String s;
|
||||
bincludeGrouping = _bincludeGrouping;
|
||||
if ( addQuery )
|
||||
if (addQuery)
|
||||
{
|
||||
String sFromClause = getFromClause();
|
||||
String sSelectClause = getSelectClause(_baddAliasFieldNames);
|
||||
String queryclause = sSelectClause + " " + sFromClause;
|
||||
m_xQueryAnalyzer.setQuery(queryclause);
|
||||
if (CurDBMetaData.getFilterConditions() != null)
|
||||
StringBuilder queryclause = new StringBuilder(sSelectClause).append(" ").append(getFromClause());
|
||||
m_xQueryAnalyzer.setQuery(queryclause.toString());
|
||||
if (CurDBMetaData.getFilterConditions() != null && CurDBMetaData.getFilterConditions().length > 0)
|
||||
{
|
||||
if (CurDBMetaData.getFilterConditions().length > 0)
|
||||
{
|
||||
CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions()));
|
||||
m_queryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
|
||||
}
|
||||
CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions()));
|
||||
m_queryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
|
||||
}
|
||||
}
|
||||
s = m_xQueryAnalyzer.getQuery();
|
||||
if (_bincludeGrouping)
|
||||
{
|
||||
appendGroupByColumns(_baddAliasFieldNames);
|
||||
|
@ -325,7 +305,6 @@ public class SQLQueryComposer
|
|||
}
|
||||
appendSortingcriteria(_baddAliasFieldNames);
|
||||
|
||||
s = m_xQueryAnalyzer.getQuery();
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -340,8 +319,10 @@ public class SQLQueryComposer
|
|||
{
|
||||
FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname);
|
||||
CommandName curComposedCommandName = getComposedCommandByDisplayName(CurFieldColumn.getCommandName());
|
||||
if ( curComposedCommandName == null )
|
||||
if (curComposedCommandName == null)
|
||||
{
|
||||
return _fieldname;
|
||||
}
|
||||
String curAliasName = curComposedCommandName.getAliasName();
|
||||
return quoteName(curAliasName) + "." + quoteName(CurFieldColumn.getFieldName());
|
||||
}
|
||||
|
@ -350,13 +331,11 @@ public class SQLQueryComposer
|
|||
{
|
||||
if (composedCommandNames != null)
|
||||
{
|
||||
CommandName curComposedName;
|
||||
for (int i = 0; i < composedCommandNames.size(); i++)
|
||||
for (CommandName commandName : composedCommandNames)
|
||||
{
|
||||
curComposedName = (CommandName) composedCommandNames.elementAt(i);
|
||||
if (curComposedName.getAliasName().equals(_AliasName))
|
||||
if (commandName.getAliasName().equals(_AliasName))
|
||||
{
|
||||
return curComposedName;
|
||||
return commandName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -367,13 +346,11 @@ public class SQLQueryComposer
|
|||
{
|
||||
if (composedCommandNames != null)
|
||||
{
|
||||
CommandName curComposedName;
|
||||
for (int i = 0; i < composedCommandNames.size(); i++)
|
||||
for (CommandName commandName : composedCommandNames)
|
||||
{
|
||||
curComposedName = (CommandName) composedCommandNames.elementAt(i);
|
||||
if (curComposedName.getDisplayName().equals(_DisplayName))
|
||||
if (commandName.getDisplayName().equals(_DisplayName))
|
||||
{
|
||||
return curComposedName;
|
||||
return commandName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +397,7 @@ public class SQLQueryComposer
|
|||
rDispatchArguments[2] = Properties.createProperty("SQLException", _exception);
|
||||
xInitialize.initialize(rDispatchArguments);
|
||||
xExecute.execute();
|
||||
//TODO dispose???
|
||||
//TODO dispose???
|
||||
}
|
||||
catch (Exception typeexception)
|
||||
{
|
||||
|
@ -443,38 +420,40 @@ public class SQLQueryComposer
|
|||
public PropertyValue[][] getNormalizedStructuredFilter()
|
||||
{
|
||||
final PropertyValue[][] structuredFilter = m_queryComposer.getStructuredFilter();
|
||||
for ( int i=0; i<structuredFilter.length; ++i )
|
||||
for (int i = 0; i < structuredFilter.length; ++i)
|
||||
{
|
||||
for ( int j=0; j<structuredFilter[i].length; ++j )
|
||||
for (int j = 0; j < structuredFilter[i].length; ++j)
|
||||
{
|
||||
if ( !( structuredFilter[i][j].Value instanceof String ) )
|
||||
continue;
|
||||
final StringBuffer textualValue = new StringBuffer( (String)structuredFilter[i][j].Value );
|
||||
switch ( structuredFilter[i][j].Handle )
|
||||
if (!(structuredFilter[i][j].Value instanceof String))
|
||||
{
|
||||
case SQLFilterOperator.EQUAL:
|
||||
break;
|
||||
case SQLFilterOperator.NOT_EQUAL:
|
||||
case SQLFilterOperator.LESS_EQUAL:
|
||||
case SQLFilterOperator.GREATER_EQUAL:
|
||||
textualValue.delete( 0, 2 );
|
||||
break;
|
||||
case SQLFilterOperator.LESS:
|
||||
case SQLFilterOperator.GREATER:
|
||||
textualValue.delete( 0, 1 );
|
||||
break;
|
||||
case SQLFilterOperator.NOT_LIKE:
|
||||
textualValue.delete( 0, 8 );
|
||||
break;
|
||||
case SQLFilterOperator.LIKE:
|
||||
textualValue.delete( 0, 4 );
|
||||
break;
|
||||
case SQLFilterOperator.SQLNULL:
|
||||
textualValue.delete( 0, 7 );
|
||||
break;
|
||||
case SQLFilterOperator.NOT_SQLNULL:
|
||||
textualValue.delete( 0, 11 );
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
final StringBuffer textualValue = new StringBuffer((String) structuredFilter[i][j].Value);
|
||||
switch (structuredFilter[i][j].Handle)
|
||||
{
|
||||
case SQLFilterOperator.EQUAL:
|
||||
break;
|
||||
case SQLFilterOperator.NOT_EQUAL:
|
||||
case SQLFilterOperator.LESS_EQUAL:
|
||||
case SQLFilterOperator.GREATER_EQUAL:
|
||||
textualValue.delete(0, 2);
|
||||
break;
|
||||
case SQLFilterOperator.LESS:
|
||||
case SQLFilterOperator.GREATER:
|
||||
textualValue.delete(0, 1);
|
||||
break;
|
||||
case SQLFilterOperator.NOT_LIKE:
|
||||
textualValue.delete(0, 8);
|
||||
break;
|
||||
case SQLFilterOperator.LIKE:
|
||||
textualValue.delete(0, 4);
|
||||
break;
|
||||
case SQLFilterOperator.SQLNULL:
|
||||
textualValue.delete(0, 7);
|
||||
break;
|
||||
case SQLFilterOperator.NOT_SQLNULL:
|
||||
textualValue.delete(0, 11);
|
||||
break;
|
||||
}
|
||||
structuredFilter[i][j].Value = textualValue.toString().trim();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ package com.sun.star.wizards.query;
|
|||
|
||||
import com.sun.star.beans.PropertyAttribute;
|
||||
import com.sun.star.beans.PropertyValue;
|
||||
import com.sun.star.lang.XComponent;
|
||||
import com.sun.star.lang.XMultiServiceFactory;
|
||||
import com.sun.star.uno.Type;
|
||||
import com.sun.star.wizards.common.Properties;
|
||||
|
@ -160,6 +159,7 @@ public class CallQueryWizard
|
|||
* whole combination of objects.
|
||||
* @return Array of bytes, in order to distinguish between two sets.
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImplementationId()
|
||||
{
|
||||
byte[] byteReturn =
|
||||
|
@ -168,7 +168,7 @@ public class CallQueryWizard
|
|||
|
||||
try
|
||||
{
|
||||
byteReturn = new String("" + this.hashCode()).getBytes();
|
||||
byteReturn = ("" + this.hashCode()).getBytes();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -191,6 +191,7 @@ public class CallQueryWizard
|
|||
* @return Sequence of all types (usually interface types) provided by the
|
||||
* service.
|
||||
*/
|
||||
@Override
|
||||
public Type[] getTypes()
|
||||
{
|
||||
Type[] typeReturn =
|
||||
|
|
|
@ -58,15 +58,6 @@ public class QuerySummary extends QueryMetaData
|
|||
sReturnChar = String.valueOf((char) 13) + String.valueOf((char) 13);
|
||||
}
|
||||
|
||||
/* boolean bAssignAliases = xDBMetaData.supportsColumnAliasing();
|
||||
boolean bSupportsGroupByUnrelated = xDBMetaData.supportsGroupByUnrelated();
|
||||
boolean bSupportsOrderByUnrelated = xDBMetaData.supportsOrderByUnrelated();
|
||||
boolean bSupportsNumericFunctions = xDBMetaData.getNumericFunctions() != "";
|
||||
xDBMetaData.getMaxColumnsInGroupBy();
|
||||
xDBMetaData.getMaxColumnsInOrderBy();
|
||||
xDBMetaData.getMaxColumnsInSelect();
|
||||
xDBMetaData.getMaxCharLiteralLength(); // gef?hrlich, da h?chstwahrscheinlich nicht sauber in jedem Treiber implementiert!!!!!
|
||||
* */
|
||||
public void setSummaryString()
|
||||
{
|
||||
try
|
||||
|
@ -107,34 +98,31 @@ public class QuerySummary extends QueryMetaData
|
|||
|
||||
private String combineFilterNameFraction(PropertyValue[][] _filterconditions, int _InitResID, int _AlternativeResID)
|
||||
{
|
||||
if (_filterconditions != null)
|
||||
if (_filterconditions != null && _filterconditions.length > 0)
|
||||
{
|
||||
if (_filterconditions.length > 0)
|
||||
String sconditions = "";
|
||||
String sStart = oResource.getResText(_InitResID);
|
||||
String BaseString = oResource.getResText(RID_QUERY + 96);
|
||||
if (_filterconditions.length == 1)
|
||||
{
|
||||
String sconditions = "";
|
||||
String sStart = oResource.getResText(_InitResID);
|
||||
String BaseString = oResource.getResText(RID_QUERY + 96);
|
||||
if (_filterconditions.length == 1)
|
||||
PropertyValue[] curfilterconditions = _filterconditions[0];
|
||||
for (int i = 0; i < curfilterconditions.length; i++)
|
||||
{
|
||||
PropertyValue[] curfilterconditions = _filterconditions[0];
|
||||
for (int i = 0; i < curfilterconditions.length; i++)
|
||||
{
|
||||
sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[0][i], this);
|
||||
sconditions = appendClauseSeparator(sconditions, " " + sAnd + " ", i, curfilterconditions.length);
|
||||
}
|
||||
sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[0][i], this);
|
||||
sconditions = appendClauseSeparator(sconditions, " " + sAnd + " ", i, curfilterconditions.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (int i = 0; i < _filterconditions.length; i++)
|
||||
{
|
||||
sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[i][0], this);
|
||||
sconditions = appendClauseSeparator(sconditions, " " + sOr + " ", i, _filterconditions.length);
|
||||
}
|
||||
}
|
||||
String sreturn = sStart + sconditions;
|
||||
return sreturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (int i = 0; i < _filterconditions.length; i++)
|
||||
{
|
||||
sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[i][0], this);
|
||||
sconditions = appendClauseSeparator(sconditions, " " + sOr + " ", i, _filterconditions.length);
|
||||
}
|
||||
}
|
||||
String sreturn = sStart + sconditions;
|
||||
return sreturn;
|
||||
}
|
||||
return oResource.getResText(_AlternativeResID);
|
||||
}
|
||||
|
@ -173,14 +161,12 @@ public class QuerySummary extends QueryMetaData
|
|||
return _basestring;
|
||||
}
|
||||
// TODO: How can you merge the following two methods to a single one in a smarter way??
|
||||
|
||||
public String combinePartString(int _InitResID, String[] _FieldNames, int _AlternativeResID)
|
||||
{
|
||||
if (_FieldNames != null)
|
||||
if (_FieldNames != null && _FieldNames.length > 0)
|
||||
{
|
||||
if (_FieldNames.length > 0)
|
||||
{
|
||||
return ArrayFieldsToString(_InitResID, _FieldNames);
|
||||
}
|
||||
return ArrayFieldsToString(_InitResID, _FieldNames);
|
||||
}
|
||||
return oResource.getResText(_AlternativeResID);
|
||||
}
|
||||
|
@ -202,12 +188,9 @@ public class QuerySummary extends QueryMetaData
|
|||
|
||||
public String combinePartString(int _InitResID, String[][] _FieldNames, int _AlternativeResID, int _BaseStringID, String[] _ReplaceTags)
|
||||
{
|
||||
if (_FieldNames != null)
|
||||
if (_FieldNames != null && _FieldNames.length > 0)
|
||||
{
|
||||
if (_FieldNames.length > 0)
|
||||
{
|
||||
return ArrayFieldsToString(_InitResID, _FieldNames, _BaseStringID, _ReplaceTags);
|
||||
}
|
||||
return ArrayFieldsToString(_InitResID, _FieldNames, _BaseStringID, _ReplaceTags);
|
||||
}
|
||||
return oResource.getResText(_AlternativeResID);
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.sun.star.wizards.ui.TitlesComponent;
|
|||
|
||||
public class QueryWizard extends DatabaseObjectWizard
|
||||
{
|
||||
|
||||
public static final String SFILLUPFIELDSLISTBOX = "fillUpFieldsListbox";
|
||||
private static final int SOFIELDSELECTION_PAGE = 1;
|
||||
private static final int SOSORTING_PAGE = 2;
|
||||
|
@ -81,16 +82,19 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
private String resmsgNonNumericAsGroupBy;
|
||||
private String m_createdQuery;
|
||||
|
||||
public QueryWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext )
|
||||
public QueryWizard(XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext)
|
||||
{
|
||||
super( xMSF, 40970, i_wizardContext );
|
||||
super(xMSF, 40970, i_wizardContext);
|
||||
addResourceHandler("QueryWizard", "dbw");
|
||||
m_DBMetaData = new QuerySummary(xMSF, m_oResource);
|
||||
}
|
||||
|
||||
public static void main(String i_args[])
|
||||
{
|
||||
final String settings[] = new String[] { null, null, null };
|
||||
final String settings[] = new String[]
|
||||
{
|
||||
null, null, null
|
||||
};
|
||||
final int IDX_PIPE_NAME = 0;
|
||||
final int IDX_LOCATION = 1;
|
||||
final int IDX_DSN = 2;
|
||||
|
@ -98,28 +102,28 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
// some simple parsing
|
||||
boolean failure = false;
|
||||
int settingsIndex = -1;
|
||||
for ( int i=0; i<i_args.length; ++i )
|
||||
for (int i = 0; i < i_args.length; ++i)
|
||||
{
|
||||
if ( settingsIndex >= 0 )
|
||||
if (settingsIndex >= 0)
|
||||
{
|
||||
settings[ settingsIndex ] = i_args[i];
|
||||
settings[ settingsIndex] = i_args[i];
|
||||
settingsIndex = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( i_args[i].equals( "--pipe-name" ) )
|
||||
if (i_args[i].equals("--pipe-name"))
|
||||
{
|
||||
settingsIndex = IDX_PIPE_NAME;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( i_args[i].equals( "--database-location" ) )
|
||||
if (i_args[i].equals("--database-location"))
|
||||
{
|
||||
settingsIndex = IDX_LOCATION;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( i_args[i].equals( "--data-source-name" ) )
|
||||
if (i_args[i].equals("--data-source-name"))
|
||||
{
|
||||
settingsIndex = IDX_DSN;
|
||||
continue;
|
||||
|
@ -128,18 +132,22 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
failure = true;
|
||||
}
|
||||
|
||||
if ( settings[ IDX_PIPE_NAME ] == null )
|
||||
failure = true;
|
||||
|
||||
if ( ( settings[ IDX_DSN ] == null ) && ( settings[ IDX_LOCATION ] == null ) )
|
||||
failure = true;
|
||||
|
||||
if ( failure )
|
||||
if (settings[ IDX_PIPE_NAME] == null)
|
||||
{
|
||||
System.err.println( "supported arguments: " );
|
||||
System.err.println( " --pipe-name <name> : specifies the name of the pipe to connect to the running OOo instance" );
|
||||
System.err.println( " --database-location <url> : specifies the URL of the database document to work with" );
|
||||
System.err.println( " --data-source-name <name> : specifies the name of the data source to work with" );
|
||||
failure = true;
|
||||
}
|
||||
|
||||
if ((settings[ IDX_DSN] == null) && (settings[ IDX_LOCATION] == null))
|
||||
{
|
||||
failure = true;
|
||||
}
|
||||
|
||||
if (failure)
|
||||
{
|
||||
System.err.println("supported arguments: ");
|
||||
System.err.println(" --pipe-name <name> : specifies the name of the pipe to connect to the running OOo instance");
|
||||
System.err.println(" --database-location <url> : specifies the URL of the database document to work with");
|
||||
System.err.println(" --data-source-name <name> : specifies the name of the data source to work with");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -150,12 +158,16 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
if (serviceFactory != null)
|
||||
{
|
||||
PropertyValue[] curproperties = new PropertyValue[1];
|
||||
if ( settings[ IDX_LOCATION ] != null )
|
||||
curproperties[0] = Properties.createProperty( "DatabaseLocation", settings[ IDX_LOCATION ] );
|
||||
if (settings[ IDX_LOCATION] != null)
|
||||
{
|
||||
curproperties[0] = Properties.createProperty("DatabaseLocation", settings[ IDX_LOCATION]);
|
||||
}
|
||||
else
|
||||
curproperties[0] = Properties.createProperty( "DataSourceName", settings[ IDX_DSN ] );
|
||||
{
|
||||
curproperties[0] = Properties.createProperty("DataSourceName", settings[ IDX_DSN]);
|
||||
}
|
||||
|
||||
QueryWizard CurQueryWizard = new QueryWizard( serviceFactory, curproperties );
|
||||
QueryWizard CurQueryWizard = new QueryWizard(serviceFactory, curproperties);
|
||||
CurQueryWizard.startQueryWizard();
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +186,7 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
{
|
||||
try
|
||||
{
|
||||
if ( m_DBMetaData.getConnection( m_wizardContext ) )
|
||||
if (m_DBMetaData.getConnection(m_wizardContext))
|
||||
{
|
||||
reslblFields = m_oResource.getResText(UIConsts.RID_QUERY + 4);
|
||||
reslblFieldHeader = m_oResource.getResText(UIConsts.RID_QUERY + 19); //Fielnames in AliasComponent
|
||||
|
@ -196,13 +208,13 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
setRightPaneHeaders(m_oResource, UIConsts.RID_QUERY + 70, 8);
|
||||
this.setMaxStep(8);
|
||||
buildSteps();
|
||||
this.m_DBCommandFieldSelectio.preselectCommand( m_wizardContext, false );
|
||||
this.m_DBCommandFieldSelectio.preselectCommand(m_wizardContext, false);
|
||||
|
||||
XWindowPeer windowPeer = UnoRuntime.queryInterface( XWindowPeer.class, m_frame.getContainerWindow() );
|
||||
XWindowPeer windowPeer = UnoRuntime.queryInterface(XWindowPeer.class, m_frame.getContainerWindow());
|
||||
createWindowPeer(windowPeer);
|
||||
m_DBMetaData.setWindowPeer(this.xControl.getPeer());
|
||||
insertQueryRelatedSteps();
|
||||
executeDialog( m_frame.getContainerWindow().getPosSize() );
|
||||
executeDialog(m_frame.getContainerWindow().getPosSize());
|
||||
}
|
||||
}
|
||||
catch (java.lang.Exception jexception)
|
||||
|
@ -310,8 +322,8 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
try
|
||||
{
|
||||
m_DBCommandFieldSelectio = new CommandFieldSelection(
|
||||
this, m_DBMetaData, 120, reslblFields, reslblSelFields, reslblTables,
|
||||
m_DBMetaData.supportsQueriesInFrom(), 40850);
|
||||
this, m_DBMetaData, 120, reslblFields, reslblSelFields, reslblTables,
|
||||
m_DBMetaData.supportsQueriesInFrom(), 40850);
|
||||
m_DBCommandFieldSelectio.setAppendMode(true);
|
||||
m_DBCommandFieldSelectio.addFieldSelectionListener(new FieldSelectionListener());
|
||||
m_sortingComponent = new SortingComponent(this, SOSORTING_PAGE, 95, 27, 210, 40865);
|
||||
|
@ -341,14 +353,13 @@ public class QueryWizard extends DatabaseObjectWizard
|
|||
public boolean finishWizard()
|
||||
{
|
||||
int ncurStep = getCurrentStep();
|
||||
if ( ( ncurStep == SOSUMMARY_PAGE )
|
||||
|| ( switchToStep( ncurStep, SOSUMMARY_PAGE ) )
|
||||
)
|
||||
if ((ncurStep == SOSUMMARY_PAGE)
|
||||
|| (switchToStep(ncurStep, SOSUMMARY_PAGE)))
|
||||
{
|
||||
m_createdQuery = m_finalizer.finish();
|
||||
if ( m_createdQuery.length() > 0 )
|
||||
if (m_createdQuery.length() > 0)
|
||||
{
|
||||
loadSubComponent( CommandType.QUERY, m_createdQuery, m_finalizer.displayQueryDesign() );
|
||||
loadSubComponent(CommandType.QUERY, m_createdQuery, m_finalizer.displayQueryDesign());
|
||||
xDialog.endExecute();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ public class FilterComponent
|
|||
final int SO_FOURTHBOOLFIELDNAME = 256 + 4;
|
||||
int SO_BOOLEANLIST[] =
|
||||
|
||||
|
||||
{
|
||||
SO_FIRSTBOOLFIELDNAME, SO_SECONDBOOLFIELDNAME, SO_THIRDBOOLFIELDNAME, SO_FOURTHBOOLFIELDNAME
|
||||
};
|
||||
|
@ -254,11 +255,10 @@ public class FilterComponent
|
|||
|
||||
if (composer.getQuery().length() == 0)
|
||||
{
|
||||
final String fromClause = composer.getFromClause();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append(composer.getSelectClause(true));
|
||||
sql.append(' ');
|
||||
sql.append(fromClause);
|
||||
sql.append(composer.getFromClause());
|
||||
composer.getQueryComposer().setElementaryQuery(sql.toString());
|
||||
}
|
||||
composer.getQueryComposer().setStructuredFilter(new PropertyValue[][]
|
||||
|
@ -267,39 +267,36 @@ public class FilterComponent
|
|||
for (int i = 0; i < RowCount; i++)
|
||||
{
|
||||
ControlRow currentControlRow = oControlRows[i];
|
||||
if (currentControlRow.isEnabled())
|
||||
if (currentControlRow.isEnabled() && currentControlRow.isConditionComplete())
|
||||
{
|
||||
if (currentControlRow.isConditionComplete())
|
||||
String sFieldName = currentControlRow.getSelectedFieldName();
|
||||
int nOperator = (int) currentControlRow.getSelectedOperator();
|
||||
FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName);
|
||||
columnSet.setPropertyValue(PropertyNames.PROPERTY_NAME, aFieldColumn.getFieldName());
|
||||
columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type"));
|
||||
Object value = currentControlRow.getValue();
|
||||
switch (aFieldColumn.getFieldType())
|
||||
{
|
||||
String sFieldName = currentControlRow.getSelectedFieldName();
|
||||
int nOperator = (int) currentControlRow.getSelectedOperator();
|
||||
FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName);
|
||||
columnSet.setPropertyValue(PropertyNames.PROPERTY_NAME, aFieldColumn.getFieldName());
|
||||
columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type"));
|
||||
Object value = currentControlRow.getValue();
|
||||
switch (aFieldColumn.getFieldType())
|
||||
{
|
||||
case DataType.TIMESTAMP:
|
||||
case DataType.DATE:
|
||||
value = ((Double) value) - oQueryMetaData.getNullDateCorrection();
|
||||
break;
|
||||
}
|
||||
column.removeProperty("Value");
|
||||
final short operator = currentControlRow.getSelectedOperator();
|
||||
if ((operator == SQLFilterOperator.SQLNULL)
|
||||
|| (operator == SQLFilterOperator.NOT_SQLNULL)
|
||||
|| AnyConverter.isVoid(value))
|
||||
{
|
||||
column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), new String());
|
||||
value = new Any(new Type(TypeClass.VOID), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), value);
|
||||
}
|
||||
columnSet.setPropertyValue("Value", value);
|
||||
composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL, nOperator);
|
||||
case DataType.TIMESTAMP:
|
||||
case DataType.DATE:
|
||||
value = ((Double) value) - oQueryMetaData.getNullDateCorrection();
|
||||
break;
|
||||
}
|
||||
column.removeProperty("Value");
|
||||
final short operator = currentControlRow.getSelectedOperator();
|
||||
if ((operator == SQLFilterOperator.SQLNULL)
|
||||
|| (operator == SQLFilterOperator.NOT_SQLNULL)
|
||||
|| AnyConverter.isVoid(value))
|
||||
{
|
||||
column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), new String());
|
||||
value = new Any(new Type(TypeClass.VOID), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), value);
|
||||
}
|
||||
columnSet.setPropertyValue("Value", value);
|
||||
composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL, nOperator);
|
||||
}
|
||||
}
|
||||
filterconditions = composer.getNormalizedStructuredFilter();
|
||||
|
@ -342,7 +339,7 @@ public class FilterComponent
|
|||
FieldName = _filtercondition.Name;
|
||||
}
|
||||
String sreturn = JavaTools.replaceSubString(_BaseString, FieldName, "<FIELDNAME>");
|
||||
String soperator = sLogicOperators[_filtercondition.Handle-1];
|
||||
String soperator = sLogicOperators[_filtercondition.Handle - 1];
|
||||
sreturn = JavaTools.replaceSubString(sreturn, soperator, "<LOGICOPERATOR>");
|
||||
String sDisplayValue = "";
|
||||
if ((_filtercondition.Handle != SQLFilterOperator.SQLNULL)
|
||||
|
|
Loading…
Reference in a new issue