• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DataTarget类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testQueryAggregateProjection

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@Test
public void testQueryAggregateProjection() {

	final DataTarget<TestJpaDomain> DataTarget = JpaTarget.of(TestJpaDomain.class);

	Optional<Long> key = getDatastore().query().target(DataTarget).findOne(KEY.max());
	assertTrue(key.isPresent());
	assertEquals(new Long(2), key.get());

	key = getDatastore().query().target(DataTarget).findOne(KEY.min());
	assertTrue(key.isPresent());
	assertEquals(new Long(1), key.get());

	Optional<Long> sum = getDatastore().query().target(DataTarget).findOne(KEY.sum());
	assertTrue(sum.isPresent());
	assertEquals(new Long(3), sum.get());

	Optional<Long> count = getDatastore().query().target(DataTarget).findOne(KEY.count());
	assertEquals(new Long(2), count.get());
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa-querydsl,代码行数:21,代码来源:AbstractQueryDslTest.java


示例2: testQueryStream

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@Test
public void testQueryStream() {

	List<String> results = getDatastore().query().target(DataTarget.named(TestJpaDomain.class.getName()))
			.sort(KEY.asc()).stream(KEY).map((r) -> r.toString()).collect(Collectors.toList());

	assertNotNull(results);
	assertEquals(2, results.size());

	String res = results.get(0);
	assertNotNull(res);
	assertEquals("1", res);

	List<Long> results2 = getDatastore().query().target(QueryDslTarget.of(QTestJpaDomain.testJpaDomain))
			.sort(KEY.asc()).stream(KEY, STR).map((r) -> r.getValue(KEY)).collect(Collectors.toList());

	Long lng = results2.get(0);
	assertNotNull(lng);
	assertEquals(new Long(1), lng);

}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa-querydsl,代码行数:22,代码来源:AbstractQueryDslTest.java


示例3: selectable9

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
public void selectable9() {
	// tag::selectable9[]
	Datastore datastore = obtainDatastore();

	final PathProperty<Long> ID = PathProperty.create("id", Long.class);
	final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);

	SingleSelect<Long> singleSelect = Components.input.singleSelect(ID) // <1>
			.dataSource(datastore, DataTarget.named("testData"), PropertySet.of(ID, DESCRIPTION)) // <2>
			.itemCaptionGenerator(propertyBox -> propertyBox.getValue(DESCRIPTION)) // <3>
			.build();

	singleSelect.setValue(Long.valueOf(1)); // <4>
	Long selectedId = singleSelect.getValue(); // <5>

	singleSelect.refresh(); // <6>
	// end::selectable9[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:19,代码来源:ExampleSelectable.java


示例4: JpaBulkInsert

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
/**
 * Create a JPA batch insert.
 * @param context Datastore context
 * @param beanIntrospector Bean introspector
 * @param target Data target
 * @param propertySet Property set
 * @param writeOptions Write options
 */
@SuppressWarnings("unchecked")
public JpaBulkInsert(JpaDatastoreCommodityContext context, BeanIntrospector beanIntrospector, DataTarget<?> target,
		PropertySet<?> propertySet, WriteOption[] writeOptions) {
	super();

	ObjectUtils.argumentNotNull(context, "JpaDatastoreCommodityContext must be not null");
	ObjectUtils.argumentNotNull(target, "Data target must be not null");
	ObjectUtils.argumentNotNull(propertySet, "PropertySet must be not null");

	this.context = context;
	this.beanIntrospector = beanIntrospector;
	this.target = target;
	this.propertySet = propertySet;
	this.writeOptions = writeOptions;

	// inherit resolvers
	context.getExpressionResolvers().forEach(r -> expressionResolverRegistry.addExpressionResolver(r));
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:27,代码来源:JpaBulkInsert.java


示例5: selectable11

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
public void selectable11() {
	// tag::selectable11[]
	Datastore datastore = obtainDatastore();

	final PathProperty<Long> ID = PathProperty.create("id", Long.class);
	final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);
	final DataTarget<?> TARGET = DataTarget.named("testData");
	final PropertySet<?> PROPERTIES = PropertySet.of(ID, DESCRIPTION);

	SingleSelect<Long> singleSelect = Components.input.singleSelect(ID)
			.dataSource(datastore, DataTarget.named("testData"), PROPERTIES)
			.itemConverter(
					value -> datastore.query().target(TARGET).filter(ID.eq(value)).findOne(PROPERTIES).orElse(null)) // <1>
			.build();
	// end::selectable11[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:17,代码来源:ExampleSelectable.java


示例6: update

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@Override
public OperationResult update(DataTarget<?> target, PropertyBox propertyBox, WriteOption... options) {

	ObjectUtils.argumentNotNull(target, "DataTarget must be not null");
	ObjectUtils.argumentNotNull(propertyBox, "PropertyBox must be not null");

	return withEntityManager(entityManager -> {

		// get entity class
		Class<?> entity = getEntityClass(target, entityManager);

		// create a new instance
		Object instance = entity.newInstance();

		// merge entity
		entityManager.merge(getBeanIntrospector().write(propertyBox, instance));

		// check auto-flush
		if (isAutoFlush() || JpaDatastoreUtils.isFlush(options)) {
			entityManager.flush();
		}

		return OperationResult.builder().type(OperationType.UPDATE).affectedCount(1).build();

	});
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:27,代码来源:DefaultJpaDatastore.java


示例7: testGeneratedId

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@Test
@Transactional
@Rollback
public void testGeneratedId() {
	final PathProperty<Long> CODE = PathProperty.create("code", Long.class);
	final PathProperty<String> VALUE = PathProperty.create("value", String.class);

	final DataTarget<TestGeneratedId> TARGET = JpaTarget.of(TestGeneratedId.class);

	OperationResult result = getDatastore().insert(TARGET,
			PropertyBox.builder(CODE, VALUE).set(VALUE, "Test value").build(), JpaWriteOption.FLUSH);
	assertEquals(1, result.getAffectedCount());
	assertEquals(1, result.getInsertedKeys().size());

	assertEquals(Long.valueOf(1), result.getInsertedKeys().values().iterator().next());

	// bring back ids
	PropertyBox box = PropertyBox.builder(CODE, VALUE).set(VALUE, "Test v2").build();
	result = getDatastore().insert(TARGET, box, JpaWriteOption.FLUSH, DefaultWriteOption.BRING_BACK_GENERATED_IDS);
	assertEquals(1, result.getAffectedCount());
	assertEquals(1, result.getInsertedKeys().size());
	assertEquals(Long.valueOf(2), box.getValue(CODE));
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:24,代码来源:AbstractJpaDatastoreTest.java


示例8: findParents

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
private void findParents(List<String> parents, String name) {
	if (name != null) {

		final DataTarget<?> R_TARGET = DataTarget.named("test_recur");

		RelationalTarget<?> group_alias_1 = RelationalTarget.of(R_TARGET).alias("g1");
		RelationalTarget<?> group_alias_2 = RelationalTarget.of(R_TARGET).alias("g2");

		QueryFilter f1 = group_alias_1.property(TestRecur.PROPERTIES.requireProperty("parent")).isNotNull();
		QueryFilter f2 = group_alias_2.property(TestRecur.PROPERTIES.requireProperty("name"))
				.eq(group_alias_1.property(TestRecur.PROPERTIES.requireProperty("parent")));

		RelationalTarget<?> target = group_alias_1.innerJoin(group_alias_2).on(f1.and(f2)).add();

		List<String> group_parents = getDatastore().query().target(target)
				.filter(group_alias_1.property(TestRecur.PROPERTIES.requireProperty("name")).eq(name))
				.list(group_alias_2.property(TestRecur.PROPERTIES.requireProperty("name")));

		if (!group_parents.isEmpty()) {
			parents.addAll(group_parents);
			for (String p : group_parents) {
				findParents(parents, p);
			}
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:27,代码来源:AbstractJpaDatastoreTest.java


示例9: init

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@PostConstruct
public void init() {
	Components.configure(this)
			// set full to view content
			.fullSize().spacing()
			.add(Components.button().caption("Add new").styleName(ValoTheme.BUTTON_PRIMARY)
					// navigate to "manage" view
					.onClick(e -> ViewNavigator.require().toView("manage").navigate()).build())
			// build and add listing
			.addAndExpandFull(listing = Components.listing.properties(MProduct.PRODUCT)
					// setup data source using Datastore with 'products' table name target and product ID as pk
					.dataSource(datastore, DataTarget.named("products"), MProduct.ID)
					// disable auto refresh: will be triggered on view enter
					.autoRefresh(false)
					// when user clicks on a row, open the 'view' named View providing product id parameter
					.withItemClickListener((i, p, e) -> ViewNavigator.require().toView("view")
							.withParameter("id", i.getValue(MProduct.ID)).navigate())
					// set full size and build
					.fullSize().build());
}
 
开发者ID:holon-platform,项目名称:holon-examples,代码行数:21,代码来源:Home.java


示例10: subquery1

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public void subquery1() {
	// tag::subquery1[]
	Datastore datastore = getDatastore(); // this is supposed to be a relational Datastore implementation

	final DataTarget TARGET1 = DataTarget.named("testTarget1");
	final PathProperty<Integer> PROPERTY1 = TARGET1.property("test", Integer.class);

	final DataTarget TARGET2 = DataTarget.named("testTarget2");
	final PathProperty<Integer> PROPERTY2 = TARGET2.property("test", Integer.class);

	SubQuery<Integer> subQuery = SubQuery.create(datastore).target(TARGET2).filter(PROPERTY1.goe(1))
			.select(PROPERTY1); // <1>

	Stream<Integer> results = datastore.query().target(TARGET1).filter(PROPERTY2.in(subQuery)).stream(PROPERTY2); // <2>
	// end::subquery1[]
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:18,代码来源:ExampleQuery.java


示例11: subquery2

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public void subquery2() {
	// tag::subquery2[]
	Datastore datastore = getDatastore(); // this is supposed to be a relational Datastore implementation

	final DataTarget TARGET1 = DataTarget.named("testTarget1");
	final PathProperty<Integer> PROPERTY1 = TARGET1.property("test", Integer.class);

	final DataTarget TARGET2 = DataTarget.named("testTarget2");
	final PathProperty<Integer> PROPERTY2 = TARGET2.property("test", Integer.class);

	Stream<Integer> results = datastore.query().target(TARGET1)
			.filter(SubQuery.create(datastore).target(TARGET2).filter(PROPERTY2.eq(PROPERTY1)).exists())
			.stream(PROPERTY2); // <1>

	results = datastore.query().target(TARGET1)
			.filter(SubQuery.create(datastore).target(TARGET2).filter(PROPERTY2.eq(PROPERTY1)).notExists())
			.stream(PROPERTY2); // <2>
	// end::subquery2[]
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:21,代码来源:ExampleQuery.java


示例12: joins

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public void joins() {
	// tag::joins[]
	final DataTarget TARGET1 = DataTarget.named("testTarget1");
	final PathProperty<Integer> PROPERTY1 = TARGET1.property("test", Integer.class);

	final DataTarget TARGET2 = DataTarget.named("testTarget2");
	final PathProperty<Integer> PROPERTY2 = TARGET2.property("test", Integer.class);

	RelationalTarget<String> RT = RelationalTarget.of(TARGET1) // <1>
			.join(TARGET2, JoinType.INNER).on(PROPERTY2.eq(PROPERTY1)).add(); // <2>

	RT = RelationalTarget.of(TARGET1).innerJoin(TARGET2).on(PROPERTY2.eq(PROPERTY1)).add(); // <3>
	RT = RelationalTarget.of(TARGET1).leftJoin(TARGET2).on(PROPERTY2.eq(PROPERTY1)).add(); // <4>
	RT = RelationalTarget.of(TARGET1).rightJoin(TARGET2).on(PROPERTY2.eq(PROPERTY1)).add(); // <5>

	Stream<Integer> results = getDatastore().query().target(RT).stream(PROPERTY1); // <6>
	// end::joins[]
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:20,代码来源:ExampleQuery.java


示例13: listing10

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
public void listing10() {
	// tag::listing10[]
	Datastore datastore = getDatastore();

	PropertyListing listing = Components.listing.properties(PROPERTIES) //
			.dataSource(datastore, DataTarget.named("test"), ID) // <1>
			.commitHandler((addedItems, modifiedItems, removedItems) -> { // <2>
				// ...
			}).build();

	final PropertyBox ITEM = PropertyBox.builder(PROPERTIES).set(ID, 777L).set(DESCRIPTION, "A description")
			.build();

	listing.addItem(ITEM); // <3>

	listing.refreshItem(ITEM); // <4>

	listing.removeItem(ITEM); // <5>
	// end::listing10[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:21,代码来源:ExampleListing.java


示例14: testQueryDefinition

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@Test
public void testQueryDefinition() {

	DefaultQueryDefinition qd = new DefaultQueryDefinition();
	qd.setTarget(DataTarget.named("target"));

	assertTrue(qd.getTarget().isPresent());
	assertEquals("target", qd.getTarget().get().getName());

	qd.setLimit(Integer.valueOf(10));
	qd.setOffset(Integer.valueOf(20));

	assertTrue(qd.getLimit().isPresent());
	assertTrue(qd.getLimit().isPresent());
	assertEquals(new Integer(10), qd.getLimit().get());
	assertEquals(new Integer(20), qd.getOffset().get());

	qd.addFilter(TestPropertySet.NAME.isNotNull());
	assertTrue(qd.getFilter().isPresent());

	QuerySort qs = TestPropertySet.NAME.asc();
	qd.addSort(qs);
	assertEquals(qs, qd.getSort().get());

}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:26,代码来源:TestQuery.java


示例15: listing11

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
public void listing11() {
	// tag::listing11[]
	Datastore datastore = getDatastore();

	PropertyListing listing = Components.listing.properties(PROPERTIES) //
			.dataSource(datastore, DataTarget.named("test"), ID) //
			.buffered(true) // <1>
			.build();

	final PropertyBox ITEM = PropertyBox.builder(PROPERTIES).set(ID, 777L).set(DESCRIPTION, "A description")
			.build();

	listing.addItem(ITEM); // <2>
	listing.refreshItem(ITEM); // <3>
	listing.removeItem(ITEM); // <4>

	listing.commit(); // <5>
	listing.discard(); // <6>
	// end::listing11[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:21,代码来源:ExampleListing.java


示例16: AbstractBulkOperation

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
/**
 * Constructor
 * @param datastore Parent Datastore (not null)
 * @param target Data target (not null)
 * @param dialect JDBC dialect (not null)
 * @param traceEnabled Whether tracing is enabled
 */
@SuppressWarnings("unchecked")
public AbstractBulkOperation(JdbcDatastore datastore, DataTarget<?> target, JdbcDialect dialect,
		boolean traceEnabled) {
	super();
	ObjectUtils.argumentNotNull(datastore, "Datastore must be not null");
	ObjectUtils.argumentNotNull(target, "Data target must be not null");
	ObjectUtils.argumentNotNull(dialect, "Dialect must be not null");
	this.datastore = datastore;
	this.target = target;
	this.dialect = dialect;
	this.traceEnabled = traceEnabled;

	// inherit resolvers
	datastore.getExpressionResolvers().forEach(r -> expressionResolverRegistry.addExpressionResolver(r));
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jdbc,代码行数:23,代码来源:AbstractBulkOperation.java


示例17: resolve

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@Override
public Optional<TablePrimaryKey> resolve(DataTarget expression, ResolutionContext context)
		throws InvalidExpressionException {

	// validate
	expression.validate();

	String tableName = null;
	Optional<TablePrimaryKey> targetPrimaryKey = Optional.empty();

	// resolve target
	final DataTarget<?> target = context.resolve(expression, DataTarget.class, context).orElse(expression);
	target.validate();
	tableName = target.getName();

	if (targetPrimaryKey.isPresent()) {
		return targetPrimaryKey;
	}

	return retrieve(tableName);
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jdbc,代码行数:22,代码来源:PrimaryKeyResolver.java


示例18: testQueryProjection

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
@Test
public void testQueryProjection() {

	final DataTarget<TestJpaDomain> DataTarget = JpaTarget.of(TestJpaDomain.class);

	long count = getDatastore().query().target(DataTarget).count();
	assertEquals(2, count);

	List<PropertyBox> results = getDatastore().query().target(DataTarget).list(PROPS);
	assertNotNull(results);
	assertEquals(2, results.size());

	List<String> values = getDatastore().query().target(DataTarget)
			.list(PathProperty.create("stringValue", String.class));
	assertNotNull(values);
	assertEquals(2, values.size());

	values = getDatastore().query().target(DataTarget)
			.list(QueryDslProperty.of(QTestJpaDomain.testJpaDomain.stringValue));
	assertNotNull(values);
	assertEquals(2, values.size());

	values = getDatastore().query().target(DataTarget)
			.list(QueryDslProperty.of(QTestJpaDomain.testJpaDomain.stringValue));
	assertNotNull(values);
	assertEquals(2, values.size());

	Optional<Long> cnt = getDatastore().query().target(DataTarget)
			.findOne(PathProperty.create("stringValue", String.class).count());
	assertTrue(cnt.isPresent());
	assertEquals(new Long(2), cnt.get());
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa-querydsl,代码行数:33,代码来源:AbstractQueryDslTest.java


示例19: selectable10

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
public void selectable10() {
	// tag::selectable10[]
	Datastore datastore = obtainDatastore();

	final PathProperty<Long> ID = PathProperty.create("id", Long.class);
	final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);

	SingleSelect<Long> singleSelect = Components.input.singleSelect(ID)
			.dataSource(datastore, DataTarget.named("testData"), PropertySet.of(ID, DESCRIPTION)) //
			.withQueryConfigurationProvider(() -> ID.gt(0L)) // <1>
			.itemCaptionGenerator(propertyBox -> propertyBox.getValue(DESCRIPTION)).build();
	// end::selectable10[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:14,代码来源:ExampleSelectable.java


示例20: listing3

import com.holonplatform.core.datastore.DataTarget; //导入依赖的package包/类
public void listing3() {
	// tag::listing3[]
	Datastore datastore = getDatastore();

	PropertyListing listing = Components.listing.properties(PROPERTIES) //
			.dataSource(datastore, DataTarget.named("test"), ID) // <1>
			.build();
	// end::listing3[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:10,代码来源:ExampleListing.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AnyItemType类代码示例发布时间:2022-05-23
下一篇:
Java ColorIcon类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap