本文整理汇总了Java中com.haulmont.cuba.gui.data.DsBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DsBuilder类的具体用法?Java DsBuilder怎么用?Java DsBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DsBuilder类属于com.haulmont.cuba.gui.data包,在下文中一共展示了DsBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTagsDs
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected CollectionDatasource<Tag, UUID> createTagsDs(TagType required) {
DsBuilder builder;
if (required == null) {
builder = new DsBuilder(getDsContext())
.setViewName("tag-with-type")
.setAllowCommit(false)
.setRefreshMode(CollectionDatasource.RefreshMode.NEVER);
} else {
builder = new DsBuilder()
.setDsClass(TagsCollectionDatasource.class);
}
builder.setJavaClass(Tag.class);
if (required == null) {
return builder.buildCollectionDatasource();
} else {
TagsCollectionDatasource ds = (TagsCollectionDatasource) builder.buildCollectionDatasource();
ds.setRequiredTagType(required);
ds.refresh();
return ds;
}
}
示例2: createOptionsDatasourceForLookup
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
/**
* Creates the collection datasource that is used for selecting the dynamic attribute value. If the
* CategoryAttribute has "where" or "join" clauses then only items that satisfy these clauses will be presented in
* the options datasource
*/
public CollectionDatasource createOptionsDatasourceForLookup(MetaClass metaClass, String joinClause, String whereClause) {
CollectionDatasource optionsDatasource = DsBuilder.create()
.setMetaClass(metaClass)
.setViewName(View.MINIMAL)
.buildCollectionDatasource();
String query = "select e from " + metaClass.getName() + " e";
if (!Strings.isNullOrEmpty(joinClause)) {
query += " " + joinClause;
}
if (!Strings.isNullOrEmpty(whereClause)) {
query += " where " + whereClause.replaceAll("\\{E\\}", "e");
}
optionsDatasource.setQuery(query);
optionsDatasource.refresh();
return optionsDatasource;
}
示例3: createOptionsDataSource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
protected CollectionDatasource<Entity<Object>, Object> createOptionsDataSource(MetaClass metaClass) {
CollectionDatasource ds = DsBuilder.create(datasource.getDsContext())
.setMetaClass(metaClass)
.setViewName(entityView)
.buildCollectionDatasource();
ds.setRefreshOnComponentValueChange(true);
((DatasourceImplementation) ds).initialized();
if (!StringUtils.isBlank(entityWhere)) {
QueryTransformer transformer = QueryTransformerFactory.createTransformer(
"select e from " + metaClass.getName() + " e");
transformer.addWhere(entityWhere);
String q = transformer.getResult();
ds.setQuery(q);
}
if (WindowParams.DISABLE_AUTO_REFRESH.getBool(datasource.getDsContext().getFrameContext())) {
if (ds instanceof CollectionDatasource.Suspendable)
((CollectionDatasource.Suspendable) ds).refreshIfNotSuspended();
else
ds.refresh();
}
return ds;
}
示例4: createMasterDsContext
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
private void createMasterDsContext() {
masterDsContext = new DsContextImpl(dataService);
DsBuilder masterDsBuilder = new DsBuilder(masterDsContext);
masterDsBuilder.reset().setId("masterDs")
.setMetaClass(metadataSession.getClass(TestMasterEntity.class))
.setViewName("withDetail");
masterDs = masterDsBuilder.buildDatasource();
masterDsBuilder.reset().setId("detailDs")
.setMetaClass(metadataSession.getClass(TestDetailEntity.class))
.setMaster(masterDs)
.setProperty("detail");
detailDs = masterDsBuilder.buildDatasource();
masterDsBuilder.reset().setId("embeddedDs")
.setMetaClass(metadataSession.getClass(TestEmbeddableEntity.class))
.setMaster(detailDs)
.setProperty("embeddable");
embeddableDs = masterDsBuilder.buildDatasource();
for (Datasource ds : masterDsContext.getAll()) {
((DatasourceImplementation) ds).initialized();
}
}
示例5: createMasterDsContext
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
private void createMasterDsContext() {
masterDsContext = new DsContextImpl(dataService);
DsBuilder masterDsBuilder = new DsBuilder(masterDsContext);
masterDsBuilder.reset().setId("masterDs")
.setMetaClass(metadataSession.getClass(TestMasterEntity.class))
.setViewName("withDetails");
masterDs = masterDsBuilder.buildDatasource();
masterDsBuilder.reset().setId("detailsDs")
.setMetaClass(metadataSession.getClass(TestDetailEntity.class))
.setMaster(masterDs)
.setProperty("details");
detailsDs = masterDsBuilder.buildCollectionDatasource();
masterDsBuilder.reset().setId("masterPartsDs")
.setMetaClass(metadataSession.getClass(TestDetailEntity.class))
.setMaster(detailsDs)
.setProperty("parts");
masterPartsDs = masterDsBuilder.buildCollectionDatasource();
for (Datasource ds : masterDsContext.getAll()) {
((DatasourceImplementation) ds).initialized();
}
}
示例6: createDetailDsContext
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
private void createDetailDsContext() {
detailDsContext = new DsContextImpl(dataService);
DsBuilder detailDsBuilder = new DsBuilder(detailDsContext);
detailDsBuilder.reset().setId("detailDs")
.setMetaClass(metadataSession.getClass(TestDetailEntity.class))
.setViewName("_local");
detailDs = detailDsBuilder.buildDatasource();
detailDsBuilder.reset().setId("embeddedDs")
.setMetaClass(metadataSession.getClass(TestEmbeddableEntity.class))
.setMaster(detailDs)
.setProperty("embeddable");
embeddableDs = detailDsBuilder.buildDatasource();
detailDsBuilder.reset().setId("partsDs")
.setMetaClass(metadataSession.getClass(TestPartEntity.class))
.setMaster(detailDs)
.setProperty("parts");
partsDs = detailDsBuilder.buildCollectionDatasource();
for (Datasource ds : detailDsContext.getAll()) {
((DatasourceImplementation) ds).initialized();
}
}
示例7: testDatasource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
@Test
public void testDatasource() {
OptionsList component = factory.createComponent(OptionsList.class);
//noinspection unchecked
Datasource<User> testDs = new DsBuilder()
.setId("testDs")
.setJavaClass(User.class)
.setView(viewRepository.getView(User.class, View.LOCAL))
.buildDatasource();
testDs.setItem(new User());
((DatasourceImpl) testDs).valid();
assertNull(component.getValue());
component.setDatasource(testDs, "group");
assertNotNull(component.getDatasource());
}
示例8: getTestCollectionDatasource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
protected CollectionDatasource<Group, UUID> getTestCollectionDatasource() {
// noinspection unchecked
CollectionDatasource<Group, UUID> collectionDatasource = new DsBuilder()
.setId("testDs")
.setJavaClass(Group.class)
.setView(viewRepository.getView(Group.class, View.LOCAL))
.setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
.setAllowCommit(false)
.buildCollectionDatasource();
for (int i = 0; i < 3; i++) {
Group group = metadata.create(Group.class);
group.setName("Group #" + (i + 1));
Group parentGroup = metadata.create(Group.class);
parentGroup.setName("Parent group #" + (i + 1));
group.setParent(parentGroup);
collectionDatasource.addItem(group);
}
((CollectionDatasourceImpl) collectionDatasource).valid();
return collectionDatasource;
}
示例9: testDatasource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
@Test
public void testDatasource() {
OptionsGroup component = factory.createComponent(OptionsGroup.class);
//noinspection unchecked
Datasource<User> testDs = new DsBuilder()
.setId("testDs")
.setJavaClass(User.class)
.setView(viewRepository.getView(User.class, View.LOCAL))
.buildDatasource();
testDs.setItem(new User());
((DatasourceImpl) testDs).valid();
assertNull(component.getValue());
component.setDatasource(testDs, "group");
assertNotNull(component.getDatasource());
}
示例10: createTagsDs
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
protected CollectionDatasource<Tag, UUID> createTagsDs(TagType required) {
DsBuilder builder;
if (required == null) {
builder = new DsBuilder(getDsContext())
.setViewName("tag-with-type")
.setAllowCommit(false)
.setRefreshMode(CollectionDatasource.RefreshMode.NEVER);
} else {
builder = new DsBuilder()
.setDsClass(TagsCollectionDatasource.class);
}
builder.setJavaClass(Tag.class);
if (required == null) {
return builder.buildCollectionDatasource();
} else {
TagsCollectionDatasource ds = (TagsCollectionDatasource) builder.buildCollectionDatasource();
ds.setRequiredTagType(required);
ds.refresh();
return ds;
}
}
示例11: createItemDatasource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
protected Datasource createItemDatasource(Entity item) {
Datasource fieldDatasource = DsBuilder.create()
.setAllowCommit(false)
.setMetaClass(datasource.getMetaClass())
.setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
.setViewName(View.LOCAL)
.buildDatasource();
((DatasourceImplementation) fieldDatasource).valid();
//noinspection unchecked
fieldDatasource.setItem(item);
return fieldDatasource;
}
示例12: initDatasource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
protected void initDatasource() {
entitiesDs = DsBuilder.create(getDsContext())
.setId("entitiesDs")
.setMetaClass(metaClass)
.setView(view)
.buildCollectionDatasource();
entitiesDs.setQuery(String.format("select e from %s e", metaClass.getName()));
}
示例13: createPartDsContext
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
private void createPartDsContext() {
partDsContext = new DsContextImpl(dataService);
DsBuilder partDsBuilder = new DsBuilder(partDsContext);
partDsBuilder.reset().setId("partDs")
.setMetaClass(metadataSession.getClass(TestPartEntity.class))
.setViewName("_local");
partDs = partDsBuilder.buildDatasource();
for (Datasource ds : partDsContext.getAll()) {
((DatasourceImplementation) ds).initialized();
}
}
示例14: testDatasource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
@Test
public void testDatasource() {
TextField component = factory.createComponent(TextField.class);
//noinspection unchecked
Datasource<User> testDs = new DsBuilder()
.setId("testDs")
.setJavaClass(User.class)
.setView(viewRepository.getView(User.class, View.LOCAL))
.buildDatasource();
testDs.setItem(new User());
((DatasourceImpl) testDs).valid();
assertNull(component.getValue());
testDs.getItem().setLogin("Ok");
component.setValue("none");
component.setDatasource(testDs, "login");
assertEquals("Ok", component.getValue());
component.setValue("user");
assertEquals("user", testDs.getItem().getLogin());
testDs.getItem().setLogin("login");
assertEquals("login", component.getValue());
}
示例15: testDatasource
import com.haulmont.cuba.gui.data.DsBuilder; //导入依赖的package包/类
@Test
public void testDatasource() throws ParseException {
DateField component = factory.createComponent(DateField.class);
//noinspection unchecked
Datasource<User> testDs = new DsBuilder()
.setId("testDs")
.setJavaClass(User.class)
.setView(viewRepository.getView(User.class, View.LOCAL))
.buildDatasource();
testDs.setItem(new User());
((DatasourceImpl) testDs).valid();
assertNull(component.getValue());
Date dsInitValue = new SimpleDateFormat("dd.MM.yyyy").parse("12.12.2000");
testDs.getItem().setCreateTs(dsInitValue);
component.setValue(new Date());
component.setDatasource(testDs, "createTs");
assertEquals(dsInitValue, component.getValue());
Date componentValue = new SimpleDateFormat("dd.MM.yyyy").parse("06.06.2000");
component.setValue(componentValue);
assertEquals(componentValue, testDs.getItem().getCreateTs());
Date dsValue = new SimpleDateFormat("dd.MM.yyyy").parse("08.08.2000");
testDs.getItem().setCreateTs(dsValue);
assertEquals(dsValue, component.getValue());
}