當前位置: 首頁>>代碼示例>>Java>>正文


Java DataRow類代碼示例

本文整理匯總了Java中org.apache.cayenne.DataRow的典型用法代碼示例。如果您正苦於以下問題:Java DataRow類的具體用法?Java DataRow怎麽用?Java DataRow使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataRow類屬於org.apache.cayenne包,在下文中一共展示了DataRow類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getReader

import org.apache.cayenne.DataRow; //導入依賴的package包/類
@Override
public RowReader getReader(Map<String, ?> parameters) {

	// TODO: fetching DataRows and then converting them to Object[] is kind
	// of expensive... maybe we can create Object[] bypassing DR, ideally by
	// iterating a JDBC ResultSet

	SQLSelect<DataRow> select = SQLSelect.dataRowQuery(sqlTemplate);
	select.params(parameters);

	switch (capsStrategy) {

	case LOWER:
		select.lowerColumnNames();
		break;
	case UPPER:
		select.upperColumnNames();
		break;
	case DEFAULT:
		select.upperColumnNames();
		break;
	}

	return new JdbcRowReader(attributes, context.iterator(select));
}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:26,代碼來源:JdbcExtractor.java

示例2: testAttributesFromDataRow

import org.apache.cayenne.DataRow; //導入依賴的package包/類
@Test
public void testAttributesFromDataRow() {

	DataRow row = new DataRow(5);
	row.put("A1", new Object());
	row.put("A2", null);
	row.put("A0", "aaaa");

	RowAttribute[] attributes = reader.attributesFromDataRow(row);
	assertNotNull(attributes);
	assertEquals(3, attributes.length);

	assertEquals("A0", attributes[0].getSourceName());
	assertEquals("db:A0", attributes[0].getTargetPath());
	
	assertEquals("A1", attributes[1].getSourceName());
	assertEquals("db:A1", attributes[1].getTargetPath());
	
	assertEquals("A2", attributes[2].getSourceName());
	assertEquals("db:A2", attributes[2].getTargetPath());
}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:22,代碼來源:JdbcRowReader_DynamicAttributesTest.java

示例3: createOrUpdateEtl8

import org.apache.cayenne.DataRow; //導入依賴的package包/類
private void createOrUpdateEtl8(int id, BigDecimal c1, BigDecimal c2, BigDecimal c3) {

		DataRow etl8 = getEtl8(id);
		if (etl8 == null) {
			srcRunSql(String.format("INSERT INTO utest.etl8 (ID, C_DECIMAL1, C_DECIMAL2, C_DECIMAL3) " +
				"VALUES (%d, %s, %s, %s)", id, c1, c2, c3));
		} else {
			srcRunSql(String.format("UPDATE utest.etl8 SET C_DECIMAL1 = %s, C_DECIMAL2 = %s, C_DECIMAL3 = %s " +
					"WHERE id = %d", c1, c2, c3, id));
		}

		etl8 = getEtl8(id);
		assertNotNull(etl8);
		assertEquals(c1, etl8.get("C_DECIMAL1"));
		assertEquals(c2, etl8.get("C_DECIMAL2"));
		assertEquals(c3, etl8.get("C_DECIMAL3"));
	}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:18,代碼來源:CreateOrUpdate_ValueConvertersIT.java

示例4: testRelate_ToMany_New

import org.apache.cayenne.DataRow; //導入依賴的package包/類
@Test
public void testRelate_ToMany_New() {

    insert("e2", "id, name", "24, 'xxx'");

    Response response = target("/e2/24/e3s")
            .request()
            .post(Entity.json("{\"name\":\"zzz\"}"));

    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    assertEquals("{\"data\":[{REPLACED_ID,\"name\":\"zzz\",\"phoneNumber\":null}],\"total\":1}",
            response.readEntity(String.class).replaceFirst("\"id\":[\\d]+", "REPLACED_ID"));

    assertEquals(1, intForQuery("SELECT count(1) FROM utest.e3"));

    DataRow row = SQLSelect.dataRowQuery("SELECT e2_id, name FROM utest.e3").lowerColumnNames()
            .selectOne(newContext());
    assertEquals("zzz", row.get("name"));
    assertEquals(24, row.get("e2_id"));
}
 
開發者ID:nhl,項目名稱:link-rest,代碼行數:21,代碼來源:POST_Related_IT.java

示例5: testRelate_ToMany_New_CompoundId

