本文整理汇总了Java中net.sf.jasperreports.engine.design.JasperDesign.getMainDataset方法的典型用法代码示例。如果您正苦于以下问题:Java JasperDesign.getMainDataset方法的具体用法?Java JasperDesign.getMainDataset怎么用?Java JasperDesign.getMainDataset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.design.JasperDesign
的用法示例。
在下文中一共展示了JasperDesign.getMainDataset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentSortField
import net.sf.jasperreports.engine.design.JasperDesign; //导入方法依赖的package包/类
private String getCurrentSortField(JasperReportsContext jasperReportsContext, ReportContext reportContext, String uuid, String sortDatasetName, String sortColumnName, String sortColumnType)
{
JasperDesignCache cache = JasperDesignCache.getInstance(jasperReportsContext, reportContext);
SortAction action = new SortAction();
action.init(jasperReportsContext, reportContext);
CommandTarget target = action.getCommandTarget(UUID.fromString(uuid));
if (target != null)
{
JasperDesign jasperDesign = cache.getJasperDesign(target.getUri());
JRDesignDataset dataset = (JRDesignDataset)jasperDesign.getMainDataset();
List<JRSortField> existingFields = dataset.getSortFieldsList();
String sortField = null;
if (existingFields != null && existingFields.size() > 0) {
for (JRSortField field: existingFields) {
if (field.getName().equals(sortColumnName) && field.getType().getName().equals(sortColumnType)) {
sortField = sortColumnName + SortElement.SORT_COLUMN_TOKEN_SEPARATOR + sortColumnType + SortElement.SORT_COLUMN_TOKEN_SEPARATOR;
switch (field.getOrderValue()) {
case ASCENDING:
sortField += SortElement.SORT_ORDER_ASC;
break;
case DESCENDING:
sortField += SortElement.SORT_ORDER_DESC;
break;
}
break;
}
}
}
return sortField;
}
return null;
}
示例2: getExistingFiltersForField
import net.sf.jasperreports.engine.design.JasperDesign; //导入方法依赖的package包/类
private List<FieldFilter> getExistingFiltersForField(
JasperReportsContext jasperReportsContext,
ReportContext reportContext,
String uuid,
String filterFieldName
)
{
JasperDesignCache cache = JasperDesignCache.getInstance(jasperReportsContext, reportContext);
FilterAction action = new FilterAction();
action.init(jasperReportsContext, reportContext);
CommandTarget target = action.getCommandTarget(UUID.fromString(uuid));
List<FieldFilter> result = new ArrayList<FieldFilter>();
if (target != null)
{
JasperDesign jasperDesign = cache.getJasperDesign(target.getUri());
JRDesignDataset dataset = (JRDesignDataset)jasperDesign.getMainDataset();
// get existing filter as JSON string
String serializedFilters = "[]";
JRPropertiesMap propertiesMap = dataset.getPropertiesMap();
if (propertiesMap.getProperty(FilterCommand.DATASET_FILTER_PROPERTY) != null) {
serializedFilters = propertiesMap.getProperty(FilterCommand.DATASET_FILTER_PROPERTY);
}
List<? extends DatasetFilter> existingFilters = JacksonUtil.getInstance(jasperReportsContext).loadList(serializedFilters, FieldFilter.class);
if (existingFilters.size() > 0) {
for (DatasetFilter filter: existingFilters) {
if (((FieldFilter)filter).getField().equals(filterFieldName)) {
result.add((FieldFilter)filter);
break;
}
}
}
}
return result;
}
示例3: performAction
import net.sf.jasperreports.engine.design.JasperDesign; //导入方法依赖的package包/类
@Override
public void performAction() throws ActionException {
if (filterData != null) {
CommandTarget target = getCommandTarget(UUID.fromString(filterData.getTableUuid()));
if (target != null)
{
JasperDesignCache cache = JasperDesignCache.getInstance(getJasperReportsContext(), getReportContext());
JasperDesign jasperDesign = cache.getJasperDesign(target.getUri());
JRDesignDataset dataset = (JRDesignDataset)jasperDesign.getMainDataset();
// obtain command stack
CommandStack commandStack = getCommandStack();
// execute command
try {
commandStack.execute(
new ResetInCacheCommand(
new FilterCommand(getJasperReportsContext(), dataset, getFilterData()),
getJasperReportsContext(),
getReportContext(),
target.getUri()
)
);
} catch (CommandException e) {
throw new ActionException(e);
}
}
}
}
示例4: performAction
import net.sf.jasperreports.engine.design.JasperDesign; //导入方法依赖的package包/类
@Override
public void performAction() throws ActionException
{
if (sortData != null)
{
CommandTarget target = getCommandTarget(UUID.fromString(sortData.getTableUuid()));
if (target != null)
{
JasperDesignCache cache = JasperDesignCache.getInstance(getJasperReportsContext(), getReportContext());
JasperDesign jasperDesign = cache.getJasperDesign(target.getUri());
JRDesignDataset dataset = (JRDesignDataset)jasperDesign.getMainDataset();
// obtain command stack
CommandStack commandStack = getCommandStack();
// execute command
try {
commandStack.execute(
new ResetInCacheCommand(
new SortCommand(getJasperReportsContext(), dataset, sortData),
getJasperReportsContext(),
getReportContext(),
target.getUri()
)
);
} catch (CommandException e) {
throw new ActionException(e);
}
}
}
}