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


Java DataTable类代码示例

本文整理汇总了Java中com.belladati.sdk.dataset.data.DataTable的典型用法代码示例。如果您正苦于以下问题:Java DataTable类的具体用法?Java DataTable怎么用?Java DataTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataTable类属于com.belladati.sdk.dataset.data包,在下文中一共展示了DataTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadData

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
@Override
public void uploadData(String id, DataTable data) {
	List<DataRow> rows = data.getRows();
	if (rows.size() == 0) {
		// if we don't have data, do nothing
		return;
	}
	try {
		client.postUpload("api/import/" + id, tokenHolder, data.toJson().toString());
	} catch (UnexpectedResponseException e) {
		if (e.getResponseCode() == 400) {
			Pattern codePattern = Pattern.compile(".*?'(.*?)'.*");
			Matcher codeMatcher = codePattern.matcher(e.getResponseContent());
			if (codeMatcher.matches()) {
				throw new UnknownServerColumnException(id, codeMatcher.group(1));
			}
		}
		throw new UnexpectedResponseException(e.getResponseCode(), e.getResponseContent(), e);
	}
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:21,代码来源:BellaDatiServiceImpl.java

示例2: uploadJson

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** JSON data is sent correctly */
public void uploadJson() {
	final DataTable table = DataTable.createBasicInstance(column).createRow("content");

	server.register(url, new TestRequestHandler() {
		@Override
		protected void handle(HttpHolder holder) throws IOException {
			HttpEntity entity = ((BasicHttpEntityEnclosingRequest) holder.request).getEntity();
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			entity.writeTo(baos);
			JsonNode json = new ObjectMapper().readTree(baos.toByteArray());
			baos.close();

			assertEquals(json, table.toJson());
		}
	});

	getService().uploadData(id, table);

	server.assertRequestUris(url);
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:22,代码来源:DataImportTest.java

示例3: uploadFromDataSet

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** can import data from a data set */
public void uploadFromDataSet() {
	final DataTable table = DataTable.createBasicInstance(column).createRow("content");

	server.register(url, new TestRequestHandler() {
		@Override
		protected void handle(HttpHolder holder) throws IOException {
			HttpEntity entity = ((BasicHttpEntityEnclosingRequest) holder.request).getEntity();
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			entity.writeTo(baos);
			JsonNode json = new ObjectMapper().readTree(baos.toByteArray());
			baos.close();

			assertEquals(json, table.toJson());
		}
	});

	DataSet dataSet = new DataSetImpl(getService(), builder.buildDataSetNode(id, "", "", "", ""));
	dataSet.uploadData(table);

	server.assertRequestUris(url);
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:23,代码来源:DataImportTest.java

示例4: rowJsonEscape

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** convert row to JSON with reserved characters */
public void rowJsonEscape() {
	String col2 = "col2";
	String col3 = "col3";
	final String val1 = "\"I'm a text with ; and , in it\"";
	final String val2 = "\"I'm more text with ; and , in it\"";
	final String val3 = "nothing special here";

	DataRow row = DataTable.createBasicInstance(column, col2, col3).createRow().setAll(val1, val2, val3);
	ArrayNode rowJson = (ArrayNode) row.toJson();

	assertEquals(rowJson.size(), 3);
	assertEquals(rowJson.get(0).asText(), val1);
	assertEquals(rowJson.get(1).asText(), val2);
	assertEquals(rowJson.get(2).asText(), val3);
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:17,代码来源:DataSetDataTest.java

示例5: uploadJson

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** JSON data is sent correctly */
public void uploadJson() {
	final DataTable table = DataTable.createBasicInstance(column).createRow("content");

	server.register(url, new TestRequestHandler() {
		@Override
		protected void handle(HttpHolder holder) throws IOException {
			HttpEntity entity = ((BasicHttpEntityEnclosingRequest) holder.request).getEntity();
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			entity.writeTo(baos);
			JsonNode json = new ObjectMapper().readTree(baos.toByteArray());
			baos.close();

			assertEquals(json, table.toJson());
		}
	});

	service.uploadData(id, table);

	server.assertRequestUris(url);
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-android,代码行数:22,代码来源:DataImportTest.java

示例6: uploadFromDataSet

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** can import data from a data set */
public void uploadFromDataSet() {
	final DataTable table = DataTable.createBasicInstance(column).createRow("content");
	DataSet dataSet = new DataSetImpl(service, builder.buildDataSetNode(id, "", "", "", ""));

	server.register(url, new TestRequestHandler() {
		@Override
		protected void handle(HttpHolder holder) throws IOException {
			HttpEntity entity = ((BasicHttpEntityEnclosingRequest) holder.request).getEntity();
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			entity.writeTo(baos);
			JsonNode json = new ObjectMapper().readTree(baos.toByteArray());
			baos.close();

			assertEquals(json, table.toJson());
		}
	});

	dataSet.uploadData(table);

	server.assertRequestUris(url);
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-android,代码行数:23,代码来源:DataImportTest.java

示例7: createDataTable

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
@Override
public DataTable createDataTable() {
	List<String> columns = new ArrayList<String>();
	for (Attribute attribute : attributes) {
		columns.add(attribute.getCode());
	}
	for (Indicator indicator : indicators) {
		columns.add(indicator.getCode());
	}
	return DataTable.createBasicInstance(columns);
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:12,代码来源:DataSetImpl.java

示例8: dataSetTable

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** data set can create import table */
public void dataSetTable() {
	String attributeCode = "A";
	String indicatorCode = "I";
	ObjectNode node = builder.buildDataSetNode(dataSetId, name, description, owner, lastChange);
	node.put("attributes",
		new ObjectMapper().createArrayNode().add(builder.buildAttributeNode(id, name, attributeCode, "String")));
	node.put("indicators", new ObjectMapper().createArrayNode()
		.add(builder.buildIndicatorNode(id, name, indicatorCode, formula, "data_indicator")));
	DataTable table = new DataSetImpl(getService(), node).createDataTable();
	assertEquals(table.getColumns(), Arrays.asList(new DataColumn(attributeCode), new DataColumn(indicatorCode)));
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:13,代码来源:DataSetStructureTest.java

示例9: nonExistingColumn

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** non-existing column server error */
public void nonExistingColumn() {
	server.registerError(url, 400, "Indicator/attribute '" + column + "' doesn't exist");

	try {
		getService().uploadData(id, DataTable.createBasicInstance(column).createRow("content"));
		fail("No exception thrown");
	} catch (UnknownServerColumnException e) {
		assertEquals(e.getId(), id);
		assertEquals(e.getColumn(), column);
	}
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:13,代码来源:DataImportTest.java

示例10: otherError

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** unrelated server error */
@Test(expectedExceptions = UnexpectedResponseException.class)
public void otherError() {
	server.registerError(url, 400, "something else");

	getService().uploadData(id, DataTable.createBasicInstance(column).createRow("content"));
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:8,代码来源:DataImportTest.java

示例11: columnsStrings

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** create with multiple columns passed as strings */
public void columnsStrings() {
	String other = "other";
	DataTable table = DataTable.createBasicInstance(column, other);
	assertEquals(table.getColumns(), Arrays.asList(new DataColumn(column), new DataColumn(other)));
	assertEquals(table.createRow().getColumns(), table.getColumns());
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:8,代码来源:DataSetDataTest.java

示例12: columnsStringList

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** create with multiple columns passed as list */
public void columnsStringList() {
	String other = "other";
	DataTable table = DataTable.createBasicInstance(Arrays.asList(column, other));
	assertEquals(table.getColumns(), Arrays.asList(new DataColumn(column), new DataColumn(other)));
	assertEquals(table.createRow().getColumns(), table.getColumns());
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:8,代码来源:DataSetDataTest.java

示例13: columnsObjects

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** create with multiple columns passed as strings */
public void columnsObjects() {
	DataColumn col1 = new DataColumn(column);
	DataColumn col2 = new DataColumn("other");
	DataTable table = DataTable.createDetailedInstance(col1, col2);
	assertEquals(table.getColumns(), Arrays.asList(col1, col2));
	assertSame(table.getColumns().get(0), col1);
	assertSame(table.getColumns().get(1), col2);
	assertEquals(table.createRow().getColumns(), table.getColumns());
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:11,代码来源:DataSetDataTest.java

示例14: columnsObjectList

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** create with multiple columns passed as list */
public void columnsObjectList() {
	DataColumn col1 = new DataColumn(column);
	DataColumn col2 = new DataColumn("other");
	DataTable table = DataTable.createDetailedInstance(Arrays.asList(col1, col2));
	assertEquals(table.getColumns(), Arrays.asList(col1, col2));
	assertSame(table.getColumns().get(0), col1);
	assertSame(table.getColumns().get(1), col2);
	assertEquals(table.createRow().getColumns(), table.getColumns());
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:11,代码来源:DataSetDataTest.java

示例15: createRows

import com.belladati.sdk.dataset.data.DataTable; //导入依赖的package包/类
/** create rows */
public void createRows() {
	DataTable table = DataTable.createBasicInstance(column);
	assertEquals(table.getRows().size(), 0);
	table.createRow();
	assertEquals(table.getRows().size(), 1);
	table.createRow("abc");
	assertEquals(table.getRows().size(), 2);
}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:10,代码来源:DataSetDataTest.java


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