import org.apache.cayenne.DataRow; //導入依賴的package包/類
@Test
public void testRelate_ToMany_New_CompoundId() {

    insert("e17", "id1, id2, name", "1, 1, 'aaa'");

    Response response = target("/e17/e18s")
            .matrixParam("parentId1", 1)
            .matrixParam("parentId2", 1)
            .request()
            .post(Entity.json("{\"name\":\"xxx\"}"));

    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    assertEquals("{\"data\":[{REPLACED_ID,\"name\":\"xxx\"}],\"total\":1}",
            response.readEntity(String.class).replaceFirst("\"id\":[\\d]+", "REPLACED_ID"));

    assertEquals(1, intForQuery("SELECT count(1) FROM utest.e18"));

    DataRow row = SQLSelect.dataRowQuery("SELECT e17_id1, e17_id2, name FROM utest.e18").lowerColumnNames()
            .selectOne(newContext());
    assertEquals("xxx", row.get("name"));
    assertEquals(1, row.get("e17_id1"));
    assertEquals(1, row.get("e17_id2"));
}
 
開發者ID:nhl,項目名稱:link-rest,代碼行數:24,代碼來源:POST_Related_IT.java

示例6: filterSearchForProject

import org.apache.cayenne.DataRow; //導入依賴的package包/類
/**
 * Filter the results of a free-text SNOMED-CT search to include 
 * only the "common concepts" recorded for that project and its parent projects. 
 * While specifying root concepts is optional, it is more efficient to specify the same root concepts
 * that were used for the search to be filtered.
 * @param p - the project.
 * @param unfiltered - the unfiltered result of a search.
 * @param rootConcepts - root concepts - can be null but more efficient if specified.
 * @return
 */
public static List<ResultItem> filterSearchForProject(List<ResultItem> unfiltered, Project p, Collection<Long> rootConcepts) {
	final List<Project> parents = p.getOrderedParents().collect(Collectors.toList());
	Expression qual = ProjectConcept.PROJECT.in(parents);
	if (rootConcepts != null) {
		qual = qual.andExp(ProjectConcept.CONCEPT.dot(Concept.RECURSIVE_PARENT_CONCEPTS).dot(Concept.CONCEPT_ID).in(rootConcepts));
	}
	final List<DataRow> ids = SelectQuery.dataRowQuery(ProjectConcept.class, qual).select(p.getObjectContext());
	final Set<Long> commonConceptIds = ids.stream()
			.map(dr -> (Long) dr.get(ProjectConcept.CONCEPTCONCEPTID_PK_COLUMN))
			.distinct().collect(Collectors.toSet());
	return unfiltered.stream()
			.filter(ri -> commonConceptIds.contains(ri.getConceptId()))
			.collect(Collectors.toList());
}
 
開發者ID:wardle,項目名稱:rsterminology,代碼行數:25,代碼來源:SearchUtilities.java

示例7: attributesFromDataRow

import org.apache.cayenne.DataRow; //導入依賴的package包/類
RowAttribute[] attributesFromDataRow(DataRow row) {

		List<String> names = new ArrayList<>(row.keySet());

		// ensure predictable order on each run...
		Collections.sort(names);

		RowAttribute[] attributes = new RowAttribute[row.size()];
		for (int i = 0; i < attributes.length; i++) {
			String name = names.get(i);
			attributes[i] = new BaseRowAttribute(Object.class, name, ASTDbPath.DB_PREFIX + name, i);
		}

		return attributes;
	}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:16,代碼來源:JdbcRowReader.java

示例8: JdbcRowReader

import org.apache.cayenne.DataRow; //導入依賴的package包/類
public JdbcRowReader(RowAttribute[] attributes, ResultIterator<DataRow> rows) {
	this.rows = rows;
	this.attributes = attributes;
}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:5,代碼來源:JdbcRowReader.java

示例9: DataRowRow

import org.apache.cayenne.DataRow; //導入依賴的package包/類
DataRowRow(RowAttribute[] attributes, DataRow row) {
	this.attributes = attributes;
	this.row = row;
}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:5,代碼來源:DataRowRow.java

示例10: before

import org.apache.cayenne.DataRow; //導入依賴的package包/類
@Before
public void before() {
	@SuppressWarnings("unchecked")
	ResultIterator<DataRow> rows = mock(ResultIterator.class);
	this.reader = new JdbcRowReader(null, rows);
}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:7,代碼來源:JdbcRowReader_DynamicAttributesTest.java

示例11: getEtl8

import org.apache.cayenne.DataRow; //導入依賴的package包/類
private DataRow getEtl8(int id) {
	return SQLSelect.dataRowQuery("SELECT ID, C_DECIMAL1, C_DECIMAL2, C_DECIMAL3 FROM utest.etl8 WHERE ID = " + id)
			.selectFirst(srcStack.runtime().newContext());
}
 
開發者ID:nhl,項目名稱:link-move,代碼行數:5,代碼來源:CreateOrUpdate_ValueConvertersIT.java


注:本文中的org.apache.cayenne.DataRow類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。