public void jaxrs() { Client client = ClientBuilder.newClient(); // <1> PropertyBox box1 = PropertyBox.builder(PROPERTYSET).set(CODE, 1).set(NAME, "Test").build(); client.target("https://host/test/serialize").request().put(Entity.entity(box1, MediaType.APPLICATION_JSON)); // <2> PropertyBox box2 = PROPERTYSET .execute(() -> client.target("https://host/test/deserialize").request().get(PropertyBox.class)); // <3> } // end::jaxrs[]
public void jaxrs() { Client client = ClientBuilder.newClient(); // <2> PropertyBox box1 = PropertyBox.builder(PROPERTYSET).set(CODE, 1).set(NAME, "Test").build(); client.target("https://host/test/serialize").request().put(Entity.entity(box1, MediaType.APPLICATION_JSON)); // <3> PropertyBox box2 = PROPERTYSET .execute(() -> client.target("https://host/test/deserialize").request().get(PropertyBox.class)); // <4> } // end::jaxrs[]
@GET @Path("get") @Produces(MediaType.APPLICATION_JSON) public PropertyBox getPropertyBox() { // <1> return PropertyBox.builder(PROPERTY_SET).set(A_PROPERTY, 1).build(); }
public void input30() { VerticalLayout myLayout = new VerticalLayout(); // tag::input30[] PropertyInputForm form = PropertyInputForm.builder(new VerticalLayout(), SUBJECT) // <1> .composer(Composable.componentContainerComposer()) // <2> .build(); myLayout.add(form.getComponent()); // <3> form.setValue(PropertyBox.builder(SUBJECT).set(ID, 1L).set(NAME, "One").build()); // <4> // end::input30[] }
public void listing8() { // tag::listing8[] PropertyListing listing = Components.listing.properties(PROPERTIES) // .build(); listing.setSelectionMode(SelectionMode.MULTI); // <1> final PropertyBox ITEM = PropertyBox.builder(PROPERTIES).set(ID, 1L).build(); Set<PropertyBox> selected = listing.getSelectedItems(); // <2> boolean isSelected = listing.isSelected(ITEM); // <3> listing.select(ITEM); // <4> listing.deselectAll(); // <5> listing.selectAll(); // <6> // end::listing8[] }
public void introspect2() { // tag::introspector2[] MyBean instance = new MyBean(); instance.setId(7L); PropertyBox value = BeanIntrospector.get().read(instance); // <1> final NumericProperty<Long> ID = NumericProperty.longType("id"); BeanIntrospector.get().write(PropertyBox.builder(ID).set(ID, 8L).build(), instance); // <2> // end::introspector2[] }
void operations() { Datastore datastore = getJpaDatastore(); PropertyBox value = PropertyBox.builder(Test.PROPERTIES).set(Test.PROPERTIES.property("id"), 1L) .set(Test.PROPERTIES.property("value"), "test").build(); // <3> datastore.save(Test.TARGET, value); List<PropertyBox> values = datastore.query(Test.TARGET).filter(Test.PROPERTIES.property("id").gt(0L)) .sort(Test.PROPERTIES.property("value").desc()).list(Test.PROPERTIES); // <4> } // end::beans1[]
public void serializeAndDeserialize() { Gson gson = GsonConfiguration.builder().create(); // <1> PropertyBox box = PropertyBox.builder(PROPERTY_SET).set(ID, 1L).set(DESCRIPTION, "Test").build(); // <2> // serialize String json = gson.toJson(box); // <3> // deserialize box = PROPERTY_SET.execute(() -> gson.fromJson(json, PropertyBox.class)); // <4> } // end::serdeser[]
public void naming2() { // tag::naming2[] Datastore datastore = JdbcDatastore.builder().dataSource(createOrObtainDatasource()).build(); // <1> PropertyBox value = PropertyBox.builder(TEST).set(ID, 1L).set(VALUE, "One").build(); datastore.save(TARGET, value); // <2> Stream<PropertyBox> results = datastore.query().target(TARGET).filter(ID.goe(1L)).stream(TEST); // <3> List<String> values = datastore.query().target(TARGET).sort(ID.asc()).list(VALUE); // <4> datastore.bulkDelete(TARGET).filter(ID.gt(0L)).execute(); // <5> // end::naming2[] }
public void ids1() { // tag::ids1[] Datastore datastore = getJpaDatastore(); PropertyBox value = PropertyBox.builder(TEST).set(VALUE, "test").build(); OperationResult result = datastore.insert(TARGET, value, JpaWriteOption.FLUSH); // <1> Optional<Long> idValue = result.getInsertedKey(ID); // <2> // end::ids1[] }
public void listing7() { // tag::listing7[] PropertyListing listing = Components.listing.properties(PROPERTIES) // .selectionMode(SelectionMode.SINGLE) // <1> .build(); final PropertyBox ITEM = PropertyBox.builder(PROPERTIES).set(ID, 1L).build(); PropertyBox selected = listing.getFirstSelectedItem().orElse(null); // <2> boolean isSelected = listing.isSelected(ITEM); // <3> listing.select(ITEM); // <4> listing.deselectAll(); // <5> // end::listing7[] }
public void view2() { // tag::view2[] final NumericProperty<Long> ID = NumericProperty.longType("id"); final StringProperty DESCRIPTION = StringProperty.create("description"); final PropertySet<?> PROPERTIES = PropertySet.of(ID, DESCRIPTION); PropertyViewGroup viewGroup = Components.view.propertyGroup().properties(PROPERTIES).build(); // <1> PropertyViewForm viewForm = Components.view.formVertical().properties(PROPERTIES).build(); // <2> viewForm.setValue(PropertyBox.builder(PROPERTIES).set(ID, 1L).set(DESCRIPTION, "Test").build()); // <3> PropertyBox value = viewForm.getValue(); // <4> // end::view2[] }
public void ids2() { // tag::ids2[] final PathProperty<Long> KEY = PathProperty.create("key", Long.class); // <1> final PathProperty<String> TEXT = PathProperty.create("text", String.class); Datastore datastore = getDatastore(); // build or obtain a JDBC Datastore PropertyBox value = PropertyBox.builder(KEY, TEXT).set(TEXT, "test").build(); // <2> datastore.insert(DataTarget.named("tableName"), value, DefaultWriteOption.BRING_BACK_GENERATED_IDS); // <3> Long keyValue = value.getValue(KEY); // <4> // end::ids2[] }
public void listing3() { // tag::listing3[] PropertyListing listing = PropertyListing.builder(SUBJECT) // <1> .items(PropertyBox.builder(SUBJECT).set(ID, 1L).set(NAME, "One").build()).build(); listing = PropertyListing.builder(SUBJECT) // <2> .addItem(PropertyBox.builder(SUBJECT).set(ID, 1L).set(NAME, "One").build()) .addItem(PropertyBox.builder(SUBJECT).set(ID, 2L).set(NAME, "Two").build()).build(); // end::listing3[] }
public void group2() { // tag::group2[] PropertyInputGroup group = Components.input.propertyGroup().properties(PROPERTIES).build(); group.setValue(PropertyBox.builder(PROPERTIES).set(ID, 1L).set(DESCRIPTION, "TestDescription").build()); // <1> PropertyBox value = group.getValue(); // <2> group.addValueChangeListener(e -> { // <3> PropertyBox changedValue = e.getValue(); }); // end::group2[] }
public void serializeh1() { // tag::serializeh1[] final NumericProperty<Long> KEY = NumericProperty.longType("key"); final StringProperty NAME = StringProperty.create("name"); final StringProperty SURNAME = StringProperty.create("surname"); final PropertyBoxProperty NESTED = PropertyBoxProperty.create("nested", NAME, SURNAME); // <1> final PropertySet<?> PROPERTY_SET = PropertySet.of(KEY, NESTED); // <2> PropertyBox value = PropertyBox.builder(PROPERTY_SET).set(KEY, 1L) .set(NESTED, PropertyBox.builder(NAME, SURNAME).set(NAME, "John").set(SURNAME, "Doe").build()).build(); // <3> // end::serializeh1[] }
public void serializationConfig() { // tag::sconfig[] StringProperty NAME = StringProperty.create("name"); // <1> VirtualProperty<String> VRT = VirtualProperty.create(String.class, pb -> "(" + pb.getValue(NAME) + ")") .name("vrt"); // <2> final PropertySet<?> PROPERTY_SET = PropertySet.builderOf(NAME, VRT).withConfiguration( JsonConfigProperties.PROPERTYBOX_SERIALIZATION_MODE, PropertyBoxSerializationMode.ALL).build(); // <3> PropertyBox propertyBox = PropertyBox.builder(PROPERTY_SET).set(NAME, "test").build(); // <4> // end::sconfig[] }
public void mapping3() { // tag::mapping3[] Datastore datastore = JdbcDatastore.builder().dataSource(createOrObtainDatasource()).build(); // <1> PropertyBox value = PropertyBox.builder(MyEntity.PROPERTIES) // .set(MyEntity.PROPERTIES.property("id"), 1L) // .set(MyEntity.PROPERTIES.property("value"), "One").build(); datastore.save(MyEntity.TARGET, value); // <2> Stream<PropertyBox> results = datastore.query().target(MyEntity.TARGET) .filter(MyEntity.PROPERTIES.property("id").goe(1L)).stream(MyEntity.PROPERTIES); // <3> // end::mapping3[] }