當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。