Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type safety (#1531) #5

Merged
merged 1 commit into from
Jan 10, 2024
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ meta.log
build.log
/updates/
/workspace/
/data/org.eclipse.birt.report.data.oda.jdbc/drivers/*.jar
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ private void removeIndirectRefOfAggregates(List<ComputedColumnHandle> list,
* @return
* @throws BirtException
*/
@SuppressWarnings("unchecked")
private boolean isCommonBinding(ComputedColumnHandle cch, Map<String, ComputedColumnHandle> bindingMap)
throws BirtException {
ScriptExpression se = ChartReportItemUtil.newExpression(session.getModelAdaptor(), cch);
Expand Down Expand Up @@ -674,7 +673,7 @@ protected boolean isLibraryHandle() {
* @param queryDefn query definition.
* @param reportItemHandle the item handle contains groups.
*/
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({})
private void handleGroup(QueryDefinition queryDefn, ExtendedItemHandle reportItemHandle,
IModelAdapter modelAdapter) {
ReportItemHandle handle = ChartReportItemUtil.getBindingHolder(reportItemHandle);
Expand Down Expand Up @@ -796,7 +795,6 @@ protected boolean isInMultiView() {
*
* @return data set name
*/
@SuppressWarnings("unchecked")
String getInheritedDataSet() {
List<DataSetHandle> list = DEUtil.getDataSetList(itemHandle.getContainer());
if (list.size() > 0) {
Expand Down Expand Up @@ -908,7 +906,6 @@ protected List<ComputedColumn> generateComputedColumns(DataSetHandle dataSetHand
*
* @return direct dataset
*/
@SuppressWarnings("unchecked")
protected DataSetHandle getDataSetFromHandle() {
DataSetHandle handle = ChartReportItemHelper.instance().getBindingDataSetHandle(itemHandle);
if (handle != null) {
Expand Down Expand Up @@ -1129,7 +1126,6 @@ public DataType getDataType(String expression) {
return ChartItemUtil.getExpressionDataType(expression, itemHandle);
}

@SuppressWarnings("unchecked")
protected String[] getAllReportItemReferences() {
List<ReportItemHandle> availableList = itemHandle.getAvailableDataBindingReferenceList();
List<ReportItemHandle> referenceList = new ArrayList<>();
Expand Down Expand Up @@ -1353,10 +1349,9 @@ protected IDataRowExpressionEvaluator createBaseEvaluator(ExtendedItemHandle han
if (actualResultSet != null) {
if (ChartReportItemUtil.isOldChartUsingInternalGroup(itemHandle, cm)) {
return createSimpleExpressionEvaluator(actualResultSet);
} else {
return new BaseGroupedQueryResultSetEvaluator(actualResultSet.getResultIterator(),
ChartReportItemUtil.isSetSummaryAggregation(cm), cm, itemHandle);
}
return new BaseGroupedQueryResultSetEvaluator(actualResultSet.getResultIterator(),
ChartReportItemUtil.isSetSummaryAggregation(cm), cm, itemHandle);
}
} catch (BirtException e) {
throw new ChartException(ChartReportItemUIActivator.ID, ChartException.DATA_BINDING, e);
Expand Down Expand Up @@ -1576,7 +1571,6 @@ private Iterator<FilterConditionHandle> getFiltersIterator() {
* @return
* @throws BirtException
*/
@SuppressWarnings("unchecked")
protected IDataRowExpressionEvaluator createCubeEvaluator(CubeHandle cube, final Chart cm,
List<String> columnExpression) throws BirtException {
// Use the chart model in context, because this model will be updated
Expand Down Expand Up @@ -1607,9 +1601,9 @@ protected IDataRowExpressionEvaluator createCubeEvaluator(CubeHandle cube, final

// Generates a set of available binding names.
Set<String> bindingNames = new HashSet<>();
List<Object> bindings = queryDef.getBindings();
List<IBinding> bindings = queryDef.getBindings();
for (int i = 0; i < bindings.size(); i++) {
bindingNames.add(((Binding) bindings.get(i)).getBindingName());
bindingNames.add(bindings.get(i).getBindingName());
}

ExpressionSet exprSet = new ExpressionSet();
Expand Down Expand Up @@ -2206,9 +2200,8 @@ public Object evaluate(String expression) {
String newExpr = bindingExprsMap.get(expression);
if (newExpr != null) {
return fResultIterator.getValue(newExpr);
} else {
return fResultIterator.getValue(expression);
}
return fResultIterator.getValue(expression);
} catch (BirtException e) {
sLogger.log(e);
}
Expand Down Expand Up @@ -2376,7 +2369,6 @@ private final ColumnBindingInfo[] getPreviewHeadersInfo(List<ComputedColumnHandl
*
* @return
*/
@SuppressWarnings("unchecked")
private List<GroupHandle> getGroupsOfSharedBinding() {
List<GroupHandle> groupList = new ArrayList<>();
ListingHandle table = null;
Expand Down Expand Up @@ -3028,9 +3020,8 @@ boolean isSharingChart(boolean isRecursive) {
boolean isShare = isSharedBinding();
if (isRecursive) {
return isShare && isChartReportItemHandle(ChartReportItemUtil.getReportItemReference(itemHandle));
} else {
return isShare && isChartReportItemHandle(itemHandle.getDataBindingReference());
}
return isShare && isChartReportItemHandle(itemHandle.getDataBindingReference());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public AbstractChartBaseQueryGenerator(ReportItemHandle handle, Chart cm, boolea
* @param baseSD
* @throws ChartException
*/
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings("deprecation")
protected void addValueSeriesAggregateBindingForGrouping(BaseQueryDefinition query,
EList<SeriesDefinition> seriesDefinitions, GroupDefinition innerMostGroupDef,
Map<String, String[]> valueExprMap, SeriesDefinition baseSD) throws ChartException {
Expand Down Expand Up @@ -241,11 +241,11 @@ protected void addValueSeriesAggregateBindingForGrouping(BaseQueryDefinition que
newBinding.setExportable(colBinding.exportable());
newBinding.setFilter(colBinding.getFilter());
newBinding.setTimeFunction(colBinding.getTimeFunction());
for (Object o : colBinding.getAggregatOns()) {
newBinding.getAggregatOns().add(o);
for (String s : colBinding.getAggregatOns()) {
newBinding.getAggregatOns().add(s);
}
for (Object o : colBinding.getArguments()) {
newBinding.addArgument((IBaseExpression) o);
for (IBaseExpression arg : colBinding.getArguments()) {
newBinding.addArgument(arg);
}

query.addBinding(newBinding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
import org.eclipse.birt.data.engine.api.IBaseExpression;
import org.eclipse.birt.data.engine.api.IBaseQueryDefinition;
import org.eclipse.birt.data.engine.api.IBinding;
import org.eclipse.birt.data.engine.api.IGroupDefinition;
import org.eclipse.birt.data.engine.api.IScriptExpression;
import org.eclipse.birt.data.engine.api.ISubqueryDefinition;
import org.eclipse.birt.data.engine.api.querydefn.Binding;
import org.eclipse.birt.data.engine.api.querydefn.GroupDefinition;
import org.eclipse.birt.data.engine.api.querydefn.ScriptExpression;
import org.eclipse.birt.data.engine.api.querydefn.SubqueryDefinition;
import org.eclipse.birt.data.engine.core.DataException;
Expand Down Expand Up @@ -345,7 +345,7 @@ public static void copyAndInsertBindingFromContainer(ISubqueryDefinition query,
binding.addAggregateOn(aggregateOn);
// Copy groups if used and not added previously
if (findGroupInQuery(query, aggregateOn) == null) {
GroupDefinition group = findGroupInQuery(query.getParentQuery(), aggregateOn);
IGroupDefinition group = findGroupInQuery(query.getParentQuery(), aggregateOn);
if (group != null) {
((SubqueryDefinition) query).addGroup(group);
}
Expand All @@ -365,10 +365,10 @@ public static void copyAndInsertBindingFromContainer(ISubqueryDefinition query,
}

@SuppressWarnings("unchecked")
private static GroupDefinition findGroupInQuery(IBaseQueryDefinition query, String groupName) {
List<GroupDefinition> groups = query.getGroups();
private static IGroupDefinition findGroupInQuery(IBaseQueryDefinition query, String groupName) {
List<IGroupDefinition> groups = query.getGroups();
if (groups != null) {
for (GroupDefinition group : groups) {
for (IGroupDefinition group : groups) {
if (group.getName().equals(groupName)) {
return group;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.script.ScriptContext;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.core.security.PropertySecurity;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;
import org.mozilla.javascript.Scriptable;

Expand Down Expand Up @@ -103,7 +102,7 @@ public enum DataEngineFlowMode {
private int cacheOption;
private int cacheCount;

private String tmpDir = PropertySecurity.getSystemProperty("java.io.tmpdir"); //$NON-NLS-1$
private String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
private ClassLoader classLoader;

/** stream id for internal use, don't use it externally */
Expand Down Expand Up @@ -398,9 +397,8 @@ public boolean hasOutStream(String streamID, String subStreamID, int streamType)

if (writer != null) {
return writer.exists(relativePath);
} else {
return false;
}
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public interface IBaseDataSetDesign {
*
* @return the computed columns. An empty list if none is defined.
*/
List getComputedColumns();
List<IComputedColumn> getComputedColumns();

/**
* Returns a list of filters. The List contains
Expand All @@ -81,7 +81,7 @@ public interface IBaseDataSetDesign {
*
* @return the filters. An empty list if none is defined.
*/
List getFilters();
List<IFilterDefinition> getFilters();

/**
* Get a list of sort hints.
Expand All @@ -99,7 +99,7 @@ public interface IBaseDataSetDesign {
*
* @return the parameter definitions. An empty list if none is defined.
*/
List getParameters();
List<IParameterDefinition> getParameters();

/**
* Returns the primary result set hints as a list of
Expand All @@ -110,15 +110,15 @@ public interface IBaseDataSetDesign {
* the data set can provide the definition from the underlying data
* access provider.
*/
List getResultSetHints();
List<IColumnDefinition> getResultSetHints();

/**
* Returns the set of input parameter bindings as an unordered collection of
* {@link org.eclipse.birt.data.engine.api.IInputParameterBinding} objects.
*
* @return the input parameter bindings. An empty collection if none is defined.
*/
Collection getInputParamBindings();
Collection<IInputParameterBinding> getInputParamBindings();

/**
* Returns the <code>beforeOpen</code> script to be called just before opening
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface IBaseQueryDefinition extends IBaseTransform, IDataQueryDefiniti
* @return the list of groups. If no group is defined, null is returned.
*/

List getGroups();
List<IGroupDefinition> getGroups();

/**
* Indicates if the report will use the detail rows. Allows the data engine to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface IBaseTransform {
*
* @return the filters. null if no filter is defined.
*/
List getFilters();
List<IFilterDefinition> getFilters();

/**
* Returns an unordered collection of subqueries that are alternative views of
Expand All @@ -42,14 +42,14 @@ public interface IBaseTransform {
* @see ISubqueryDefinition
*/

Collection getSubqueries();
Collection<ISubqueryDefinition> getSubqueries();

/**
* Returns the sort criteria as an ordered list of
* {@link org.eclipse.birt.data.engine.api.ISortDefinition} objects.
*
* @return the sort criteria
*/
List getSorts();
List<ISortDefinition> getSorts();

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 Actuate Corporation.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
*
* Contributors:
* Actuate Corporation - initial API and implementation
Expand Down Expand Up @@ -72,7 +72,7 @@ public interface IBinding {
* @return
* @throws DataException
*/
List getAggregatOns() throws DataException;
List<String> getAggregatOns() throws DataException;

/**
* Add aggregate on to the binding.
Expand All @@ -89,7 +89,7 @@ public interface IBinding {
* @return
* @throws DataException
*/
List getArguments() throws DataException;
List<IBaseExpression> getArguments() throws DataException;

/**
* Imply whether the data of this binding should be candidate for data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ public interface IExpressionCollection extends IBaseExpression {
/**
* Gets the expression collection.
*/
Collection getExpressions();
Collection<IBaseExpression> getExpressions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.birt.data.engine.api.IBaseQueryDefinition;
import org.eclipse.birt.data.engine.api.IBinding;
import org.eclipse.birt.data.engine.api.IDataQueryDefinition;
import org.eclipse.birt.data.engine.api.IGroupDefinition;
import org.eclipse.birt.data.engine.api.IQueryDefinition;
import org.eclipse.birt.data.engine.api.IQueryExecutionHints;
import org.eclipse.birt.data.engine.core.DataException;
Expand Down Expand Up @@ -92,7 +93,7 @@ public List getGroups() {
*
* @param group Group definition to add
*/
public void addGroup(GroupDefinition group) {
public void addGroup(IGroupDefinition group) {
groups.add(group);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public String getAggrFunction() {
* @see org.eclipse.birt.data.engine.api.IBinding#getAggregatOns()
*/
@Override
public List getAggregatOns() {
public List<String> getAggregatOns() {
return this.aggregateOn;
}

Expand All @@ -137,7 +137,7 @@ public List getAggregatOns() {
* @see org.eclipse.birt.data.engine.api.IBinding#getArguments()
*/
@Override
public List getArguments() throws DataException {
public List<IBaseExpression> getArguments() throws DataException {
if (this.orderedArgument != null) {
// ordered list already computed;
return this.orderedArgument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public interface IDataSetInstanceHandle extends IJavascriptContext {
* @return Extension properties as a Map of String->String pairs. Null if no
* extension property is defined
*/
Map getAllExtensionProperties();
Map<String, String> getAllExtensionProperties();

/**
* Gets the current value of the named data set input parameter.
Expand Down
Loading