当前位置: 首页>>代码示例>>Java>>正文


Java JasperDesign.getMainDataset方法代码示例

本文整理汇总了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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:37,代码来源:SortElementJsonHandler.java

示例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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:38,代码来源:SortElementJsonHandler.java

示例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);
			}
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:32,代码来源:FilterAction.java

示例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);
			}
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:33,代码来源:SortAction.java


注:本文中的net.sf.jasperreports.engine.design.JasperDesign.getMainDataset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。