本文整理汇总了Java中org.dashbuilder.dataset.DataSetFactory类的典型用法代码示例。如果您正苦于以下问题:Java DataSetFactory类的具体用法?Java DataSetFactory怎么用?Java DataSetFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataSetFactory类属于org.dashbuilder.dataset包,在下文中一共展示了DataSetFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCSVConfig
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
@Test
public void testCSVConfig() throws Exception {
DataSetDef dataSetDef = DataSetDefFactory.newCSVDataSetDef()
.datePattern("dd/MM/yyyy")
.numberPattern("#,###")
.allColumns(true)
.buildDef();
DataSet dataSet = DataSetFactory.newDataSetBuilder()
.date("date")
.number("number")
.row(new Date(), 1d)
.buildDataSet();
when(dataSetLookupServices.lookupDataSet(any(), any())).thenReturn(dataSet);
tested.show(dataSetDef, null, displayerListener);
ArgumentCaptor<Displayer> argumentCaptor = ArgumentCaptor.forClass(Displayer.class);
verify(displayerListener).onDataLoaded(argumentCaptor.capture());
Displayer displayer = argumentCaptor.getValue();
DisplayerSettings settings = displayer.getDisplayerSettings();
assertEquals(settings.getColumnSettings("date").getValuePattern(), "dd/MM/yyyy");
assertEquals(settings.getColumnSettings("number").getValuePattern(), "#,###");
}
示例2: initMetricCategory
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
private void initMetricCategory() {
GalleryTreeNodeList nodeList = new GalleryTreeNodeList(AppConstants.INSTANCE.gallerytree_metrics());
mainNodes.add(nodeList);
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_metrics_basic(), createPlaceRequest(
DisplayerSettingsFactory.newMetricSettings()
.title(AppConstants.INSTANCE.gallerytree_metrics_basic_title())
.titleVisible(true)
.dataset(SALES_OPPS)
.filter(CLOSING_DATE, timeFrame("begin[quarter February] till now"))
.column(AMOUNT, SUM).expression("value/1000").format(AppConstants.INSTANCE.gallerytree_metrics_basic_column1(), "$ #,### K")
.width(300).height(150)
.margins(50, 50, 50, 50)
.backgroundColor("FDE8D4")
.filterOn(false, false, true)
.buildSettings()
)));
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_metrics_basic_static(), createPlaceRequest(
DisplayerSettingsFactory.newMetricSettings()
.title(AppConstants.INSTANCE.gallerytree_metrics_basic_static_title())
.titleVisible(true)
.column("tweets").format(AppConstants.INSTANCE.gallerytree_metrics_basic_static_column1(), "#,###")
.width(300).height(150)
.margins(50, 50, 50, 50)
.backgroundColor("ADE8D4")
.filterOff(true)
.dataset(DataSetFactory.newDataSetBuilder()
.number("tweets")
.row(54213d)
.buildDataSet())
.buildSettings()
)));
}
示例3: testTableSettings
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
@Test
public void testTableSettings() {
when(dataSetHandler.getLastDataSet()).thenReturn(DataSetFactory.newDataSetBuilder()
.label("dept")
.date("date")
.number("amount")
.buildDataSet());
when(displayer.getDisplayerConstraints()).thenReturn(
new DisplayerConstraints(null)
.supportsAttribute(TABLE_GROUP)
.supportsAttribute(EXPORT_GROUP));
when(displayer.getDisplayerSettings()).thenReturn(DisplayerSettingsFactory.newTableSettings()
.tablePageSize(10)
.tableWidth(500)
.tableOrderEnabled(true)
.tableOrderDefault("date", SortOrder.ASCENDING)
.tableColumnPickerEnabled(false)
.allowCsvExport(true)
.allowExcelExport(false)
.buildSettings());
presenter.init(displayer);
verify(view).clear();
verify(view).addTextProperty(eq(TABLE_WIDTH), eq("500"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addBooleanProperty(TABLE_SORTENABLED, true);
verify(view).addListProperty(eq(TABLE_SORTCOLUMNID), anyListOf(String.class), eq("date"));
verify(view).addListProperty(eq(TABLE_SORTORDER), anyListOf(String.class), eq(SortOrder.ASCENDING.toString()));
verify(view).addBooleanProperty(TABLE_COLUMN_PICKER_ENABLED, false);
verify(view).addBooleanProperty(EXPORT_TO_CSV, true);
verify(view).addBooleanProperty(EXPORT_TO_XLS, false);
verify(view).show();
}
示例4: exportToExcelWorksWhenDataSetHasNulls
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
@Test
public void exportToExcelWorksWhenDataSetHasNulls() {
DataSetExportServicesImpl exporter = new DataSetExportServicesImpl(dataSetManagerM,
gitStorageM,
exceptionManagerM);
DataSet dataSetWithNulls = DataSetFactory.newDataSetBuilder()
.date("Date of birth")
.number("Age")
.text("Description")
.row(null,
null,
null).buildDataSet();
SXSSFWorkbook workbook = exporter.dataSetToWorkbook(dataSetWithNulls);
assertNotNull("Export of dataset containing null should succeed",
workbook);
// Verify header
SXSSFRow firstRow = workbook.getSheetAt(0).getRow(0);
assertEquals("Date of birth", firstRow.getCell(0).getStringCellValue());
assertEquals("Age", firstRow.getCell(1).getStringCellValue());
assertEquals("Description", firstRow.getCell(2).getStringCellValue());
// Verify data row
SXSSFRow secondRow = workbook.getSheetAt(0).getRow(1);
assertEquals("", secondRow.getCell(0).getStringCellValue());
assertEquals("", secondRow.getCell(1).getStringCellValue());
assertEquals("", secondRow.getCell(2).getStringCellValue());
}
示例5: initLineChartCategory
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
private void initLineChartCategory() {
GalleryTreeNodeList nodeList = new GalleryTreeNodeList(AppConstants.INSTANCE.gallerytree_line());
mainNodes.add(nodeList);
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_line_basic(), createPlaceRequest(
DisplayerSettingsFactory.newLineChartSettings()
.dataset(SALES_OPPS)
.group(CLOSING_DATE).dynamic(12, MONTH, true)
.column(CLOSING_DATE).format(AppConstants.INSTANCE.gallerytree_line_basic_column1(), "MMM dd, yyyy")
.column(AMOUNT, SUM).format(AppConstants.INSTANCE.gallerytree_line_basic_column2(), "$ #,###")
.title(AppConstants.INSTANCE.gallerytree_line_basic_title())
.margins(20, 50, 100, 120)
.filterOn(false, true, true)
.buildSettings()
)));
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_line_multi(), createPlaceRequest(
DisplayerSettingsFactory.newLineChartSettings()
.dataset(SALES_OPPS)
.group(COUNTRY)
.column(COUNTRY, "Country")
.column(AMOUNT, MIN).format(AppConstants.INSTANCE.gallerytree_line_multi_column1(), "$ #,###")
.column(AMOUNT, MAX).format(AppConstants.INSTANCE.gallerytree_line_multi_column2(), "$ #,###")
.column(AMOUNT, AVERAGE).format(AppConstants.INSTANCE.gallerytree_line_multi_column3(), "$ #,###")
.title(AppConstants.INSTANCE.gallerytree_line_multi_title())
.margins(30, 100, 80, 80)
.filterOn(false, true, true)
.buildSettings()
)));
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_line_multi_static(), createPlaceRequest(
DisplayerSettingsFactory.newLineChartSettings()
.title(AppConstants.INSTANCE.gallerytree_line_multi_static_title())
.margins(20, 80, 50, 120)
.column("month", "Month")
.column("2014").format(AppConstants.INSTANCE.gallerytree_line_multi_static_column1(), "$ #,###")
.column("2015").format(AppConstants.INSTANCE.gallerytree_line_multi_static_column2(), "$ #,###")
.column("2016").format(AppConstants.INSTANCE.gallerytree_line_multi_static_column3(), "$ #,###")
.dataset(DataSetFactory.newDataSetBuilder()
.label("month")
.number("2014")
.number("2015")
.number("2016")
.row(JANUARY, 1000d, 2000d, 3000d)
.row(FEBRUARY, 1400d, 2300d, 2000d)
.row(MARCH, 1300d, 2000d, 1400d)
.row(APRIL, 900d, 2100d, 1500d)
.row(MAY, 1300d, 2300d, 1600d)
.row(JUNE, 1010d, 2000d, 1500d)
.row(JULY, 1050d, 2400d, 3000d)
.row(AUGUST, 2300d, 2000d, 3200d)
.row(SEPTEMBER, 1900d, 2700d, 3000d)
.row(OCTOBER, 1200d, 2200d, 3100d)
.row(NOVEMBER, 1400d, 2100d, 3100d)
.row(DECEMBER, 1100d, 2100d, 4200d)
.buildDataSet())
.buildSettings()
)));
}
示例6: initMeterChartCategory
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
private void initMeterChartCategory() {
GalleryTreeNodeList nodeList = new GalleryTreeNodeList(AppConstants.INSTANCE.gallerytree_meter());
mainNodes.add(nodeList);
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_meter_basic(), createPlaceRequest(
DisplayerSettingsFactory.newMeterChartSettings()
.title(AppConstants.INSTANCE.gallerytree_meter_basic_title())
.dataset(SALES_OPPS)
.column(AMOUNT, SUM, AppConstants.INSTANCE.gallerytree_meter_basic_column1())
.expression("value/1000")
.format(AppConstants.INSTANCE.gallerytree_meter_basic_column1(), "$ #,### K")
.width(400).height(200)
.meter(0, 15000, 25000, 35000)
.filterOn(false, true, true)
.buildSettings()
)));
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_meter_multi(), createPlaceRequest(
DisplayerSettingsFactory.newMeterChartSettings()
.title(AppConstants.INSTANCE.gallerytree_meter_multi_title())
.dataset(SALES_OPPS)
.group(CREATION_DATE).dynamic(12, YEAR, true)
.column(CREATION_DATE, "Year")
.column(AMOUNT, SUM)
.expression("value/1000")
.format(AppConstants.INSTANCE.gallerytree_meter_multi_column1(), "$ #,###")
.width(600).height(200)
.meter(0, 1000, 3000, 5000)
.filterOn(false, true, true)
.buildSettings()
)));
nodeList.add(new GalleryPlaceRequest(AppConstants.INSTANCE.gallerytree_meter_multi_static(), createPlaceRequest(
DisplayerSettingsFactory.newMeterChartSettings()
.title(AppConstants.INSTANCE.gallerytree_meter_multi_static_title())
.width(500).height(200)
.meter(30, 160, 190, 220)
.column("person").format(AppConstants.INSTANCE.gallerytree_meter_multi_static_column1())
.column("heartRate").format(AppConstants.INSTANCE.gallerytree_meter_multi_static_column2(), "#,### bpm")
.dataset(DataSetFactory.newDataSetBuilder()
.label("person")
.number("heartRate")
.row("David", 52)
.row("Roger", 120)
.row("Mark", 74)
.row("Michael", 78)
.row("Kris", 74)
.buildDataSet())
.buildSettings()
)));
}
示例7: buildDataSet
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
public DataSet buildDataSet(Map<String,String> params) {
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
int startYear = currentYear + parseParam(params.get("startYear"), -2);
int endYear = currentYear + parseParam(params.get("endYear"), 2);
int opportunitiesPerMonth = parseParam(params.get("oppsPerMonth"), 30);
DataSetBuilder builder = DataSetFactory.newDataSetBuilder()
.number(AMOUNT)
.date(CREATION_DATE)
.date(CLOSING_DATE)
.label(PIPELINE)
.label(STATUS)
.label(CUSTOMER)
.label(COUNTRY)
.label(PRODUCT)
.label(SALES_PERSON)
.number(PROBABILITY)
.label(SOURCE)
.number(EXPECTED_AMOUNT)
.label(COLOR);
for (int year = startYear; year <= endYear; year++) {
for (int month = 0; month < 12; month++) {
for (int i = 0; i < opportunitiesPerMonth; i++) {
double amount = MIN_AMOUNT + random.nextDouble() * (MAX_AMOUNT - MIN_AMOUNT);
double probability = random.nextDouble() * 100.0;
Date creationDate = buildDate(month, year);
String color = "GREEN";
if (probability < 25) color = "RED";
else if (probability < 50) color = "GREY";
else if (probability < 75) color = "YELLOW";
builder.row(amount,
creationDate,
addDates(creationDate, (int) (AVG_CLOSING_DAYS + random.nextDouble() * AVG_CLOSING_DAYS * 0.5)),
randomValue(DIC_PIPELINE),
randomValue(DIC_STATUS),
randomValue(DIC_CUSTOMER),
randomValue(DIC_COUNTRIES),
randomValue(DIC_PRODUCT),
randomValue(DIC_SALES_PERSON),
probability,
randomValue(DIC_SOURCE),
amount * (1 + (random.nextDouble() * ((month*i)%10)/10)),
color);
}
}
}
return builder.buildDataSet();
}
示例8: testGeneralSettings
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
@Test
public void testGeneralSettings() {
when(dataSetHandler.getLastDataSet()).thenReturn(DataSetFactory.newDataSetBuilder()
.label("dept")
.number("amount")
.buildDataSet());
when(displayer.getDisplayerSettings()).thenReturn(DisplayerSettingsFactory.newBarChartSettings()
.dataset("dset")
.group("dept")
.column("dept").format("Department")
.column("amount").format("Total", "#.##0").expression("value/100")
.title("Sales by dept")
.titleVisible(true)
.legendOn(Position.BOTTOM)
.width(400).height(200)
.xAxisTitle("Depts")
.yAxisTitle("Amount $")
.margins(10, 80, 80, 100)
.filterOn(false, true, true)
.refreshOn(3, false)
.buildSettings());
// Call to init implies calling to presenter.show() internally (see above)
presenter.init(displayer);
verify(view).clear();
verify(view).addTextProperty(TITLE, "Sales by dept");
verify(view).addBooleanProperty(TITLE_VISIBLE, true);
verify(view, never()).addBooleanProperty(EXPORT_TO_CSV, false);
verify(view, never()).addBooleanProperty(EXPORT_TO_XLS, false);
verify(view).addTextProperty(eq(CHART_WIDTH), eq("400"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addTextProperty(eq(CHART_HEIGHT), eq("200"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addColorProperty(eq(CHART_BGCOLOR), anyString());
verify(view).addBooleanProperty(CHART_3D, false);
verify(view).addTextProperty(eq(CHART_MARGIN_TOP), eq("10"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addTextProperty(eq(CHART_MARGIN_BOTTOM), eq("80"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addTextProperty(eq(CHART_MARGIN_LEFT), eq("80"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addTextProperty(eq(CHART_MARGIN_RIGHT), eq("100"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addBooleanProperty(CHART_SHOWLEGEND, true);
verify(view).addListProperty(eq(CHART_LEGENDPOSITION), anyListOf(String.class), anyString());
verify(view).addBooleanProperty(XAXIS_SHOWLABELS, true);
verify(view).addTextProperty(XAXIS_LABELSANGLE, "0");
verify(view).addTextProperty(XAXIS_TITLE, "Depts");
verify(view).addBooleanProperty(YAXIS_SHOWLABELS, true);
verify(view).addTextProperty(YAXIS_TITLE, "Amount $");
verify(view).addBooleanProperty(FILTER_ENABLED, true);
verify(view).addBooleanProperty(FILTER_SELFAPPLY_ENABLED, false);
verify(view).addBooleanProperty(FILTER_NOTIFICATION_ENABLED, true);
verify(view).addBooleanProperty(FILTER_LISTENING_ENABLED, true);
verify(view).addTextProperty(eq(REFRESH_INTERVAL), eq("3"), any(DisplayerSettingsEditor.LongValidator.class));
verify(view).addBooleanProperty(REFRESH_STALE_DATA, false);
verify(view).addTextProperty(eq("columns.dept.name"), anyString(), eq("Department"));
verify(view).addTextProperty(eq("columns.amount.name"), anyString(), eq("Total"));
verify(view).addTextProperty(eq("columns.amount.expression"), anyString(), eq("value/100"));
verify(view).addTextProperty(eq("columns.amount.pattern"), anyString(), eq("#.##0"));
verify(view).show();
}
示例9: createDataSet
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
@Override
public DataSet createDataSet(String uuid) {
DataSet dataSet = DataSetFactory.newEmptyDataSet();
dataSet.setUUID(uuid);
return dataSet;
}
示例10: testDataSet
import org.dashbuilder.dataset.DataSetFactory; //导入依赖的package包/类
/**
* <p>Test the data set connection and obtain the preview result.</p>
*
*/
public void testDataSet(final TestDataSetCallback testDataSetCallback) {
checkDataSetDefNotNull();
// Reset columns and filter configuration.
getDataSetDef().setAllColumnsEnabled(true);
getDataSetDef().setColumns(null);
getDataSetDef().setDataSetFilter(null);
DataSetDef editCloneWithoutCacheSettings = getDataSetDef().clone();
editCloneWithoutCacheSettings.setCacheEnabled(false);
final DataSetLookup lookup = DataSetFactory.newDataSetLookupBuilder()
.dataset(dataSetDef.getUUID())
.rowOffset(0)
.rowNumber(6)
.buildLookup();
try {
DataSetHandler editHandler = new DataSetEditHandler(clientServices, lookup, editCloneWithoutCacheSettings);
editHandler.lookupDataSet(new DataSetReadyCallback() {
@Override
public void callback(final DataSet dataSet) {
testDataSetCallback.onSuccess(dataSet);
}
@Override
public void notFound() {
testDataSetCallback.onError(new ClientRuntimeError(DataSetEditorConstants.INSTANCE.defNotFound()));
}
@Override
public boolean onError(final ClientRuntimeError error) {
testDataSetCallback.onError(error);
return false;
}
});
} catch (final Exception e) {
testDataSetCallback.onError(new ClientRuntimeError(e));
}
}